i2ptunnel: Fix IRC USER filtering

Wasn't passing through user and realname fields
Pass through RFC 2812 mode field if present
reported by RN
This commit is contained in:
zzz
2022-11-12 15:26:27 -05:00
parent 7b75ee5a0a
commit e54f5ffadd
3 changed files with 33 additions and 7 deletions

View File

@@ -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;
}

View File

@@ -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:

View File

@@ -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";