mirror of https://github.com/oxen-io/lokinet
try not to crash
This commit is contained in:
parent
4ca34995bf
commit
ab509e0a13
|
@ -22,8 +22,8 @@ extern "C" {
|
|||
struct llarp_link;
|
||||
|
||||
/**
|
||||
* wire layer transport session for point to point communication between us and
|
||||
* another
|
||||
* wire layer transport session for point to point communication between us
|
||||
* and another
|
||||
*/
|
||||
struct llarp_link_session;
|
||||
|
||||
|
@ -75,8 +75,9 @@ struct llarp_link
|
|||
const char *(*name)(void);
|
||||
void (*get_our_address)(struct llarp_link *, struct llarp_ai *);
|
||||
/*
|
||||
int (*register_listener)(struct llarp_link *, struct llarp_link_ev_listener);
|
||||
void (*deregister_listener)(struct llarp_link *, int);
|
||||
int (*register_listener)(struct llarp_link *, struct
|
||||
llarp_link_ev_listener); void (*deregister_listener)(struct llarp_link *,
|
||||
int);
|
||||
*/
|
||||
bool (*configure)(struct llarp_link *, struct llarp_ev_loop *, const char *,
|
||||
int, uint16_t);
|
||||
|
@ -101,7 +102,8 @@ llarp_link_initialized(struct llarp_link *link);
|
|||
struct llarp_link_session
|
||||
{
|
||||
void *impl;
|
||||
/** send an entire message, splits up into smaller pieces and does encryption
|
||||
/** send an entire message, splits up into smaller pieces and does
|
||||
* encryption
|
||||
*/
|
||||
bool (*sendto)(struct llarp_link_session *, llarp_buffer_t);
|
||||
/** return true if this session is timed out */
|
||||
|
|
|
@ -348,13 +348,15 @@ llarp_router::on_verify_server_rc(llarp_async_verify_rc *job)
|
|||
llarp_dht_put_peer(router->dht, &router->validRouters[pk]);
|
||||
|
||||
// this was an outbound establish job
|
||||
if(ctx->establish_job->session)
|
||||
if(ctx->establish_job)
|
||||
{
|
||||
auto session = ctx->establish_job->session;
|
||||
router->FlushOutboundFor(pk, session->get_parent(session));
|
||||
// this frees the job
|
||||
router->pendingEstablishJobs.erase(pk);
|
||||
}
|
||||
else // this was an inbound session
|
||||
router->FlushOutboundFor(pk, GetLinkWithSessionByPubkey(pk));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -482,6 +484,19 @@ llarp_router::SessionClosed(const llarp::RouterID &remote)
|
|||
validRouters.erase(itr);
|
||||
}
|
||||
|
||||
llarp_link *
|
||||
llarp_router::GetLinkWithSessionByPubkey(const llarp::RouterID &pubkey)
|
||||
{
|
||||
for(auto &link : inboundLinks)
|
||||
{
|
||||
if(link->has_session_to(link, pubkey))
|
||||
return link;
|
||||
}
|
||||
if(outboundLink->has_session_to(outboundLink, pubkey))
|
||||
return outboundLink;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
llarp_router::FlushOutboundFor(const llarp::RouterID &remote,
|
||||
llarp_link *chosen)
|
||||
|
@ -492,6 +507,11 @@ llarp_router::FlushOutboundFor(const llarp::RouterID &remote,
|
|||
{
|
||||
return;
|
||||
}
|
||||
if(!chosen)
|
||||
{
|
||||
DiscardOutboundFor(remote);
|
||||
return;
|
||||
}
|
||||
while(itr->second.size())
|
||||
{
|
||||
auto buf = llarp::StackBuffer< decltype(linkmsg_buffer) >(linkmsg_buffer);
|
||||
|
|
|
@ -190,6 +190,9 @@ struct llarp_router
|
|||
void
|
||||
ScheduleTicker(uint64_t i = 1000);
|
||||
|
||||
llarp_link *
|
||||
GetLinkWithSessionByPubkey(const llarp::RouterID &remote);
|
||||
|
||||
void
|
||||
async_verify_RC(llarp_rc *rc, bool isExpectingClient,
|
||||
llarp_link_establish_job *job = nullptr);
|
||||
|
|
Loading…
Reference in New Issue