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"); this.disconnect("Go fuck yourself");
return; 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) { if(sc == null) {
this.bungee.getLogger().log(Level.WARNING, "player '" + un + "' doesn't have a websocket IP, remote address: " + this.ch.getHandle().remoteAddress().toString()); this.bungee.getLogger().log(Level.WARNING, "player '" + un + "' doesn't have a websocket IP, remote address: " + this.ch.getHandle().remoteAddress().toString());
}else { }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()); 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 != null) {
if(dnm.equalsIgnoreCase("null")) { if(dnm.equalsIgnoreCase("null")) {
this.bungee.getLogger().log(Level.INFO, "Player '" + un + "' [" + sc.toString() + "] is using an offline download"); 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() { public void killConnection() {
localToRemote.remove(localAddress); synchronized(localToRemote) {
origins.remove(localAddress); localToRemote.remove(localAddress);
origins.remove(localAddress);
}
if(tcpChannel != null && tcpChannel.isOpen()) { if(tcpChannel != null && tcpChannel.isOpen()) {
try { try {
tcpChannel.disconnect().sync(); tcpChannel.disconnect().sync();
@ -72,16 +74,20 @@ public class WebSocketProxy extends SimpleChannelInboundHandler<ByteBuf> {
socketChannel.closeFuture().addListener(new GenericFutureListener<Future<? super Void>>() { socketChannel.closeFuture().addListener(new GenericFutureListener<Future<? super Void>>() {
@Override @Override
public void operationComplete(Future<? super Void> paramF) throws Exception { public void operationComplete(Future<? super Void> paramF) throws Exception {
localToRemote.remove(localAddress); synchronized(localToRemote) {
origins.remove(localAddress); localToRemote.remove(localAddress);
origins.remove(localAddress);
}
} }
}); });
} }
}); });
tcpChannel = (NioSocketChannel) clientBootstrap.connect().sync().channel(); tcpChannel = (NioSocketChannel) clientBootstrap.connect().sync().channel();
localToRemote.put(localAddress = tcpChannel.localAddress(), realRemoteAddr); synchronized(localToRemote) {
if(origin != null) { localToRemote.put(localAddress = tcpChannel.localAddress(), realRemoteAddr);
origins.put(localAddress, origin); if(origin != null) {
origins.put(localAddress, origin);
}
} }
return true; return true;
} }
@ -111,8 +117,10 @@ public class WebSocketProxy extends SimpleChannelInboundHandler<ByteBuf> {
} }
public void finalize() { public void finalize() {
localToRemote.remove(localAddress); synchronized(localToRemote) {
origins.remove(localAddress); 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: listeners:
- fallback_server: lobby - fallback_server: lobby
tab_list: GLOBAL_PING tab_list: GLOBAL_PING
@ -49,14 +52,11 @@ listeners:
limit_lockout: 25 limit_lockout: 25
lockout_duration: 900 lockout_duration: 900
exceptions: [] exceptions: []
stats: 1795b100-6c57-4568-957f-810efbd77cc3
groups: {}
player_limit: -1 player_limit: -1
timeout: 30000 origin_blacklist_block_offline_download: false
servers: origin_blacklist_block_missing_origin_header: false
lobby:
address: localhost:25569
restricted: false
server_name: EaglercraftBungee Server
display_ban_type_on_kick: false
permissions: permissions:
default: default:
- bungeecord.command.server - bungeecord.command.server
@ -79,4 +79,8 @@ permissions:
- bungeecord.command.eag.blockdomain - bungeecord.command.eag.blockdomain
- bungeecord.command.eag.blockdomainname - bungeecord.command.eag.blockdomainname
- bungeecord.command.eag.unblockdomain - 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