diff --git a/llarp/constants/link_layer.hpp b/llarp/constants/link_layer.hpp index 0f941a8b2..31b82fb89 100644 --- a/llarp/constants/link_layer.hpp +++ b/llarp/constants/link_layer.hpp @@ -7,3 +7,4 @@ constexpr size_t MAX_LINK_MSG_SIZE = 8192; static constexpr auto DefaultLinkSessionLifetime = 1min; constexpr size_t MaxSendQueueSize = 1024; +static constexpr auto LinkLayerConnectTimeout = 5s; diff --git a/llarp/iwp/session.cpp b/llarp/iwp/session.cpp index 557a45c4d..631101947 100644 --- a/llarp/iwp/session.cpp +++ b/llarp/iwp/session.cpp @@ -331,7 +331,7 @@ namespace llarp { return now > m_LastRX && now - m_LastRX > SessionAliveTimeout; } - return now - m_CreatedAt > SessionAliveTimeout; + return now - m_CreatedAt >= LinkLayerConnectTimeout; } bool diff --git a/llarp/service/endpoint.cpp b/llarp/service/endpoint.cpp index 89d5578b0..0551413fe 100644 --- a/llarp/service/endpoint.cpp +++ b/llarp/service/endpoint.cpp @@ -819,6 +819,11 @@ namespace llarp std::string name, std::function>)> handler) { + if (not NameIsValid(name)) + { + handler(std::nullopt); + return; + } auto& cache = m_state->nameCache; const auto maybe = cache.Get(name); if (maybe.has_value()) diff --git a/llarp/service/name.cpp b/llarp/service/name.cpp index ea8146abc..a1af5f439 100644 --- a/llarp/service/name.cpp +++ b/llarp/service/name.cpp @@ -19,6 +19,9 @@ namespace llarp::service bool NameIsValid(std::string_view lnsName) { + // make sure it ends with .loki because no fucking shit right? + if (not ends_with(lnsName, ".loki")) + return false; // strip off .loki suffix lnsName = lnsName.substr(0, lnsName.find_last_of('.'));