fix route poking via rpc:

* immediately poke routes when we are told to use an exit so that packets get pushed which makes an exit path happen
* fix up cmake oddity in nsis section
pull/1643/head
Jeff Becker 3 years ago
parent 209bcc39dd
commit 499bb38e6f
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -43,4 +43,3 @@ set(CPACK_NSIS_DELETE_ICONS_EXTRA
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS) get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Unspecified") list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Unspecified")
list(APPEND CPACK_COMPONENTS_ALL liblokinet)

@ -292,6 +292,13 @@ namespace llarp
virtual bool virtual bool
ConnectionToRouterAllowed(const RouterID& router) const = 0; ConnectionToRouterAllowed(const RouterID& router) const = 0;
/// return true if we have an exit as a client
virtual bool
HasClientExit() const
{
return false;
};
virtual path::BuildLimiter& virtual path::BuildLimiter&
pathBuildLimiter() = 0; pathBuildLimiter() = 0;

@ -402,7 +402,7 @@ namespace llarp
/// return true if we are a client with an exit configured /// return true if we are a client with an exit configured
bool bool
HasClientExit() const; HasClientExit() const override;
const byte_t* const byte_t*
pubkey() const override pubkey() const override

@ -456,38 +456,54 @@ namespace llarp::rpc
{ {
auto mapExit = [=](service::Address addr) mutable { auto mapExit = [=](service::Address addr) mutable {
ep->MapExitRange(range, addr); ep->MapExitRange(range, addr);
r->routePoker().Enable();
r->routePoker().Up();
bool shouldSendAuth = false; bool shouldSendAuth = false;
if (token.has_value()) if (token.has_value())
{ {
shouldSendAuth = true; shouldSendAuth = true;
ep->SetAuthInfoForEndpoint(*exit, service::AuthInfo{*token}); ep->SetAuthInfoForEndpoint(*exit, service::AuthInfo{*token});
} }
auto onGoodResult = [r, reply](std::string reason) {
if (r->HasClientExit())
reply(CreateJSONResponse(reason));
else
reply(CreateJSONError("we dont have an exit?"));
};
auto onBadResult = [r, reply, ep, range](std::string reason) {
r->routePoker().Down();
ep->UnmapExitRange(range);
reply(CreateJSONError(reason));
};
if (addr.IsZero())
{
onGoodResult("added null exit");
return;
}
ep->EnsurePathToService( ep->EnsurePathToService(
addr, addr,
[reply, r, shouldSendAuth](auto, service::OutboundContext* ctx) { [onBadResult, onGoodResult, shouldSendAuth, addrStr = addr.ToString()](
auto, service::OutboundContext* ctx) {
if (ctx == nullptr) if (ctx == nullptr)
{ {
reply(CreateJSONError("could not find exit")); onBadResult("could not find exit");
return; return;
} }
auto onGoodResult = [r, reply](std::string reason) {
r->routePoker().Enable();
reply(CreateJSONResponse(reason));
};
if (not shouldSendAuth) if (not shouldSendAuth)
{ {
onGoodResult("OK"); onGoodResult("OK: connected to " + addrStr);
return; return;
} }
ctx->AsyncSendAuth([onGoodResult, reply](service::AuthResult result) { ctx->AsyncSendAuth(
// TODO: refactor this code. We are 5 lambdas deep here! [onGoodResult, onBadResult](service::AuthResult result) {
if (result.code != service::AuthResultCode::eAuthAccepted) // TODO: refactor this code. We are 5 lambdas deep here!
{ if (result.code != service::AuthResultCode::eAuthAccepted)
reply(CreateJSONError(result.reason)); {
return; onBadResult(result.reason);
} return;
onGoodResult(result.reason); }
}); onGoodResult(result.reason);
});
}, },
5s); 5s);
}; };
@ -520,7 +536,6 @@ namespace llarp::rpc
else else
{ {
reply(CreateJSONError("lns name resolved to a snode")); reply(CreateJSONError("lns name resolved to a snode"));
return;
} }
}); });
} }

Loading…
Cancel
Save