Update of /cvsroot/freenet/freenet/src/freenet/message
In directory sc8-pr-cvs1:/tmp/cvs-serv9009/src/freenet/message

Modified Files:
        Identify.java Request.java 
Log Message:
6278:
Make Identify a (more or less) regular message. We pull the ref off it when we receive 
it, but later it gets executed by NewIdentify, which asks RT if it wants it, and if it 
does, verifies the signature (significant CPU operation!), and adds it.
Do NOT verify references on the RSL thread.
Cache fingerprint on DSAPublicKey


Index: Identify.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/Identify.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -r1.6 -r1.7
--- Identify.java       24 Oct 2003 02:24:58 -0000      1.6
+++ Identify.java       25 Oct 2003 00:45:35 -0000      1.7
@@ -1,12 +1,14 @@
 package freenet.message;
 import freenet.*;
 import freenet.node.*;
+import freenet.node.states.FNP.NewIdentify;
 import freenet.support.*;
 import java.util.*;
 import freenet.node.states.request.*;
 
 public class Identify extends NodeMessage {
     
+    protected final FieldSet nodeRef;
     protected final NodeReference sourceRef;
     
     public static final String messageName="Identify";
@@ -14,17 +16,18 @@
     public Identify(long id, NodeReference ref) {
        super(id);
        sourceRef = ref;
+       nodeRef = null;
     }
     
     public Identify(ConnectionHandler source, RawMessage raw) 
        throws InvalidMessageException {
        super(source, raw);
-       FieldSet nodeRef  = otherFields.getSet("Source");
+       nodeRef  = otherFields.getSet("Source");
        if(nodeRef == null) 
            throw new InvalidMessageException("No reference found");
        try {
-           // Verify it so we can pass it on
-           sourceRef = new NodeReference(nodeRef, true, 
+           // Verifying it is far too expensive to do here
+           sourceRef = new NodeReference(nodeRef, false, 
                                          source.peerIdentity());
        } catch (BadReferenceException e) {
            throw new InvalidMessageException("Failed to read NodeReference: "
@@ -52,8 +55,15 @@
     }
     
     public final State getInitialState() {
-       return null;
-       // Only used in ConnectionHandler
+       return new NewIdentify(id);
+    }
+    
+    public final NodeReference getVerifiedSource() 
+       throws BadReferenceException {
+       if(sourceRef.isSigned()) return sourceRef;
+       if(nodeRef == null) return null;
+       return new NodeReference(nodeRef, true, 
+                                source.peerIdentity());
     }
     
     public final NodeReference getSource() {

Index: Request.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/message/Request.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -w -r1.16 -r1.17
--- Request.java        24 Oct 2003 02:24:58 -0000      1.16
+++ Request.java        25 Oct 2003 00:45:35 -0000      1.17
@@ -49,7 +49,8 @@
                                ","+nodeRef+" for "+source, Logger.MINOR);
                if(nodeRef == null)
                    throw new InvalidMessageException("Can't find Source field");
-               ref = new NodeReference(nodeRef, false, true, source.peerIdentity());
+               // Do not verify at this stage; if it's useful we should do it later
+               ref = new NodeReference(nodeRef, false, false, source.peerIdentity());
                if(ref.isSigned()) {
                    source.setTargetReference(ref);
                    Core.logger.log(this, "Set targetReference on "+source+" to "+ref,

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to