>> > I wonder what we could do if a node knew it didn't need hole > punching or a node knew a particular peer didn't need hole > punching. (How the node would know is irrelevant at this point in > the discussion.) >
Exactly ;) But that only works when a node knows, 100% that it is not behind a NAT. While it would be best if the node automatically detected, right now, only a human can say. After talking on IRC with toad and Zothar, I've made a patch to allow a human to set that, and thus set the Max backoff time. Of course, I didn't know about svn diff until it was too late, and I had already moved it, and removed .svn files to make a unix style diff. http://code.bulix.org/6007 I tried to clean it up a bit, to remove a few changes that other people had made to the tree while I was working. That follows- http://code.bulix.org/6008 diff -r -u freenet/src/freenet/node/ARKFetcher.java modified/src/ freenet/node/ARKFetcher.java --- freenet/src/freenet/node/ARKFetcher.java 2006-06-02 11:29:14.000000000 -0400 +++ modified/src/freenet/node/ARKFetcher.java 2006-06-02 11:34:45.000000000 -0400 @@ -15,6 +15,11 @@ import freenet.support.Logger; import freenet.support.SimpleFieldSet; +import freenet.config.Config; +import freenet.config.LongCallback; +import freenet.config.SubConfig; + + /** * Fetch an ARK. Permanent, tied to a PeerNode, stops itself after a successful fetch. */ @@ -25,18 +30,18 @@ private ClientGetter getter; private FreenetURI fetchingURI; private boolean shouldRun = false; - private static final int MAX_BACKOFF = 60*60*1000; private static final int MIN_BACKOFF = 5*1000; private int backoff = MIN_BACKOFF; private String identity; private boolean isFetching = false; - + public ARKFetcher(PeerNode peer, Node node) { this.peer = peer; this.node = node; this.identity = peer.getIdentityString(); } + /** * Called when the node starts / is added, and also when we fail to connect twice * after a new reference. (So we get one from the ARK, we wait for the current @@ -141,7 +146,7 @@ return; } backoff += backoff; - if(backoff > MAX_BACKOFF) backoff = MAX_BACKOFF; + if(backoff > node.Max_Arkbackoff) backoff = node.Max_Arkbackoff; Logger.minor(this, "Failed to fetch ARK for "+peer+", now backing off ARK fetches for "+(int) (backoff / 1000)+" seconds"); // We may be on the PacketSender thread. // FIXME should this be exponential backoff? diff -r -u freenet/src/freenet/node/Node.java modified/src/freenet/ node/Node.java --- freenet/src/freenet/node/Node.java 2006-06-02 11:29:14.000000000 -0400 +++ modified/src/freenet/node/Node.java 2006-06-02 11:27:07.000000000 -0400 @@ -601,6 +601,8 @@ private static NodeStarter nodeStarter; + public int Max_Arkbackoff; + /** * Read all storable settings (identity etc) from the node file. * @param filename The name of the file to read from. @@ -921,7 +923,7 @@ bootID = random.nextLong(); throttledPacketSendAverage = new TimeDecayingRunningAverage(1, 10*60*1000 /* should be significantly longer than a typical transfer */, 0, Long.MAX_VALUE); - + Max_Arkbackoff=60*60*1000; // Setup node-specific configuration SubConfig nodeConfig = new SubConfig("node", config); @@ -1126,7 +1128,17 @@ } - + + nodeConfig.register("MaximumArkdelay", 60*60*1000 /* 1 per minute */,2, true, "Maximum delay between ARK requests", "Maximum delay (in seconds) between ARK requests- Do not touch this unless you are *SURE* you are not behind a NAT.", + new IntCallback() { + public int get() { + return Max_Arkbackoff; + } + public void set(int val) { + if(val == Max_Arkbackoff) return; + val = Max_Arkbackoff; + } + }); // Directory for node-related files other than store nodeConfig.register("nodeDir", ".", 6, true, "Node directory", "Name of directory to put node-related files e.g. peers list in",
