Created
November 18, 2019 18:07
-
-
Save notlesh/209a708e9a1836f14663bfa339ecf416 to your computer and use it in GitHub Desktop.
lokinet mods that might help fix `hop 0` bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/llarp/iwp/linklayer.cpp b/llarp/iwp/linklayer.cpp | |
index 30eee514..acb80d56 100644 | |
--- a/llarp/iwp/linklayer.cpp | |
+++ b/llarp/iwp/linklayer.cpp | |
@@ -79,6 +79,7 @@ namespace llarp | |
{ | |
std::shared_ptr< ILinkSession > session; | |
auto itr = m_AuthedAddrs.find(from); | |
+ bool isNewSession = false; | |
if(itr == m_AuthedAddrs.end()) | |
{ | |
ACQUIRE_LOCK(Lock_t lock, m_PendingMutex); | |
@@ -86,6 +87,7 @@ namespace llarp | |
{ | |
if(not permitInbound) | |
return; | |
+ isNewSession = true; | |
m_Pending.insert({from, std::make_shared< Session >(this, from)}); | |
} | |
session = m_Pending.find(from)->second; | |
@@ -98,7 +100,11 @@ namespace llarp | |
} | |
if(session) | |
{ | |
- session->Recv_LL(std::move(pkt)); | |
+ bool success = session->Recv_LL(std::move(pkt)); | |
+ if (! success and isNewSession) { | |
+ LogWarn("Brand new session failed; removing from pending sessions list"); | |
+ m_Pending.erase(m_Pending.find(from)); | |
+ } | |
} | |
} | |
diff --git a/llarp/iwp/session.cpp b/llarp/iwp/session.cpp | |
index 84a2ea23..69a2fb56 100644 | |
--- a/llarp/iwp/session.cpp | |
+++ b/llarp/iwp/session.cpp | |
@@ -597,7 +597,7 @@ namespace llarp | |
} | |
} | |
SendMACK(); | |
- Pump(); | |
+ // Pump(); | |
m_Parent->PumpDone(); | |
} | |
@@ -807,7 +807,7 @@ namespace llarp | |
return m_State == State::Ready; | |
} | |
- void | |
+ bool | |
Session::Recv_LL(ILinkSession::Packet_t data) | |
{ | |
switch(m_State) | |
@@ -817,10 +817,12 @@ namespace llarp | |
{ | |
// initial data | |
// enter introduction phase | |
- if(DecryptMessageInPlace(data)) | |
+ if(DecryptMessageInPlace(data)) { | |
HandleGotIntro(std::move(data)); | |
- else | |
+ } else { | |
LogError("bad intro from ", m_RemoteAddr); | |
+ return false; | |
+ } | |
} | |
else | |
{ | |
@@ -846,6 +848,7 @@ namespace llarp | |
HandleSessionData(std::move(data)); | |
break; | |
} | |
+ return true; | |
} | |
} // namespace iwp | |
} // namespace llarp | |
diff --git a/llarp/iwp/session.hpp b/llarp/iwp/session.hpp | |
index 657b153b..083a77b7 100644 | |
--- a/llarp/iwp/session.hpp | |
+++ b/llarp/iwp/session.hpp | |
@@ -72,7 +72,7 @@ namespace llarp | |
void | |
Close() override; | |
- void Recv_LL(ILinkSession::Packet_t) override; | |
+ bool Recv_LL(ILinkSession::Packet_t) override; | |
bool | |
SendKeepAlive() override; | |
@@ -242,4 +242,4 @@ namespace llarp | |
} // namespace iwp | |
} // namespace llarp | |
-#endif | |
\ No newline at end of file | |
+#endif | |
diff --git a/llarp/link/session.hpp b/llarp/link/session.hpp | |
index 572ac9b0..8c81a5a1 100644 | |
--- a/llarp/link/session.hpp | |
+++ b/llarp/link/session.hpp | |
@@ -61,8 +61,9 @@ namespace llarp | |
/// recv packet on low layer | |
/// not used by utp | |
- virtual void Recv_LL(Packet_t) | |
+ virtual bool Recv_LL(Packet_t) | |
{ | |
+ return true; | |
} | |
/// send a keepalive to the remote endpoint |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment