try switching logic

pull/1334/head
Jeff Becker 5 years ago
parent 92f8c059e9
commit a33dbce680
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -11,7 +11,7 @@ namespace llarp
struct NoOpCrypto final : public Crypto struct NoOpCrypto final : public Crypto
{ {
private: private:
std::atomic<uint64_t> m_value; std::atomic< uint64_t > m_value;
static constexpr byte_t MAX_BYTE = std::numeric_limits< byte_t >::max(); static constexpr byte_t MAX_BYTE = std::numeric_limits< byte_t >::max();

@ -684,9 +684,10 @@ namespace llarp
} }
else else
{ {
sendFunc = std::bind(&TunEndpoint::SendToServiceOrQueue, this, sendFunc =
itr->second.as_array(), std::placeholders::_1, std::bind(&TunEndpoint::SendToServiceOrQueue, this,
service::eProtocolTraffic); service::Address(itr->second.as_array()),
std::placeholders::_1, service::eProtocolTraffic);
} }
// prepare packet for insertion into network // prepare packet for insertion into network
// this includes clearing IP addresses, recalculating checksums, etc // this includes clearing IP addresses, recalculating checksums, etc

@ -1848,10 +1848,10 @@ namespace llarp
bool bool
Router::HasSessionTo(const RouterID &remote) const Router::HasSessionTo(const RouterID &remote) const
{ {
for(const auto & link : outboundLinks) for(const auto &link : outboundLinks)
if(link->HasSessionTo(remote)) if(link->HasSessionTo(remote))
return true; return true;
for(const auto & link : inboundLinks) for(const auto &link : inboundLinks)
if(link->HasSessionTo(remote)) if(link->HasSessionTo(remote))
return true; return true;
return false; return false;

@ -821,11 +821,12 @@ namespace llarp
Endpoint::HandleDataMessage(const PathID_t& src, Endpoint::HandleDataMessage(const PathID_t& src,
std::shared_ptr< ProtocolMessage > msg) std::shared_ptr< ProtocolMessage > msg)
{ {
msg->sender.UpdateAddr();
auto path = GetPathByID(src); auto path = GetPathByID(src);
if(path) if(path)
PutReplyIntroFor(msg->tag, path->intro); PutIntroFor(msg->tag, path->intro);
msg->sender.UpdateAddr(); PutSenderFor(msg->tag, msg->sender);
PutIntroFor(msg->tag, msg->introReply); PutReplyIntroFor(msg->tag, msg->introReply);
EnsureReplyPath(msg->sender); EnsureReplyPath(msg->sender);
return ProcessDataMessage(msg); return ProcessDataMessage(msg);
} }
@ -1070,11 +1071,9 @@ namespace llarp
} }
bool bool
Endpoint::SendToServiceOrQueue(const RouterID& addr, Endpoint::SendToServiceOrQueue(const service::Address& remote,
const llarp_buffer_t& data, ProtocolType t) const llarp_buffer_t& data, ProtocolType t)
{ {
service::Address remote(addr.as_array());
// inbound converstation // inbound converstation
auto now = Now(); auto now = Now();
@ -1120,8 +1119,8 @@ namespace llarp
m.introReply = p->intro; m.introReply = p->intro;
PutReplyIntroFor(f.T, m.introReply); PutReplyIntroFor(f.T, m.introReply);
m.sender = m_Identity.pub; m.sender = m_Identity.pub;
m.seqno = GetSeqNoForConvo(f.T);
f.F = m.introReply.pathID; f.F = m.introReply.pathID;
f.S = GetSeqNoForConvo(f.T);
transfer->P = remoteIntro.pathID; transfer->P = remoteIntro.pathID;
if(!f.EncryptAndSign(m, K, m_Identity)) if(!f.EncryptAndSign(m, K, m_Identity))
{ {

@ -207,8 +207,8 @@ namespace llarp
HandlePathBuilt(path::Path_ptr path) override; HandlePathBuilt(path::Path_ptr path) override;
bool bool
SendToServiceOrQueue(const RouterID& addr, const llarp_buffer_t& payload, SendToServiceOrQueue(const service::Address& addr,
ProtocolType t); const llarp_buffer_t& payload, ProtocolType t);
bool bool
SendToSNodeOrQueue(const RouterID& addr, const llarp_buffer_t& payload); SendToSNodeOrQueue(const RouterID& addr, const llarp_buffer_t& payload);

@ -59,7 +59,7 @@ namespace llarp
ProtocolFrame f; ProtocolFrame f;
f.N.Randomize(); f.N.Randomize();
f.T = currentConvoTag; f.T = currentConvoTag;
f.S = m_Endpoint->GetSeqNoForConvo(f.T); f.S = ++sequenceNo;
auto now = m_Endpoint->Now(); auto now = m_Endpoint->Now();
if(remoteIntro.ExpiresSoon(now)) if(remoteIntro.ExpiresSoon(now))
@ -87,7 +87,7 @@ namespace llarp
m_DataHandler->PutIntroFor(f.T, remoteIntro); m_DataHandler->PutIntroFor(f.T, remoteIntro);
m_DataHandler->PutReplyIntroFor(f.T, path->intro); m_DataHandler->PutReplyIntroFor(f.T, path->intro);
m.proto = t; m.proto = t;
m.seqno = sequenceNo++; m.seqno = m_Endpoint->GetSeqNoForConvo(f.T);
m.introReply = path->intro; m.introReply = path->intro;
f.F = m.introReply.pathID; f.F = m.introReply.pathID;
m.sender = m_Endpoint->GetIdentity().pub; m.sender = m_Endpoint->GetIdentity().pub;

Loading…
Cancel
Save