From 64c7ed42fc62afe96ce922c3897ea2206edfb71d Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 22 May 2019 12:20:50 -0400 Subject: [PATCH] make format --- libabyss/include/abyss/server.hpp | 4 ++-- libabyss/main.cpp | 10 +++++----- libabyss/src/server.cpp | 3 ++- llarp/dns/server.cpp | 27 ++++++++++++++------------- llarp/dns/server.hpp | 9 +++++---- llarp/ev/ev.cpp | 2 +- llarp/ev/ev.h | 2 +- llarp/exit/session.cpp | 2 +- llarp/handlers/exit.cpp | 3 ++- llarp/handlers/exit.hpp | 2 +- llarp/handlers/tun.cpp | 25 +++++++++++++------------ llarp/handlers/tun.hpp | 2 +- llarp/iwp/linklayer.cpp | 2 +- llarp/iwp/linklayer.hpp | 2 +- llarp/link/server.cpp | 2 +- llarp/link/server.hpp | 4 ++-- llarp/messages/relay_commit.cpp | 2 +- llarp/nodedb.cpp | 5 +++-- llarp/nodedb.hpp | 5 +++-- llarp/path/path.cpp | 2 +- llarp/path/path.hpp | 2 +- llarp/path/pathbuilder.cpp | 14 +++++++------- llarp/router/abstractrouter.hpp | 2 +- llarp/router/router.cpp | 2 +- llarp/router/router.hpp | 6 +++--- llarp/service/async_key_exchange.cpp | 2 +- llarp/service/async_key_exchange.hpp | 6 +++--- llarp/service/endpoint.cpp | 15 +++++++-------- llarp/service/endpoint.hpp | 20 ++++++++++++-------- llarp/service/protocol.cpp | 10 +++++----- llarp/service/protocol.hpp | 9 ++++----- llarp/service/sendcontext.cpp | 4 ++-- 32 files changed, 108 insertions(+), 99 deletions(-) diff --git a/libabyss/include/abyss/server.hpp b/libabyss/include/abyss/server.hpp index 70d690f5f..e2f446578 100644 --- a/libabyss/include/abyss/server.hpp +++ b/libabyss/include/abyss/server.hpp @@ -45,7 +45,7 @@ namespace abyss virtual ~BaseReqHandler(); bool - ServeAsync(llarp_ev_loop_ptr loop, std::shared_ptr logic, + ServeAsync(llarp_ev_loop_ptr loop, std::shared_ptr< llarp::Logic > logic, const sockaddr* bindaddr); void @@ -76,7 +76,7 @@ namespace abyss OnAccept(struct llarp_tcp_acceptor*, struct llarp_tcp_conn*); llarp_ev_loop_ptr m_loop; - std::shared_ptr m_Logic; + std::shared_ptr< llarp::Logic > m_Logic; llarp_tcp_acceptor m_acceptor; std::list< std::unique_ptr< IRPCHandler > > m_Conns; llarp_time_t m_ReqTimeout; diff --git a/libabyss/main.cpp b/libabyss/main.cpp index d927a4961..759edc431 100644 --- a/libabyss/main.cpp +++ b/libabyss/main.cpp @@ -25,9 +25,9 @@ struct DemoHandler : public abyss::httpd::IRPCHandler struct DemoCall : public abyss::http::IRPCClientHandler { std::function< void(void) > m_Callback; - std::shared_ptr m_Logic; + std::shared_ptr< llarp::Logic > m_Logic; - DemoCall(abyss::http::ConnImpl* impl, std::shared_ptr logic, + DemoCall(abyss::http::ConnImpl* impl, std::shared_ptr< llarp::Logic > logic, std::function< void(void) > callback) : abyss::http::IRPCClientHandler(impl) , m_Callback(callback) @@ -58,9 +58,9 @@ struct DemoCall : public abyss::http::IRPCClientHandler struct DemoClient : public abyss::http::JSONRPC { llarp_ev_loop_ptr m_Loop; - std::shared_ptr m_Logic; + std::shared_ptr< llarp::Logic > m_Logic; - DemoClient(llarp_ev_loop_ptr l, std::shared_ptr logic) + DemoClient(llarp_ev_loop_ptr l, std::shared_ptr< llarp::Logic > logic) : abyss::http::JSONRPC(), m_Loop(std::move(l)), m_Logic(logic) { } @@ -119,7 +119,7 @@ main(ABSL_ATTRIBUTE_UNUSED int argc, ABSL_ATTRIBUTE_UNUSED char* argv[]) llarp::SetLogLevel(llarp::eLogDebug); llarp_threadpool* threadpool = llarp_init_same_process_threadpool(); llarp_ev_loop_ptr loop = llarp_make_ev_loop(); - auto logic = std::make_shared(threadpool); + auto logic = std::make_shared< llarp::Logic >(threadpool); sockaddr_in addr; addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); addr.sin_port = htons(1222); diff --git a/libabyss/src/server.cpp b/libabyss/src/server.cpp index f65a63a28..bae67bf09 100644 --- a/libabyss/src/server.cpp +++ b/libabyss/src/server.cpp @@ -333,7 +333,8 @@ namespace abyss } bool - BaseReqHandler::ServeAsync(llarp_ev_loop_ptr loop, std::shared_ptr logic, + BaseReqHandler::ServeAsync(llarp_ev_loop_ptr loop, + std::shared_ptr< llarp::Logic > logic, const sockaddr* bindaddr) { m_loop = loop; diff --git a/llarp/dns/server.cpp b/llarp/dns/server.cpp index 089b130cf..17d84e9ce 100644 --- a/llarp/dns/server.cpp +++ b/llarp/dns/server.cpp @@ -9,12 +9,13 @@ namespace llarp namespace dns { Proxy::Proxy(llarp_ev_loop_ptr serverLoop, Logic_ptr serverLogic, - llarp_ev_loop_ptr clientLoop, Logic_ptr clientLogic, IQueryHandler* h) - : m_ServerLoop(serverLoop), - m_ServerLogic(serverLogic), - m_ClientLoop(clientLoop), - m_ClientLogic(clientLogic), - m_QueryHandler(h) + llarp_ev_loop_ptr clientLoop, Logic_ptr clientLogic, + IQueryHandler* h) + : m_ServerLoop(serverLoop) + , m_ServerLogic(serverLogic) + , m_ClientLoop(clientLoop) + , m_ClientLogic(clientLogic) + , m_QueryHandler(h) { m_Client.user = this; m_Server.user = this; @@ -125,16 +126,16 @@ namespace llarp auto itr = m_Forwarded.find(tx); if(itr == m_Forwarded.end()) return; - + const Addr requester = itr->second; - std::vector tmp(pkt->sz); + std::vector< byte_t > tmp(pkt->sz); std::copy_n(pkt->cur, pkt->sz, tmp.begin()); auto self = shared_from_this(); m_ServerLogic->queue_func([=]() { // forward reply to requester via server llarp_buffer_t tmpbuf(tmp); llarp_ev_udp_sendto(&self->m_Server, requester, tmpbuf); - }); + }); // remove pending m_Forwarded.erase(itr); } @@ -172,7 +173,7 @@ namespace llarp // no upstream resolvers // let's serv fail it msg.AddServFail(); - + SendServerMessageTo(from, std::move(msg)); } else if(itr == m_Forwarded.end()) @@ -180,13 +181,13 @@ namespace llarp // new forwarded query tx.from = PickRandomResolver(); m_Forwarded[tx] = from; - std::vector tmp(pkt->sz); + std::vector< byte_t > tmp(pkt->sz); std::copy_n(pkt->cur, pkt->sz, tmp.begin()); - + m_ClientLogic->queue_func([=] { // do query llarp_buffer_t buf(tmp); - llarp_ev_udp_sendto(&self->m_Client, tx.from, buf); + llarp_ev_udp_sendto(&self->m_Client, tx.from, buf); }); } else diff --git a/llarp/dns/server.hpp b/llarp/dns/server.hpp index 50652499f..b7d9aa195 100644 --- a/llarp/dns/server.hpp +++ b/llarp/dns/server.hpp @@ -30,11 +30,12 @@ namespace llarp std::function< void(Message) > sendReply) = 0; }; - struct Proxy : public std::enable_shared_from_this + struct Proxy : public std::enable_shared_from_this< Proxy > { - using Logic_ptr = std::shared_ptr; - Proxy(llarp_ev_loop_ptr serverLoop, Logic_ptr serverLogic, llarp_ev_loop_ptr clientLoop, Logic_ptr clientLogic, IQueryHandler * handler); - + using Logic_ptr = std::shared_ptr< Logic >; + Proxy(llarp_ev_loop_ptr serverLoop, Logic_ptr serverLogic, + llarp_ev_loop_ptr clientLoop, Logic_ptr clientLogic, + IQueryHandler* handler); bool Start(const llarp::Addr addr, diff --git a/llarp/ev/ev.cpp b/llarp/ev/ev.cpp index 68cf3bd4a..aa357b739 100644 --- a/llarp/ev/ev.cpp +++ b/llarp/ev/ev.cpp @@ -43,7 +43,7 @@ llarp_make_ev_loop() void llarp_ev_loop_run_single_process(llarp_ev_loop_ptr ev, struct llarp_threadpool *tp, - std::shared_ptr logic) + std::shared_ptr< llarp::Logic > logic) { while(ev->running()) { diff --git a/llarp/ev/ev.h b/llarp/ev/ev.h index 8f6c734b4..689482121 100644 --- a/llarp/ev/ev.h +++ b/llarp/ev/ev.h @@ -54,7 +54,7 @@ llarp_make_ev_loop(); void llarp_ev_loop_run_single_process(llarp_ev_loop_ptr ev, struct llarp_threadpool *tp, - std::shared_ptr logic); + std::shared_ptr< llarp::Logic > logic); /// get the current time on the event loop llarp_time_t diff --git a/llarp/exit/session.cpp b/llarp/exit/session.cpp index ffee724b2..2e0fd9e47 100644 --- a/llarp/exit/session.cpp +++ b/llarp/exit/session.cpp @@ -288,7 +288,7 @@ namespace llarp auto& msg = queue.front(); if(path) { - msg.S = path->NextSeqNo(); + msg.S = path->NextSeqNo(); if(path->SendRoutingMessage(msg, router)) m_LastUse = now; } diff --git a/llarp/handlers/exit.cpp b/llarp/handlers/exit.cpp index 9c4aafa5d..cf7e78414 100644 --- a/llarp/handlers/exit.cpp +++ b/llarp/handlers/exit.cpp @@ -25,7 +25,8 @@ namespace llarp ExitEndpoint::ExitEndpoint(const std::string &name, AbstractRouter *r) : m_Router(r) - , m_Resolver(std::make_shared(r->netloop(), r->logic(), r->netloop(), r->logic(), this)) + , m_Resolver(std::make_shared< dns::Proxy >( + r->netloop(), r->logic(), r->netloop(), r->logic(), this)) , m_Name(name) , m_Tun{{0}, 0, {0}, 0, 0, 0, 0, 0, 0, 0} , m_LocalResolverAddr("127.0.0.1", 53) diff --git a/llarp/handlers/exit.hpp b/llarp/handlers/exit.hpp index 5c6834b06..87abf9e6b 100644 --- a/llarp/handlers/exit.hpp +++ b/llarp/handlers/exit.hpp @@ -130,7 +130,7 @@ namespace llarp KickIdentOffExit(const PubKey& pk); AbstractRouter* m_Router; - std::shared_ptr m_Resolver; + std::shared_ptr< dns::Proxy > m_Resolver; bool m_ShouldInitTun; std::string m_Name; bool m_PermitExit; diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index 7eaed8973..a30b7085c 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -96,19 +96,20 @@ namespace llarp { if(k == "isolate-network" && IsTrueValue(v.c_str())) { - #if defined(__linux__) - LogInfo(Name(), " isolating network..."); - if(!SpawnIsolatedNetwork()) - { - LogError(Name(), " failed to spawn isolated network"); - return false; - } - LogInfo(Name(), " booyeah network isolation succeeded"); - return true; - #else - LogError(Name(), " network isolation is not supported on your platform"); +#if defined(__linux__) + LogInfo(Name(), " isolating network..."); + if(!SpawnIsolatedNetwork()) + { + LogError(Name(), " failed to spawn isolated network"); return false; - #endif + } + LogInfo(Name(), " booyeah network isolation succeeded"); + return true; +#else + LogError(Name(), + " network isolation is not supported on your platform"); + return false; +#endif } if(k == "strict-connect") { diff --git a/llarp/handlers/tun.hpp b/llarp/handlers/tun.hpp index 6e87c6f18..c81abb537 100644 --- a/llarp/handlers/tun.hpp +++ b/llarp/handlers/tun.hpp @@ -230,7 +230,7 @@ namespace llarp #endif /// our dns resolver - std::shared_ptr m_Resolver; + std::shared_ptr< dns::Proxy > m_Resolver; /// maps ip address to timestamp last active std::unordered_map< huint32_t, llarp_time_t, huint32_t::Hash > diff --git a/llarp/iwp/linklayer.cpp b/llarp/iwp/linklayer.cpp index 11514e7ae..45dbbadd6 100644 --- a/llarp/iwp/linklayer.cpp +++ b/llarp/iwp/linklayer.cpp @@ -44,7 +44,7 @@ namespace llarp } bool - LinkLayer::Start(std::shared_ptr l) + LinkLayer::Start(std::shared_ptr< Logic > l) { if(!ILinkLayer::Start(l)) return false; diff --git a/llarp/iwp/linklayer.hpp b/llarp/iwp/linklayer.hpp index f4079823f..8e8f129cb 100644 --- a/llarp/iwp/linklayer.hpp +++ b/llarp/iwp/linklayer.hpp @@ -31,7 +31,7 @@ namespace llarp } bool - Start(std::shared_ptr l) override; + Start(std::shared_ptr< Logic > l) override; std::shared_ptr< ILinkSession > NewOutboundSession(const RouterContact &rc, diff --git a/llarp/link/server.cpp b/llarp/link/server.cpp index 7d13d69a3..6938a1db1 100644 --- a/llarp/link/server.cpp +++ b/llarp/link/server.cpp @@ -245,7 +245,7 @@ namespace llarp } bool - ILinkLayer::Start(std::shared_ptr l) + ILinkLayer::Start(std::shared_ptr< Logic > l) { m_Logic = l; ScheduleTick(100); diff --git a/llarp/link/server.hpp b/llarp/link/server.hpp index 1d65c4e42..8923ada95 100644 --- a/llarp/link/server.hpp +++ b/llarp/link/server.hpp @@ -126,7 +126,7 @@ namespace llarp TryEstablishTo(RouterContact rc); virtual bool - Start(std::shared_ptr l); + Start(std::shared_ptr< llarp::Logic > l); void Stop(); @@ -239,7 +239,7 @@ namespace llarp bool PutSession(const std::shared_ptr< ILinkSession >& s); - std::shared_ptr m_Logic = nullptr; + std::shared_ptr< llarp::Logic > m_Logic = nullptr; llarp_ev_loop_ptr m_Loop; Addr m_ourAddr; llarp_udp_io m_udp; diff --git a/llarp/messages/relay_commit.cpp b/llarp/messages/relay_commit.cpp index 60ec1dd74..05f8ae88b 100644 --- a/llarp/messages/relay_commit.cpp +++ b/llarp/messages/relay_commit.cpp @@ -242,7 +242,7 @@ namespace llarp // store it into netdb if we don't have it if(!n->Has(rc.pubkey)) { - std::shared_ptr l = self->context->Router()->logic(); + std::shared_ptr< Logic > l = self->context->Router()->logic(); n->InsertAsync(rc, l, [=]() { self->context->ForwardLRCM(self->hop->info.upstream, self->frames); diff --git a/llarp/nodedb.cpp b/llarp/nodedb.cpp index 0501a0a04..ea0bdf8ae 100644 --- a/llarp/nodedb.cpp +++ b/llarp/nodedb.cpp @@ -109,7 +109,7 @@ llarp_nodedb::getRCFilePath(const llarp::RouterID &pubkey) const static void handle_async_insert_rc(llarp_nodedb *nodedb, const llarp::RouterContact &rc, - std::shared_ptr logic, + std::shared_ptr< llarp::Logic > logic, const std::function< void(void) > &completedHook) { nodedb->Insert(rc); @@ -120,7 +120,8 @@ handle_async_insert_rc(llarp_nodedb *nodedb, const llarp::RouterContact &rc, } void -llarp_nodedb::InsertAsync(llarp::RouterContact rc, std::shared_ptr logic, +llarp_nodedb::InsertAsync(llarp::RouterContact rc, + std::shared_ptr< llarp::Logic > logic, std::function< void(void) > completionHandler) { disk->addJob( diff --git a/llarp/nodedb.hpp b/llarp/nodedb.hpp index 40cd301cc..da22a1b43 100644 --- a/llarp/nodedb.hpp +++ b/llarp/nodedb.hpp @@ -89,7 +89,8 @@ struct llarp_nodedb /// insert and write to disk in background void - InsertAsync(llarp::RouterContact rc, std::shared_ptr l = nullptr, + InsertAsync(llarp::RouterContact rc, + std::shared_ptr< llarp::Logic > l = nullptr, std::function< void(void) > completionHandler = nullptr); ssize_t @@ -153,7 +154,7 @@ struct llarp_async_verify_rc /// nodedb storage llarp_nodedb *nodedb; // llarp::Logic for queue_job - std::shared_ptr logic; // includes a llarp_threadpool + std::shared_ptr< llarp::Logic > logic; // includes a llarp_threadpool llarp_threadpool *cryptoworker; llarp::thread::ThreadPool *diskworker; diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index c458b4d64..7c9291acd 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -63,7 +63,7 @@ namespace llarp return m_Router->crypto(); } - std::shared_ptr + std::shared_ptr< Logic > PathContext::logic() { return m_Router->logic(); diff --git a/llarp/path/path.hpp b/llarp/path/path.hpp index 866bee487..95464ac05 100644 --- a/llarp/path/path.hpp +++ b/llarp/path/path.hpp @@ -708,7 +708,7 @@ namespace llarp llarp::Crypto* crypto(); - std::shared_ptr + std::shared_ptr< Logic > logic(); AbstractRouter* diff --git a/llarp/path/pathbuilder.cpp b/llarp/path/pathbuilder.cpp index 2be15298a..7f16dd60c 100644 --- a/llarp/path/pathbuilder.cpp +++ b/llarp/path/pathbuilder.cpp @@ -23,11 +23,11 @@ namespace llarp User* user = nullptr; Handler result; - size_t idx = 0; - AbstractRouter* router = nullptr; - llarp_threadpool* worker = nullptr; - std::shared_ptr logic = nullptr; - Crypto* crypto = nullptr; + size_t idx = 0; + AbstractRouter* router = nullptr; + llarp_threadpool* worker = nullptr; + std::shared_ptr< Logic > logic = nullptr; + Crypto* crypto = nullptr; LR_CommitMessage LRCM; ~AsyncPathKeyExchangeContext() @@ -131,8 +131,8 @@ namespace llarp /// Generate all keys asynchronously and call handler when done void - AsyncGenerateKeys(Path_t p, std::shared_ptr l, llarp_threadpool* pool, User* u, - Handler func) + AsyncGenerateKeys(Path_t p, std::shared_ptr< Logic > l, + llarp_threadpool* pool, User* u, Handler func) { path = p; logic = l; diff --git a/llarp/router/abstractrouter.hpp b/llarp/router/abstractrouter.hpp index 808baf6aa..6de36e78f 100644 --- a/llarp/router/abstractrouter.hpp +++ b/llarp/router/abstractrouter.hpp @@ -62,7 +62,7 @@ namespace llarp HandleRecvLinkMessageBuffer(ILinkSession *from, const llarp_buffer_t &msg) = 0; - virtual std::shared_ptr + virtual std::shared_ptr< Logic > logic() const = 0; virtual llarp_dht_context * diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 3fccf12ee..0a878ac6b 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -215,7 +215,7 @@ namespace llarp } Router::Router(struct llarp_threadpool *_tp, llarp_ev_loop_ptr __netloop, - std::shared_ptr l) + std::shared_ptr< Logic > l) : ready(false) , _netloop(__netloop) , tp(_tp) diff --git a/llarp/router/router.hpp b/llarp/router/router.hpp index c707b5a48..60df1b479 100644 --- a/llarp/router/router.hpp +++ b/llarp/router/router.hpp @@ -86,7 +86,7 @@ namespace llarp /// should we obey the service node whitelist? bool whitelistRouters = false; - std::shared_ptr + std::shared_ptr< Logic > logic() const override { return _logic; @@ -183,7 +183,7 @@ namespace llarp llarp_ev_loop_ptr _netloop; llarp_threadpool *tp; - std::shared_ptr _logic; + std::shared_ptr< Logic > _logic; std::unique_ptr< Crypto > _crypto; path::PathContext paths; exit::Context _exitContext; @@ -318,7 +318,7 @@ namespace llarp std::unordered_map< RouterID, llarp_time_t, PubKey::Hash > lokinetRouters; Router(struct llarp_threadpool *tp, llarp_ev_loop_ptr __netloop, - std::shared_ptr logic); + std::shared_ptr< Logic > logic); ~Router(); diff --git a/llarp/service/async_key_exchange.cpp b/llarp/service/async_key_exchange.cpp index 998f808dd..e3201780a 100644 --- a/llarp/service/async_key_exchange.cpp +++ b/llarp/service/async_key_exchange.cpp @@ -8,7 +8,7 @@ namespace llarp { namespace service { - AsyncKeyExchange::AsyncKeyExchange(std::shared_ptr l, Crypto* c, + AsyncKeyExchange::AsyncKeyExchange(std::shared_ptr< Logic > l, Crypto* c, const ServiceInfo& r, const Identity& localident, const PQPubKey& introsetPubKey, diff --git a/llarp/service/async_key_exchange.hpp b/llarp/service/async_key_exchange.hpp index 10f057e71..e7c1d893d 100644 --- a/llarp/service/async_key_exchange.hpp +++ b/llarp/service/async_key_exchange.hpp @@ -14,7 +14,7 @@ namespace llarp { struct AsyncKeyExchange { - std::shared_ptr logic; + std::shared_ptr< Logic > logic; Crypto* crypto; SharedSecret sharedKey; ServiceInfo remote; @@ -28,8 +28,8 @@ namespace llarp IDataHandler* handler; ConvoTag tag; - AsyncKeyExchange(std::shared_ptr l, Crypto* c, const ServiceInfo& r, - const Identity& localident, + AsyncKeyExchange(std::shared_ptr< Logic > l, Crypto* c, + const ServiceInfo& r, const Identity& localident, const PQPubKey& introsetPubKey, const Introduction& remote, IDataHandler* h, const ConvoTag& t); diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index 90e67ca95..67a2726ad 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -648,11 +648,10 @@ namespace llarp Endpoint::IsolatedNetworkMainLoop() { m_IsolatedNetLoop = llarp_make_ev_loop(); - m_IsolatedLogic = std::make_shared(); + m_IsolatedLogic = std::make_shared< llarp::Logic >(); if(SetupNetworking()) - llarp_ev_loop_run_single_process(m_IsolatedNetLoop, - m_IsolatedLogic->thread, - m_IsolatedLogic); + llarp_ev_loop_run_single_process( + m_IsolatedNetLoop, m_IsolatedLogic->thread, m_IsolatedLogic); else { m_IsolatedNetLoop.reset(); @@ -1043,14 +1042,14 @@ namespace llarp void Endpoint::Pump(llarp_time_t) { EndpointLogic()->queue_func([&]() { - // send downstream packets to user for snode + // send downstream packets to user for snode for(const auto& item : m_SNodeSessions) item.second->FlushDownstream(); // send downstrream traffic to user for hidden service util::Lock lock(&m_InboundTrafficQueueMutex); while(m_InboundTrafficQueue.size()) { - const auto & msg = m_InboundTrafficQueue.top(); + const auto& msg = m_InboundTrafficQueue.top(); llarp_buffer_t buf(msg->payload); HandleWriteIPPacket(buf, [&]() -> huint32_t { return ObtainIPForAddr(msg->sender.Addr(), false); @@ -1212,13 +1211,13 @@ namespace llarp && (NumInStatus(path::ePathBuilding) < m_NumPaths)); } - std::shared_ptr + std::shared_ptr< Logic > Endpoint::RouterLogic() { return m_Router->logic(); } - std::shared_ptr + std::shared_ptr< Logic > Endpoint::EndpointLogic() { return m_IsolatedLogic ? m_IsolatedLogic : m_Router->logic(); diff --git a/llarp/service/endpoint.hpp b/llarp/service/endpoint.hpp index d1335f39a..7b15f947a 100644 --- a/llarp/service/endpoint.hpp +++ b/llarp/service/endpoint.hpp @@ -92,12 +92,12 @@ namespace llarp /// router's logic /// use when sending any data on a path - std::shared_ptr + std::shared_ptr< Logic > RouterLogic(); /// endpoint's logic /// use when writing any data to local network interfaces - std::shared_ptr + std::shared_ptr< Logic > EndpointLogic(); /// borrow endpoint's net loop for sending data to user on local network @@ -323,7 +323,7 @@ namespace llarp /// spawn a new process that contains a network isolated process /// return true if we set up isolation and the event loop is up - /// otherwise return false + /// otherwise return false virtual bool SpawnIsolatedNetwork() { @@ -410,12 +410,16 @@ namespace llarp using PendingTraffic = std::unordered_map< Address, PendingBufferQueue, Address::Hash >; - using ProtocolMessagePtr = std::shared_ptr; - using RecvPacketQueue_t = std::priority_queue, ComparePtr >; + using ProtocolMessagePtr = std::shared_ptr< ProtocolMessage >; + using RecvPacketQueue_t = + std::priority_queue< ProtocolMessagePtr, + std::vector< ProtocolMessagePtr >, + ComparePtr< ProtocolMessagePtr > >; util::Mutex m_InboundTrafficQueueMutex; /// ordered queue for inbound hidden service traffic - RecvPacketQueue_t m_InboundTrafficQueue GUARDED_BY(m_InboundTrafficQueueMutex); + RecvPacketQueue_t m_InboundTrafficQueue + GUARDED_BY(m_InboundTrafficQueueMutex); using PendingRouters = std::unordered_map< RouterID, RouterLookupJob, RouterID::Hash >; @@ -434,8 +438,8 @@ namespace llarp using ConvoMap = std::unordered_map< ConvoTag, Session, ConvoTag::Hash >; AbstractRouter* m_Router; - std::shared_ptr m_IsolatedLogic = nullptr; - llarp_ev_loop_ptr m_IsolatedNetLoop = nullptr; + std::shared_ptr< Logic > m_IsolatedLogic = nullptr; + llarp_ev_loop_ptr m_IsolatedNetLoop = nullptr; std::string m_Keyfile; std::string m_Name; std::string m_NetNS; diff --git a/llarp/service/protocol.cpp b/llarp/service/protocol.cpp index 3ad1b80e6..1460434fa 100644 --- a/llarp/service/protocol.cpp +++ b/llarp/service/protocol.cpp @@ -246,15 +246,15 @@ namespace llarp struct AsyncFrameDecrypt { Crypto* crypto; - std::shared_ptr logic; + std::shared_ptr< Logic > logic; std::shared_ptr< ProtocolMessage > msg; const Identity& m_LocalIdentity; IDataHandler* handler; const ProtocolFrame frame; const Introduction fromIntro; - AsyncFrameDecrypt(std::shared_ptr l, Crypto* c, const Identity& localIdent, - IDataHandler* h, + AsyncFrameDecrypt(std::shared_ptr< Logic > l, Crypto* c, + const Identity& localIdent, IDataHandler* h, const std::shared_ptr< ProtocolMessage >& m, const ProtocolFrame& f, const Introduction& recvIntro) : crypto(c) @@ -366,8 +366,8 @@ namespace llarp } bool - ProtocolFrame::AsyncDecryptAndVerify(std::shared_ptr logic, Crypto* c, - path::Path_ptr recvPath, + ProtocolFrame::AsyncDecryptAndVerify(std::shared_ptr< Logic > logic, + Crypto* c, path::Path_ptr recvPath, llarp_threadpool* worker, const Identity& localIdent, IDataHandler* handler) const diff --git a/llarp/service/protocol.hpp b/llarp/service/protocol.hpp index 94db8abb6..d967cc24c 100644 --- a/llarp/service/protocol.hpp +++ b/llarp/service/protocol.hpp @@ -66,12 +66,11 @@ namespace llarp static void ProcessAsync(std::shared_ptr< ProtocolMessage > self); - bool - operator<(const ProtocolMessage & other) const + bool + operator<(const ProtocolMessage& other) const { return seqno < other.seqno; } - }; /// outer message @@ -127,8 +126,8 @@ namespace llarp Sign(Crypto* c, const Identity& localIdent); bool - AsyncDecryptAndVerify(std::shared_ptr logic, Crypto* c, path::Path_ptr fromPath, - llarp_threadpool* worker, + AsyncDecryptAndVerify(std::shared_ptr< Logic > logic, Crypto* c, + path::Path_ptr fromPath, llarp_threadpool* worker, const Identity& localIdent, IDataHandler* handler) const; diff --git a/llarp/service/sendcontext.cpp b/llarp/service/sendcontext.cpp index ff2305c2f..04a97a880 100644 --- a/llarp/service/sendcontext.cpp +++ b/llarp/service/sendcontext.cpp @@ -83,7 +83,7 @@ namespace llarp LogError("No cached session key"); return; } - + ProtocolMessage m; m_DataHandler->PutIntroFor(f.T, remoteIntro); m_DataHandler->PutReplyIntroFor(f.T, path->intro); @@ -98,7 +98,7 @@ namespace llarp { LogError("failed to sign"); return; - } + } Send(f, path); }