mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-17 15:25:35 +00:00
commit
8d630eb5a6
@ -547,6 +547,7 @@ set(TEST_SRC
|
||||
test/test_llarp_queue.cpp
|
||||
test/test_llarp_queue_manager.cpp
|
||||
test/test_llarp_thread_pool.cpp
|
||||
test/test_service_address.cpp
|
||||
)
|
||||
|
||||
set(TEST_EXE testAll)
|
||||
|
@ -205,7 +205,7 @@ namespace llarp
|
||||
{
|
||||
if(HasAddress(addr.data()))
|
||||
{
|
||||
huint32_t ip = ObtainIPForAddr(addr.data(), true);
|
||||
huint32_t ip = ObtainIPForAddr(addr.data(), false);
|
||||
msg.AddINReply(ip);
|
||||
}
|
||||
else
|
||||
@ -460,6 +460,7 @@ namespace llarp
|
||||
|
||||
if(m_SNodes.at(itr->second))
|
||||
{
|
||||
llarp::LogInfo(Name(), " send to service node");
|
||||
sendFunc = std::bind(&TunEndpoint::SendToSNodeOrQueue, this,
|
||||
itr->second.data(), std::placeholders::_1);
|
||||
}
|
||||
@ -480,6 +481,7 @@ namespace llarp
|
||||
});
|
||||
if(m_Exit)
|
||||
m_Exit->FlushUpstreamTraffic();
|
||||
FlushSNodeTraffic();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -123,6 +123,17 @@ namespace llarp
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Endpoint::FlushSNodeTraffic()
|
||||
{
|
||||
auto itr = m_SNodeSessions.begin();
|
||||
while(itr != m_SNodeSessions.end())
|
||||
{
|
||||
itr->second->FlushUpstreamTraffic();
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Endpoint::Tick(llarp_time_t now)
|
||||
{
|
||||
@ -1068,8 +1079,7 @@ namespace llarp
|
||||
void
|
||||
Endpoint::EnsurePathToSNode(const RouterID& snode)
|
||||
{
|
||||
auto range = m_SNodeSessions.equal_range(snode);
|
||||
if(range.first == range.second)
|
||||
if(m_SNodeSessions.count(snode) == 0)
|
||||
{
|
||||
auto themIP = ObtainIPForAddr(snode, true);
|
||||
m_SNodeSessions.emplace(std::make_pair(
|
||||
|
@ -162,6 +162,9 @@ namespace llarp
|
||||
bool
|
||||
SendToSNodeOrQueue(const byte_t* addr, llarp_buffer_t payload);
|
||||
|
||||
void
|
||||
FlushSNodeTraffic();
|
||||
|
||||
struct PendingBuffer
|
||||
{
|
||||
std::vector< byte_t > payload;
|
||||
|
24
test/test_service_address.cpp
Normal file
24
test/test_service_address.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <service/address.hpp>
|
||||
|
||||
struct ServiceAddressTest : public ::testing::Test
|
||||
{
|
||||
const std::string snode =
|
||||
"8zfiwpgonsu5zpddpxwdurxyb19x6r96xy4qbikff99jwsziws9y.snode";
|
||||
const std::string loki =
|
||||
"7okic5x5do3uh3usttnqz9ek3uuoemdrwzto1hciwim9f947or6y.loki";
|
||||
};
|
||||
|
||||
TEST_F(ServiceAddressTest, TestParseSNodeNotLoki)
|
||||
{
|
||||
llarp::service::Address addr;
|
||||
ASSERT_TRUE(addr.FromString(snode, ".snode"));
|
||||
ASSERT_FALSE(addr.FromString(snode, ".loki"));
|
||||
}
|
||||
|
||||
TEST_F(ServiceAddressTest, TestParseLokiNotSNode)
|
||||
{
|
||||
llarp::service::Address addr;
|
||||
ASSERT_FALSE(addr.FromString(loki, ".snode"));
|
||||
ASSERT_TRUE(addr.FromString(loki, ".loki"));
|
||||
}
|
Loading…
Reference in New Issue
Block a user