mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
tweak parameters for path build and obtain path if we have none
This commit is contained in:
parent
8e4b0a7963
commit
f110f3f3ad
|
@ -24,7 +24,7 @@
|
|||
|
||||
#define MAXHOPS (8)
|
||||
#define DEFAULT_PATH_LIFETIME (10 * 60 * 1000)
|
||||
#define PATH_BUILD_TIMEOUT (30 * 1000)
|
||||
#define PATH_BUILD_TIMEOUT (15 * 1000)
|
||||
#define MESSAGE_PAD_SIZE (512)
|
||||
|
||||
namespace llarp
|
||||
|
|
|
@ -101,6 +101,9 @@ namespace llarp
|
|||
Path*
|
||||
GetPathByRouter(const RouterID& router) const;
|
||||
|
||||
Path*
|
||||
GetNewestPathByRouter(const RouterID& router) const;
|
||||
|
||||
Path*
|
||||
GetPathByID(const PathID_t& id) const;
|
||||
|
||||
|
|
|
@ -64,6 +64,28 @@ namespace llarp
|
|||
return path;
|
||||
}
|
||||
|
||||
Path*
|
||||
PathSet::GetNewestPathByRouter(const RouterID& id) const
|
||||
{
|
||||
Path* chosen = nullptr;
|
||||
auto itr = m_Paths.begin();
|
||||
while(itr != m_Paths.end())
|
||||
{
|
||||
if(itr->second->IsReady())
|
||||
{
|
||||
if(itr->second->Endpoint() == id)
|
||||
{
|
||||
if(chosen == nullptr)
|
||||
chosen = itr->second;
|
||||
else if(chosen->intro.expiresAt < itr->second->intro.expiresAt)
|
||||
chosen = itr->second;
|
||||
}
|
||||
}
|
||||
++itr;
|
||||
}
|
||||
return chosen;
|
||||
}
|
||||
|
||||
Path*
|
||||
PathSet::GetPathByRouter(const RouterID& id) const
|
||||
{
|
||||
|
|
|
@ -906,29 +906,27 @@ namespace llarp
|
|||
}
|
||||
}
|
||||
}
|
||||
if(p == nullptr)
|
||||
if(p)
|
||||
{
|
||||
llarp::LogError("no path found");
|
||||
return false;
|
||||
// TODO: check expiration of our end
|
||||
ProtocolMessage m(f.T);
|
||||
m.proto = t;
|
||||
m.introReply = p->intro;
|
||||
m.sender = m_Identity.pub;
|
||||
m.PutBuffer(data);
|
||||
f.N.Randomize();
|
||||
f.S = GetSeqNoForConvo(f.T);
|
||||
f.C.Zero();
|
||||
transfer.Y.Randomize();
|
||||
transfer.P = remoteIntro.pathID;
|
||||
if(!f.EncryptAndSign(&Router()->crypto, m, K, m_Identity))
|
||||
{
|
||||
llarp::LogError("failed to encrypt and sign");
|
||||
return false;
|
||||
}
|
||||
llarp::LogInfo(Name(), " send ", data.sz, " via ", remoteIntro);
|
||||
return p->SendRoutingMessage(&transfer, Router());
|
||||
}
|
||||
// TODO: check expiration of our end
|
||||
ProtocolMessage m(f.T);
|
||||
m.proto = t;
|
||||
m.introReply = p->intro;
|
||||
m.sender = m_Identity.pub;
|
||||
m.PutBuffer(data);
|
||||
f.N.Randomize();
|
||||
f.S = GetSeqNoForConvo(f.T);
|
||||
f.C.Zero();
|
||||
transfer.Y.Randomize();
|
||||
transfer.P = remoteIntro.pathID;
|
||||
if(!f.EncryptAndSign(&Router()->crypto, m, K, m_Identity))
|
||||
{
|
||||
llarp::LogError("failed to encrypt and sign");
|
||||
return false;
|
||||
}
|
||||
llarp::LogInfo(Name(), " send ", data.sz, " via ", remoteIntro);
|
||||
return p->SendRoutingMessage(&transfer, Router());
|
||||
}
|
||||
}
|
||||
if(HasPathToService(remote))
|
||||
|
@ -1242,7 +1240,7 @@ namespace llarp
|
|||
f.T = *tags.begin();
|
||||
f.S = m_Endpoint->GetSeqNoForConvo(f.T);
|
||||
|
||||
auto path = m_PathSet->GetPathByRouter(remoteIntro.router);
|
||||
auto path = m_PathSet->GetNewestPathByRouter(remoteIntro.router);
|
||||
if(!path)
|
||||
{
|
||||
llarp::LogError("cannot encrypt and send: no path for intro ",
|
||||
|
|
Loading…
Reference in a new issue