]> git.meshlink.io Git - meshlink/commitdiff
Don't use SPTPS to decrypt the ID request.
authorGuus Sliepen <guus@meshlink.io>
Sun, 13 Apr 2014 12:17:36 +0000 (14:17 +0200)
committerGuus Sliepen <guus@meshlink.io>
Sun, 13 Apr 2014 12:17:36 +0000 (14:17 +0200)
src/meta.c
src/protocol_auth.c

index b15ed8374eaca3cef2a18d8acef4ac291535d53c..645954965550c601e098f18185c191617aaef540 100644 (file)
@@ -51,6 +51,12 @@ bool send_meta(connection_t *c, const char *buffer, int length) {
        logger(DEBUG_META, LOG_DEBUG, "Sending %d bytes of metadata to %s (%s)", length,
                           c->name, c->hostname);
 
+       if(c->allow_request == ID) {
+               buffer_add(&c->outbuf, buffer, length);
+               io_set(&c->io, IO_READ | IO_WRITE);
+               return true;
+       }
+
        return sptps_send_record(&c->sptps, 0, buffer, length);
 }
 
@@ -133,5 +139,32 @@ bool receive_meta(connection_t *c) {
                return false;
        }
 
+       if(c->allow_request == ID) {
+               endp = memchr(bufp, '\n', inlen);
+               if(endp)
+                       endp++;
+               else
+                       endp = bufp + inlen;
+
+               buffer_add(&c->inbuf, bufp, endp - bufp);
+
+               inlen -= endp - bufp;
+               bufp = endp;
+
+               while(c->inbuf.len) {
+                       char *request = buffer_readline(&c->inbuf);
+                       if(request) {
+                               bool result = receive_request(c, request);
+                               if(!result)
+                                       return false;
+                               continue;
+                       } else {
+                               break;
+                       }
+               }
+
+               return true;
+       }
+
        return sptps_receive_data(&c->sptps, bufp, inlen);
 }
index 670bfbc23ee0cc48e908d481e150186dfa634db6..1255ff0862b68ebd286d482fc51d1329ab656d46 100644 (file)
@@ -349,8 +349,6 @@ bool id_h(connection_t *c, const char *request) {
                return false;
        }
 
-       c->allow_request = METAKEY;
-
        c->allow_request = ACK;
        char label[25 + strlen(myself->name) + strlen(c->name)];