patched crash loops and concurrency bugs in bungeecord

This commit is contained in:
LAX1DUDE 2022-05-28 19:38:16 -07:00
parent 814cf401b7
commit a5b84481b0
8 changed files with 37 additions and 19 deletions

View File

@ -137,7 +137,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection {
this.disconnect("Go fuck yourself");
return;
}
InetAddress sc = WebSocketProxy.localToRemote.get(this.ch.getHandle().remoteAddress());
InetAddress sc;
synchronized(WebSocketProxy.localToRemote) {
sc = WebSocketProxy.localToRemote.get(this.ch.getHandle().remoteAddress());
}
if(sc == null) {
this.bungee.getLogger().log(Level.WARNING, "player '" + un + "' doesn't have a websocket IP, remote address: " + this.ch.getHandle().remoteAddress().toString());
}else {
@ -150,7 +153,10 @@ public class InitialHandler extends PacketHandler implements PendingConnection {
this.bungee.getLogger().log(Level.INFO, "Player '" + un + "' [" + sc.toString() + "] has remote websocket IP: " + sc.getHostAddress());
}
}
String dnm = WebSocketProxy.origins.get(this.ch.getHandle().remoteAddress());
String dnm;
synchronized(WebSocketProxy.localToRemote) {
dnm = WebSocketProxy.origins.get(this.ch.getHandle().remoteAddress());
}
if(dnm != null) {
if(dnm.equalsIgnoreCase("null")) {
this.bungee.getLogger().log(Level.INFO, "Player '" + un + "' [" + sc.toString() + "] is using an offline download");

View File

@ -47,8 +47,10 @@ public class WebSocketProxy extends SimpleChannelInboundHandler<ByteBuf> {
}
public void killConnection() {
synchronized(localToRemote) {
localToRemote.remove(localAddress);
origins.remove(localAddress);
}
if(tcpChannel != null && tcpChannel.isOpen()) {
try {
tcpChannel.disconnect().sync();
@ -72,17 +74,21 @@ public class WebSocketProxy extends SimpleChannelInboundHandler<ByteBuf> {
socketChannel.closeFuture().addListener(new GenericFutureListener<Future<? super Void>>() {
@Override
public void operationComplete(Future<? super Void> paramF) throws Exception {
synchronized(localToRemote) {
localToRemote.remove(localAddress);
origins.remove(localAddress);
}
}
});
}
});
tcpChannel = (NioSocketChannel) clientBootstrap.connect().sync().channel();
synchronized(localToRemote) {
localToRemote.put(localAddress = tcpChannel.localAddress(), realRemoteAddr);
if(origin != null) {
origins.put(localAddress, origin);
}
}
return true;
}
}catch(Throwable t) {
@ -111,8 +117,10 @@ public class WebSocketProxy extends SimpleChannelInboundHandler<ByteBuf> {
}
public void finalize() {
synchronized(localToRemote) {
localToRemote.remove(localAddress);
origins.remove(localAddress);
}
}
}

View File

@ -1,3 +1,6 @@
origin_blacklist_block_replit_clients: false
enable_web_origin_blacklist: true
server_name: EaglercraftBungee Server
listeners:
- fallback_server: lobby
tab_list: GLOBAL_PING
@ -49,14 +52,11 @@ listeners:
limit_lockout: 25
lockout_duration: 900
exceptions: []
stats: 1795b100-6c57-4568-957f-810efbd77cc3
groups: {}
player_limit: -1
timeout: 30000
servers:
lobby:
address: localhost:25569
restricted: false
server_name: EaglercraftBungee Server
display_ban_type_on_kick: false
origin_blacklist_block_offline_download: false
origin_blacklist_block_missing_origin_header: false
permissions:
default:
- bungeecord.command.server
@ -79,4 +79,8 @@ permissions:
- bungeecord.command.eag.blockdomain
- bungeecord.command.eag.blockdomainname
- bungeecord.command.eag.unblockdomain
groups: {}
origin_blacklist_subscriptions:
- https://g.eags.us/eaglercraft/origin_blacklist.txt
- https://raw.githubusercontent.com/LAX1DUDE/eaglercraft/main/stable-download/origin_blacklist.txt
display_ban_type_on_kick: false
timeout: 30000