From 8943be6c3a0e39f143ed03745f980f87794e154e Mon Sep 17 00:00:00 2001 From: Jeff Date: Tue, 29 Sep 2020 09:26:45 -0400 Subject: [PATCH] serialize auth codes in rpc (#1369) * serialize auth codes in rpc * format * format * config and route fixups * bump lokimq * fix compile * discard unknown members in service keys * format --- llarp/config/config.cpp | 2 +- llarp/config/config.hpp | 2 +- llarp/config/ini.cpp | 3 ++- llarp/config/ini.hpp | 2 +- llarp/router/route_poker.cpp | 3 +++ llarp/router_contact.hpp | 2 +- llarp/service/endpoint.cpp | 8 ++++++++ llarp/service/identity.cpp | 4 +++- 8 files changed, 20 insertions(+), 6 deletions(-) diff --git a/llarp/config/config.cpp b/llarp/config/config.cpp index 287fb73f9..777aa9ba5 100644 --- a/llarp/config/config.cpp +++ b/llarp/config/config.cpp @@ -559,7 +559,7 @@ namespace llarp } void - Config::Save() const + Config::Save() { m_Parser.Save(); } diff --git a/llarp/config/config.hpp b/llarp/config/config.hpp index bef5410f1..a960bea8b 100644 --- a/llarp/config/config.hpp +++ b/llarp/config/config.hpp @@ -229,7 +229,7 @@ namespace llarp generateBaseRouterConfig(fs::path defaultDataDir); void - Save() const; + Save(); void Override(std::string section, std::string key, std::string value); diff --git a/llarp/config/ini.cpp b/llarp/config/ini.cpp index 6d3eb0970..c62329abd 100644 --- a/llarp/config/ini.cpp +++ b/llarp/config/ini.cpp @@ -171,7 +171,7 @@ namespace llarp } void - ConfigParser::Save() const + ConfigParser::Save() { // if we have no overrides keep the config the same on disk if (m_Overrides.empty()) @@ -189,6 +189,7 @@ namespace llarp ofs << key << "=" << value << std::endl; } } + m_Overrides.clear(); } } // namespace llarp diff --git a/llarp/config/ini.hpp b/llarp/config/ini.hpp index c9a8637a0..f39229746 100644 --- a/llarp/config/ini.hpp +++ b/llarp/config/ini.hpp @@ -46,7 +46,7 @@ namespace llarp /// save config and any overrides to the file it was loaded from void - Save() const; + Save(); private: bool diff --git a/llarp/router/route_poker.cpp b/llarp/router/route_poker.cpp index d38c49bb0..2e2f5e505 100644 --- a/llarp/router/route_poker.cpp +++ b/llarp/router/route_poker.cpp @@ -72,6 +72,9 @@ namespace llarp { AddRoute(ip); } + + const auto ep = router.hiddenServiceContext().GetDefault(); + net::AddDefaultRouteViaInterface(ep->GetIfName()); } } } // namespace llarp diff --git a/llarp/router_contact.hpp b/llarp/router_contact.hpp index dc861a19f..c373c023a 100644 --- a/llarp/router_contact.hpp +++ b/llarp/router_contact.hpp @@ -19,7 +19,7 @@ namespace lokimq { - struct bt_list_consumer; + class bt_list_consumer; } // namespace lokimq namespace llarp diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index bd08d9a70..a04692c99 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -190,6 +190,14 @@ namespace llarp auto obj = path::Builder::ExtractStatus(); obj["exitMap"] = m_ExitMap.ExtractStatus(); obj["identity"] = m_Identity.pub.Addr().ToString(); + + util::StatusObject authCodes; + for (const auto& [service, info] : m_RemoteAuthInfos) + { + authCodes[service.ToString()] = info.token; + } + obj["authCodes"] = authCodes; + return m_state->ExtractStatus(obj); } diff --git a/llarp/service/identity.cpp b/llarp/service/identity.cpp index abdab267c..a4a97776c 100644 --- a/llarp/service/identity.cpp +++ b/llarp/service/identity.cpp @@ -28,7 +28,9 @@ namespace llarp return false; if (!BEncodeMaybeReadDictInt("v", version, read, key, buf)) return false; - return read; + if (not read) + return bencode_discard(buf); + return true; } void