i2ptunnel: Return error message from IRC client on failure to build tunnels

previously just closed the socket
This commit is contained in:
zzz
2023-01-15 12:38:00 -05:00
parent 19e3122f48
commit 399575aba5

View File

@@ -137,7 +137,18 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase {
if (clientDest == null)
throw new UnknownHostException("Could not resolve " + addr.getHostName());
int port = addr.getPort();
i2ps = createI2PSocket(clientDest, port);
try {
i2ps = createI2PSocket(clientDest, port);
} catch (RuntimeException re) {
// tunnel build failure
_log.error("Error connecting", re);
try {
String name = addr != null ? addr.getHostName() : "undefined";
String msg = ":" + name + " 499 you :" + re.getMessage() + "\r\n";
s.getOutputStream().write(DataHelper.getUTF8(msg));
} catch (IOException ioe) {}
throw re;
}
i2ps.setReadTimeout(readTimeout);
StringBuffer expectedPong = new StringBuffer();
DCCHelper dcc = _dccEnabled ? new DCC(s.getLocalAddress().getAddress()) : null;