make format

pull/618/head
Jeff Becker 5 years ago
parent 9c96aecf3f
commit 64c7ed42fc
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -45,7 +45,7 @@ namespace abyss
virtual ~BaseReqHandler(); virtual ~BaseReqHandler();
bool bool
ServeAsync(llarp_ev_loop_ptr loop, std::shared_ptr<llarp::Logic> logic, ServeAsync(llarp_ev_loop_ptr loop, std::shared_ptr< llarp::Logic > logic,
const sockaddr* bindaddr); const sockaddr* bindaddr);
void void
@ -76,7 +76,7 @@ namespace abyss
OnAccept(struct llarp_tcp_acceptor*, struct llarp_tcp_conn*); OnAccept(struct llarp_tcp_acceptor*, struct llarp_tcp_conn*);
llarp_ev_loop_ptr m_loop; llarp_ev_loop_ptr m_loop;
std::shared_ptr<llarp::Logic> m_Logic; std::shared_ptr< llarp::Logic > m_Logic;
llarp_tcp_acceptor m_acceptor; llarp_tcp_acceptor m_acceptor;
std::list< std::unique_ptr< IRPCHandler > > m_Conns; std::list< std::unique_ptr< IRPCHandler > > m_Conns;
llarp_time_t m_ReqTimeout; llarp_time_t m_ReqTimeout;

