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();
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);
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<llarp::Logic> 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;

@ -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<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)
: 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<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)
{
}
@ -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<llarp::Logic>(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);

@ -333,7 +333,8 @@ namespace abyss
}
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)
{
m_loop = loop;

@ -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<byte_t> 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<byte_t> 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

@ -30,11 +30,12 @@ namespace llarp
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>;
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,

@ -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<llarp::Logic> logic)
std::shared_ptr< llarp::Logic > logic)
{
while(ev->running())
{

@ -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<llarp::Logic> logic);
std::shared_ptr< llarp::Logic > logic);
/// get the current time on the event loop
llarp_time_t

@ -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;
}

@ -25,7 +25,8 @@ namespace llarp
ExitEndpoint::ExitEndpoint(const std::string &name, AbstractRouter *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_Tun{{0}, 0, {0}, 0, 0, 0, 0, 0, 0, 0}
, m_LocalResolverAddr("127.0.0.1", 53)

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

@ -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")
{

@ -230,7 +230,7 @@ namespace llarp
#endif
/// our dns resolver
std::shared_ptr<dns::Proxy> 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 >

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

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

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

@ -126,7 +126,7 @@ namespace llarp
TryEstablishTo(RouterContact rc);
virtual bool
Start(std::shared_ptr<llarp::Logic> 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<llarp::Logic> 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;

@ -242,7 +242,7 @@ namespace llarp
// store it into netdb if we don't have it
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, [=]() {
self->context->ForwardLRCM(self->hop->info.upstream,
self->frames);

@ -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<llarp::Logic> 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<llarp::Logic> logic,
llarp_nodedb::InsertAsync(llarp::RouterContact rc,
std::shared_ptr< llarp::Logic > logic,
std::function< void(void) > completionHandler)
{
disk->addJob(

@ -89,7 +89,8 @@ struct llarp_nodedb
/// insert and write to disk in background
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);
ssize_t
@ -153,7 +154,7 @@ struct llarp_async_verify_rc
/// nodedb storage
llarp_nodedb *nodedb;
// 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::thread::ThreadPool *diskworker;

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

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

@ -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> 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<Logic> 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;

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

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

@ -86,7 +86,7 @@ namespace llarp
/// should we obey the service node whitelist?
bool whitelistRouters = false;
std::shared_ptr<Logic>
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> _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> logic);
std::shared_ptr< Logic > logic);
~Router();

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

@ -14,7 +14,7 @@ namespace llarp
{
struct AsyncKeyExchange
{
std::shared_ptr<Logic> 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<Logic> 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);

@ -648,11 +648,10 @@ namespace llarp
Endpoint::IsolatedNetworkMainLoop()
{
m_IsolatedNetLoop = llarp_make_ev_loop();
m_IsolatedLogic = std::make_shared<llarp::Logic>();
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<Logic>
std::shared_ptr< Logic >
Endpoint::RouterLogic()
{
return m_Router->logic();
}
std::shared_ptr<Logic>
std::shared_ptr< Logic >
Endpoint::EndpointLogic()
{
return m_IsolatedLogic ? m_IsolatedLogic : m_Router->logic();

@ -92,12 +92,12 @@ namespace llarp
/// router's logic
/// use when sending any data on a path
std::shared_ptr<Logic>
std::shared_ptr< Logic >
RouterLogic();
/// endpoint's logic
/// use when writing any data to local network interfaces
std::shared_ptr<Logic>
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<ProtocolMessage>;
using RecvPacketQueue_t = std::priority_queue<ProtocolMessagePtr, std::vector<ProtocolMessagePtr>, ComparePtr<ProtocolMessagePtr> >;
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<Logic> 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;

@ -246,15 +246,15 @@ namespace llarp
struct AsyncFrameDecrypt
{
Crypto* crypto;
std::shared_ptr<Logic> 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<Logic> 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> 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

@ -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> 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;

@ -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);
}

Loading…
Cancel
Save