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
* 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 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);

View File

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

View File

@ -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) {