2004-10-17 jrandom

* Don't b0rk on whitespace in the router address.
This commit is contained in:
jrandom
2004-10-17 21:03:05 +00:00
committed by zzz
parent 78aa4ca137
commit 9011d5604a
4 changed files with 37 additions and 30 deletions

View File

@@ -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 2004-10-16 jrandom
* More aggressively reduce the capacity of peers if their tunnels are * More aggressively reduce the capacity of peers if their tunnels are

View File

@@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
* *
*/ */
public class RouterVersion { 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 String VERSION = "0.4.1.2";
public final static long BUILD = 7; public final static long BUILD = 8;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION); System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);

View File

@@ -64,15 +64,19 @@ public class TCPAddress {
return; return;
} }
String host = addr.getOptions().getProperty(PROP_HOST); String host = addr.getOptions().getProperty(PROP_HOST);
if (host == null) {
_host = null;
_port = -1;
} else {
try { try {
InetAddress iaddr = InetAddress.getByName(host); InetAddress iaddr = InetAddress.getByName(host.trim());
_host = iaddr.getHostAddress(); _host = iaddr.getHostAddress();
_addr = iaddr; _addr = iaddr;
String port = addr.getOptions().getProperty(PROP_PORT); String port = addr.getOptions().getProperty(PROP_PORT);
if ( (port != null) && (port.trim().length() > 0) ) { if ( (port != null) && (port.trim().length() > 0) ) {
try { try {
_port = Integer.parseInt(port); _port = Integer.parseInt(port.trim());
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
_log.error("Invalid port [" + port + "]", nfe); _log.error("Invalid port [" + port + "]", nfe);
_port = -1; _port = -1;
@@ -85,6 +89,7 @@ public class TCPAddress {
_port = -1; _port = -1;
} }
} }
}
public RouterAddress toRouterAddress() { public RouterAddress toRouterAddress() {
if ( (_host == null) || (_port <= 0) ) if ( (_host == null) || (_port <= 0) )
@@ -146,21 +151,20 @@ public class TCPAddress {
if (_addr != null) if (_addr != null)
rv += _addr.getHostAddress().hashCode(); rv += _addr.getHostAddress().hashCode();
else else
if (_host != null) rv += _host.hashCode(); if (_host != null) rv += _host.trim().hashCode();
return rv; return rv;
} }
public boolean equals(Object val) { public boolean equals(Object val) {
if ( (val != null) && (val instanceof TCPAddress) ) { if ( (val != null) && (val instanceof TCPAddress) ) {
TCPAddress addr = (TCPAddress)val; TCPAddress addr = (TCPAddress)val;
if ( (_addr != null) && (_addr.getHostAddress() != null) String hostname = null;
&& (addr.getAddress() != null) && (addr.getAddress().getHostAddress() != null) ) { if (addr.getHost() != null)
return DataHelper.eq(getAddress().getHostAddress(), addr.getAddress().getHostAddress()) hostname = addr.getHost().trim();
&& (getPort() == addr.getPort()); String ourHost = getHost();
} else { if (ourHost != null)
return DataHelper.eq(getHost(), addr.getHost()) ourHost = ourHost.trim();
&& (getPort() == addr.getPort()); return DataHelper.eq(hostname, ourHost) && getPort() == addr.getPort();
}
} }
return false; return false;
} }

View File

@@ -524,7 +524,7 @@ public class TCPTransport extends TransportImpl {
String port = _context.getProperty(LISTEN_PORT, DEFAULT_LISTEN_PORT+""); String port = _context.getProperty(LISTEN_PORT, DEFAULT_LISTEN_PORT+"");
if (port != null) { if (port != null) {
try { try {
int portNum = Integer.parseInt(port); int portNum = Integer.parseInt(port.trim());
if ( (portNum >= 1) && (portNum < 65535) ) if ( (portNum >= 1) && (portNum < 65535) )
return portNum; return portNum;
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {