Author: toad
Date: 2007-09-21 18:33:11 +0000 (Fri, 21 Sep 2007)
New Revision: 15250
Modified:
trunk/freenet/src/freenet/node/FNPPacketMangler.java
Log:
When we get a connection from an old-opennet-peer, we should do the wantPeer
check *again* and if we don't want it, let it connect and then tell it to go
away (this should be very rare!).
Also don't connect at all if opennet is disabled.
Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java 2007-09-21
18:25:14 UTC (rev 15249)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java 2007-09-21
18:33:11 UTC (rev 15250)
@@ -570,8 +570,19 @@
long bootID = Fields.bytesToLong(data);
// Promote if necessary
- if(oldOpennetPeer)
+ boolean dontWant = false;
+ if(oldOpennetPeer) {
+ OpennetManager opennet = node.getOpennet();
+ if(opennet == null) {
+ Logger.normal(this, "Dumping incoming old-opennet peer
as opennet just turned off: "+pn+".");
+ return null;
+ }
+ if(!opennet.wantPeer(pn, true)) {
+ Logger.normal(this, "No longer want peer "+pn+"
- dumping it after connecting");
+ dontWant = true;
+ }
node.peers.addPeer(pn);
+ }
// Send the completion before parsing the data, because this is easiest
// Doesn't really matter - if it fails, we get loads of errors
anyway...
@@ -582,7 +593,10 @@
if(pn.completedHandshake(bootID, data, 8, data.length-8, cipher,
encKey, replyTo, phase == 2)) {
if(sendCompletion)
sendSignedDHCompletion(3, ctx.getCipher(), pn, replyTo,
ctx);
- pn.maybeSendInitialMessages();
+ if(dontWant)
+ node.peers.disconnect(pn, true, false);
+ else
+ pn.maybeSendInitialMessages();
} else {
Logger.error(this, "Handshake not completed");
}