Author: toad
Date: 2007-03-27 22:51:24 +0000 (Tue, 27 Mar 2007)
New Revision: 12393

Modified:
   trunk/freenet/src/freenet/node/PeerNode.java
   trunk/freenet/src/freenet/support/SimpleFieldSet.java
Log:
Read negtypes in PeerNode.

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2007-03-27 22:41:37 UTC 
(rev 12392)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2007-03-27 22:51:24 UTC 
(rev 12393)
@@ -169,6 +169,9 @@
     /** Hash of node identity. Used as setup key. */
     final byte[] identityHash;

+    /** Negotiation types supported */
+    int[] negTypes;
+    
     /** Integer hash of node identity. Used as hashCode(). */
     final int hashCode;

@@ -400,6 +403,10 @@
                detectedPeer = (Peer) nominalPeer.firstElement();
         }

+        negTypes = fs.getIntArray("auth.negTypes");
+        if(negTypes == null)
+               negTypes = new int[] { 0 };
+        
         /* Read the DSA key material for the peer */
         try {
                SimpleFieldSet sfs = fs.subset("dsaGroup");
@@ -1776,6 +1783,14 @@

         if(logMINOR) Logger.minor(this, "Parsed successfully; changedAnything 
= "+changedAnything);

+        int[] newNegTypes = fs.getIntArray("auth.negTypes");
+        if(newNegTypes == null)
+               newNegTypes = new int[] { 0 };
+        if(!Arrays.equals(negTypes, newNegTypes)) {
+               changedAnything = true;
+               negTypes = newNegTypes;
+        }
+        
         if(parseARK(fs, false))
                changedAnything = true;
         if(name != null && !name.equals(myName)) {
@@ -1946,6 +1961,7 @@
                for(int i=0;i<nominalPeer.size();i++) {
                        fs.putAppend("physical.udp", 
nominalPeer.get(i).toString());
                }
+               fs.put("auth.negTypes", negTypes);
         fs.putSingle("identity", getIdentityString());
         fs.putSingle("location", Double.toString(currentLocation.getValue()));
         fs.putSingle("testnet", Boolean.toString(testnetEnabled));

Modified: trunk/freenet/src/freenet/support/SimpleFieldSet.java
===================================================================
--- trunk/freenet/src/freenet/support/SimpleFieldSet.java       2007-03-27 
22:41:37 UTC (rev 12392)
+++ trunk/freenet/src/freenet/support/SimpleFieldSet.java       2007-03-27 
22:51:24 UTC (rev 12393)
@@ -643,4 +643,18 @@
                        putAppend(key, Integer.toString(value[i]));
        }

+       public int[] getIntArray(String key) {
+               String[] strings = getAll(key);
+               int[] ret = new int[strings.length];
+               for(int i=0;i<strings.length;i++) {
+                       try {
+                               ret[i] = Integer.parseInt(strings[i]);
+                       } catch (NumberFormatException e) {
+                               Logger.error(this, "Cannot parse "+strings[i]+" 
: "+e, e);
+                               return null;
+                       }
+               }
+               return ret;
+       }
+
 }


Reply via email to