2004-10-05 jrandom

* Allow peers on the same LAN to communicate with each other safely even
      when they cannot talk to each other through the external address.
This commit is contained in:
jrandom
2004-10-06 01:12:03 +00:00
committed by zzz
parent 98c780415b
commit 29287da37c
4 changed files with 24 additions and 10 deletions

View File

@ -1,4 +1,8 @@
$Id: history.txt,v 1.33 2004/10/05 10:38:37 jrandom Exp $
$Id: history.txt,v 1.34 2004/10/05 14:21:47 jrandom Exp $
2004-10-05 jrandom
* Allow peers on the same LAN to communicate with each other safely even
when they cannot talk to each other through the external address.
2004-10-05 jrandom
* Display how much time is left before the graceful shutdown is complete.

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.42 $ $Date: 2004/10/04 12:30:23 $";
public final static String ID = "$Revision: 1.43 $ $Date: 2004/10/05 10:39:19 $";
public final static String VERSION = "0.4.1.1";
public final static long BUILD = 8;
public final static long BUILD = 9;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -675,22 +675,29 @@ public class ConnectionHandler {
private boolean verifyReachability() {
if (_actualPeer == null) return false;
_remoteAddress = new TCPAddress(_actualPeer.getTargetAddress(TCPTransport.STYLE));
if (!_transport.allowAddress(_remoteAddress))
if ( (_remoteAddress.getPort() <= 0) || (_remoteAddress.getPort() > 65535) )
return false;
TCPAddress testAddress = _remoteAddress;
// if it is a LAN address, test with that address and not the public one
if (!TCPAddress.isPubliclyRoutable(_from)) {
testAddress = new TCPAddress(_from, _remoteAddress.getPort());
}
try {
return verifyReachability(_remoteAddress);
return verifyReachability(testAddress);
} catch (IOException ioe) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error verifying "
+ _actualPeer.getIdentity().calculateHash().toBase64().substring(0,6)
+ "at " + _remoteAddress, ioe);
+ "at " + testAddress, ioe);
return false;
} catch (DataFormatException dfe) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error verifying "
+ _actualPeer.getIdentity().calculateHash().toBase64().substring(0,6)
+ "at " + _remoteAddress, dfe);
+ "at " + testAddress, dfe);
return false;
}
}

View File

@ -112,13 +112,16 @@ public class TCPAddress {
public void setPort(int port) { _port = port; }
public boolean isPubliclyRoutable() {
if (_host == null) return false;
return isPubliclyRoutable(_host);
}
public static boolean isPubliclyRoutable(String host) {
if (host == null) return false;
try {
InetAddress addr = InetAddress.getByName(_host);
InetAddress addr = InetAddress.getByName(host);
byte quad[] = addr.getAddress();
if (quad.length != 4) {
if (_log.shouldLog(Log.ERROR))
_log.error("Refusing IPv6 address (" + _host + " / " + addr.getHostAddress() + ") "
_log.error("Refusing IPv6 address (" + host + " / " + addr.getHostAddress() + ") "
+ " since not all peers support it, and we don't support restricted routes");
return false;
}