diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java index d33e0f265..8add30c05 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelIRCClient.java @@ -228,36 +228,6 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable String outmsg = outboundFilter(inmsg); if(outmsg!=null) { - if (outmsg.indexOf("PING") >= 0) { - // Most clients just send a PING and are happy with any old PONG. Others, - // like BitchX, actually expect certain behavior. It sends two different pings: - // "PING :irc.freshcoffee.i2p" and "PING 1234567890 127.0.0.1" (where the IP is the proxy) - // the PONG to the former seems to be "PONG 127.0.0.1", while the PONG to the later is - // ":irc.freshcoffee.i2p PONG irc.freshcoffe.i2p :1234567890". - // We don't want to send them our proxy's IP address, so we need to rewrite the PING - // sent to the server, but when we get a PONG back, use what we expected, rather than - // what they sent. - // - // Yuck. - StringTokenizer tok = new StringTokenizer(inmsg, " "); - int tokens = tok.countTokens(); - if ( (tokens <= 2) || (tokens == 3) ) { // "PING nonce" or "PING nonce serverIP" - tok.nextToken(); // skip - //_expectedPong = "PONG 127.0.0.1 :" + tok.nextToken(); - _expectedPong = "PONG " + tok.nextToken(); - } else { - // if it isn't one of those two, we will filter out all PONGs, which means - // the client will fail. whee! - if (_log.shouldLog(Log.ERROR)) - _log.error("IRC client sent a PING we don't understand (\"" + inmsg + "\"), so we're filtering it"); - _expectedPong = null; - } - if (_log.shouldLog(Log.WARN)) { - _log.warn("outbound rewritten PING: "+outmsg + ", waiting for [" + _expectedPong + "]"); - _log.warn(" - outbound was: "+inmsg); - } - } - if(!inmsg.equals(outmsg)) { if (_log.shouldLog(Log.WARN)) { _log.warn("outbound FILTERED: "+outmsg); @@ -377,7 +347,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable return null; } - public static String outboundFilter(String s) { + public String outboundFilter(String s) { String field[]=s.split(" ",3); String command; @@ -415,18 +385,38 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable command = field[0].toUpperCase(); if ("PING".equals(command)) { - // e.g. "PING", "PING nonce", or "PING nonce serverIP" - if (field.length == 1) { - return "PING"; - } else if (field.length == 2) { - return "PING " + field[1]; - } else if (field.length == 3) { - return "PING " + field[1]; + // Most clients just send a PING and are happy with any old PONG. Others, + // like BitchX, actually expect certain behavior. It sends two different pings: + // "PING :irc.freshcoffee.i2p" and "PING 1234567890 127.0.0.1" (where the IP is the proxy) + // the PONG to the former seems to be "PONG 127.0.0.1", while the PONG to the later is + // ":irc.freshcoffee.i2p PONG irc.freshcoffe.i2p :1234567890". + // We don't want to send them our proxy's IP address, so we need to rewrite the PING + // sent to the server, but when we get a PONG back, use what we expected, rather than + // what they sent. + // + // Yuck. + + String rv = null; + if (field.length == 1) { // PING + rv = "PING"; + _expectedPong = "PONG 127.0.0.1"; + } else if (field.length == 2) { // PING nonce + rv = "PING " + field[1]; + _expectedPong = "PONG " + field[1]; + } else if (field.length == 3) { // PING nonce serverLocation + rv = "PING " + field[1]; + _expectedPong = "PONG " + field[1]; } else { if (_log.shouldLog(Log.ERROR)) _log.error("IRC client sent a PING we don't understand, filtering it (\"" + s + "\")"); - return null; + rv = null; + _expectedPong = null; } + + if (_log.shouldLog(Log.WARN)) + _log.warn("sending ping " + rv + ", waiting for " + _expectedPong + " orig was [" + s + "]"); + + return rv; } if ("PONG".equals(command)) return "PONG 127.0.0.1"; // no way to know what the ircd to i2ptunnel server con is, so localhost works diff --git a/history.txt b/history.txt index 2a262200f..29efff5f1 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,7 @@ -$Id: history.txt,v 1.446 2006/04/05 12:08:04 jrandom Exp $ +$Id: history.txt,v 1.447 2006/04/06 05:33:46 jrandom Exp $ + +2006-04-06 jrandom + * Fix for a bug in the new irc ping/pong filter (thanks Complication!) 2006-04-06 jrandom * Fixed a typo in the reply cleanup code diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 5464e2d4e..41709cce3 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -15,9 +15,9 @@ import net.i2p.CoreVersion; * */ public class RouterVersion { - public final static String ID = "$Revision: 1.386 $ $Date: 2006/04/05 12:08:10 $"; + public final static String ID = "$Revision: 1.387 $ $Date: 2006/04/06 05:33:47 $"; public final static String VERSION = "0.6.1.14"; - public final static long BUILD = 1; + public final static long BUILD = 2; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/RouterWatchdog.java b/router/java/src/net/i2p/router/RouterWatchdog.java index 6ed140b35..da1ee1e05 100644 --- a/router/java/src/net/i2p/router/RouterWatchdog.java +++ b/router/java/src/net/i2p/router/RouterWatchdog.java @@ -53,6 +53,7 @@ class RouterWatchdog implements Runnable { private void dumpStatus() { if (_log.shouldLog(Log.ERROR)) { Job cur = _context.jobQueue().getLastJob(); + /* if (cur != null) _log.error("Most recent job: " + cur); _log.error("Last job began: " @@ -61,6 +62,7 @@ class RouterWatchdog implements Runnable { _log.error("Last job ended: " + DataHelper.formatDuration(_context.clock().now()-_context.jobQueue().getLastJobEnd()) + " ago"); + */ _log.error("Ready and waiting jobs: " + _context.jobQueue().getReadyCount()); _log.error("Job lag: " + _context.jobQueue().getMaxLag()); _log.error("Participating tunnel count: " + _context.tunnelManager().getParticipatingCount());