Convert to use memFn

pull/638/head
Michael 5 years ago
parent 3822fe2341
commit 75430a234c
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C

@ -12,6 +12,7 @@
#include <nodedb.hpp> #include <nodedb.hpp>
#include <router/router.hpp> #include <router/router.hpp>
#include <util/logger.h> #include <util/logger.h>
#include <util/memfn.hpp>
#include <util/metrics.hpp> #include <util/metrics.hpp>
#include <util/scheduler.hpp> #include <util/scheduler.hpp>
@ -50,8 +51,7 @@ namespace llarp
llarp::LogError("failed to load config file ", configfile); llarp::LogError("failed to load config file ", configfile);
return false; return false;
} }
using namespace std::placeholders; config->visit(util::memFn(&Context::iter_config, this));
config->visit(std::bind(&Context::iter_config, this, _1, _2, _3));
if(!disableMetrics) if(!disableMetrics)
{ {

@ -4,6 +4,7 @@
#include <nodedb.hpp> #include <nodedb.hpp>
#include <path/path.hpp> #include <path/path.hpp>
#include <router/abstractrouter.hpp> #include <router/abstractrouter.hpp>
#include <util/memfn.hpp>
namespace llarp namespace llarp
{ {
@ -97,19 +98,11 @@ namespace llarp
BaseSession::HandlePathBuilt(llarp::path::Path_ptr p) BaseSession::HandlePathBuilt(llarp::path::Path_ptr p)
{ {
path::Builder::HandlePathBuilt(p); path::Builder::HandlePathBuilt(p);
p->SetDropHandler(std::bind(&BaseSession::HandleTrafficDrop, this, p->SetDropHandler(util::memFn(&BaseSession::HandleTrafficDrop, this));
std::placeholders::_1, std::placeholders::_2, p->SetDeadChecker(util::memFn(&BaseSession::CheckPathDead, this));
std::placeholders::_3)); p->SetExitTrafficHandler(util::memFn(&BaseSession::HandleTraffic, this));
p->SetDeadChecker(std::bind(&BaseSession::CheckPathDead, this, p->AddObtainExitHandler(util::memFn(&BaseSession::HandleGotExit, this));
std::placeholders::_1,
std::placeholders::_2));
p->SetExitTrafficHandler(
std::bind(&BaseSession::HandleTraffic, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3));
p->AddObtainExitHandler(std::bind(&BaseSession::HandleGotExit, this,
std::placeholders::_1,
std::placeholders::_2));
routing::ObtainExitMessage obtain; routing::ObtainExitMessage obtain;
obtain.S = p->NextSeqNo(); obtain.S = p->NextSeqNo();
obtain.T = llarp::randint(); obtain.T = llarp::randint();

@ -13,6 +13,7 @@
#include <router/abstractrouter.hpp> #include <router/abstractrouter.hpp>
#include <service/context.hpp> #include <service/context.hpp>
#include <util/logic.hpp> #include <util/logic.hpp>
#include <util/memfn.hpp>
#include <nodedb.hpp> #include <nodedb.hpp>
#include <util/str.hpp> #include <util/str.hpp>
@ -150,9 +151,8 @@ namespace llarp
} }
m_Exit = std::make_shared< llarp::exit::ExitSession >( m_Exit = std::make_shared< llarp::exit::ExitSession >(
exitRouter, exitRouter,
std::bind(&TunEndpoint::QueueInboundPacketForExit, this, util::memFn(&TunEndpoint::QueueInboundPacketForExit, this), router,
std::placeholders::_1), m_NumPaths, numHops, ShouldBundleRC());
router, m_NumPaths, numHops, ShouldBundleRC());
llarp::LogInfo(Name(), " using exit at ", exitRouter); llarp::LogInfo(Name(), " using exit at ", exitRouter);
} }
if(k == "local-dns") if(k == "local-dns")

@ -1,6 +1,7 @@
#include <iwp/iwp.hpp> #include <iwp/iwp.hpp>
#include <iwp/linklayer.hpp> #include <iwp/linklayer.hpp>
#include <router/abstractrouter.hpp> #include <router/abstractrouter.hpp>
#include <util/memfn.hpp>
namespace llarp namespace llarp
{ {
@ -9,15 +10,14 @@ namespace llarp
std::unique_ptr< ILinkLayer > std::unique_ptr< ILinkLayer >
NewServerFromRouter(AbstractRouter* r) NewServerFromRouter(AbstractRouter* r)
{ {
using namespace std::placeholders;
return NewServer( return NewServer(
r->encryption(), std::bind(&AbstractRouter::rc, r), r->encryption(), std::bind(&AbstractRouter::rc, r),
std::bind(&AbstractRouter::HandleRecvLinkMessageBuffer, r, _1, _2), util::memFn(&AbstractRouter::HandleRecvLinkMessageBuffer, r),
std::bind(&AbstractRouter::OnSessionEstablished, r, _1), util::memFn(&AbstractRouter::OnSessionEstablished, r),
std::bind(&AbstractRouter::CheckRenegotiateValid, r, _1, _2), util::memFn(&AbstractRouter::CheckRenegotiateValid, r),
std::bind(&AbstractRouter::Sign, r, _1, _2), util::memFn(&AbstractRouter::Sign, r),
std::bind(&AbstractRouter::OnConnectTimeout, r, _1), util::memFn(&AbstractRouter::OnConnectTimeout, r),
std::bind(&AbstractRouter::SessionClosed, r, _1)); util::memFn(&AbstractRouter::SessionClosed, r));
} }
std::unique_ptr< ILinkLayer > std::unique_ptr< ILinkLayer >

@ -8,6 +8,7 @@
#include <util/buffer.hpp> #include <util/buffer.hpp>
#include <util/logger.hpp> #include <util/logger.hpp>
#include <util/logic.hpp> #include <util/logic.hpp>
#include <util/memfn.hpp>
#include <nodedb.hpp> #include <nodedb.hpp>
#include <functional> #include <functional>
@ -161,9 +162,7 @@ namespace llarp
bool bool
LR_CommitRecord::BDecode(llarp_buffer_t* buf) LR_CommitRecord::BDecode(llarp_buffer_t* buf)
{ {
using namespace std::placeholders; return bencode_read_dict(util::memFn(&LR_CommitRecord::OnKey, this), buf);
return bencode_read_dict(std::bind(&LR_CommitRecord::OnKey, this, _1, _2),
buf);
} }
bool bool

@ -14,6 +14,7 @@
#include <util/buffer.hpp> #include <util/buffer.hpp>
#include <util/encode.hpp> #include <util/encode.hpp>
#include <util/logger.hpp> #include <util/logger.hpp>
#include <util/memfn.hpp>
#include <util/file_logger.hpp> #include <util/file_logger.hpp>
#include <util/logger_syslog.hpp> #include <util/logger_syslog.hpp>
#include <util/metrics.hpp> #include <util/metrics.hpp>
@ -462,8 +463,7 @@ namespace llarp
bool bool
Router::Configure(Config *conf) Router::Configure(Config *conf)
{ {
using namespace std::placeholders; conf->visit(util::memFn(&Router::router_iter_config, this));
conf->visit(std::bind(&Router::router_iter_config, this, _1, _2, _3));
if(!InitOutboundLinks()) if(!InitOutboundLinks())
return false; return false;
if(!Ready()) if(!Ready())
@ -1147,9 +1147,10 @@ namespace llarp
void void
Router::ServiceNodeLookupRouterWhenExpired(RouterID router) Router::ServiceNodeLookupRouterWhenExpired(RouterID router)
{ {
dht()->impl->LookupRouter(router, using namespace std::placeholders;
std::bind(&Router::HandleDHTLookupForExplore, dht()->impl->LookupRouter(
this, router, std::placeholders::_1)); router,
std::bind(&Router::HandleDHTLookupForExplore, this, router, _1));
} }
void void
@ -1926,9 +1927,7 @@ namespace llarp
bool bool
Validate() Validate()
{ {
using namespace std::placeholders; config->visit(util::memFn(&RouterConfigValidator::ValidateEntry, this));
config->visit(
std::bind(&RouterConfigValidator::ValidateEntry, this, _1, _2, _3));
return valid; return valid;
} }
}; };

@ -7,6 +7,7 @@
#include <exit/context.hpp> #include <exit/context.hpp>
#include <util/encode.hpp> #include <util/encode.hpp>
#include <util/memfn.hpp>
#include <libabyss.hpp> #include <libabyss.hpp>
namespace llarp namespace llarp
@ -151,8 +152,7 @@ namespace llarp
{ {
LogInfo("Updating service node list"); LogInfo("Updating service node list");
QueueRPC("get_all_service_nodes_keys", nlohmann::json::object(), QueueRPC("get_all_service_nodes_keys", nlohmann::json::object(),
std::bind(&CallerImpl::NewAsyncUpdatePubkeyListConn, this, util::memFn(&CallerImpl::NewAsyncUpdatePubkeyListConn, this));
std::placeholders::_1));
} }
bool bool
@ -166,8 +166,7 @@ namespace llarp
{ {
return new GetServiceNodeListHandler( return new GetServiceNodeListHandler(
impl, this, impl, this,
std::bind(&CallerImpl::HandleServiceNodeListUpdated, this, util::memFn(&CallerImpl::HandleServiceNodeListUpdated, this));
std::placeholders::_1, std::placeholders::_2));
} }
void void

@ -3,6 +3,7 @@
#include <crypto/crypto.hpp> #include <crypto/crypto.hpp>
#include <crypto/types.hpp> #include <crypto/types.hpp>
#include <util/logic.hpp> #include <util/logic.hpp>
#include <util/memfn.hpp>
namespace llarp namespace llarp
{ {
@ -50,9 +51,7 @@ namespace llarp
// compure post handshake session key // compure post handshake session key
// PKE (A, B, N) // PKE (A, B, N)
SharedSecret sharedSecret; SharedSecret sharedSecret;
using namespace std::placeholders; path_dh_func dh_client = util::memFn(&Crypto::dh_client, crypto);
path_dh_func dh_client =
std::bind(&Crypto::dh_client, crypto, _1, _2, _3, _4);
if(!self->m_LocalIdentity.KeyExchange(dh_client, sharedSecret, if(!self->m_LocalIdentity.KeyExchange(dh_client, sharedSecret,
self->remote, self->frame.N)) self->remote, self->frame.N))
{ {

@ -17,6 +17,7 @@
#include <util/logic.hpp> #include <util/logic.hpp>
#include <util/str.hpp> #include <util/str.hpp>
#include <util/buffer.hpp> #include <util/buffer.hpp>
#include <util/memfn.hpp>
#include <hook/shell.hpp> #include <hook/shell.hpp>
namespace llarp namespace llarp
@ -795,11 +796,9 @@ namespace llarp
void void
Endpoint::HandlePathBuilt(path::Path_ptr p) Endpoint::HandlePathBuilt(path::Path_ptr p)
{ {
using namespace std::placeholders; p->SetDataHandler(util::memFn(&Endpoint::HandleHiddenServiceFrame, this));
p->SetDataHandler( p->SetDropHandler(util::memFn(&Endpoint::HandleDataDrop, this));
std::bind(&Endpoint::HandleHiddenServiceFrame, this, _1, _2)); p->SetDeadChecker(util::memFn(&Endpoint::CheckPathIsDead, this));
p->SetDropHandler(std::bind(&Endpoint::HandleDataDrop, this, _1, _2, _3));
p->SetDeadChecker(std::bind(&Endpoint::CheckPathIsDead, this, _1, _2));
path::Builder::HandlePathBuilt(p); path::Builder::HandlePathBuilt(p);
} }
@ -982,8 +981,7 @@ namespace llarp
using namespace std::placeholders; using namespace std::placeholders;
HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup( HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup(
this, std::bind(&Endpoint::OnLookup, this, _1, _2, _3), remote, this, util::memFn(&Endpoint::OnLookup, this), remote, GenTXID());
GenTXID());
LogInfo("doing lookup for ", remote, " via ", path->Endpoint()); LogInfo("doing lookup for ", remote, " via ", path->Endpoint());
if(job->SendRequestViaPath(path, Router())) if(job->SendRequestViaPath(path, Router()))
{ {

@ -6,6 +6,7 @@
#include <service/endpoint.hpp> #include <service/endpoint.hpp>
#include <nodedb.hpp> #include <nodedb.hpp>
#include <profiling.hpp> #include <profiling.hpp>
#include <util/memfn.hpp>
namespace llarp namespace llarp
{ {
@ -127,12 +128,9 @@ namespace llarp
/// don't use it if we are marked bad /// don't use it if we are marked bad
if(markedBad) if(markedBad)
return; return;
p->SetDataHandler(std::bind(&OutboundContext::HandleHiddenServiceFrame, p->SetDataHandler(
this, std::placeholders::_1, util::memFn(&OutboundContext::HandleHiddenServiceFrame, this));
std::placeholders::_2)); p->SetDropHandler(util::memFn(&OutboundContext::HandleDataDrop, this));
p->SetDropHandler(std::bind(&OutboundContext::HandleDataDrop, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3));
// we now have a path to the next intro, swap intros // we now have a path to the next intro, swap intros
if(p->Endpoint() == m_NextIntro.router && remoteIntro != m_NextIntro) if(p->Endpoint() == m_NextIntro.router && remoteIntro != m_NextIntro)
SwapIntros(); SwapIntros();
@ -198,10 +196,7 @@ namespace llarp
if(path) if(path)
{ {
HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup( HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup(
m_Endpoint, m_Endpoint, util::memFn(&OutboundContext::OnIntroSetUpdate, this),
std::bind(&OutboundContext::OnIntroSetUpdate, this,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3),
addr, m_Endpoint->GenTXID()); addr, m_Endpoint->GenTXID());
updatingIntroSet = job->SendRequestViaPath(path, m_Endpoint->Router()); updatingIntroSet = job->SendRequestViaPath(path, m_Endpoint->Router());

@ -4,6 +4,7 @@
#include <util/buffer.hpp> #include <util/buffer.hpp>
#include <util/logic.hpp> #include <util/logic.hpp>
#include <util/mem.hpp> #include <util/mem.hpp>
#include <util/memfn.hpp>
namespace llarp namespace llarp
{ {
@ -315,9 +316,8 @@ namespace llarp
// PKE (A, B, N) // PKE (A, B, N)
SharedSecret sharedSecret; SharedSecret sharedSecret;
using namespace std::placeholders; path_dh_func dh_server =
path_dh_func dh_server = std::bind( util::memFn(&Crypto::dh_server, CryptoManager::instance());
&Crypto::dh_server, CryptoManager::instance(), _1, _2, _3, _4);
if(!self->m_LocalIdentity.KeyExchange(dh_server, sharedSecret, if(!self->m_LocalIdentity.KeyExchange(dh_server, sharedSecret,
self->msg->sender, self->frame.N)) self->msg->sender, self->frame.N))

@ -4,13 +4,12 @@
#include <messages/discard.hpp> #include <messages/discard.hpp>
#include <messages/link_intro.hpp> #include <messages/link_intro.hpp>
#include <util/metrics.hpp> #include <util/metrics.hpp>
#include <util/memfn.hpp>
namespace llarp namespace llarp
{ {
namespace utp namespace utp
{ {
using namespace std::placeholders;
void void
Session::OnLinkEstablished(ILinkLayer* p) Session::OnLinkEstablished(ILinkLayer* p)
{ {
@ -613,7 +612,7 @@ namespace llarp
ABSL_ATTRIBUTE_UNUSED void* res = utp_set_userdata(sock, this); ABSL_ATTRIBUTE_UNUSED void* res = utp_set_userdata(sock, this);
assert(res == this); assert(res == this);
assert(s == sock); assert(s == sock);
GotLIM = std::bind(&InboundSession::InboundLIM, this, _1); GotLIM = util::memFn(&InboundSession::InboundLIM, this);
} }
bool bool
@ -678,7 +677,7 @@ namespace llarp
gotLIM = true; gotLIM = true;
EnterState(eSessionReady); EnterState(eSessionReady);
/// future LIM are used for session renegotiation /// future LIM are used for session renegotiation
GotLIM = std::bind(&Session::GotSessionRenegotiate, this, _1); GotLIM = util::memFn(&Session::GotSessionRenegotiate, this);
} }
return true; return true;
} }
@ -702,7 +701,7 @@ namespace llarp
assert(res == this); assert(res == this);
assert(s == sock); assert(s == sock);
GotLIM = std::bind(&OutboundSession::OutboundLIM, this, _1); GotLIM = util::memFn(&OutboundSession::OutboundLIM, this);
} }
void void
@ -729,7 +728,7 @@ namespace llarp
return false; return false;
} }
/// future LIM are used for session renegotiation /// future LIM are used for session renegotiation
GotLIM = std::bind(&Session::GotSessionRenegotiate, this, _1); GotLIM = util::memFn(&Session::GotSessionRenegotiate, this);
EnterState(eSessionReady); EnterState(eSessionReady);
return true; return true;
} }

@ -1,14 +1,13 @@
#include <utp/utp.hpp> #include <utp/utp.hpp>
#include <utp/linklayer.hpp>
#include <router/abstractrouter.hpp> #include <router/abstractrouter.hpp>
#include <util/memfn.hpp>
#include <utp/linklayer.hpp>
namespace llarp namespace llarp
{ {
namespace utp namespace utp
{ {
using namespace std::placeholders;
LinkLayer_ptr LinkLayer_ptr
NewServer(const SecretKey& routerEncSecret, GetRCFunc getrc, NewServer(const SecretKey& routerEncSecret, GetRCFunc getrc,
LinkMessageHandler h, SessionEstablishedHandler est, LinkMessageHandler h, SessionEstablishedHandler est,
@ -22,15 +21,14 @@ namespace llarp
LinkLayer_ptr LinkLayer_ptr
NewServerFromRouter(AbstractRouter* r) NewServerFromRouter(AbstractRouter* r)
{ {
using namespace std::placeholders;
return NewServer( return NewServer(
r->encryption(), std::bind(&AbstractRouter::rc, r), r->encryption(), util::memFn(&AbstractRouter::rc, r),
std::bind(&AbstractRouter::HandleRecvLinkMessageBuffer, r, _1, _2), util::memFn(&AbstractRouter::HandleRecvLinkMessageBuffer, r),
std::bind(&AbstractRouter::OnSessionEstablished, r, _1), util::memFn(&AbstractRouter::OnSessionEstablished, r),
std::bind(&AbstractRouter::CheckRenegotiateValid, r, _1, _2), util::memFn(&AbstractRouter::CheckRenegotiateValid, r),
std::bind(&AbstractRouter::Sign, r, _1, _2), util::memFn(&AbstractRouter::Sign, r),
std::bind(&AbstractRouter::OnConnectTimeout, r, _1), util::memFn(&AbstractRouter::OnConnectTimeout, r),
std::bind(&AbstractRouter::SessionClosed, r, _1)); util::memFn(&AbstractRouter::SessionClosed, r));
} }
} // namespace utp } // namespace utp

Loading…
Cancel
Save