<1.0.6> Fixes, made builtin HTTP server timeout configurable

This commit is contained in:
lax1dude 2024-06-23 15:33:54 -07:00
parent 18bb218734
commit 7425179b36
16 changed files with 63 additions and 53 deletions

View File

@ -17,13 +17,13 @@ package net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity;
*/
public class EaglerXVelocityVersion {
public static final String NATIVE_VELOCITY_BUILD = "3.3.0-SNAPSHOT:e60e2063:b399";
public static final String NATIVE_VELOCITY_BUILD = "3.3.0-SNAPSHOT:9d25d309:b400";
public static final String ID = "EaglerXVelocity";
public static final String PLUGIN_ID = "eaglerxvelocity";
public static final String NAME = "EaglercraftXVelocity";
public static final String 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";
public static final String VERSION = "1.0.5";
public static final String VERSION = "1.0.6";
public static final String[] AUTHORS = new String[] { "lax1dude", "ayunami2000" };
}

View File

@ -39,9 +39,9 @@ public class EaglercraftRegisterCapeEvent {
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

@ -52,9 +52,9 @@ public class EaglercraftRegisterSkinEvent {
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

@ -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

@ -121,6 +121,7 @@ public class EaglerVelocityConfig {
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 EaglerVelocityConfig {
Set<String> disableFNAWSkinsOnServers = new HashSet((Collection<String>)configYml.getList("disable_fnaw_skins_on_servers"));
final EaglerVelocityConfig ret = new EaglerVelocityConfig(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);
@ -250,6 +251,7 @@ public class EaglerVelocityConfig {
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;
@ -295,6 +297,10 @@ public class EaglerVelocityConfig {
return websocketHandshakeTimeout;
}
public long getBuiltinHttpServerTimeout() {
return builtinHttpServerTimeout;
}
public int getHttpWebsocketCompressionLevel() {
return httpWebsocketCompressionLevel;
}
@ -439,7 +445,7 @@ public class EaglerVelocityConfig {
}
private EaglerVelocityConfig(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,
@ -453,6 +459,7 @@ public class EaglerVelocityConfig {
this.serverListeners = serverListeners;
this.websocketHandshakeTimeout = websocketHandshakeTimeout;
this.websocketKeepAliveTimeout = websocketKeepAliveTimeout;
this.builtinHttpServerTimeout = builtinHttpServerTimeout;
this.httpWebsocketCompressionLevel = httpWebsocketCompressionLevel;
this.contentTypes = contentTypes;
this.downloadVanillaSkins = downloadVanillaSkins;

View File

@ -72,6 +72,7 @@ public class EaglerPipeline {
EaglerVelocityConfig conf = EaglerXVelocity.getEagler().getConfig();
long handshakeTimeout = conf.getWebsocketHandshakeTimeout();
long keepAliveTimeout = conf.getWebsocketKeepAliveTimeout();
long httpTimeout = conf.getBuiltinHttpServerTimeout();
List<Channel> channelsList;
synchronized(openChannels) {
long millis = System.currentTimeMillis();
@ -80,8 +81,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

@ -1167,7 +1167,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;
@ -1348,7 +1349,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);
}
}
@ -1356,7 +1357,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

@ -139,10 +139,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

@ -148,9 +148,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;
}
@ -206,21 +206,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: 'EaglercraftXVelocity 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 +1 @@
{"id":"eaglerxvelocity","name":"EaglercraftXVelocity","version":"1.0.5","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","authors":["lax1dude", "ayunami2000"],"dependencies":[],"main":"net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity"}
{"id":"eaglerxvelocity","name":"EaglercraftXVelocity","version":"1.0.6","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","authors":["lax1dude", "ayunami2000"],"dependencies":[],"main":"net.lax1dude.eaglercraft.v1_8.plugin.gateway_velocity.EaglerXVelocity"}

View File

@ -1 +1 @@
1.0.5
1.0.6