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)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "Unspecified")
list(APPEND CPACK_COMPONENTS_ALL liblokinet)

@ -292,6 +292,13 @@ namespace llarp
virtual bool
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&
pathBuildLimiter() = 0;

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

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

Loading…
Cancel
Save