2005-09-30 jrandom
* Only allow autodetection of our IP address if we haven't received an inbound connection in the last two minutes. * Increase the default max streaming resends to 8 from 5 (and down from the earlier 10)
This commit is contained in:
@ -55,6 +55,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
|
||||
private static final int TREND_COUNT = 3;
|
||||
static final int INITIAL_WINDOW_SIZE = 4;
|
||||
static final int DEFAULT_MAX_SENDS = 8;
|
||||
|
||||
public ConnectionOptions() {
|
||||
super();
|
||||
@ -102,7 +103,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
setResendDelay(getInt(opts, PROP_INITIAL_RESEND_DELAY, 1000));
|
||||
setSendAckDelay(getInt(opts, PROP_INITIAL_ACK_DELAY, 500));
|
||||
setWindowSize(getInt(opts, PROP_INITIAL_WINDOW_SIZE, INITIAL_WINDOW_SIZE));
|
||||
setMaxResends(getInt(opts, PROP_MAX_RESENDS, 5));
|
||||
setMaxResends(getInt(opts, PROP_MAX_RESENDS, DEFAULT_MAX_SENDS));
|
||||
setWriteTimeout(getInt(opts, PROP_WRITE_TIMEOUT, -1));
|
||||
setInactivityTimeout(getInt(opts, PROP_INACTIVITY_TIMEOUT, 2*60*1000));
|
||||
setInactivityAction(getInt(opts, PROP_INACTIVITY_ACTION, INACTIVITY_ACTION_DISCONNECT));
|
||||
@ -135,7 +136,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
|
||||
if (opts.containsKey(PROP_INITIAL_WINDOW_SIZE))
|
||||
setWindowSize(getInt(opts, PROP_INITIAL_WINDOW_SIZE, INITIAL_WINDOW_SIZE));
|
||||
if (opts.containsKey(PROP_MAX_RESENDS))
|
||||
setMaxResends(getInt(opts, PROP_MAX_RESENDS, 5));
|
||||
setMaxResends(getInt(opts, PROP_MAX_RESENDS, DEFAULT_MAX_SENDS));
|
||||
if (opts.containsKey(PROP_WRITE_TIMEOUT))
|
||||
setWriteTimeout(getInt(opts, PROP_WRITE_TIMEOUT, -1));
|
||||
if (opts.containsKey(PROP_INACTIVITY_TIMEOUT))
|
||||
|
@ -1,4 +1,10 @@
|
||||
$Id: history.txt,v 1.272 2005/09/30 02:32:47 ragnarok Exp $
|
||||
$Id: history.txt,v 1.273 2005/09/30 12:51:32 ragnarok Exp $
|
||||
|
||||
2005-09-30 jrandom
|
||||
* Only allow autodetection of our IP address if we haven't received an
|
||||
inbound connection in the last two minutes.
|
||||
* Increase the default max streaming resends to 8 from 5 (and down from
|
||||
the earlier 10)
|
||||
|
||||
2005-09-29 ragnarok
|
||||
* Export petnames from syndie to the router's petname db instead of
|
||||
|
@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
|
||||
*
|
||||
*/
|
||||
public class RouterVersion {
|
||||
public final static String ID = "$Revision: 1.250 $ $Date: 2005/09/29 14:19:23 $";
|
||||
public final static String ID = "$Revision: 1.251 $ $Date: 2005/09/30 02:17:57 $";
|
||||
public final static String VERSION = "0.6.1";
|
||||
public final static long BUILD = 1;
|
||||
public final static long BUILD = 2;
|
||||
public static void main(String args[]) {
|
||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||
System.out.println("Router ID: " + RouterVersion.ID);
|
||||
|
@ -355,6 +355,8 @@ public class EstablishmentManager {
|
||||
|
||||
_transport.addRemotePeerState(peer);
|
||||
|
||||
_transport.inboundConnectionReceived();
|
||||
|
||||
_context.statManager().addRateData("udp.inboundEstablishTime", state.getLifetime(), 0);
|
||||
sendOurInfo(peer);
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
private short _reachabilityStatus;
|
||||
private long _reachabilityStatusLastUpdated;
|
||||
private long _introducersSelectedOn;
|
||||
private long _lastInboundReceivedOn;
|
||||
|
||||
/** summary info to distribute */
|
||||
private RouterAddress _externalAddress;
|
||||
@ -135,6 +136,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
_reachabilityStatus = CommSystemFacade.STATUS_UNKNOWN;
|
||||
_introManager = new IntroductionManager(_context, this);
|
||||
_introducersSelectedOn = -1;
|
||||
_lastInboundReceivedOn = -1;
|
||||
|
||||
_context.statManager().createRateStat("udp.alreadyConnected", "What is the lifetime of a reestablished session", "udp", new long[] { 60*1000, 10*60*1000, 60*60*1000, 24*60*60*1000 });
|
||||
_context.statManager().createRateStat("udp.droppedPeer", "How long ago did we receive from a dropped peer (duration == session lifetime", "udp", new long[] { 60*60*1000, 24*60*60*1000 });
|
||||
@ -270,6 +272,17 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
public InetAddress getLocalAddress() { return _externalListenHost; }
|
||||
public int getExternalPort() { return _externalListenPort; }
|
||||
|
||||
/**
|
||||
* If we have received an inbound connection in the last 2 minutes, don't allow
|
||||
* our IP to change.
|
||||
*/
|
||||
private static final int ALLOW_IP_CHANGE_INTERVAL = 2*60*1000;
|
||||
|
||||
void inboundConnectionReceived() {
|
||||
// use OS clock since its an ordering thing, not a time thing
|
||||
_lastInboundReceivedOn = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Someone we tried to contact gave us what they think our IP address is.
|
||||
* Right now, we just blindly trust them, changing our IP and port on a
|
||||
@ -277,22 +290,31 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
*
|
||||
*/
|
||||
void externalAddressReceived(Hash from, byte ourIP[], int ourPort) {
|
||||
boolean isValid = isValid(ourIP);
|
||||
boolean explicitSpecified = explicitAddressSpecified();
|
||||
boolean inboundRecent = _lastInboundReceivedOn + ALLOW_IP_CHANGE_INTERVAL > System.currentTimeMillis();
|
||||
if (_log.shouldLog(Log.INFO))
|
||||
_log.info("External address received: " + RemoteHostId.toString(ourIP) + ":" + ourPort + " from " + from.toBase64());
|
||||
_log.info("External address received: " + RemoteHostId.toString(ourIP) + ":" + ourPort + " from "
|
||||
+ from.toBase64() + ", isValid? " + isValid + ", explicitSpecified? " + explicitSpecified
|
||||
+ ", receivedInboundRecent? " + inboundRecent);
|
||||
|
||||
if (explicitAddressSpecified())
|
||||
if (explicitSpecified)
|
||||
return;
|
||||
|
||||
boolean fixedPort = getIsPortFixed();
|
||||
boolean updated = false;
|
||||
boolean fireTest = false;
|
||||
if (!isValid(ourIP)) {
|
||||
if (!isValid) {
|
||||
// ignore them
|
||||
if (_log.shouldLog(Log.ERROR))
|
||||
_log.error("The router " + from.toBase64() + " told us we have an invalid IP - "
|
||||
+ RemoteHostId.toString(ourIP) + ". Lets throw tomatoes at them");
|
||||
_context.shitlist().shitlistRouter(from, "They said we had an invalid IP");
|
||||
return;
|
||||
} else if (inboundRecent) {
|
||||
// use OS clock since its an ordering thing, not a time thing
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Ignoring IP address suggestion, since we have received an inbound con recently");
|
||||
} else {
|
||||
synchronized (this) {
|
||||
if ( (_externalListenHost == null) ||
|
||||
|
Reference in New Issue
Block a user