(1.2.7) Fixes, made builtin HTTP server timeout configurable

This commit is contained in:
lax1dude 2024-06-23 15:12:00 -07:00
parent 77c6c217f4
commit 18bb218734
16 changed files with 62 additions and 52 deletions

View File

@ -57,7 +57,7 @@ import net.md_5.bungee.BungeeCord;
*/
public class EaglerXBungee extends Plugin {
public static final String NATIVE_BUNGEECORD_BUILD = "1.21-R0.1-SNAPSHOT:8a88ce4:1849";
public static final String NATIVE_BUNGEECORD_BUILD = "1.21-R0.1-SNAPSHOT:cda4537:1851";
public static final String NATIVE_WATERFALL_BUILD = "1.21-R0.1-SNAPSHOT:de8345a:579";
static {

View File

@ -41,9 +41,9 @@ public class EaglercraftRegisterCapeEvent extends Event {
public void setForceUsePreset(int p) {
customTex = new byte[5];
customTex[0] = (byte)1;
customTex[1] = (byte)(p >> 24);
customTex[2] = (byte)(p >> 16);
customTex[3] = (byte)(p >> 8);
customTex[1] = (byte)(p >>> 24);
customTex[2] = (byte)(p >>> 16);
customTex[3] = (byte)(p >>> 8);
customTex[4] = (byte)(p & 0xFF);
}

View File

@ -53,9 +53,9 @@ public class EaglercraftRegisterSkinEvent extends Event {
useLoginResultTextures = false;
customTex = new byte[5];
customTex[0] = (byte)1;
customTex[1] = (byte)(p >> 24);
customTex[2] = (byte)(p >> 16);
customTex[3] = (byte)(p >> 8);
customTex[1] = (byte)(p >>> 24);
customTex[2] = (byte)(p >>> 16);
customTex[3] = (byte)(p >>> 8);
customTex[4] = (byte)(p & 0xFF);
customURL = null;
}

View File

@ -121,6 +121,7 @@ public class EaglerBungeeConfig {
long websocketKeepAliveTimeout = configYml.getInt("websocket_connection_timeout", 15000);
long websocketHandshakeTimeout = configYml.getInt("websocket_handshake_timeout", 5000);
long builtinHttpServerTimeout = configYml.getInt("builtin_http_server_timeout", 10000);
int websocketCompressionLevel = configYml.getInt("http_websocket_compression_level", 6);
boolean downloadVanillaSkins = configYml.getBoolean("download_vanilla_skins_to_clients", false);
@ -148,12 +149,12 @@ public class EaglerBungeeConfig {
Set<String> disableFNAWSkinsOnServers = new HashSet((Collection<String>)configYml.getList("disable_fnaw_skins_on_servers"));
final EaglerBungeeConfig ret = new EaglerBungeeConfig(serverName, serverUUID, websocketKeepAliveTimeout,
websocketHandshakeTimeout, websocketCompressionLevel, serverListeners, contentTypes,
downloadVanillaSkins, validSkinUrls, uuidRateLimitPlayer, uuidRateLimitGlobal, skinRateLimitPlayer,
skinRateLimitGlobal, skinCacheURI, keepObjectsDays, keepProfilesDays, maxObjects, maxProfiles,
antagonistsRateLimit, sqliteDriverClass, sqliteDriverPath, eaglerPlayersVanillaSkin,
enableIsEaglerPlayerProperty, authConfig, updatesConfig, iceServers, voiceChat,
disableVoiceOnServers, disableFNAWSkinsEverywhere, disableFNAWSkinsOnServers);
websocketHandshakeTimeout, builtinHttpServerTimeout, websocketCompressionLevel, serverListeners,
contentTypes, downloadVanillaSkins, validSkinUrls, uuidRateLimitPlayer, uuidRateLimitGlobal,
skinRateLimitPlayer, skinRateLimitGlobal, skinCacheURI, keepObjectsDays, keepProfilesDays, maxObjects,
maxProfiles, antagonistsRateLimit, sqliteDriverClass, sqliteDriverPath, eaglerPlayersVanillaSkin,
enableIsEaglerPlayerProperty, authConfig, updatesConfig, iceServers, voiceChat, disableVoiceOnServers,
disableFNAWSkinsEverywhere, disableFNAWSkinsOnServers);
if(eaglerPlayersVanillaSkin != null) {
VanillaDefaultSkinProfileLoader.lookupVanillaSkinUser(ret);
@ -241,6 +242,7 @@ public class EaglerBungeeConfig {
private final UUID serverUUID;
private final long websocketKeepAliveTimeout;
private final long websocketHandshakeTimeout;
private final long builtinHttpServerTimeout;
private final int httpWebsocketCompressionLevel;
private final Map<String, EaglerListenerConfig> serverListeners;
private final Map<String, HttpContentType> contentTypes;
@ -286,6 +288,10 @@ public class EaglerBungeeConfig {
return websocketHandshakeTimeout;
}
public long getBuiltinHttpServerTimeout() {
return builtinHttpServerTimeout;
}
public int getHttpWebsocketCompressionLevel() {
return httpWebsocketCompressionLevel;
}
@ -430,7 +436,7 @@ public class EaglerBungeeConfig {
}
private EaglerBungeeConfig(String serverName, UUID serverUUID, long websocketKeepAliveTimeout,
long websocketHandshakeTimeout, int httpWebsocketCompressionLevel,
long websocketHandshakeTimeout, long builtinHttpServerTimeout, int httpWebsocketCompressionLevel,
Map<String, EaglerListenerConfig> serverListeners, Map<String, HttpContentType> contentTypes,
boolean downloadVanillaSkins, Collection<String> validSkinUrls, int uuidRateLimitPlayer,
int uuidRateLimitGlobal, int skinRateLimitPlayer, int skinRateLimitGlobal, String skinCacheURI,
@ -444,6 +450,7 @@ public class EaglerBungeeConfig {
this.serverListeners = serverListeners;
this.websocketHandshakeTimeout = websocketHandshakeTimeout;
this.websocketKeepAliveTimeout = websocketKeepAliveTimeout;
this.builtinHttpServerTimeout = builtinHttpServerTimeout;
this.httpWebsocketCompressionLevel = httpWebsocketCompressionLevel;
this.contentTypes = contentTypes;
this.downloadVanillaSkins = downloadVanillaSkins;

View File

@ -27,7 +27,7 @@ public class EaglerUpdateConfig {
int certPacketDataRateLimit = config.getInt("cert_packet_data_rate_limit", 524288);
boolean enableEagcertFolder = config.getBoolean("enable_eagcert_folder", true);
boolean downloadLatestCerts = config.getBoolean("download_latest_certs", true);
int checkForUpdatesEvery = config.getInt("check_for_update_every", 900);
int checkForUpdatesEvery = config.getInt("check_for_update_every", 28800);
Collection<String> downloadCertURLs = (Collection<String>)config.getList("download_certs_from");
return new EaglerUpdateConfig(blockAllClientUpdates, discardLoginPacketCerts, certPacketDataRateLimit,
enableEagcertFolder, downloadLatestCerts, checkForUpdatesEvery, downloadCertURLs);

View File

@ -71,6 +71,7 @@ public class EaglerPipeline {
EaglerBungeeConfig conf = EaglerXBungee.getEagler().getConfig();
long handshakeTimeout = conf.getWebsocketHandshakeTimeout();
long keepAliveTimeout = conf.getWebsocketKeepAliveTimeout();
long httpTimeout = conf.getBuiltinHttpServerTimeout();
List<Channel> channelsList;
synchronized(openChannels) {
long millis = System.currentTimeMillis();
@ -79,8 +80,8 @@ public class EaglerPipeline {
Channel c = channelIterator.next();
final EaglerConnectionInstance i = c.attr(EaglerPipeline.CONNECTION_INSTANCE).get();
long handshakeTimeoutForConnection = 500l;
if(i.isRegularHttp) handshakeTimeoutForConnection = 10000l;
if(i.isWebSocket) handshakeTimeoutForConnection = handshakeTimeout;
if(i.isRegularHttp) handshakeTimeoutForConnection = httpTimeout;
else if(i.isWebSocket) handshakeTimeoutForConnection = handshakeTimeout;
if(i == null || (!i.hasBeenForwarded && millis - i.creationTime > handshakeTimeoutForConnection)
|| millis - i.lastClientPongPacket > keepAliveTimeout || !c.isActive()) {
if(c.isActive()) {

View File

@ -1038,7 +1038,8 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
if(connectionClosed) {
return;
}
if(!hasFirstPacket && (conf.isAllowMOTD() || conf.isAllowQuery()) && (str = str.toLowerCase()).startsWith("accept:")) {
if (!hasFirstPacket && (conf.isAllowMOTD() || conf.isAllowQuery()) && str.length() < 128
&& (str = str.toLowerCase()).startsWith("accept:")) {
str = str.substring(7).trim();
hasFirstPacket = true;
hasBinaryConnection = false;
@ -1210,7 +1211,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
buffer.writeShort(message.length());
for(int i = 0, l = message.length(), j; i < l; ++i) {
j = message.charAt(i);
buffer.writeByte((j >> 8) & 0xFF);
buffer.writeByte((j >>> 8) & 0xFF);
buffer.writeByte(j & 0xFF);
}
}
@ -1218,7 +1219,7 @@ public class HttpWebSocketHandler extends ChannelInboundHandlerAdapter {
public static void writeLegacyRedirect(ByteBuf buffer, String redirect) {
buffer.writeBytes(legacyRedirectHeader);
byte[] redirect_ = redirect.getBytes(StandardCharsets.UTF_8);
buffer.writeByte((redirect_.length >> 8) & 0xFF);
buffer.writeByte((redirect_.length >>> 8) & 0xFF);
buffer.writeByte(redirect_.length & 0xFF);
buffer.writeBytes(redirect_);
}

View File

@ -140,10 +140,10 @@ public class MOTDQueryHandler extends EaglerQuerySimpleHandler implements MOTDCo
byte[] iconPixels = new byte[16384];
for(int i = 0, j; i < 4096; ++i) {
j = i << 2;
iconPixels[j] = (byte)((bitmap[i] >> 16) & 0xFF);
iconPixels[j + 1] = (byte)((bitmap[i] >> 8) & 0xFF);
iconPixels[j] = (byte)(bitmap[i] >>> 16);
iconPixels[j + 1] = (byte)(bitmap[i] >>> 8);
iconPixels[j + 2] = (byte)(bitmap[i] & 0xFF);
iconPixels[j + 3] = (byte)((bitmap[i] >> 24) & 0xFF);
iconPixels[j + 3] = (byte)(bitmap[i] >>> 24);
}
sendBinaryResponse(iconPixels);
iconDirty = false;

View File

@ -89,9 +89,9 @@ public class CapePackets {
byte[] ret = new byte[1 + 16 + 4];
ret[0] = (byte)PACKET_OTHER_CAPE_PRESET;
SkinPackets.UUIDToBytes(uuid, ret, 1);
ret[17] = (byte)(presetId >> 24);
ret[18] = (byte)(presetId >> 16);
ret[19] = (byte)(presetId >> 8);
ret[17] = (byte)(presetId >>> 24);
ret[18] = (byte)(presetId >>> 16);
ret[19] = (byte)(presetId >>> 8);
ret[20] = (byte)(presetId & 0xFF);
return ret;
}

View File

@ -147,9 +147,9 @@ public class SkinPackets {
byte[] ret = new byte[1 + 16 + 4];
ret[0] = (byte)PACKET_OTHER_SKIN_PRESET;
UUIDToBytes(uuid, ret, 1);
ret[17] = (byte)(presetId >> 24);
ret[18] = (byte)(presetId >> 16);
ret[19] = (byte)(presetId >> 8);
ret[17] = (byte)(presetId >>> 24);
ret[18] = (byte)(presetId >>> 16);
ret[19] = (byte)(presetId >>> 8);
ret[20] = (byte)(presetId & 0xFF);
return ret;
}
@ -205,21 +205,21 @@ public class SkinPackets {
public static void UUIDToBytes(UUID uuid, byte[] bytes, int off) {
long msb = uuid.getMostSignificantBits();
long lsb = uuid.getLeastSignificantBits();
bytes[off] = (byte)(msb >> 56l);
bytes[off + 1] = (byte)(msb >> 48l);
bytes[off + 2] = (byte)(msb >> 40l);
bytes[off + 3] = (byte)(msb >> 32l);
bytes[off + 4] = (byte)(msb >> 24l);
bytes[off + 5] = (byte)(msb >> 16l);
bytes[off + 6] = (byte)(msb >> 8l);
bytes[off] = (byte)(msb >>> 56l);
bytes[off + 1] = (byte)(msb >>> 48l);
bytes[off + 2] = (byte)(msb >>> 40l);
bytes[off + 3] = (byte)(msb >>> 32l);
bytes[off + 4] = (byte)(msb >>> 24l);
bytes[off + 5] = (byte)(msb >>> 16l);
bytes[off + 6] = (byte)(msb >>> 8l);
bytes[off + 7] = (byte)(msb & 0xFFl);
bytes[off + 8] = (byte)(lsb >> 56l);
bytes[off + 9] = (byte)(lsb >> 48l);
bytes[off + 10] = (byte)(lsb >> 40l);
bytes[off + 11] = (byte)(lsb >> 32l);
bytes[off + 12] = (byte)(lsb >> 24l);
bytes[off + 13] = (byte)(lsb >> 16l);
bytes[off + 14] = (byte)(lsb >> 8l);
bytes[off + 8] = (byte)(lsb >>> 56l);
bytes[off + 9] = (byte)(lsb >>> 48l);
bytes[off + 10] = (byte)(lsb >>> 40l);
bytes[off + 11] = (byte)(lsb >>> 32l);
bytes[off + 12] = (byte)(lsb >>> 24l);
bytes[off + 13] = (byte)(lsb >>> 16l);
bytes[off + 14] = (byte)(lsb >>> 8l);
bytes[off + 15] = (byte)(lsb & 0xFFl);
}

View File

@ -21,10 +21,10 @@ public class SkinRescaler {
for(int i = 0, j, k; i < imageIn.length; ++i) {
j = i << 2;
k = imageIn[i];
imageOut[j] = (byte)(k >> 24);
imageOut[j] = (byte)(k >>> 24);
imageOut[j + 1] = (byte)(k & 0xFF);
imageOut[j + 2] = (byte)(k >> 8);
imageOut[j + 3] = (byte)(k >> 16);
imageOut[j + 2] = (byte)(k >>> 8);
imageOut[j + 3] = (byte)(k >>> 16);
}
}
@ -65,10 +65,10 @@ public class SkinRescaler {
j = (dstY + y) * imgDstWidth + dstX + x;
}
j = j << 2;
imageOut[j] = (byte)(i >> 24);
imageOut[j] = (byte)(i >>> 24);
imageOut[j + 1] = (byte)(i & 0xFF);
imageOut[j + 2] = (byte)(i >> 8);
imageOut[j + 3] = (byte)(i >> 16);
imageOut[j + 2] = (byte)(i >>> 8);
imageOut[j + 3] = (byte)(i >>> 16);
}
}
}

View File

@ -2,6 +2,7 @@ server_name: 'EaglercraftXBungee Server'
server_uuid: ${random_uuid}
websocket_connection_timeout: 15000
websocket_handshake_timeout: 5000
builtin_http_server_timeout: 10000
http_websocket_compression_level: 6
download_vanilla_skins_to_clients: true
valid_skin_download_urls:

View File

@ -6,4 +6,4 @@ download_latest_certs: true
download_certs_from:
- 'https://eaglercraft.com/backup.cert'
- 'https://deev.is/eagler/backup.cert'
check_for_update_every: 900
check_for_update_every: 28800

View File

@ -1,5 +1,5 @@
name: EaglercraftXBungee
main: net.lax1dude.eaglercraft.v1_8.plugin.gateway_bungeecord.EaglerXBungee
version: 1.2.6
version: 1.2.7
description: Plugin to allow EaglercraftX 1.8 players to join your network, or allow EaglercraftX 1.8 players to use your network as a proxy to join other networks
author: lax1dude

View File

@ -1 +1 @@
1.2.6
1.2.7