diff --git a/history.txt b/history.txt index 3dbe12ce1..082fa6459 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,7 @@ -$Id: history.txt,v 1.51 2004/10/16 22:58:09 jrandom Exp $ +$Id: history.txt,v 1.52 2004/10/16 23:00:21 jrandom Exp $ + +2004-10-17 jrandom + * Don't b0rk on whitespace in the router address. 2004-10-16 jrandom * More aggressively reduce the capacity of peers if their tunnels are diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 5e364f549..68b51e146 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.57 $ $Date: 2004/10/16 13:00:47 $"; + public final static String ID = "$Revision: 1.58 $ $Date: 2004/10/16 22:58:09 $"; public final static String VERSION = "0.4.1.2"; - public final static long BUILD = 7; + public final static long BUILD = 8; public static void main(String args[]) { System.out.println("I2P Router version: " + VERSION); System.out.println("Router ID: " + RouterVersion.ID); diff --git a/router/java/src/net/i2p/router/transport/tcp/TCPAddress.java b/router/java/src/net/i2p/router/transport/tcp/TCPAddress.java index 521c60c8d..bbf2b1050 100644 --- a/router/java/src/net/i2p/router/transport/tcp/TCPAddress.java +++ b/router/java/src/net/i2p/router/transport/tcp/TCPAddress.java @@ -64,25 +64,30 @@ public class TCPAddress { return; } String host = addr.getOptions().getProperty(PROP_HOST); - try { - InetAddress iaddr = InetAddress.getByName(host); - _host = iaddr.getHostAddress(); - _addr = iaddr; - - String port = addr.getOptions().getProperty(PROP_PORT); - if ( (port != null) && (port.trim().length() > 0) ) { - try { - _port = Integer.parseInt(port); - } catch (NumberFormatException nfe) { - _log.error("Invalid port [" + port + "]", nfe); - _port = -1; - } - } else { - _port = -1; - } - } catch (UnknownHostException uhe) { + if (host == null) { _host = null; _port = -1; + } else { + try { + InetAddress iaddr = InetAddress.getByName(host.trim()); + _host = iaddr.getHostAddress(); + _addr = iaddr; + + String port = addr.getOptions().getProperty(PROP_PORT); + if ( (port != null) && (port.trim().length() > 0) ) { + try { + _port = Integer.parseInt(port.trim()); + } catch (NumberFormatException nfe) { + _log.error("Invalid port [" + port + "]", nfe); + _port = -1; + } + } else { + _port = -1; + } + } catch (UnknownHostException uhe) { + _host = null; + _port = -1; + } } } @@ -146,21 +151,20 @@ public class TCPAddress { if (_addr != null) rv += _addr.getHostAddress().hashCode(); else - if (_host != null) rv += _host.hashCode(); + if (_host != null) rv += _host.trim().hashCode(); return rv; } public boolean equals(Object val) { if ( (val != null) && (val instanceof TCPAddress) ) { TCPAddress addr = (TCPAddress)val; - if ( (_addr != null) && (_addr.getHostAddress() != null) - && (addr.getAddress() != null) && (addr.getAddress().getHostAddress() != null) ) { - return DataHelper.eq(getAddress().getHostAddress(), addr.getAddress().getHostAddress()) - && (getPort() == addr.getPort()); - } else { - return DataHelper.eq(getHost(), addr.getHost()) - && (getPort() == addr.getPort()); - } + String hostname = null; + if (addr.getHost() != null) + hostname = addr.getHost().trim(); + String ourHost = getHost(); + if (ourHost != null) + ourHost = ourHost.trim(); + return DataHelper.eq(hostname, ourHost) && getPort() == addr.getPort(); } return false; } diff --git a/router/java/src/net/i2p/router/transport/tcp/TCPTransport.java b/router/java/src/net/i2p/router/transport/tcp/TCPTransport.java index 1494f73bc..4a0f79dec 100644 --- a/router/java/src/net/i2p/router/transport/tcp/TCPTransport.java +++ b/router/java/src/net/i2p/router/transport/tcp/TCPTransport.java @@ -524,7 +524,7 @@ public class TCPTransport extends TransportImpl { String port = _context.getProperty(LISTEN_PORT, DEFAULT_LISTEN_PORT+""); if (port != null) { try { - int portNum = Integer.parseInt(port); + int portNum = Integer.parseInt(port.trim()); if ( (portNum >= 1) && (portNum < 65535) ) return portNum; } catch (NumberFormatException nfe) {