Author: toad
Date: 2008-12-06 16:32:31 +0000 (Sat, 06 Dec 2008)
New Revision: 24102
Modified:
trunk/freenet/src/freenet/clients/http/staticfiles/defaultbookmarks.dat
trunk/freenet/src/freenet/node/FNPPacketMangler.java
trunk/freenet/src/freenet/node/OpennetManager.java
trunk/freenet/src/freenet/node/OpennetPeerNode.java
trunk/freenet/src/freenet/node/PacketSender.java
trunk/freenet/src/freenet/node/PeerNode.java
trunk/freenet/src/freenet/node/RequestHandler.java
trunk/freenet/src/freenet/node/Version.java
trunk/freenet/test/freenet/support/io/MockInputStream.java
Log:
Un-revert.
Modified:
trunk/freenet/src/freenet/clients/http/staticfiles/defaultbookmarks.dat
===================================================================
--- trunk/freenet/src/freenet/clients/http/staticfiles/defaultbookmarks.dat
2008-12-06 16:28:56 UTC (rev 24101)
+++ trunk/freenet/src/freenet/clients/http/staticfiles/defaultbookmarks.dat
2008-12-06 16:32:31 UTC (rev 24102)
@@ -7,26 +7,26 @@
BookmarkCategory0.Content.Bookmark0.Name=The Ultimate FreeNet Index
BookmarkCategory0.Content.Bookmark0.Description=A new one-page index with a
menu including categories
BookmarkCategory0.Content.Bookmark0.hasAnActivelink=true
[EMAIL
PROTECTED],3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/Ultimate-Freenet-Index/35/
[EMAIL
PROTECTED],3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/Ultimate-Freenet-Index/37/
BookmarkCategory0.Content.Bookmark3.Name=Index des sites Français
BookmarkCategory0.Content.Bookmark3.Description=A small French index with
descriptions
BookmarkCategory0.Content.Bookmark3.hasAnActivelink=true
[EMAIL
PROTECTED],pOloLxnKWM~AL24iDMHOAvTvCqMlB-p2BO9zK96TOZA,AQACAAE/index_fr/73/
[EMAIL
PROTECTED],pOloLxnKWM~AL24iDMHOAvTvCqMlB-p2BO9zK96TOZA,AQACAAE/index_fr/77/
BookmarkCategory0.Content.Bookmark2.Name=Freenet Activelink Index (SLOW:
graphical index, preloads all the sites, so takes *ages* to load)
BookmarkCategory0.Content.Bookmark2.hasAnActivelink=true
BookmarkCategory0.Content.Bookmark2.Description=A graphical freenet index
(this will take a long time to load as it preloads the sites)
[EMAIL
PROTECTED],xTFOV9ddCQQk6vQ6G~jfL6IzRUgmfMcZJ6nuySu~NUc,AQACAAE/activelink-index/93/
[EMAIL
PROTECTED],xTFOV9ddCQQk6vQ6G~jfL6IzRUgmfMcZJ6nuySu~NUc,AQACAAE/activelink-index/95/
BookmarkCategory0.Content.Bookmark1.Name=Freenet Activelink Index Text Version
(a quick-loading non-graphical index site, no porn)
BookmarkCategory0.Content.Bookmark1.hasAnActivelink=true
BookmarkCategory0.Content.Bookmark1.Description=Text version of the Activelink
Index
[EMAIL
PROTECTED],xTFOV9ddCQQk6vQ6G~jfL6IzRUgmfMcZJ6nuySu~NUc,AQACAAE/activelink-index-text/54/
[EMAIL
PROTECTED],xTFOV9ddCQQk6vQ6G~jfL6IzRUgmfMcZJ6nuySu~NUc,AQACAAE/activelink-index-text/56/
BookmarkCategory1.Name=Freenet related software and documentation
BookmarkCategory1.Content.BookmarkCategory=0
BookmarkCategory1.Content.Bookmark=5
BookmarkCategory1.Content.Bookmark0.Name=Freenet Message System
BookmarkCategory1.Content.Bookmark0.Description=The official freesite of FMS,
a spam resistant message board system for Freenet
BookmarkCategory1.Content.Bookmark0.hasAnActivelink=true
[EMAIL PROTECTED],~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/84/
[EMAIL PROTECTED],~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/85/
BookmarkCategory1.Content.Bookmark1.Name=Freemail
BookmarkCategory1.Content.Bookmark1.Description=The official site for Freemail
- email over Freenet
BookmarkCategory1.Content.Bookmark1.hasAnActivelink=true
@@ -39,7 +39,7 @@
BookmarkCategory1.Content.Bookmark3.Name=Freesite HOWTO
BookmarkCategory1.Content.Bookmark3.Description=A more detailed explanation of
publishing freesites
BookmarkCategory1.Content.Bookmark3.hasAnActivelink=true
[EMAIL PROTECTED],9T20t3xoG-dQfMO94LGOl9AxRTkaz~TykFY-voqaTQI,AQACAAE/FAFS/4/
[EMAIL PROTECTED],9T20t3xoG-dQfMO94LGOl9AxRTkaz~TykFY-voqaTQI,AQACAAE/FAFS/44/
BookmarkCategory1.Content.Bookmark4.hasAnActivelink=true
BookmarkCategory1.Content.Bookmark4.Name=The Freenet Applications Freesite
BookmarkCategory1.Content.Bookmark4.Description=Various links to Freenet
applications, and instructions for using them
Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java 2008-12-06
16:28:56 UTC (rev 24101)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java 2008-12-06
16:32:31 UTC (rev 24102)
@@ -303,7 +303,7 @@
OpennetManager opennet = node.getOpennet();
if(opennet != null) {
// Try old opennet connections.
- if(opennet.wantPeer(null, false, true)) {
+ if(opennet.wantPeer(null, false, true, true)) {
// We want a peer.
// Try old connections.
PeerNode[] oldPeers = opennet.getOldPeers();
@@ -1201,7 +1201,7 @@
Logger.normal(this, "Dumping incoming
old-opennet peer as opennet just turned off: "+pn+".");
return;
}
- if(!opennet.wantPeer(pn, true, false)) {
+ if(!opennet.wantPeer(pn, true, false, true)) {
Logger.normal(this, "No longer want peer "+pn+"
- dumping it after connecting");
dontWant = true;
}
@@ -1417,7 +1417,7 @@
Logger.normal(this, "Dumping incoming
old-opennet peer as opennet just turned off: "+pn+".");
return true;
}
- if(!opennet.wantPeer(pn, true, false)) {
+ if(!opennet.wantPeer(pn, true, false, true)) {
Logger.normal(this, "No longer want peer "+pn+"
- dumping it after connecting");
dontWant = true;
}
Modified: trunk/freenet/src/freenet/node/OpennetManager.java
===================================================================
--- trunk/freenet/src/freenet/node/OpennetManager.java 2008-12-06 16:28:56 UTC
(rev 24101)
+++ trunk/freenet/src/freenet/node/OpennetManager.java 2008-12-06 16:32:31 UTC
(rev 24102)
@@ -58,7 +58,7 @@
* if we have no other option. */
private final LRUQueue oldPeers;
/** Maximum number of old peers */
- static final int MAX_OLD_PEERS = 50;
+ static final int MAX_OLD_PEERS = 25;
/** Time at which last dropped a peer */
private long timeLastDropped;
/** Number of successful CHK requests since last added a node */
@@ -246,7 +246,7 @@
if(logMINOR) Logger.minor(this, "Not adding
"+pn.userToString()+" to opennet list as already there");
return null;
}
- if(wantPeer(pn, true, false)) return pn;
+ if(wantPeer(pn, true, false, false)) return pn;
else return null;
// Start at bottom. Node must prove itself.
}
@@ -265,6 +265,10 @@
dropExcessPeers();
}
+ private long timeLastAddedOldOpennetPeer = -1;
+
+ private static final int OLD_OPENNET_PEER_INTERVAL = 30*1000;
+
/**
* Trim the peers list and possibly add a new node. Note that if we are
not adding a new node,
* we will only return true every MIN_TIME_BETWEEN_OFFERS, to prevent
problems caused by many
@@ -273,11 +277,19 @@
* @param addAtLRU If there is a node to add, add it at the bottom
rather than the top. Normally
* we set this on new path folded nodes so that they will be replaced
if during the trial period,
* plus the time it takes to get a new path folding offer, they don't
have a successful request.
- * @param justChecking If true, and nodeToAddNow == null, we don't
actually send an offer, we
- * just want to know if there is space for a node.
+ * @param justChecking If true, we want to know whether there is space
for a node to be added
+ * RIGHT NOW. If false, the normal behaviour applies: if nodeToAddNow
is passed in, we decide
+ * whether to add that node, if it's null, we decide whether to send an
offer subject to the
+ * inter-offer time.
+ * @param oldOpennetPeer If true, we are trying to add an
old-opennet-peer which has reconnected.
+ * There is a throttle, we accept no more than one old-opennet-peer
every 30 seconds. On receiving
+ * a packet, we call once to decide whether to try to parse it against
the old-opennet-peers, and
+ * then again to decide whether it is worth keeping; in the latter case
if we decide not, the
+ * old-opennet-peer will be told to disconnect and go away, but
normally we don't reach that point
+ * because of the first check.
* @return True if the node was added / should be added.
*/
- public boolean wantPeer(PeerNode nodeToAddNow, boolean addAtLRU,
boolean justChecking) {
+ public boolean wantPeer(PeerNode nodeToAddNow, boolean addAtLRU,
boolean justChecking, boolean oldOpennetPeer) {
boolean notMany = false;
boolean noDisconnect;
synchronized(this) {
@@ -301,6 +313,9 @@
if(nodeToAddNow != null || !justChecking)
timeLastOffered =
System.currentTimeMillis();
notMany = true;
+ // Don't check timeLastAddedOldOpennetPeer,
since we want it anyway. But do update it.
+ if(oldOpennetPeer)
+ timeLastAddedOldOpennetPeer =
System.currentTimeMillis();
}
noDisconnect = successCount <
MIN_SUCCESS_BETWEEN_DROP_CONNS;
}
@@ -336,8 +351,12 @@
peersLRU.remove(toDrop);
dropList.add(toDrop);
}
- if(canAdd) {
- long now = System.currentTimeMillis();
+ long now = System.currentTimeMillis();
+ if(canAdd && oldOpennetPeer) {
+ if(timeLastAddedOldOpennetPeer > 0 && now -
timeLastAddedOldOpennetPeer > OLD_OPENNET_PEER_INTERVAL)
+ canAdd = false;
+ }
+ if(canAdd && !justChecking) {
if(nodeToAddNow != null) {
successCount = 0;
if(addAtLRU)
@@ -348,6 +367,8 @@
oldPeers.remove(nodeToAddNow);
if(!dropList.isEmpty())
timeLastDropped = now;
+ if(oldOpennetPeer)
+ timeLastAddedOldOpennetPeer =
now;
} else {
if(now - timeLastOffered <=
MIN_TIME_BETWEEN_OFFERS && !hasDisconnected) {
if(logMINOR)
@@ -403,11 +424,12 @@
for(int i=0;i<peers.length;i++) {
OpennetPeerNode pn = peers[i];
if(pn == null) continue;
- if(!pn.isDroppable()) continue;
+ if(!pn.isDroppable(false)) continue;
// LOCKING: Always take the OpennetManager lock
first
if(!pn.isConnected()) {
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Possibly
dropping opennet peer "+pn+" as is disconnected");
+ pn.setWasDropped();
return pn;
}
}
@@ -417,10 +439,11 @@
for(int i=0;i<peers.length;i++) {
OpennetPeerNode pn = peers[i];
if(pn == null) continue;
- if(!pn.isDroppable()) continue;
+ if(!pn.isDroppable(false)) continue;
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Possibly dropping
opennet peer "+pn+" "+
(System.currentTimeMillis() - timeLastDropped)+" ms since last dropped peer");
+ pn.setWasDropped();
return pn;
}
}
@@ -439,16 +462,18 @@
// Re-add it: nasty race condition when we have
few peers
}
}
- if(!wantPeer(pn, false, false)) // Start at top as it just
succeeded
+ if(!wantPeer(pn, false, false, false)) // Start at top as it
just succeeded
node.peers.disconnect(pn, true, false);
}
public void onRemove(OpennetPeerNode pn) {
synchronized (this) {
peersLRU.remove(pn);
- oldPeers.push(pn);
- while (oldPeers.size() > MAX_OLD_PEERS)
- oldPeers.pop();
+ if(pn.isDroppable(true) && !pn.grabWasDropped()) {
+ oldPeers.push(pn);
+ while (oldPeers.size() > MAX_OLD_PEERS)
+ oldPeers.pop();
+ }
}
}
Modified: trunk/freenet/src/freenet/node/OpennetPeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/OpennetPeerNode.java 2008-12-06 16:28:56 UTC
(rev 24101)
+++ trunk/freenet/src/freenet/node/OpennetPeerNode.java 2008-12-06 16:32:31 UTC
(rev 24102)
@@ -35,13 +35,14 @@
return true;
}
- public boolean isDroppable() {
+ public boolean isDroppable(boolean ignoreDisconnect) {
long now = System.currentTimeMillis();
if(now - getPeerAddedTime() < OpennetManager.DROP_MIN_AGE)
return false; // New node
if(now - node.usm.getStartedTime() <
OpennetManager.DROP_STARTUP_DELAY)
return false; // Give them time to connect after we
startup
int status = getPeerNodeStatus();
+ if(!ignoreDisconnect) {
synchronized(this) {
if((status ==
PeerManager.PEER_NODE_STATUS_DISCONNECTED) && (!super.neverConnected()) &&
now - timeLastDisconnect <
OpennetManager.DROP_DISCONNECT_DELAY &&
@@ -50,6 +51,7 @@
return false;
}
}
+ }
return true;
}
@@ -119,4 +121,20 @@
opennet.crypto.socket.getAddressTracker().setPresumedGuiltyAt(System.currentTimeMillis()+60*60*1000);
}
+ private boolean wasDropped;
+
+ synchronized void setWasDropped() {
+ wasDropped = true;
+ }
+
+ synchronized boolean wasDropped() {
+ return wasDropped;
+ }
+
+ synchronized boolean grabWasDropped() {
+ boolean ret = wasDropped;
+ wasDropped = false;
+ return ret;
+ }
+
}
Modified: trunk/freenet/src/freenet/node/PacketSender.java
===================================================================
--- trunk/freenet/src/freenet/node/PacketSender.java 2008-12-06 16:28:56 UTC
(rev 24101)
+++ trunk/freenet/src/freenet/node/PacketSender.java 2008-12-06 16:32:31 UTC
(rev 24102)
@@ -306,28 +306,31 @@
}
brokeAt = newBrokeAt;
- // Consider sending connect requests to our opennet old-peers.
- // No point if they are NATed, of course... but we don't know
whether they are.
+ /* Attempt to connect to old-opennet-peers.
+ * Constantly send handshake packets, in order to get through a
NAT.
+ * Most JFK(1)'s are less than 300 bytes. 25*300/15 = avg
500B/sec bandwidth cost.
+ * Well worth it to allow us to reconnect more quickly. */
+
OpennetManager om = node.getOpennet();
if(om != null) {
- int connCount = node.peers.quickCountConnectedPeers();
- int minDelay = connCount == 0 ?
MIN_OLD_OPENNET_CONNECT_DELAY_NO_CONNS : MIN_OLD_OPENNET_CONNECT_DELAY;
- if(logDEBUG)
- Logger.debug(this, "Conns " + connCount + "
minDelay " + minDelay + " old opennet peers " + om.countOldOpennetPeers() + "
last sent " + (now - timeLastSentOldOpennetConnectAttempt) + " startup " + (now
- node.startupTime));
- if(now - timeLastSentOldOpennetConnectAttempt >
minDelay &&
- connCount <=
MIN_CONNECTIONS_TRY_OLD_OPENNET_PEERS &&
- om.countOldOpennetPeers() > 0 &&
- now - node.startupTime >
OpennetManager.DROP_STARTUP_DELAY) {
- PeerNode pn = om.randomOldOpennetNode();
- if(pn != null) {
- if(logMINOR)
- Logger.minor(this, "Sending
old-opennet connect attempt to " + pn);
+ PeerNode[] peers = om.getOldPeers();
+
+ for(PeerNode pn : peers) {
+ if(pn.isConnected()) continue; // Race
condition??
+ if(pn.noContactDetails()) {
+ pn.startARKFetcher();
+ continue;
+ }
+ if(pn.shouldSendHandshake()) {
+ // Send handshake if necessary
+ long beforeHandshakeTime =
System.currentTimeMillis();
pn.getOutgoingMangler().sendHandshake(pn);
- timeLastSentOldOpennetConnectAttempt =
now;
- if(pn.noContactDetails() &&
node.getPeerNodes().length > 0 && connCount > 0 && node.random.nextBoolean())
- pn.startARKFetcher();
+ long afterHandshakeTime =
System.currentTimeMillis();
+ if((afterHandshakeTime -
beforeHandshakeTime) > (2 * 1000))
+ Logger.error(this,
"afterHandshakeTime is more than 2 seconds past beforeHandshakeTime (" +
(afterHandshakeTime - beforeHandshakeTime) + ") in PacketSender working with "
+ pn.userToString());
}
}
+
}
if(now - lastClearedOldSwapChains > 10000) {
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2008-12-06 16:28:56 UTC
(rev 24101)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2008-12-06 16:32:31 UTC
(rev 24102)
@@ -1905,7 +1905,6 @@
} else if(bootIDChanged && logMINOR)
Logger.minor(this, "Changed boot ID from " +
bootID + " to " + thisBootID + " for " + getPeer());
this.bootID = thisBootID;
- boolean newPacketTracker = false;
if(currentTracker != null &&
currentTracker.packets.trackerID == trackerID &&
!currentTracker.packets.isDeprecated()) {
if(isJFK4 && !jfk4SameAsOld)
Logger.error(this, "In JFK(4), found
tracker ID "+trackerID+" but other side says is new! for "+this);
@@ -1923,7 +1922,6 @@
} else if(trackerID == -1) {
// Create a new tracker unconditionally
packets = new PacketTracker(this);
- newPacketTracker = true;
if(logMINOR) Logger.minor(this, "Creating new
PacketTracker as instructed for "+this);
} else if(trackerID == -2 && !bootIDChanged) {
// Reuse if not deprecated and not boot ID
changed
@@ -1935,7 +1933,6 @@
if(logMINOR) Logger.minor(this,
"Re-using packet tracker (not given an ID): "+packets.trackerID+" on "+this+"
from prev "+previousTracker);
} else {
packets = new PacketTracker(this);
- newPacketTracker = true;
if(logMINOR) Logger.minor(this, "Cannot
reuse trackers (not given an ID) on "+this);
}
} else {
@@ -1946,11 +1943,9 @@
packets = new PacketTracker(this,
trackerID);
} else
packets = new PacketTracker(this);
- newPacketTracker = true;
if(logMINOR) Logger.minor(this, "Creating new
tracker (last resort) on "+this);
}
if(bootIDChanged) {
- newPacketTracker = true;
oldPrev = previousTracker;
oldCur = currentTracker;
previousTracker = null;
@@ -1964,7 +1959,7 @@
// else it's a rekey
}
newTracker = new KeyTracker(this, packets, encCipher,
encKey);
- if(logMINOR) Logger.minor(this, "New key tracker in
completedHandshake: "+newTracker+" for "+shortToString()+" neg type "+negType+"
new packet tracker: "+newPacketTracker);
+ if(logMINOR) Logger.minor(this, "New key tracker in
completedHandshake: "+newTracker+" for "+shortToString()+" neg type "+negType);
if(unverified) {
if(unverifiedTracker != null) {
// Keep the old unverified tracker if
possible.
Modified: trunk/freenet/src/freenet/node/RequestHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestHandler.java 2008-12-06 16:28:56 UTC
(rev 24101)
+++ trunk/freenet/src/freenet/node/RequestHandler.java 2008-12-06 16:32:31 UTC
(rev 24102)
@@ -558,7 +558,7 @@
private boolean finishOpennetNoRelayInner(OpennetManager om) {
if(logMINOR)
Logger.minor(this, "Finishing opennet: sending own
reference");
- if(!om.wantPeer(null, false, false))
+ if(!om.wantPeer(null, false, false, false))
return false; // Don't want a reference
try {
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2008-12-06 16:28:56 UTC (rev
24101)
+++ trunk/freenet/src/freenet/node/Version.java 2008-12-06 16:32:31 UTC (rev
24102)
@@ -24,11 +24,11 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- private static final int buildNumber = 1190;
+ private static final int buildNumber = 1189;
/** Oldest build of Fred we will talk to */
private static final int oldLastGoodBuild = 1188;
- private static final int newLastGoodBuild = 1190;
+ private static final int newLastGoodBuild = 1189;
static final long transitionTime;
static {
Property changes on: trunk/freenet/test/freenet/support/io/MockInputStream.java
___________________________________________________________________
Added: svn:mergeinfo
+
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs