From facbb8c9506d8ced1ce94a56f6220c2ab39ebe77 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Sat, 18 Jun 2011 16:33:47 +0000 Subject: [PATCH] * IRC Server: Send a message back if the tunnel is up but the server is down --- .../src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java index 4537389bd2..e21a5a4ab6 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCServer.java @@ -63,6 +63,13 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable { public static final String PROP_HOSTNAME_DEFAULT="%f.b32.i2p"; private static final long HEADER_TIMEOUT = 60*1000; + private final static byte[] ERR_UNAVAILABLE = + (":ircserver.i2p 499 you :" + + "This I2P IRC server is unvailable. It may be down or undergoing maintenance. " + + "Please try again later." + + "\r\n") + .getBytes(); + /** * @throws IllegalArgumentException if the I2PTunnel does not contain * valid config to contact the router @@ -125,7 +132,11 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable { Socket s = new Socket(remoteHost, remotePort); new I2PTunnelRunner(s, socket, slock, null, modifiedRegistration.getBytes(), null); } catch (SocketException ex) { - // TODO send the equivalent of a 503? + try { + // Send a response so the user doesn't just see a disconnect + // and blame his router or the network. + socket.getOutputStream().write(ERR_UNAVAILABLE); + } catch (IOException ioe) {} try { socket.close(); } catch (IOException ioe) {} -- GitLab