From 98e691f315277a98a4135e4f944cc15d0c67e978 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 22 Apr 2019 19:35:19 +0100 Subject: [PATCH] Tidy up more parts of the service/ directory --- llarp/CMakeLists.txt | 9 ++- llarp/dht/context.hpp | 2 +- llarp/dht/messages/gotintro.hpp | 2 +- llarp/dht/messages/pubintro.hpp | 2 +- llarp/dht/node.hpp | 2 +- llarp/dht/publishservicejob.hpp | 2 +- llarp/dht/serviceaddresslookup.hpp | 2 +- llarp/dht/taglookup.hpp | 2 +- llarp/path/path.hpp | 2 +- llarp/path/pathset.hpp | 2 +- llarp/service/Identity.cpp | 17 ++--- llarp/service/Identity.hpp | 24 +++---- llarp/service/Info.hpp | 11 ++-- llarp/service/Intro.cpp | 2 +- llarp/service/async_key_exchange.hpp | 2 +- llarp/service/config.cpp | 8 +-- llarp/service/context.cpp | 66 +++++++++---------- llarp/service/context.hpp | 19 +++--- llarp/service/endpoint.hpp | 2 +- llarp/service/handler.hpp | 4 +- .../service/hidden_service_address_lookup.hpp | 2 +- llarp/service/info.cpp | 4 +- llarp/service/{IntroSet.cpp => intro_set.cpp} | 8 +-- llarp/service/{IntroSet.hpp => intro_set.hpp} | 8 +-- llarp/service/lookup.hpp | 6 +- llarp/service/outbound_context.hpp | 2 +- llarp/service/protocol.cpp | 62 +++++++++-------- llarp/service/protocol.hpp | 6 +- llarp/service/sendcontext.cpp | 26 ++++---- llarp/service/sendcontext.hpp | 2 +- llarp/service/session.hpp | 4 +- llarp/service/tag.hpp | 6 +- llarp/service/tag_lookup_job.hpp | 2 +- llarp/service/types.cpp | 1 - llarp/service/types.hpp | 6 -- llarp/service/vanity.hpp | 2 +- .../test_llarp_dht_serviceaddresslookup.cpp | 2 +- test/dht/test_llarp_dht_taglookup.cpp | 2 +- test/service/test_llarp_service_identity.cpp | 4 +- 39 files changed, 160 insertions(+), 177 deletions(-) rename llarp/service/{IntroSet.cpp => intro_set.cpp} (95%) rename llarp/service/{IntroSet.hpp => intro_set.hpp} (96%) delete mode 100644 llarp/service/types.cpp delete mode 100644 llarp/service/types.hpp diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index f256b2c6a..6b61f7e19 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -221,19 +221,18 @@ set(LIB_SRC service/endpoint.cpp service/handler.cpp service/hidden_service_address_lookup.cpp - service/Identity.cpp + service/identity.cpp service/info.cpp - service/Intro.cpp - service/IntroSet.cpp + service/intro_set.cpp + service/intro.cpp service/lookup.cpp service/outbound_context.cpp service/pendingbuffer.cpp service/protocol.cpp service/sendcontext.cpp service/session.cpp - service/tag.cpp service/tag_lookup_job.cpp - service/types.cpp + service/tag.cpp service/vanity.cpp utp/inbound_message.cpp utp/linklayer.cpp diff --git a/llarp/dht/context.hpp b/llarp/dht/context.hpp index 511ac57ef..b0789c567 100644 --- a/llarp/dht/context.hpp +++ b/llarp/dht/context.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include diff --git a/llarp/dht/messages/gotintro.hpp b/llarp/dht/messages/gotintro.hpp index 5ae6c9285..8d511b37f 100644 --- a/llarp/dht/messages/gotintro.hpp +++ b/llarp/dht/messages/gotintro.hpp @@ -2,7 +2,7 @@ #define LLARP_DHT_MESSAGES_GOT_INTRO_HPP #include -#include +#include #include diff --git a/llarp/dht/messages/pubintro.hpp b/llarp/dht/messages/pubintro.hpp index d9348c913..6854965d1 100644 --- a/llarp/dht/messages/pubintro.hpp +++ b/llarp/dht/messages/pubintro.hpp @@ -1,7 +1,7 @@ #ifndef LLARP_DHT_MESSAGES_PUB_INTRO_HPP #define LLARP_DHT_MESSAGES_PUB_INTRO_HPP #include -#include +#include #include diff --git a/llarp/dht/node.hpp b/llarp/dht/node.hpp index 8cd778ade..59cb96372 100644 --- a/llarp/dht/node.hpp +++ b/llarp/dht/node.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace llarp { diff --git a/llarp/dht/publishservicejob.hpp b/llarp/dht/publishservicejob.hpp index b69877cbc..52da0993e 100644 --- a/llarp/dht/publishservicejob.hpp +++ b/llarp/dht/publishservicejob.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include diff --git a/llarp/dht/serviceaddresslookup.hpp b/llarp/dht/serviceaddresslookup.hpp index 708eac5d0..122ea31a0 100644 --- a/llarp/dht/serviceaddresslookup.hpp +++ b/llarp/dht/serviceaddresslookup.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include namespace llarp { diff --git a/llarp/dht/taglookup.hpp b/llarp/dht/taglookup.hpp index e028af7e5..bb8ebe212 100644 --- a/llarp/dht/taglookup.hpp +++ b/llarp/dht/taglookup.hpp @@ -2,7 +2,7 @@ #define LLARP_DHT_TAGLOOKUP #include -#include +#include #include namespace llarp diff --git a/llarp/path/path.hpp b/llarp/path/path.hpp index d9c9460ed..52dfa0eba 100644 --- a/llarp/path/path.hpp +++ b/llarp/path/path.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/llarp/path/pathset.hpp b/llarp/path/pathset.hpp index ac173cdb7..756e0dc9b 100644 --- a/llarp/path/pathset.hpp +++ b/llarp/path/pathset.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/llarp/service/Identity.cpp b/llarp/service/Identity.cpp index b523e078c..878134ff3 100644 --- a/llarp/service/Identity.cpp +++ b/llarp/service/Identity.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -57,12 +57,11 @@ namespace llarp } void - Identity::RegenerateKeys(llarp::Crypto* crypto) + Identity::RegenerateKeys(Crypto* crypto) { crypto->encryption_keygen(enckey); crypto->identity_keygen(signkey); - pub.Update(llarp::seckey_topublic(enckey), - llarp::seckey_topublic(signkey)); + pub.Update(seckey_topublic(enckey), seckey_topublic(signkey)); crypto->pqe_keygen(pq); } @@ -81,7 +80,7 @@ namespace llarp } bool - Identity::EnsureKeys(const std::string& fname, llarp::Crypto* c) + Identity::EnsureKeys(const std::string& fname, Crypto* c) { std::array< byte_t, 4096 > tmp; llarp_buffer_t buf(tmp); @@ -91,7 +90,7 @@ namespace llarp { if(ec) { - llarp::LogError(ec); + LogError(ec); return false; } // regen and encode @@ -125,14 +124,12 @@ namespace llarp if(!vanity.IsZero()) van = vanity; // update pubkeys - pub.Update(llarp::seckey_topublic(enckey), - llarp::seckey_topublic(signkey), van); + pub.Update(seckey_topublic(enckey), seckey_topublic(signkey), van); return true; } bool - Identity::SignIntroSet(IntroSet& i, llarp::Crypto* crypto, - llarp_time_t now) const + Identity::SignIntroSet(IntroSet& i, Crypto* crypto, llarp_time_t now) const { if(i.I.size() == 0) return false; diff --git a/llarp/service/Identity.hpp b/llarp/service/Identity.hpp index bc1cf7830..481f2c6e2 100644 --- a/llarp/service/Identity.hpp +++ b/llarp/service/Identity.hpp @@ -2,9 +2,9 @@ #define LLARP_SERVICE_IDENTITY_HPP #include -#include -#include -#include +#include +#include +#include #include namespace llarp @@ -14,11 +14,11 @@ namespace llarp namespace service { // private keys - struct Identity final : public llarp::IBEncodeMessage + struct Identity final : public IBEncodeMessage { - llarp::SecretKey enckey; - llarp::SecretKey signkey; - llarp::PQKeyPair pq; + SecretKey enckey; + SecretKey signkey; + PQKeyPair pq; uint64_t version = 0; VanityNonce vanity; @@ -29,7 +29,7 @@ namespace llarp // regenerate secret keys void - RegenerateKeys(llarp::Crypto* c); + RegenerateKeys(Crypto* c); // load from file bool @@ -39,20 +39,20 @@ namespace llarp BEncode(llarp_buffer_t* buf) const override; bool - EnsureKeys(const std::string& fpath, llarp::Crypto* c); + EnsureKeys(const std::string& fpath, Crypto* c); bool - KeyExchange(llarp::path_dh_func dh, SharedSecret& sharedkey, + KeyExchange(path_dh_func dh, SharedSecret& sharedkey, const ServiceInfo& other, const KeyExchangeNonce& N) const; bool DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override; bool - SignIntroSet(IntroSet& i, llarp::Crypto* c, llarp_time_t now) const; + SignIntroSet(IntroSet& i, Crypto* c, llarp_time_t now) const; bool - Sign(llarp::Crypto*, Signature& sig, const llarp_buffer_t& buf) const; + Sign(Crypto*, Signature& sig, const llarp_buffer_t& buf) const; }; } // namespace service } // namespace llarp diff --git a/llarp/service/Info.hpp b/llarp/service/Info.hpp index bcac130d0..b88bb6da4 100644 --- a/llarp/service/Info.hpp +++ b/llarp/service/Info.hpp @@ -2,7 +2,8 @@ #define LLARP_SERVICE_INFO_HPP #include -#include +#include +#include #include #include @@ -13,11 +14,11 @@ namespace llarp namespace service { - struct ServiceInfo final : public llarp::IBEncodeMessage + struct ServiceInfo final : public IBEncodeMessage { private: - llarp::PubKey enckey; - llarp::PubKey signkey; + PubKey enckey; + PubKey signkey; public: VanityNonce vanity; @@ -52,7 +53,7 @@ namespace llarp } bool - Verify(llarp::Crypto* crypto, const llarp_buffer_t& payload, + Verify(Crypto* crypto, const llarp_buffer_t& payload, const Signature& sig) const; const PubKey& diff --git a/llarp/service/Intro.cpp b/llarp/service/Intro.cpp index 770f035da..c15c8e342 100644 --- a/llarp/service/Intro.cpp +++ b/llarp/service/Intro.cpp @@ -1,4 +1,4 @@ -#include +#include namespace llarp { diff --git a/llarp/service/async_key_exchange.hpp b/llarp/service/async_key_exchange.hpp index e70bf4eed..e2dede04c 100644 --- a/llarp/service/async_key_exchange.hpp +++ b/llarp/service/async_key_exchange.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_ASYNC_KEY_EXCHANGE_HPP #include -#include +#include #include namespace llarp diff --git a/llarp/service/config.cpp b/llarp/service/config.cpp index e8f39db26..84e3a6585 100644 --- a/llarp/service/config.cpp +++ b/llarp/service/config.cpp @@ -9,12 +9,12 @@ namespace llarp bool Config::Load(const std::string& fname) { - llarp::ConfigParser parser; + ConfigParser parser; if(!parser.LoadFile(fname.c_str())) return false; - parser.IterAll([&](const llarp::ConfigParser::String_t& name, - const llarp::ConfigParser::Section_t& section) { - llarp::service::Config::section_t values; + parser.IterAll([&](const ConfigParser::String_t& name, + const ConfigParser::Section_t& section) { + Config::section_t values; values.first.assign(name.begin(), name.end()); for(const auto& item : section) values.second.emplace_back(string_view_string(item.first), diff --git a/llarp/service/context.cpp b/llarp/service/context.cpp index e93914990..be3af1905 100644 --- a/llarp/service/context.cpp +++ b/llarp/service/context.cpp @@ -118,12 +118,12 @@ namespace llarp return m_Endpoints.size() ? true : false; } - llarp::service::Endpoint * + service::Endpoint * Context::getFirstEndpoint() { if(!m_Endpoints.size()) { - llarp::LogError("No endpoints found"); + LogError("No endpoints found"); return nullptr; } auto itr = m_Endpoints.begin(); @@ -137,11 +137,11 @@ namespace llarp { if(!m_Endpoints.size()) { - llarp::LogError("No endpoints found"); + LogError("No endpoints found"); return false; } i.index = 0; - // llarp::util::Lock lock(access); + // util::Lock lock(access); auto itr = m_Endpoints.begin(); while(itr != m_Endpoints.end()) { @@ -155,34 +155,34 @@ namespace llarp return true; } - llarp::handlers::TunEndpoint * + handlers::TunEndpoint * Context::getFirstTun() { - llarp::service::Endpoint *endpointer = this->getFirstEndpoint(); + service::Endpoint *endpointer = this->getFirstEndpoint(); if(!endpointer) { return nullptr; } - llarp::handlers::TunEndpoint *tunEndpoint = - static_cast< llarp::handlers::TunEndpoint * >(endpointer); + handlers::TunEndpoint *tunEndpoint = + static_cast< handlers::TunEndpoint * >(endpointer); return tunEndpoint; } llarp_tun_io * Context::getRange() { - llarp::handlers::TunEndpoint *tunEndpoint = this->getFirstTun(); + handlers::TunEndpoint *tunEndpoint = this->getFirstTun(); if(!tunEndpoint) { - llarp::LogError("No tunnel endpoint found"); + LogError("No tunnel endpoint found"); return nullptr; } return &tunEndpoint->tunif; } bool - Context::FindBestAddressFor(const llarp::AlignedBuffer< 32 > &addr, - bool isSNode, huint32_t &ip) + Context::FindBestAddressFor(const AlignedBuffer< 32 > &addr, bool isSNode, + huint32_t &ip) { auto itr = m_Endpoints.begin(); while(itr != m_Endpoints.end()) @@ -204,12 +204,12 @@ namespace llarp } bool - Context::Prefetch(const llarp::service::Address &addr) + Context::Prefetch(const service::Address &addr) { - llarp::handlers::TunEndpoint *tunEndpoint = this->getFirstTun(); + handlers::TunEndpoint *tunEndpoint = this->getFirstTun(); if(!tunEndpoint) { - llarp::LogError("No tunnel endpoint found"); + LogError("No tunnel endpoint found"); return false; } // HiddenServiceAddresslookup *lookup = new @@ -227,11 +227,11 @@ namespace llarp { Context::mapAddressAll_context *context = (Context::mapAddressAll_context *)endpointCfg->user; - llarp::handlers::TunEndpoint *tunEndpoint = - (llarp::handlers::TunEndpoint *)endpointCfg->endpoint; + handlers::TunEndpoint *tunEndpoint = + (handlers::TunEndpoint *)endpointCfg->endpoint; if(!tunEndpoint) { - llarp::LogError("No tunnel endpoint found"); + LogError("No tunnel endpoint found"); return true; // still continue } return tunEndpoint->MapAddress( @@ -239,8 +239,8 @@ namespace llarp } bool - Context::MapAddressAll(const llarp::service::Address &addr, - llarp::Addr &localPrivateIpAddr) + Context::MapAddressAll(const service::Address &addr, + Addr &localPrivateIpAddr) { struct Context::mapAddressAll_context context; context.serviceAddr = addr; @@ -278,10 +278,10 @@ namespace llarp { if(!itr->second->Start()) { - llarp::LogError(itr->first, " failed to start"); + LogError(itr->first, " failed to start"); return false; } - llarp::LogInfo(itr->first, " started"); + LogInfo(itr->first, " started"); ++itr; } return true; @@ -294,8 +294,8 @@ namespace llarp auto itr = m_Endpoints.find(conf.first); if(itr != m_Endpoints.end()) { - llarp::LogError("cannot add hidden service with duplicate name: ", - conf.first); + LogError("cannot add hidden service with duplicate name: ", + conf.first); return false; } } @@ -319,8 +319,7 @@ namespace llarp endpointConstructors = { {"tun", [](const std::string &nick, AbstractRouter *r, - llarp::service::Context *c) - -> std::unique_ptr< service::Endpoint > { + service::Context *c) -> std::unique_ptr< service::Endpoint > { return std::make_unique< handlers::TunEndpoint >(nick, r, c); }}, {"null", @@ -334,7 +333,7 @@ namespace llarp auto itr = endpointConstructors.find(endpointType); if(itr == endpointConstructors.end()) { - llarp::LogError("no such endpoint type: ", endpointType); + LogError("no such endpoint type: ", endpointType); return false; } @@ -348,7 +347,7 @@ namespace llarp service->SetOption("keyfile", keyfile); // load keyfile, so we have the correct name for logging } - llarp::LogInfo("Establishing endpoint identity"); + LogInfo("Establishing endpoint identity"); service->LoadKeyFile(); // only start endpoint not tun // now Name() will be correct } @@ -361,8 +360,8 @@ namespace llarp auto &v = option.second; if(!service->SetOption(k, v)) { - llarp::LogError("failed to set ", k, "=", v, - " for hidden service endpoint ", conf.first); + LogError("failed to set ", k, "=", v, " for hidden service endpoint ", + conf.first); return false; } } @@ -371,17 +370,16 @@ namespace llarp // start if(service->Start()) { - llarp::LogInfo("autostarting hidden service endpoint ", - service->Name()); + LogInfo("autostarting hidden service endpoint ", service->Name()); m_Endpoints.emplace(conf.first, std::move(service)); return true; } - llarp::LogError("failed to start hidden service endpoint ", conf.first); + LogError("failed to start hidden service endpoint ", conf.first); return false; } else { - llarp::LogInfo("added hidden service endpoint ", service->Name()); + LogInfo("added hidden service endpoint ", service->Name()); m_Endpoints.emplace(conf.first, std::move(service)); return true; } diff --git a/llarp/service/context.hpp b/llarp/service/context.hpp index e7ec2628f..468e058eb 100644 --- a/llarp/service/context.hpp +++ b/llarp/service/context.hpp @@ -15,7 +15,7 @@ namespace llarp /// holds all the hidden service endpoints we own struct Context { - Context(AbstractRouter *r); + explicit Context(AbstractRouter *r); ~Context(); void @@ -32,15 +32,15 @@ namespace llarp hasEndpoints(); /// DRY refactor - llarp::service::Endpoint * + service::Endpoint * getFirstEndpoint(); bool - FindBestAddressFor(const llarp::AlignedBuffer< 32 > &addr, bool isSNode, + FindBestAddressFor(const AlignedBuffer< 32 > &addr, bool isSNode, huint32_t &); /// DRY refactor - llarp::handlers::TunEndpoint * + handlers::TunEndpoint * getFirstTun(); /// punch a hole to get ip range from first tun endpoint @@ -49,14 +49,14 @@ namespace llarp struct mapAddressAll_context { - llarp::service::Address serviceAddr; - llarp::Addr localPrivateIpAddr; + service::Address serviceAddr; + Addr localPrivateIpAddr; }; struct endpoint_iter { void *user; - llarp::service::Endpoint *endpoint; + service::Endpoint *endpoint; size_t index; bool (*visit)(struct endpoint_iter *); }; @@ -72,11 +72,10 @@ namespace llarp /// hint at possible path usage and trigger building early bool - Prefetch(const llarp::service::Address &addr); + Prefetch(const service::Address &addr); bool - MapAddressAll(const llarp::service::Address &addr, - llarp::Addr &localPrivateIpAddr); + MapAddressAll(const service::Address &addr, Addr &localPrivateIpAddr); /// add default endpoint with options bool diff --git a/llarp/service/endpoint.hpp b/llarp/service/endpoint.hpp index e267aa35e..7744704ae 100644 --- a/llarp/service/endpoint.hpp +++ b/llarp/service/endpoint.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/llarp/service/handler.hpp b/llarp/service/handler.hpp index 5b2f9fc74..85c661a8f 100644 --- a/llarp/service/handler.hpp +++ b/llarp/service/handler.hpp @@ -3,14 +3,14 @@ #include #include -#include +#include #include namespace llarp { namespace service { - using ConvoTag = llarp::AlignedBuffer< 16 >; + using ConvoTag = AlignedBuffer< 16 >; struct ProtocolMessage; struct IDataHandler diff --git a/llarp/service/hidden_service_address_lookup.hpp b/llarp/service/hidden_service_address_lookup.hpp index 977f84d89..a7077b93d 100644 --- a/llarp/service/hidden_service_address_lookup.hpp +++ b/llarp/service/hidden_service_address_lookup.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_HIDDEN_SERVICE_ADDRESS_LOOKUP_HPP #include -#include +#include #include namespace llarp diff --git a/llarp/service/info.cpp b/llarp/service/info.cpp index 8005a02c4..4a74dd126 100644 --- a/llarp/service/info.cpp +++ b/llarp/service/info.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -13,7 +13,7 @@ namespace llarp namespace service { bool - ServiceInfo::Verify(llarp::Crypto* crypto, const llarp_buffer_t& payload, + ServiceInfo::Verify(Crypto* crypto, const llarp_buffer_t& payload, const Signature& sig) const { return crypto->verify(signkey, payload, sig); diff --git a/llarp/service/IntroSet.cpp b/llarp/service/intro_set.cpp similarity index 95% rename from llarp/service/IntroSet.cpp rename to llarp/service/intro_set.cpp index e4d27e31f..977a4fbb7 100644 --- a/llarp/service/IntroSet.cpp +++ b/llarp/service/intro_set.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -114,7 +114,7 @@ namespace llarp } bool - IntroSet::Verify(llarp::Crypto* crypto, llarp_time_t now) const + IntroSet::Verify(Crypto* crypto, llarp_time_t now) const { std::array< byte_t, MAX_INTROSET_SIZE > tmp; llarp_buffer_t buf(tmp); @@ -153,14 +153,14 @@ namespace llarp } else if(W == nullptr) { - llarp::LogWarn("intro has too high expire time"); + LogWarn("intro has too high expire time"); return false; } } } if(IsExpired(now)) { - llarp::LogWarn("introset expired: ", *this); + LogWarn("introset expired: ", *this); return false; } return true; diff --git a/llarp/service/IntroSet.hpp b/llarp/service/intro_set.hpp similarity index 96% rename from llarp/service/IntroSet.hpp rename to llarp/service/intro_set.hpp index ab1bbc089..ab679f78b 100644 --- a/llarp/service/IntroSet.hpp +++ b/llarp/service/intro_set.hpp @@ -1,10 +1,10 @@ -#ifndef LLARP_SERVICE_INTROSET_HPP -#define LLARP_SERVICE_INTROSET_HPP +#ifndef LLARP_SERVICE_INTRO_SET_HPP +#define LLARP_SERVICE_INTRO_SET_HPP #include #include -#include -#include +#include +#include #include #include #include diff --git a/llarp/service/lookup.hpp b/llarp/service/lookup.hpp index 1e44f70cd..e0738fc21 100644 --- a/llarp/service/lookup.hpp +++ b/llarp/service/lookup.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_LOOKUP_HPP #include -#include +#include #include @@ -48,7 +48,7 @@ namespace llarp /// build a new request message and send it via a path bool - SendRequestViaPath(llarp::path::Path* p, AbstractRouter* r); + SendRequestViaPath(path::Path* p, AbstractRouter* r); ILookupHolder* parent; uint64_t txid; @@ -58,7 +58,7 @@ namespace llarp util::StatusObject ExtractStatus() const { - auto now = llarp::time_now_ms(); + auto now = time_now_ms(); util::StatusObject obj{{"txid", txid}, {"endpoint", endpoint.ToHex()}, {"name", name}, diff --git a/llarp/service/outbound_context.hpp b/llarp/service/outbound_context.hpp index 8b1a5f9ed..7a5737871 100644 --- a/llarp/service/outbound_context.hpp +++ b/llarp/service/outbound_context.hpp @@ -81,7 +81,7 @@ namespace llarp bool SelectHop(llarp_nodedb* db, const RouterContact& prev, RouterContact& cur, - size_t hop, llarp::path::PathRole roles) override; + size_t hop, path::PathRole roles) override; bool HandleHiddenServiceFrame(path::Path* p, const ProtocolFrame& frame); diff --git a/llarp/service/protocol.cpp b/llarp/service/protocol.cpp index 74ea571bf..313cab593 100644 --- a/llarp/service/protocol.cpp +++ b/llarp/service/protocol.cpp @@ -34,7 +34,7 @@ namespace llarp { ProtocolMessage* self = static_cast< ProtocolMessage* >(user); if(!self->handler->HandleDataMessage(self->srcPath, self)) - llarp::LogWarn("failed to handle data message from ", self->srcPath); + LogWarn("failed to handle data message from ", self->srcPath); delete self; } @@ -170,7 +170,7 @@ namespace llarp } bool - ProtocolFrame::DecryptPayloadInto(llarp::Crypto* crypto, + ProtocolFrame::DecryptPayloadInto(Crypto* crypto, const SharedSecret& sharedkey, ProtocolMessage& msg) const { @@ -181,7 +181,7 @@ namespace llarp } bool - ProtocolFrame::Sign(llarp::Crypto* crypto, const Identity& localIdent) + ProtocolFrame::Sign(Crypto* crypto, const Identity& localIdent) { Z.Zero(); std::array< byte_t, MAX_PROTOCOL_MESSAGE_SIZE > tmp; @@ -189,7 +189,7 @@ namespace llarp // encode if(!BEncode(&buf)) { - llarp::LogError("message too big to encode"); + LogError("message too big to encode"); return false; } // rewind @@ -200,8 +200,7 @@ namespace llarp } bool - ProtocolFrame::EncryptAndSign(llarp::Crypto* crypto, - const ProtocolMessage& msg, + ProtocolFrame::EncryptAndSign(Crypto* crypto, const ProtocolMessage& msg, const SharedSecret& sessionKey, const Identity& localIdent) { @@ -210,7 +209,7 @@ namespace llarp // encode message if(!msg.BEncode(&buf)) { - llarp::LogError("message too big to encode"); + LogError("message too big to encode"); return false; } // rewind @@ -226,8 +225,8 @@ namespace llarp // encode frame if(!BEncode(&buf2)) { - llarp::LogError("frame too big to encode"); - llarp::DumpBuffer(buf2); + LogError("frame too big to encode"); + DumpBuffer(buf2); return false; } // rewind @@ -236,7 +235,7 @@ namespace llarp // sign if(!localIdent.Sign(crypto, Z, buf2)) { - llarp::LogError("failed to sign? wtf?!"); + LogError("failed to sign? wtf?!"); return false; } return true; @@ -244,18 +243,17 @@ namespace llarp struct AsyncFrameDecrypt { - llarp::Crypto* crypto; - llarp::Logic* logic; + Crypto* crypto; + Logic* logic; ProtocolMessage* msg; const Identity& m_LocalIdentity; IDataHandler* handler; const ProtocolFrame frame; const Introduction fromIntro; - AsyncFrameDecrypt(llarp::Logic* l, llarp::Crypto* c, - const Identity& localIdent, IDataHandler* h, - ProtocolMessage* m, const ProtocolFrame& f, - const Introduction& recvIntro) + AsyncFrameDecrypt(Logic* l, Crypto* c, const Identity& localIdent, + IDataHandler* h, ProtocolMessage* m, + const ProtocolFrame& f, const Introduction& recvIntro) : crypto(c) , logic(l) , msg(m) @@ -278,7 +276,7 @@ namespace llarp if(!crypto->pqe_decrypt(self->frame.C, K, pq_keypair_to_secret(self->m_LocalIdentity.pq))) { - llarp::LogError("pqke failed C=", self->frame.C); + LogError("pqke failed C=", self->frame.C); delete self->msg; delete self; return; @@ -288,8 +286,8 @@ namespace llarp crypto->xchacha20(*buf, K, self->frame.N); if(!self->msg->BDecode(buf)) { - llarp::LogError("failed to decode inner protocol message"); - llarp::DumpBuffer(*buf); + LogError("failed to decode inner protocol message"); + DumpBuffer(*buf); delete self->msg; delete self; return; @@ -297,8 +295,8 @@ namespace llarp // verify signature of outer message after we parsed the inner message if(!self->frame.Verify(crypto, self->msg->sender)) { - llarp::LogError("intro frame has invalid signature Z=", self->frame.Z, - " from ", self->msg->sender.Addr()); + LogError("intro frame has invalid signature Z=", self->frame.Z, + " from ", self->msg->sender.Addr()); self->frame.Dump< MAX_PROTOCOL_MESSAGE_SIZE >(); self->msg->Dump< MAX_PROTOCOL_MESSAGE_SIZE >(); delete self->msg; @@ -308,7 +306,7 @@ namespace llarp if(self->handler->HasConvoTag(self->msg->tag)) { - llarp::LogError("dropping duplicate convo tag T=", self->msg->tag); + LogError("dropping duplicate convo tag T=", self->msg->tag); // TODO: send convotag reset delete self->msg; delete self; @@ -324,7 +322,7 @@ namespace llarp if(!self->m_LocalIdentity.KeyExchange(dh_server, sharedSecret, self->msg->sender, self->frame.N)) { - llarp::LogError("x25519 key exchange failed"); + LogError("x25519 key exchange failed"); self->frame.Dump< MAX_PROTOCOL_MESSAGE_SIZE >(); delete self->msg; delete self; @@ -364,7 +362,7 @@ namespace llarp } bool - ProtocolFrame::AsyncDecryptAndVerify(llarp::Logic* logic, llarp::Crypto* c, + ProtocolFrame::AsyncDecryptAndVerify(Logic* logic, Crypto* c, path::Path* recvPath, llarp_threadpool* worker, const Identity& localIdent, @@ -372,7 +370,7 @@ namespace llarp { if(T.IsZero()) { - llarp::LogInfo("Got protocol frame with new convo"); + LogInfo("Got protocol frame with new convo"); ProtocolMessage* msg = new ProtocolMessage(); msg->srcPath = recvPath->RXID(); // we need to dh @@ -384,24 +382,24 @@ namespace llarp SharedSecret shared; if(!handler->GetCachedSessionKeyFor(T, shared)) { - llarp::LogError("No cached session for T=", T); + LogError("No cached session for T=", T); return false; } ServiceInfo si; if(!handler->GetSenderFor(T, si)) { - llarp::LogError("No sender for T=", T); + LogError("No sender for T=", T); return false; } if(!Verify(c, si)) { - llarp::LogError("Signature failure from ", si.Addr()); + LogError("Signature failure from ", si.Addr()); return false; } ProtocolMessage* msg = new ProtocolMessage(); if(!DecryptPayloadInto(c, shared, *msg)) { - llarp::LogError("failed to decrypt message"); + LogError("failed to decrypt message"); delete msg; return false; } @@ -419,7 +417,7 @@ namespace llarp } bool - ProtocolFrame::Verify(llarp::Crypto* crypto, const ServiceInfo& from) const + ProtocolFrame::Verify(Crypto* crypto, const ServiceInfo& from) const { ProtocolFrame copy(*this); // save signature @@ -430,7 +428,7 @@ namespace llarp llarp_buffer_t buf(tmp); if(!copy.BEncode(&buf)) { - llarp::LogError("bencode fail"); + LogError("bencode fail"); return false; } @@ -442,7 +440,7 @@ namespace llarp } bool - ProtocolFrame::HandleMessage(llarp::routing::IMessageHandler* h, + ProtocolFrame::HandleMessage(routing::IMessageHandler* h, ABSL_ATTRIBUTE_UNUSED AbstractRouter* r) const { return h->HandleHiddenServiceFrame(*this); diff --git a/llarp/service/protocol.hpp b/llarp/service/protocol.hpp index be8d95b96..b223761be 100644 --- a/llarp/service/protocol.hpp +++ b/llarp/service/protocol.hpp @@ -5,9 +5,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/llarp/service/sendcontext.cpp b/llarp/service/sendcontext.cpp index c25b6245d..a505c7032 100644 --- a/llarp/service/sendcontext.cpp +++ b/llarp/service/sendcontext.cpp @@ -30,18 +30,17 @@ namespace llarp const routing::PathTransferMessage transfer(msg, remoteIntro.pathID); if(path->SendRoutingMessage(transfer, m_Endpoint->Router())) { - llarp::LogInfo("sent intro to ", remoteIntro.pathID, " on ", - remoteIntro.router, " seqno=", sequenceNo); + LogInfo("sent intro to ", remoteIntro.pathID, " on ", + remoteIntro.router, " seqno=", sequenceNo); lastGoodSend = m_Endpoint->Now(); ++sequenceNo; return true; } else - llarp::LogError("Failed to send frame on path"); + LogError("Failed to send frame on path"); } else - llarp::LogError("cannot send because we have no path to ", - remoteIntro.router); + LogError("cannot send because we have no path to ", remoteIntro.router); return false; } @@ -63,14 +62,13 @@ namespace llarp // shift intro if(MarkCurrentIntroBad(now)) { - llarp::LogInfo("intro shifted"); + LogInfo("intro shifted"); } } auto path = m_PathSet->GetNewestPathByRouter(remoteIntro.router); if(!path) { - llarp::LogError("cannot encrypt and send: no path for intro ", - remoteIntro); + LogError("cannot encrypt and send: no path for intro ", remoteIntro); return; } @@ -87,13 +85,13 @@ namespace llarp m.PutBuffer(payload); if(!f.EncryptAndSign(crypto, m, shared, m_Endpoint->GetIdentity())) { - llarp::LogError("failed to sign"); + LogError("failed to sign"); return; } } else { - llarp::LogError("No cached session key"); + LogError("No cached session key"); return; } @@ -101,14 +99,14 @@ namespace llarp msg.Y.Randomize(); if(path->SendRoutingMessage(msg, m_Endpoint->Router())) { - llarp::LogDebug("sent message via ", remoteIntro.pathID, " on ", - remoteIntro.router); + LogDebug("sent message via ", remoteIntro.pathID, " on ", + remoteIntro.router); ++sequenceNo; lastGoodSend = now; } else { - llarp::LogWarn("Failed to send routing message for data"); + LogWarn("Failed to send routing message for data"); } } @@ -121,7 +119,7 @@ namespace llarp { if(!MarkCurrentIntroBad(now)) { - llarp::LogWarn("no good path yet, your message may drop"); + LogWarn("no good path yet, your message may drop"); } } if(sequenceNo) diff --git a/llarp/service/sendcontext.hpp b/llarp/service/sendcontext.hpp index 6239579e1..73dfca717 100644 --- a/llarp/service/sendcontext.hpp +++ b/llarp/service/sendcontext.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_SENDCONTEXT_HPP #include -#include +#include #include #include #include diff --git a/llarp/service/session.hpp b/llarp/service/session.hpp index aad4fd804..73e723eaa 100644 --- a/llarp/service/session.hpp +++ b/llarp/service/session.hpp @@ -3,8 +3,8 @@ #include #include -#include -#include +#include +#include #include #include diff --git a/llarp/service/tag.hpp b/llarp/service/tag.hpp index ab6a562e0..c6061648b 100644 --- a/llarp/service/tag.hpp +++ b/llarp/service/tag.hpp @@ -15,13 +15,13 @@ namespace llarp { namespace service { - struct Tag : public llarp::AlignedBuffer< 16 > + struct Tag : public AlignedBuffer< 16 > { - Tag() : llarp::AlignedBuffer< SIZE >() + Tag() : AlignedBuffer< SIZE >() { } - Tag(const byte_t* d) : llarp::AlignedBuffer< SIZE >(d) + Tag(const byte_t* d) : AlignedBuffer< SIZE >(d) { } diff --git a/llarp/service/tag_lookup_job.hpp b/llarp/service/tag_lookup_job.hpp index 82256070d..76834dd91 100644 --- a/llarp/service/tag_lookup_job.hpp +++ b/llarp/service/tag_lookup_job.hpp @@ -2,7 +2,7 @@ #define LLARP_SERVICE_TAG_LOOKUP_JOB_HPP #include -#include +#include #include #include #include diff --git a/llarp/service/types.cpp b/llarp/service/types.cpp deleted file mode 100644 index f029a29bf..000000000 --- a/llarp/service/types.cpp +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/llarp/service/types.hpp b/llarp/service/types.hpp deleted file mode 100644 index 17a71ed49..000000000 --- a/llarp/service/types.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef LLARP_SERVICE_TYPES_HPP -#define LLARP_SERVICE_TYPES_HPP -#include -#include - -#endif diff --git a/llarp/service/vanity.hpp b/llarp/service/vanity.hpp index 10cc3eba0..15944a46a 100644 --- a/llarp/service/vanity.hpp +++ b/llarp/service/vanity.hpp @@ -10,7 +10,7 @@ namespace llarp { /// hidden service address - using VanityNonce = llarp::AlignedBuffer< 16 >; + using VanityNonce = AlignedBuffer< 16 >; } // namespace service } // namespace llarp #endif diff --git a/test/dht/test_llarp_dht_serviceaddresslookup.cpp b/test/dht/test_llarp_dht_serviceaddresslookup.cpp index be9168fb4..033a2613e 100644 --- a/test/dht/test_llarp_dht_serviceaddresslookup.cpp +++ b/test/dht/test_llarp_dht_serviceaddresslookup.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/dht/test_llarp_dht_taglookup.cpp b/test/dht/test_llarp_dht_taglookup.cpp index 8a8964cf1..1f19b8a4d 100644 --- a/test/dht/test_llarp_dht_taglookup.cpp +++ b/test/dht/test_llarp_dht_taglookup.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/service/test_llarp_service_identity.cpp b/test/service/test_llarp_service_identity.cpp index 1f4a1f152..d2f32da91 100644 --- a/test/service/test_llarp_service_identity.cpp +++ b/test/service/test_llarp_service_identity.cpp @@ -2,8 +2,8 @@ #include #include #include -#include -#include +#include +#include #include #include