@ -25,9 +25,9 @@ struct DemoHandler : public abyss::httpd::IRPCHandler
struct DemoCall : public abyss::http::IRPCClientHandler struct DemoCall : public abyss::http::IRPCClientHandler
{ {
std::function< void(void) > m_Callback; std::function< void(void) > m_Callback;
std::shared_ptr<llarp::Logic> m_Logic; std::shared_ptr< llarp::Logic > m_Logic;
DemoCall(abyss::http::ConnImpl* impl, std::shared_ptr<llarp::Logic> logic, DemoCall(abyss::http::ConnImpl* impl, std::shared_ptr< llarp::Logic > logic,
std::function< void(void) > callback) std::function< void(void) > callback)
: abyss::http::IRPCClientHandler(impl) : abyss::http::IRPCClientHandler(impl)
, m_Callback(callback) , m_Callback(callback)
@ -58,9 +58,9 @@ struct DemoCall : public abyss::http::IRPCClientHandler
struct DemoClient : public abyss::http::JSONRPC struct DemoClient : public abyss::http::JSONRPC
{ {
llarp_ev_loop_ptr m_Loop; llarp_ev_loop_ptr m_Loop;
std::shared_ptr<llarp::Logic> m_Logic; std::shared_ptr< llarp::Logic > m_Logic;
DemoClient(llarp_ev_loop_ptr l, std::shared_ptr<llarp::Logic> logic) DemoClient(llarp_ev_loop_ptr l, std::shared_ptr< llarp::Logic > logic)
: abyss::http::JSONRPC(), m_Loop(std::move(l)), m_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::SetLogLevel(llarp::eLogDebug);
llarp_threadpool* threadpool = llarp_init_same_process_threadpool(); llarp_threadpool* threadpool = llarp_init_same_process_threadpool();
llarp_ev_loop_ptr loop = llarp_make_ev_loop(); llarp_ev_loop_ptr loop = llarp_make_ev_loop();
auto logic = std::make_shared<llarp::Logic>(threadpool); auto logic = std::make_shared< llarp::Logic >(threadpool);
sockaddr_in addr; sockaddr_in addr;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr.sin_port = htons(1222); addr.sin_port = htons(1222);

@ -333,7 +333,8 @@ namespace abyss
} }
bool bool
BaseReqHandler::ServeAsync(llarp_ev_loop_ptr loop, std::shared_ptr<llarp::Logic> logic, BaseReqHandler::ServeAsync(llarp_ev_loop_ptr loop,
std::shared_ptr< llarp::Logic > logic,
const sockaddr* bindaddr) const sockaddr* bindaddr)
{ {
m_loop = loop; m_loop = loop;

@ -9,12 +9,13 @@ namespace llarp
namespace dns namespace dns
{ {
Proxy::Proxy(llarp_ev_loop_ptr serverLoop, Logic_ptr serverLogic, Proxy::Proxy(llarp_ev_loop_ptr serverLoop, Logic_ptr serverLogic,
llarp_ev_loop_ptr clientLoop, Logic_ptr clientLogic, IQueryHandler* h) llarp_ev_loop_ptr clientLoop, Logic_ptr clientLogic,
: m_ServerLoop(serverLoop), IQueryHandler* h)
m_ServerLogic(serverLogic), : m_ServerLoop(serverLoop)
m_ClientLoop(clientLoop), , m_ServerLogic(serverLogic)
m_ClientLogic(clientLogic), , m_ClientLoop(clientLoop)
m_QueryHandler(h) , m_ClientLogic(clientLogic)
, m_QueryHandler(h)
{ {
m_Client.user = this; m_Client.user = this;
m_Server.user = this; m_Server.user = this;
@ -125,16 +126,16 @@ namespace llarp
auto itr = m_Forwarded.find(tx); auto itr = m_Forwarded.find(tx);
if(itr == m_Forwarded.end()) if(itr == m_Forwarded.end())
return; return;
const Addr requester = itr->second; const Addr requester = itr->second;
std::vector<byte_t> tmp(pkt->sz); std::vector< byte_t > tmp(pkt->sz);
std::copy_n(pkt->cur, pkt->sz, tmp.begin()); std::copy_n(pkt->cur, pkt->sz, tmp.begin());
auto self = shared_from_this(); auto self = shared_from_this();
m_ServerLogic->queue_func([=]() { m_ServerLogic->queue_func([=]() {
// forward reply to requester via server // forward reply to requester via server
llarp_buffer_t tmpbuf(tmp); llarp_buffer_t tmpbuf(tmp);
llarp_ev_udp_sendto(&self->m_Server, requester, tmpbuf); llarp_ev_udp_sendto(&self->m_Server, requester, tmpbuf);
}); });
// remove pending // remove pending
m_Forwarded.erase(itr); m_Forwarded.erase(itr);
} }
@ -172,7 +173,7 @@ namespace llarp
// no upstream resolvers // no upstream resolvers
// let's serv fail it // let's serv fail it
msg.AddServFail(); msg.AddServFail();
SendServerMessageTo(from, std::move(msg)); SendServerMessageTo(from, std::move(msg));
} }
else if(itr == m_Forwarded.end()) else if(itr == m_Forwarded.end())
@ -180,13 +181,13 @@ namespace llarp
// new forwarded query // new forwarded query
tx.from = PickRandomResolver(); tx.from = PickRandomResolver();
m_Forwarded[tx] = from; m_Forwarded[tx] = from;
std::vector<byte_t> tmp(pkt->sz); std::vector< byte_t > tmp(pkt->sz);
std::copy_n(pkt->cur, pkt->sz, tmp.begin()); std::copy_n(pkt->cur, pkt->sz, tmp.begin());
m_ClientLogic->queue_func([=] { m_ClientLogic->queue_func([=] {
// do query // do query
llarp_buffer_t buf(tmp); 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 else

@ -30,11 +30,12 @@ namespace llarp
std::function< void(Message) > sendReply) = 0; std::function< void(Message) > sendReply) = 0;
}; };
struct Proxy : public std::enable_shared_from_this<Proxy> struct Proxy : public std::enable_shared_from_this< Proxy >
{ {
using Logic_ptr = std::shared_ptr<Logic>; 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); Proxy(llarp_ev_loop_ptr serverLoop, Logic_ptr serverLogic,
llarp_ev_loop_ptr clientLoop, Logic_ptr clientLogic,
IQueryHandler* handler);
bool bool
Start(const llarp::Addr addr, Start(const llarp::Addr addr,

@ -43,7 +43,7 @@ llarp_make_ev_loop()
void void
llarp_ev_loop_run_single_process(llarp_ev_loop_ptr ev, llarp_ev_loop_run_single_process(llarp_ev_loop_ptr ev,
struct llarp_threadpool *tp, struct llarp_threadpool *tp,
std::shared_ptr<llarp::Logic> logic) std::shared_ptr< llarp::Logic > logic)
{ {
while(ev->running()) while(ev->running())
{ {

@ -54,7 +54,7 @@ llarp_make_ev_loop();
void void
llarp_ev_loop_run_single_process(llarp_ev_loop_ptr ev, llarp_ev_loop_run_single_process(llarp_ev_loop_ptr ev,
struct llarp_threadpool *tp, struct llarp_threadpool *tp,
std::shared_ptr<llarp::Logic> logic); std::shared_ptr< llarp::Logic > logic);
/// get the current time on the event loop /// get the current time on the event loop
llarp_time_t llarp_time_t

@ -288,7 +288,7 @@ namespace llarp
auto& msg = queue.front(); auto& msg = queue.front();
if(path) if(path)
{ {
msg.S = path->NextSeqNo(); msg.S = path->NextSeqNo();
if(path->SendRoutingMessage(msg, router)) if(path->SendRoutingMessage(msg, router))
m_LastUse = now; m_LastUse = now;
} }

@ -25,7 +25,8 @@ namespace llarp
ExitEndpoint::ExitEndpoint(const std::string &name, AbstractRouter *r) ExitEndpoint::ExitEndpoint(const std::string &name, AbstractRouter *r)
: m_Router(r) : m_Router(r)
, m_Resolver(std::make_shared<dns::Proxy>(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_Name(name)
, m_Tun{{0}, 0, {0}, 0, 0, 0, 0, 0, 0, 0} , m_Tun{{0}, 0, {0}, 0, 0, 0, 0, 0, 0, 0}
, m_LocalResolverAddr("127.0.0.1", 53) , m_LocalResolverAddr("127.0.0.1", 53)

@ -130,7 +130,7 @@ namespace llarp
KickIdentOffExit(const PubKey& pk); KickIdentOffExit(const PubKey& pk);
AbstractRouter* m_Router; AbstractRouter* m_Router;
std::shared_ptr<dns::Proxy> m_Resolver; std::shared_ptr< dns::Proxy > m_Resolver;
bool m_ShouldInitTun; bool m_ShouldInitTun;
std::string m_Name; std::string m_Name;
bool m_PermitExit; bool m_PermitExit;

@ -96,19 +96,20 @@ namespace llarp
{ {
if(k == "isolate-network" && IsTrueValue(v.c_str())) if(k == "isolate-network" && IsTrueValue(v.c_str()))
{ {
#if defined(__linux__) #if defined(__linux__)
LogInfo(Name(), " isolating network..."); LogInfo(Name(), " isolating network...");
if(!SpawnIsolatedNetwork()) if(!SpawnIsolatedNetwork())
{ {
LogError(Name(), " failed to spawn isolated network"); 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");
return false; 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") if(k == "strict-connect")
{ {

@ -230,7 +230,7 @@ namespace llarp
#endif #endif
/// our dns resolver /// our dns resolver
std::shared_ptr<dns::Proxy> m_Resolver; std::shared_ptr< dns::Proxy > m_Resolver;
/// maps ip address to timestamp last active /// maps ip address to timestamp last active
std::unordered_map< huint32_t, llarp_time_t, huint32_t::Hash > std::unordered_map< huint32_t, llarp_time_t, huint32_t::Hash >

@ -44,7 +44,7 @@ namespace llarp
} }
bool bool
LinkLayer::Start(std::shared_ptr<Logic> l) LinkLayer::Start(std::shared_ptr< Logic > l)
{ {
if(!ILinkLayer::Start(l)) if(!ILinkLayer::Start(l))
return false; return false;

@ -31,7 +31,7 @@ namespace llarp
} }
bool bool
Start(std::shared_ptr<Logic> l) override; Start(std::shared_ptr< Logic > l) override;
std::shared_ptr< ILinkSession > std::shared_ptr< ILinkSession >
NewOutboundSession(const RouterContact &rc, NewOutboundSession(const RouterContact &rc,

@ -245,7 +245,7 @@ namespace llarp
} }
bool bool
ILinkLayer::Start(std::shared_ptr<Logic> l) ILinkLayer::Start(std::shared_ptr< Logic > l)
{ {
m_Logic = l; m_Logic = l;
ScheduleTick(100); ScheduleTick(100);

@ -126,7 +126,7 @@ namespace llarp
TryEstablishTo(RouterContact rc); TryEstablishTo(RouterContact rc);
virtual bool virtual bool
Start(std::shared_ptr<llarp::Logic> l); Start(std::shared_ptr< llarp::Logic > l);
void void
Stop(); Stop();
@ -239,7 +239,7 @@ namespace llarp
bool bool
PutSession(const std::shared_ptr< ILinkSession >& s); PutSession(const std::shared_ptr< ILinkSession >& s);
std::shared_ptr<llarp::Logic> m_Logic = nullptr; std::shared_ptr< llarp::Logic > m_Logic = nullptr;
llarp_ev_loop_ptr m_Loop; llarp_ev_loop_ptr m_Loop;
Addr m_ourAddr; Addr m_ourAddr;
llarp_udp_io m_udp; llarp_udp_io m_udp;

@ -242,7 +242,7 @@ namespace llarp
// store it into netdb if we don't have it // store it into netdb if we don't have it
if(!n->Has(rc.pubkey)) if(!n->Has(rc.pubkey))
{ {
std::shared_ptr<Logic> l = self->context->Router()->logic(); std::shared_ptr< Logic > l = self->context->Router()->logic();
n->InsertAsync(rc, l, [=]() { n->InsertAsync(rc, l, [=]() {
self->context->ForwardLRCM(self->hop->info.upstream, self->context->ForwardLRCM(self->hop->info.upstream,
self->frames); self->frames);

@ -109,7 +109,7 @@ llarp_nodedb::getRCFilePath(const llarp::RouterID &pubkey) const
static void static void
handle_async_insert_rc(llarp_nodedb *nodedb, const llarp::RouterContact &rc, handle_async_insert_rc(llarp_nodedb *nodedb, const llarp::RouterContact &rc,
std::shared_ptr<llarp::Logic> logic, std::shared_ptr< llarp::Logic > logic,
const std::function< void(void) > &completedHook) const std::function< void(void) > &completedHook)
{ {
nodedb->Insert(rc); nodedb->Insert(rc);
@ -120,7 +120,8 @@ handle_async_insert_rc(llarp_nodedb *nodedb, const llarp::RouterContact &rc,
} }
void void
llarp_nodedb::InsertAsync(llarp::RouterContact rc, std::shared_ptr<llarp::Logic> logic, llarp_nodedb::InsertAsync(llarp::RouterContact rc,
std::shared_ptr< llarp::Logic > logic,
std::function< void(void) > completionHandler) std::function< void(void) > completionHandler)
{ {
disk->addJob( disk->addJob(

@ -89,7 +89,8 @@ struct llarp_nodedb
/// insert and write to disk in background /// insert and write to disk in background
void void
InsertAsync(llarp::RouterContact rc, std::shared_ptr<llarp::Logic> l = nullptr, InsertAsync(llarp::RouterContact rc,
std::shared_ptr< llarp::Logic > l = nullptr,
std::function< void(void) > completionHandler = nullptr); std::function< void(void) > completionHandler = nullptr);
ssize_t ssize_t
@ -153,7 +154,7 @@ struct llarp_async_verify_rc
/// nodedb storage /// nodedb storage
llarp_nodedb *nodedb; llarp_nodedb *nodedb;
// llarp::Logic for queue_job // llarp::Logic for queue_job
std::shared_ptr<llarp::Logic> logic; // includes a llarp_threadpool std::shared_ptr< llarp::Logic > logic; // includes a llarp_threadpool
llarp_threadpool *cryptoworker; llarp_threadpool *cryptoworker;
llarp::thread::ThreadPool *diskworker; llarp::thread::ThreadPool *diskworker;

@ -63,7 +63,7 @@ namespace llarp
return m_Router->crypto(); return m_Router->crypto();
} }
std::shared_ptr<Logic> std::shared_ptr< Logic >
PathContext::logic() PathContext::logic()
{ {
return m_Router->logic(); return m_Router->logic();

@ -708,7 +708,7 @@ namespace llarp
llarp::Crypto* llarp::Crypto*
crypto(); crypto();
std::shared_ptr<Logic> std::shared_ptr< Logic >
logic(); logic();
AbstractRouter* AbstractRouter*

@ -23,11 +23,11 @@ namespace llarp
User* user = nullptr; User* user = nullptr;
Handler result; Handler result;
size_t idx = 0; size_t idx = 0;
AbstractRouter* router = nullptr; AbstractRouter* router = nullptr;
llarp_threadpool* worker = nullptr; llarp_threadpool* worker = nullptr;
std::shared_ptr<Logic> logic = nullptr; std::shared_ptr< Logic > logic = nullptr;
Crypto* crypto = nullptr; Crypto* crypto = nullptr;
LR_CommitMessage LRCM; LR_CommitMessage LRCM;
~AsyncPathKeyExchangeContext() ~AsyncPathKeyExchangeContext()
@ -131,8 +131,8 @@ namespace llarp
/// Generate all keys asynchronously and call handler when done /// Generate all keys asynchronously and call handler when done
void void
AsyncGenerateKeys(Path_t p, std::shared_ptr<Logic> l, llarp_threadpool* pool, User* u, AsyncGenerateKeys(Path_t p, std::shared_ptr< Logic > l,
Handler func) llarp_threadpool* pool, User* u, Handler func)
{ {
path = p; path = p;
logic = l; logic = l;

@ -62,7 +62,7 @@ namespace llarp
HandleRecvLinkMessageBuffer(ILinkSession *from, HandleRecvLinkMessageBuffer(ILinkSession *from,
const llarp_buffer_t &msg) = 0; const llarp_buffer_t &msg) = 0;
virtual std::shared_ptr<Logic> virtual std::shared_ptr< Logic >
logic() const = 0; logic() const = 0;
virtual llarp_dht_context * virtual llarp_dht_context *

@ -215,7 +215,7 @@ namespace llarp
} }
Router::Router(struct llarp_threadpool *_tp, llarp_ev_loop_ptr __netloop, Router::Router(struct llarp_threadpool *_tp, llarp_ev_loop_ptr __netloop,
std::shared_ptr<Logic> l) std::shared_ptr< Logic > l)
: ready(false) : ready(false)
, _netloop(__netloop) , _netloop(__netloop)
, tp(_tp) , tp(_tp)

@ -86,7 +86,7 @@ namespace llarp
/// should we obey the service node whitelist? /// should we obey the service node whitelist?
bool whitelistRouters = false; bool whitelistRouters = false;
std::shared_ptr<Logic> std::shared_ptr< Logic >
logic() const override logic() const override
{ {
return _logic; return _logic;
@ -183,7 +183,7 @@ namespace llarp
llarp_ev_loop_ptr _netloop; llarp_ev_loop_ptr _netloop;
llarp_threadpool *tp; llarp_threadpool *tp;
std::shared_ptr<Logic> _logic; std::shared_ptr< Logic > _logic;
std::unique_ptr< Crypto > _crypto; std::unique_ptr< Crypto > _crypto;
path::PathContext paths; path::PathContext paths;
exit::Context _exitContext; exit::Context _exitContext;
@ -318,7 +318,7 @@ namespace llarp
std::unordered_map< RouterID, llarp_time_t, PubKey::Hash > lokinetRouters; std::unordered_map< RouterID, llarp_time_t, PubKey::Hash > lokinetRouters;
Router(struct llarp_threadpool *tp, llarp_ev_loop_ptr __netloop, Router(struct llarp_threadpool *tp, llarp_ev_loop_ptr __netloop,
std::shared_ptr<Logic> logic); std::shared_ptr< Logic > logic);
~Router(); ~Router();

@ -8,7 +8,7 @@ namespace llarp
{ {
namespace service namespace service
{ {
AsyncKeyExchange::AsyncKeyExchange(std::shared_ptr<Logic> l, Crypto* c, AsyncKeyExchange::AsyncKeyExchange(std::shared_ptr< Logic > l, Crypto* c,
const ServiceInfo& r, const ServiceInfo& r,
const Identity& localident, const Identity& localident,
const PQPubKey& introsetPubKey, const PQPubKey& introsetPubKey,

@ -14,7 +14,7 @@ namespace llarp
{ {
struct AsyncKeyExchange struct AsyncKeyExchange
{ {
std::shared_ptr<Logic> logic; std::shared_ptr< Logic > logic;
Crypto* crypto; Crypto* crypto;
SharedSecret sharedKey; SharedSecret sharedKey;
ServiceInfo remote; ServiceInfo remote;
@ -28,8 +28,8 @@ namespace llarp
IDataHandler* handler; IDataHandler* handler;
ConvoTag tag; ConvoTag tag;
AsyncKeyExchange(std::shared_ptr<Logic> l, Crypto* c, const ServiceInfo& r, AsyncKeyExchange(std::shared_ptr< Logic > l, Crypto* c,
const Identity& localident, const ServiceInfo& r, const Identity& localident,
const PQPubKey& introsetPubKey, const PQPubKey& introsetPubKey,
const Introduction& remote, IDataHandler* h, const Introduction& remote, IDataHandler* h,
const ConvoTag& t); const ConvoTag& t);

@ -648,11 +648,10 @@ namespace llarp
Endpoint::IsolatedNetworkMainLoop() Endpoint::IsolatedNetworkMainLoop()
{ {
m_IsolatedNetLoop = llarp_make_ev_loop(); m_IsolatedNetLoop = llarp_make_ev_loop();
m_IsolatedLogic = std::make_shared<llarp::Logic>(); m_IsolatedLogic = std::make_shared< llarp::Logic >();
if(SetupNetworking()) if(SetupNetworking())
llarp_ev_loop_run_single_process(m_IsolatedNetLoop, llarp_ev_loop_run_single_process(
m_IsolatedLogic->thread, m_IsolatedNetLoop, m_IsolatedLogic->thread, m_IsolatedLogic);
m_IsolatedLogic);
else else
{ {
m_IsolatedNetLoop.reset(); m_IsolatedNetLoop.reset();
@ -1043,14 +1042,14 @@ namespace llarp
void Endpoint::Pump(llarp_time_t) void Endpoint::Pump(llarp_time_t)
{ {
EndpointLogic()->queue_func([&]() { EndpointLogic()->queue_func([&]() {
// send downstream packets to user for snode // send downstream packets to user for snode
for(const auto& item : m_SNodeSessions) for(const auto& item : m_SNodeSessions)
item.second->FlushDownstream(); item.second->FlushDownstream();
// send downstrream traffic to user for hidden service // send downstrream traffic to user for hidden service
util::Lock lock(&m_InboundTrafficQueueMutex); util::Lock lock(&m_InboundTrafficQueueMutex);
while(m_InboundTrafficQueue.size()) while(m_InboundTrafficQueue.size())
{ {
const auto & msg = m_InboundTrafficQueue.top(); const auto& msg = m_InboundTrafficQueue.top();
llarp_buffer_t buf(msg->payload); llarp_buffer_t buf(msg->payload);
HandleWriteIPPacket(buf, [&]() -> huint32_t { HandleWriteIPPacket(buf, [&]() -> huint32_t {
return ObtainIPForAddr(msg->sender.Addr(), false); return ObtainIPForAddr(msg->sender.Addr(), false);
@ -1212,13 +1211,13 @@ namespace llarp
&& (NumInStatus(path::ePathBuilding) < m_NumPaths)); && (NumInStatus(path::ePathBuilding) < m_NumPaths));
} }
std::shared_ptr<Logic> std::shared_ptr< Logic >
Endpoint::RouterLogic() Endpoint::RouterLogic()
{ {
return m_Router->logic(); return m_Router->logic();
} }
std::shared_ptr<Logic> std::shared_ptr< Logic >
Endpoint::EndpointLogic() Endpoint::EndpointLogic()
{ {
return m_IsolatedLogic ? m_IsolatedLogic : m_Router->logic(); return m_IsolatedLogic ? m_IsolatedLogic : m_Router->logic();

@ -92,12 +92,12 @@ namespace llarp
/// router's logic /// router's logic
/// use when sending any data on a path /// use when sending any data on a path
std::shared_ptr<Logic> std::shared_ptr< Logic >
RouterLogic(); RouterLogic();
/// endpoint's logic /// endpoint's logic
/// use when writing any data to local network interfaces /// use when writing any data to local network interfaces
std::shared_ptr<Logic> std::shared_ptr< Logic >
EndpointLogic(); EndpointLogic();
/// borrow endpoint's net loop for sending data to user on local network /// 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 /// spawn a new process that contains a network isolated process
/// return true if we set up isolation and the event loop is up /// return true if we set up isolation and the event loop is up
/// otherwise return false /// otherwise return false
virtual bool virtual bool
SpawnIsolatedNetwork() SpawnIsolatedNetwork()
{ {
@ -410,12 +410,16 @@ namespace llarp
using PendingTraffic = using PendingTraffic =
std::unordered_map< Address, PendingBufferQueue, Address::Hash >; std::unordered_map< Address, PendingBufferQueue, Address::Hash >;
using ProtocolMessagePtr = std::shared_ptr<ProtocolMessage>; using ProtocolMessagePtr = std::shared_ptr< ProtocolMessage >;
using RecvPacketQueue_t = std::priority_queue<ProtocolMessagePtr, std::vector<ProtocolMessagePtr>, ComparePtr<ProtocolMessagePtr> >; using RecvPacketQueue_t =
std::priority_queue< ProtocolMessagePtr,
std::vector< ProtocolMessagePtr >,
ComparePtr< ProtocolMessagePtr > >;
util::Mutex m_InboundTrafficQueueMutex; util::Mutex m_InboundTrafficQueueMutex;
/// ordered queue for inbound hidden service traffic /// 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 = using PendingRouters =
std::unordered_map< RouterID, RouterLookupJob, RouterID::Hash >; std::unordered_map< RouterID, RouterLookupJob, RouterID::Hash >;
@ -434,8 +438,8 @@ namespace llarp
using ConvoMap = std::unordered_map< ConvoTag, Session, ConvoTag::Hash >; using ConvoMap = std::unordered_map< ConvoTag, Session, ConvoTag::Hash >;
AbstractRouter* m_Router; AbstractRouter* m_Router;
std::shared_ptr<Logic> m_IsolatedLogic = nullptr; std::shared_ptr< Logic > m_IsolatedLogic = nullptr;
llarp_ev_loop_ptr m_IsolatedNetLoop = nullptr; llarp_ev_loop_ptr m_IsolatedNetLoop = nullptr;
std::string m_Keyfile; std::string m_Keyfile;
std::string m_Name; std::string m_Name;
std::string m_NetNS; std::string m_NetNS;

@ -246,15 +246,15 @@ namespace llarp
struct AsyncFrameDecrypt struct AsyncFrameDecrypt
{ {
Crypto* crypto; Crypto* crypto;
std::shared_ptr<Logic> logic; std::shared_ptr< Logic > logic;
std::shared_ptr< ProtocolMessage > msg; std::shared_ptr< ProtocolMessage > msg;
const Identity& m_LocalIdentity; const Identity& m_LocalIdentity;
IDataHandler* handler; IDataHandler* handler;
const ProtocolFrame frame; const ProtocolFrame frame;
const Introduction fromIntro; const Introduction fromIntro;
AsyncFrameDecrypt(std::shared_ptr<Logic> l, Crypto* c, const Identity& localIdent, AsyncFrameDecrypt(std::shared_ptr< Logic > l, Crypto* c,
IDataHandler* h, const Identity& localIdent, IDataHandler* h,
const std::shared_ptr< ProtocolMessage >& m, const std::shared_ptr< ProtocolMessage >& m,
const ProtocolFrame& f, const Introduction& recvIntro) const ProtocolFrame& f, const Introduction& recvIntro)
: crypto(c) : crypto(c)
@ -366,8 +366,8 @@ namespace llarp
} }
bool bool
ProtocolFrame::AsyncDecryptAndVerify(std::shared_ptr<Logic> logic, Crypto* c, ProtocolFrame::AsyncDecryptAndVerify(std::shared_ptr< Logic > logic,
path::Path_ptr recvPath, Crypto* c, path::Path_ptr recvPath,
llarp_threadpool* worker, llarp_threadpool* worker,
const Identity& localIdent, const Identity& localIdent,
IDataHandler* handler) const IDataHandler* handler) const

@ -66,12 +66,11 @@ namespace llarp
static void static void
ProcessAsync(std::shared_ptr< ProtocolMessage > self); ProcessAsync(std::shared_ptr< ProtocolMessage > self);
bool bool
operator<(const ProtocolMessage & other) const operator<(const ProtocolMessage& other) const
{ {
return seqno < other.seqno; return seqno < other.seqno;
} }
}; };
/// outer message /// outer message
@ -127,8 +126,8 @@ namespace llarp
Sign(Crypto* c, const Identity& localIdent); Sign(Crypto* c, const Identity& localIdent);
bool bool
AsyncDecryptAndVerify(std::shared_ptr<Logic> logic, Crypto* c, path::Path_ptr fromPath, AsyncDecryptAndVerify(std::shared_ptr< Logic > logic, Crypto* c,
llarp_threadpool* worker, path::Path_ptr fromPath, llarp_threadpool* worker,
const Identity& localIdent, const Identity& localIdent,
IDataHandler* handler) const; IDataHandler* handler) const;

@ -83,7 +83,7 @@ namespace llarp
LogError("No cached session key"); LogError("No cached session key");
return; return;
} }
ProtocolMessage m; ProtocolMessage m;
m_DataHandler->PutIntroFor(f.T, remoteIntro); m_DataHandler->PutIntroFor(f.T, remoteIntro);
m_DataHandler->PutReplyIntroFor(f.T, path->intro); m_DataHandler->PutReplyIntroFor(f.T, path->intro);
@ -98,7 +98,7 @@ namespace llarp
{ {
LogError("failed to sign"); LogError("failed to sign");
return; return;
} }
Send(f, path); Send(f, path);
} }

Loading…
Cancel
Save