diff --git a/src/main/java/net/raphimc/viaproxy/ViaProxy.java b/src/main/java/net/raphimc/viaproxy/ViaProxy.java index b7307e5..d5ef6aa 100644 --- a/src/main/java/net/raphimc/viaproxy/ViaProxy.java +++ b/src/main/java/net/raphimc/viaproxy/ViaProxy.java @@ -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() {