From 9ee7275a02ef6e27f6388b5f1c3630bc6ececc87 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 17 Sep 2018 20:18:33 -0400 Subject: [PATCH] decrypt frames correctly and set return address --- llarp/handlers/tun.cpp | 5 +++-- llarp/service/protocol.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index f25bb6ead..bcf17d83f 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -201,8 +201,9 @@ namespace llarp service::ProtocolMessage *msg) { EnsureReplyPath(msg->sender); - - uint32_t themIP = ObtainIPForAddr(msg->sender.Addr()); + service::Address addr; + msg->sender.CalculateAddress(addr.data()); + uint32_t themIP = ObtainIPForAddr(addr); uint32_t usIP = m_OurIP; auto buf = llarp::Buffer(msg->payload); if(m_NetworkToUserPktQueue.EmplaceIf( diff --git a/llarp/service/protocol.cpp b/llarp/service/protocol.cpp index c26537f32..f14fc6a07 100644 --- a/llarp/service/protocol.cpp +++ b/llarp/service/protocol.cpp @@ -155,9 +155,10 @@ namespace llarp const byte_t* sharedkey, ProtocolMessage& msg) const { - msg.PutBuffer(D.Buffer()); - auto buf = llarp::Buffer(msg.payload); - return crypto->xchacha20(buf, sharedkey, N); + Encrypted tmp = D; + auto buf = tmp.Buffer(); + crypto->xchacha20(*buf, sharedkey, N); + return msg.BDecode(buf); } bool