Fixed proxy server being in an inconsistent state when an error occurred

This commit is contained in:
RaphiMC 2023-01-09 21:40:56 +01:00
parent ad907dabd3
commit 482155250d

View File

@ -137,9 +137,14 @@ public class ViaProxy {
if (currentProxyServer != null) {
throw new IllegalStateException("Proxy is already running");
}
currentProxyServer = new NetServer(Client2ProxyHandler::new, Client2ProxyChannelInitializer::new);
Logger.LOGGER.info("Binding proxy server to " + Options.BIND_ADDRESS + ":" + Options.BIND_PORT);
currentProxyServer.bind(Options.BIND_ADDRESS, Options.BIND_PORT, false);
try {
currentProxyServer = new NetServer(Client2ProxyHandler::new, Client2ProxyChannelInitializer::new);
Logger.LOGGER.info("Binding proxy server to " + Options.BIND_ADDRESS + ":" + Options.BIND_PORT);
currentProxyServer.bind(Options.BIND_ADDRESS, Options.BIND_PORT, false);
} catch (Throwable e) {
currentProxyServer = null;
throw e;
}
}
public static void stopProxy() {