From 5bd8b9914b56dafafe5e6a68a3a197f59c56ba19 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 13 Apr 2014 14:17:36 +0200 Subject: [PATCH] Don't use SPTPS to decrypt the ID request. --- src/meta.c | 33 +++++++++++++++++++++++++++++++++ src/protocol_auth.c | 2 -- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/meta.c b/src/meta.c index b15ed837..64595496 100644 --- a/src/meta.c +++ b/src/meta.c @@ -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); } diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 670bfbc2..1255ff08 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -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)]; -- 2.39.5