Author: nextgens
Date: 2008-07-17 20:20:27 +0000 (Thu, 17 Jul 2008)
New Revision: 21181

Modified:
   trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/PeerManager.java
Log:
Add two new config options related to FOAF routing

Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-07-17 
17:52:28 UTC (rev 21180)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties   2008-07-17 
20:20:27 UTC (rev 21181)
@@ -694,6 +694,10 @@
 Node.passOpennetPeersThroughDarknetLong=If true, opennet noderefs (NEVER our 
own darknet noderef) will be relayed through our darknet peers. So a node (this 
node, or its peers) can get opennet peers from its darknet peers. This is 
useful because it allows us to bootstrap new opennet peers after having lost 
our peers due to downtime, for example. However, it may make traffic analysis 
slightly easier, so turn it off if you are paranoid.
 Node.port=FNP port number (UDP)
 Node.portLong=UDP port for node-to-node communications (Freenet Node Protocol)
+Node.publishOurPeersLocation=Shall we send our peer's location to our peers?
+Node.publishOurPeersLocationLong=Shall we send our peer's location to our 
peers? Doing so helps routing but gives some information away to a potential 
attacker.
+Node.routeAccordingToOurPeersLocation=Shall we use the locations of the peers 
of our peers into account for routing purposes?
+Node.routeAccordingToOurPeersLocationLong=Shall we use the locations of the 
peers of our peers into account for routing purposes? Doing so helps routing 
but might help a potential attacker.
 Node.storeDirectory=Store directory
 Node.storeDirectoryLong=Name of directory to put store files in
 Node.storeMaxMemTooHigh=Giving more than 80% of your ram to BDB is probably 
not what you want to do!

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-07-17 17:52:28 UTC (rev 
21180)
+++ trunk/freenet/src/freenet/node/Node.java    2008-07-17 20:20:27 UTC (rev 
21181)
@@ -33,7 +33,6 @@

 import freenet.client.FetchContext;
 import freenet.clients.http.SimpleToadletServer;
-import freenet.clients.http.StartupToadlet;
 import freenet.config.EnumerableOptionCallback;
 import freenet.config.FreenetFilePersistentConfig;
 import freenet.config.InvalidConfigValueException;
@@ -106,7 +105,6 @@
 import freenet.support.LRUQueue;
 import freenet.support.Logger;
 import freenet.support.OOMHandler;
-import freenet.support.OOMHook;
 import freenet.support.PooledExecutor;
 import freenet.support.ShortBuffer;
 import freenet.support.SimpleFieldSet;
@@ -120,7 +118,6 @@
 import freenet.support.io.FileUtil;
 import freenet.support.io.NativeThread;
 import freenet.support.transport.ip.HostnameSyntaxException;
-import java.net.URI;

 /**
  * @author amphibian
@@ -413,6 +410,8 @@
        final boolean enablePerNodeFailureTables;
        final boolean enableULPRDataPropagation;
        final boolean enableSwapping;
+       private volatile boolean publishOurPeersLocation;
+       private volatile boolean routeAccordingToOurPeersLocation;
        boolean enableSwapQueueing;
        boolean enablePacketCoalescing;
        public static final short DEFAULT_MAX_HTL = (short)10;
@@ -859,6 +858,30 @@
                });
                enableSwapping = nodeConfig.getBoolean("enableSwapping");

+               nodeConfig.register("publishOurPeersLocation", true, 
sortOrder++, true, false, "Node.publishOurPeersLocation", 
"Node.publishOurPeersLocationLong", new BooleanCallback() {
+
+                       public boolean get() {
+                               return publishOurPeersLocation;
+                       }
+
+                       public void set(boolean val) throws 
InvalidConfigValueException {
+                               publishOurPeersLocation = val;
+                       }
+               });
+               publishOurPeersLocation = 
nodeConfig.getBoolean("publishOurPeersLocation");
+               
+               nodeConfig.register("routeAccordingToOurPeersLocation", true, 
sortOrder++, true, false, "Node.routeAccordingToOurPeersLocation", 
"Node.routeAccordingToOurPeersLocationLong", new BooleanCallback() {
+
+                       public boolean get() {
+                               return routeAccordingToOurPeersLocation;
+                       }
+
+                       public void set(boolean val) throws 
InvalidConfigValueException {
+                               routeAccordingToOurPeersLocation = val;
+                       }
+               });
+               routeAccordingToOurPeersLocation = 
nodeConfig.getBoolean("routeAccordingToOurPeersLocation");
+               
                nodeConfig.register("enableSwapQueueing", true, sortOrder++, 
true, false, "Node.enableSwapQueueing", "Node.enableSwapQueueingLong", new 
BooleanCallback() {
                        public boolean get() {
                                return enableSwapQueueing;
@@ -3322,4 +3345,12 @@
        public void setDispatcherHook(NodeDispatcherCallback cb) {
                this.dispatcher.setHook(cb);
        }
+       
+       public boolean shallWePublishOurPeersLocation() {
+               return publishOurPeersLocation;
+       }
+       
+       public boolean shallWeRouteAccordingToOurPeersLocation() {
+               return routeAccordingToOurPeersLocation;
+       }
 }

Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java     2008-07-17 17:52:28 UTC 
(rev 21180)
+++ trunk/freenet/src/freenet/node/PeerManager.java     2008-07-17 20:20:27 UTC 
(rev 21181)
@@ -560,6 +560,8 @@
         */
        public double[] getPeerLocationDoubles(boolean pruneBackedOffedPeers) {
                double[] locs;
+               if(!node.shallWePublishOurPeersLocation())
+                       return new double[0];
                PeerNode[] conns;
                synchronized(this) {
                        conns = connectedPeers;
@@ -885,7 +887,7 @@
                        double diff = Location.distance(loc, target);

                        double[] peersLocation = p.getPeersLocation();
-                       if(peersLocation != null) {
+                       if((node.shallWeRouteAccordingToOurPeersLocation()) && 
(peersLocation != null)) {
                                for(double l : peersLocation) {
                                        double newDiff = Location.distance(l, 
target);
                                        if(newDiff < diff) {


Reply via email to