diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java index 66b3abf41e7058dd96688cba01bad76bb5796f26..3cfbab78359f381d93e9fc5f5c1f1657a025fc38 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/irc/IRCFilter.java @@ -389,15 +389,35 @@ abstract class IRCFilter { } return s; } - + if("USER".equals(command)) { - if (field.length < idx + 2) + // USER <username> <hostname> <servername> <realname> (RFC 1459) + // USER <user> <mode> <unused> <realname> (RFC 2812) + // <realname> may contain spaces, and thus must be prefixed with a colon. + if (field.length < idx + 3) return s; // invalid, allow server response - int cidx = field[idx + 1].lastIndexOf(':'); + // Replace hostname/servername; pass numeric mode and unused '*' through unchanged + String hostname = field[idx + 1]; + try { + Integer.parseInt(hostname); + // mode + } catch (NumberFormatException nfe) { + hostname = "hostname"; + } + // Warning: max field size is 4, so servername or unused is combined with realname + // in field[idx + 2] + String servername; + if (field[idx + 2].startsWith("* ")) + servername = "*"; + else + servername = "localhost"; + String realname; + int cidx = field[idx + 2].lastIndexOf(':'); if (cidx < 0) - return "USER user hostname localhost :realname"; - String realname = field[idx + 1].substring(cidx + 1); - String ret = "USER " + field[idx] + " hostname localhost :" + realname; + realname = "realname"; + else + realname = field[idx + 2].substring(cidx + 1); + String ret = "USER " + field[idx] + ' ' + hostname + ' ' + servername + " :" + realname; return ret; } diff --git a/history.txt b/history.txt index 289c34c70b8efd22ad80017923a42062e8cf0d36..5f3c7aee60e139a520ac2aa8bd001c52889ae7fa 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,9 @@ +2022-11-12 zzz + * i2ptunnel: Fix IRC USER filtering + +2022-11-09 zzz + * SAM: Add warning at startup if not bound to localhost + 2022-11-01 zzz * GeoIP 2022-11-01 * SSU: diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index def90930fcea35dae96903e8b43b7df5da00949d..b9f86d25e4422f20495f1c0e9fe65f4a4af20eab 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Git"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 14; + public final static long BUILD = 15; /** for example "-test" */ public final static String EXTRA = "-rc";