Fix shadowing warnings

pull/562/head
Michael 5 years ago
parent b2a55fd0bc
commit 9ee525a006
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C

@ -96,12 +96,6 @@ if (NOT WIN32)
add_compile_options(-fPIC)
endif(NOT WIN32)
# turns off those annoying warnings for
# target-specific crypto code paths not
# applicable to the host's FPU -rick
if (WARNINGS_AS_ERRORS)
add_compile_options(-Werror)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-unknown-warning-option)
endif()

@ -29,9 +29,9 @@ struct MD5
std::string hex;
std::for_each(digest.begin(), digest.end(),
[&hex](const unsigned char& ch) {
char buf[4] = {0};
std::snprintf(buf, sizeof(buf), "%.2x", ch);
hex += std::string(buf);
char tmpbuf[4] = {0};
std::snprintf(tmpbuf, sizeof(tmpbuf), "%.2x", ch);
hex += std::string(tmpbuf);
});
return hex;
}

@ -65,9 +65,8 @@ MD5::MD5()
void
MD5::Update(const unsigned char *inBuf, uint32_t inLen)
{
UINT4 in[16];
UINT4 input[16];
int mdi;
unsigned int i, ii;
/* compute number of bytes mod 64 */
mdi = (int)((this->i[0] >> 3) & 0x3F);
@ -81,16 +80,17 @@ MD5::Update(const unsigned char *inBuf, uint32_t inLen)
while(inLen--)
{
/* add new character to buffer, increment mdi */
this->in[mdi++] = *inBuf++;
in[mdi++] = *inBuf++;
/* transform if necessary */
if(mdi == 0x40)
{
for(i = 0, ii = 0; i < 16; i++, ii += 4)
in[i] = (((UINT4)this->in[ii + 3]) << 24)
| (((UINT4)this->in[ii + 2]) << 16)
| (((UINT4)this->in[ii + 1]) << 8) | ((UINT4)this->in[ii]);
Transform(this->buf, in);
for(unsigned int j = 0, jj = 0; j < 16; j++, jj += 4)
{
input[j] = (((UINT4)in[jj + 3]) << 24) | (((UINT4)in[jj + 2]) << 16)
| (((UINT4)in[jj + 1]) << 8) | ((UINT4)in[jj]);
}
Transform(this->buf, input);
mdi = 0;
}
}
@ -99,36 +99,36 @@ MD5::Update(const unsigned char *inBuf, uint32_t inLen)
void
MD5::Final(uint8_t *digest)
{
UINT4 in[16];
UINT4 input[16];
int mdi;
unsigned int i, ii;
unsigned int padLen;
/* save number of bits */
in[14] = this->i[0];
in[15] = this->i[1];
input[14] = i[0];
input[15] = i[1];
/* compute number of bytes mod 64 */
mdi = (int)((this->i[0] >> 3) & 0x3F);
mdi = (int)((i[0] >> 3) & 0x3F);
/* pad out to 56 mod 64 */
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
this->Update(PADDING, padLen);
/* append length in bits and transform */
for(i = 0, ii = 0; i < 14; i++, ii += 4)
in[i] = (((UINT4)this->in[ii + 3]) << 24)
| (((UINT4)this->in[ii + 2]) << 16) | (((UINT4)this->in[ii + 1]) << 8)
| ((UINT4)this->in[ii]);
Transform(this->buf, in);
for(unsigned int j = 0, jj = 0; j < 14; j++, jj += 4)
{
input[j] = (((UINT4)in[jj + 3]) << 24) | (((UINT4)in[jj + 2]) << 16)
| (((UINT4)in[jj + 1]) << 8) | ((UINT4)in[jj]);
}
Transform(this->buf, input);
/* store buffer in digest */
for(i = 0, ii = 0; i < 4; i++, ii += 4)
for(unsigned int j = 0, jj = 0; j < 4; j++, jj += 4)
{
digest[ii] = (unsigned char)(this->buf[i] & 0xFF);
digest[ii + 1] = (unsigned char)((this->buf[i] >> 8) & 0xFF);
digest[ii + 2] = (unsigned char)((this->buf[i] >> 16) & 0xFF);
digest[ii + 3] = (unsigned char)((this->buf[i] >> 24) & 0xFF);
digest[jj] = (unsigned char)(this->buf[j] & 0xFF);
digest[jj + 1] = (unsigned char)((this->buf[j] >> 8) & 0xFF);
digest[jj + 2] = (unsigned char)((this->buf[j] >> 16) & 0xFF);
digest[jj + 3] = (unsigned char)((this->buf[j] >> 24) & 0xFF);
}
}

@ -259,7 +259,7 @@ if(WITH_SHARED)
endif()
if (WARNINGS_AS_ERRORS)
set(WARN_FLAGS -Wall -Wextra -Wextra-semi -Werror)
set(WARN_FLAGS -Wall -Wextra -Wshadow -Werror)
target_compile_options(${UTIL_LIB} PUBLIC ${WARN_FLAGS})
target_compile_options(${PLATFORM_LIB} PUBLIC ${WARN_FLAGS})
target_compile_options(${STATIC_LIB} PUBLIC ${WARN_FLAGS})

@ -54,7 +54,7 @@ namespace llarp
bootstrap = find_section(parser, "bootstrap", section_t{});
logging = find_section(parser, "logging", section_t{});
return true;
};
}
void
Config::visit(const Visitor &functor)

@ -69,7 +69,7 @@ namespace llarp
LookupRouter(const RouterID& target, RouterLookupHandler result) override
{
Key_t askpeer;
if(!nodes->FindClosest(Key_t(target), askpeer))
if(!_nodes->FindClosest(Key_t(target), askpeer))
{
return false;
}
@ -166,7 +166,7 @@ namespace llarp
llarp::AbstractRouter* router;
// for router contacts
std::unique_ptr< Bucket< RCNode > > nodes;
std::unique_ptr< Bucket< RCNode > > _nodes;
// for introduction sets
std::unique_ptr< Bucket< ISNode > > _services;
@ -193,7 +193,7 @@ namespace llarp
Bucket< RCNode >*
Nodes() const override
{
return nodes.get();
return _nodes.get();
}
const Key_t&
@ -303,7 +303,7 @@ namespace llarp
llarp::LogInfo("Exploring network via ", N, " peers");
std::set< Key_t > peers;
if(nodes->GetManyRandom(peers, N))
if(_nodes->GetManyRandom(peers, N))
{
for(const auto& peer : peers)
ExploreNetworkVia(peer);
@ -428,13 +428,13 @@ namespace llarp
}
Key_t next;
std::set< Key_t > excluding = {requester, ourKey};
if(nodes->FindCloseExcluding(target, next, excluding))
if(_nodes->FindCloseExcluding(target, next, excluding))
{
if(next == target)
{
// we know it
replies.emplace_back(new GotRouterMessage(
requester, txid, {nodes->nodes[target].rc}, false));
requester, txid, {_nodes->nodes[target].rc}, false));
}
else if(recursive) // are we doing a recursive lookup?
{
@ -497,7 +497,7 @@ namespace llarp
{"pendingIntrosetLookups", _pendingIntrosetLookups.ExtractStatus()},
{"pendingTagLookups", pendingTagLookups().ExtractStatus()},
{"pendingExploreLookups", pendingExploreLookups().ExtractStatus()},
{"nodes", nodes->ExtractStatus()},
{"nodes", _nodes->ExtractStatus()},
{"services", _services->ExtractStatus()},
{"ourKey", ourKey.ToHex()}};
return obj;
@ -509,7 +509,7 @@ namespace llarp
{
router = r;
ourKey = us;
nodes = std::make_unique< Bucket< RCNode > >(ourKey, llarp::randint);
_nodes = std::make_unique< Bucket< RCNode > >(ourKey, llarp::randint);
_services = std::make_unique< Bucket< ISNode > >(ourKey, llarp::randint);
llarp::LogDebug("initialize dht with key ", ourKey);
// start exploring
@ -636,25 +636,25 @@ namespace llarp
std::vector< RouterID > closer;
Key_t t(target.as_array());
std::set< Key_t > found;
if(!nodes)
if(!_nodes)
return false;
size_t nodeCount = nodes->size();
size_t nodeCount = _nodes->size();
if(nodeCount == 0)
{
llarp::LogError(
"cannot handle exploritory router lookup, no dht peers");
return false;
}
llarp::LogDebug("We have ", nodes->size(),
llarp::LogDebug("We have ", _nodes->size(),
" connected nodes into the DHT");
// ourKey should never be in the connected list
// requester is likely in the connected list
// 4 or connection nodes (minus a potential requestor), whatever is less
size_t want = std::min(size_t(4), nodeCount - 1);
llarp::LogDebug("We want ", want, " connected nodes in the DHT");
if(!nodes->GetManyNearExcluding(t, found, want,
std::set< Key_t >{ourKey, requester}))
if(!_nodes->GetManyNearExcluding(t, found, want,
std::set< Key_t >{ourKey, requester}))
{
llarp::LogError(
"not enough dht nodes to handle exploritory router lookup, "

@ -5,22 +5,22 @@ namespace llarp
{
namespace dns
{
record::~record(){
};
record::~record()
{
}
bool
record::parse(std::vector< byte_t > bytes)
{
return bytes.size() ? true : false;
};
}
std::vector< byte_t >
record::to_bytes()
{
std::vector< byte_t > retval;
return retval;
};
}
type_1a::type_1a() : record()
{
@ -45,7 +45,7 @@ namespace llarp
this->ipaddr = ipaddr_ipv4_bits(bytes[3], bytes[2], bytes[1], bytes[0]);
// LogDebug("Test ", this->ipaddr);
return bytes.size() ? true : false;
};
}
std::vector< byte_t >
type_1a::to_bytes()
@ -54,9 +54,11 @@ namespace llarp
vput16bits(retval, 4); // rdLength
vput32bits(retval, this->ipaddr.h); // write IP
return retval;
};
}
type_2ns::type_2ns() : record(){};
type_2ns::type_2ns() : record()
{
}
bool
type_2ns::parse(std::vector< byte_t > bytes)
@ -65,7 +67,7 @@ namespace llarp
this->ns = std::string(reinterpret_cast< char* >(bytes.data()),
bytes.size() - 2);
return true;
};
}
std::vector< byte_t >
type_2ns::to_bytes()
@ -74,9 +76,11 @@ namespace llarp
vput16bits(retval, 2 + this->ns.length()); // rdLength
vcode_domain(retval, this->ns);
return retval;
};
}
type_5cname::type_5cname() : record(){};
type_5cname::type_5cname() : record()
{
}
bool
type_5cname::parse(std::vector< byte_t > bytes)
@ -86,7 +90,7 @@ namespace llarp
std::string(reinterpret_cast< char* >(bytes.data()), bytes.size());
// LogDebug("type5 parsed ", this->cname);
return true;
};
}
std::vector< byte_t >
type_5cname::to_bytes()
@ -95,7 +99,7 @@ namespace llarp
vput16bits(retval, 2 + this->cname.length()); // rdLength
vcode_domain(retval, this->cname);
return retval;
};
}
type_6soa::type_6soa() : record()
{
@ -113,7 +117,7 @@ namespace llarp
// this->cname = std::string(reinterpret_cast<char *>(bytes.data()),
// bytes.size());
return bytes.size() ? true : false;
};
}
std::vector< byte_t >
type_6soa::to_bytes()
@ -131,9 +135,11 @@ namespace llarp
vput32bits(retval, this->minimum);
return retval;
};
}
type_12ptr::type_12ptr() : record(){};
type_12ptr::type_12ptr() : record()
{
}
bool
type_12ptr::parse(std::vector< byte_t > bytes)
@ -141,7 +147,7 @@ namespace llarp
this->revname =
std::string(reinterpret_cast< char* >(bytes.data()), bytes.size());
return bytes.size() ? true : false;
};
}
std::vector< byte_t >
type_12ptr::to_bytes()
@ -154,7 +160,7 @@ namespace llarp
// vcode_domain(retval, this->revname.substr(0, this->revname.size() -
// 2));
return retval;
};
}
type_15mx::type_15mx() : record()
{
@ -168,7 +174,7 @@ namespace llarp
std::string(reinterpret_cast< char* >(bytes.data()), bytes.size());
// LogInfo("parsed ", this->mx);
return true;
};
}
std::vector< byte_t >
type_15mx::to_bytes()
@ -178,9 +184,11 @@ namespace llarp
vput16bits(retval, this->priority); // priority
vcode_domain(retval, this->mx);
return retval;
};
}
type_16txt::type_16txt() : record(){};
type_16txt::type_16txt() : record()
{
}
bool
type_16txt::parse(std::vector< byte_t > bytes)
@ -188,7 +196,7 @@ namespace llarp
this->txt = std::string(reinterpret_cast< char* >(bytes.data()),
bytes.size() - 1);
return true;
};
}
std::vector< byte_t >
type_16txt::to_bytes()
@ -201,7 +209,7 @@ namespace llarp
retval.push_back(it);
}
return retval;
};
}
} // namespace dns
} // namespace llarp

@ -5,7 +5,9 @@ namespace llarp
{
namespace dns
{
Serialize::~Serialize(){};
Serialize::~Serialize()
{
}
bool
EncodeRData(llarp_buffer_t* buf, const std::vector< byte_t >& v)

@ -296,9 +296,9 @@ namespace llarp
struct GetTime
{
llarp_time_t
operator()(const WriteBuffer& buf) const
operator()(const WriteBuffer& writebuf) const
{
return buf.timestamp;
return writebuf.timestamp;
}
};
@ -323,9 +323,9 @@ namespace llarp
{
}
void
operator()(WriteBuffer& buf)
operator()(WriteBuffer& writebuf)
{
buf.timestamp = llarp_ev_loop_time_now_ms(loop);
writebuf.timestamp = llarp_ev_loop_time_now_ms(loop);
}
};
@ -656,7 +656,7 @@ namespace llarp
read(byte_t*, size_t);
};
}; // namespace llarp
} // namespace llarp
#ifdef _WIN32
struct llarp_fd_promise

@ -192,9 +192,9 @@ namespace llarp
{
iovec vecs[2];
// TODO: IPV6
uint32_t t = htonl(AF_INET);
vecs[0].iov_base = &t;
vecs[0].iov_len = sizeof(t);
uint32_t val = htonl(AF_INET);
vecs[0].iov_base = &val;
vecs[0].iov_len = sizeof(val);
vecs[1].iov_base = buf;
vecs[1].iov_len = sz;
return writev(fd, vecs, 2);
@ -259,7 +259,7 @@ namespace llarp
return fd != -1;
}
}; // namespace llarp
} // namespace llarp
llarp::ev_io*
llarp_kqueue_loop::bind_tcp(llarp_tcp_acceptor* tcp, const sockaddr* bindaddr)

@ -384,10 +384,12 @@ namespace llarp
context->Crypto(), context->EncryptionSecretKey(),
&LRCMFrameDecrypt::HandleDecrypted);
// copy frames so we own them
LRCMFrameDecrypt* frames = new LRCMFrameDecrypt(context, decrypter, this);
LRCMFrameDecrypt* frameDecrypt =
new LRCMFrameDecrypt(context, decrypter, this);
// decrypt frames async
decrypter->AsyncDecrypt(context->Worker(), frames->frames[0], frames);
decrypter->AsyncDecrypt(context->Worker(), frameDecrypt->frames[0],
frameDecrypt);
return true;
}
} // namespace llarp

@ -52,8 +52,12 @@ llarp::Addr::operator==(const Addr& other) const
namespace llarp
{
Addr::Addr(){};
Addr::~Addr(){};
Addr::Addr()
{
}
Addr::~Addr()
{
}
Addr::Addr(const Addr& other)
{

@ -567,7 +567,7 @@ namespace llarp
// check to see if this path is dead
if(_status == ePathEstablished)
{
auto dlt = now - m_LastLatencyTestTime;
const auto dlt = now - m_LastLatencyTestTime;
if(dlt > path::latency_interval && m_LastLatencyTestID == 0)
{
routing::PathLatencyMessage latency;
@ -590,8 +590,8 @@ namespace llarp
}
if(m_LastRecvMessage && now > m_LastRecvMessage)
{
auto dlt = now - m_LastRecvMessage;
if(m_CheckForDead && m_CheckForDead(this, dlt))
const auto delay = now - m_LastRecvMessage;
if(m_CheckForDead && m_CheckForDead(this, delay))
{
r->routerProfiling().MarkPathFail(this);
EnterState(ePathTimeout, now);

@ -143,9 +143,9 @@ namespace llarp
result = func;
worker = pool;
for(size_t idx = 0; idx < path::max_len; ++idx)
for(size_t i = 0; i < path::max_len; ++i)
{
LRCM.frames[idx].Randomize();
LRCM.frames[i].Randomize();
}
llarp_threadpool_queue_job(pool, {this, &GenerateNextKey});
}

@ -88,8 +88,6 @@ namespace llarp
// use file based logging?
bool m_UseFileLogging = false;
// default log file path
fs::path logfile = "lokinet.log";
// our router contact
RouterContact _rc;

@ -13,6 +13,6 @@ namespace llarp
{"seqno", seqno},
{"intro", intro.ExtractStatus()}};
return obj;
};
}
} // namespace service
} // namespace llarp

@ -20,14 +20,14 @@ bool
llarp_buffer_t::writef(const char* fmt, ...)
{
int written;
size_t sz = size_left();
size_t toWrite = size_left();
va_list args;
va_start(args, fmt);
written = vsnprintf(reinterpret_cast< char* >(cur), sz, fmt, args);
written = vsnprintf(reinterpret_cast< char* >(cur), toWrite, fmt, args);
va_end(args);
if(written <= 0)
return false;
if(sz < static_cast< size_t >(written))
if(toWrite < static_cast< size_t >(written))
return false;
cur += written;
return true;

@ -27,7 +27,7 @@ namespace llarp
string_view_string(const string_view& v)
{
return std::string(v);
};
}
} // namespace llarp
#endif
#endif

@ -52,7 +52,7 @@ namespace llarp
return (started + timeout) < (other.started + other.timeout);
}
};
}; // namespace llarp
} // namespace llarp
struct llarp_timer_context
{
@ -71,8 +71,8 @@ struct llarp_timer_context
m_Now = llarp::time_now_ms();
}
uint32_t ids = 0;
bool _run = true;
uint32_t currentId = 0;
bool _run = true;
~llarp_timer_context()
{
@ -117,7 +117,7 @@ struct llarp_timer_context
{
llarp::util::Lock lock(&timersMutex);
uint32_t id = ++ids;
uint32_t id = ++currentId;
timers.emplace(
id, std::make_unique< llarp::timer >(m_Now, timeout_ms, user, func));
return id;

@ -233,7 +233,7 @@ namespace llarp
return false;
const auto dlt = parent->Now() - lastActive;
return dlt >= 10000;
};
}
ILinkLayer*
Session::GetLinkLayer() const

@ -327,7 +327,7 @@ TEST_F(TestDhtBucket, TestBucketFindClosest)
target.Fill(0xf5);
ASSERT_TRUE(nodes->FindClosest(target, result));
ASSERT_EQ(oldResult, result);
};
}
TEST_F(TestDhtBucket, TestBucketRandomized_1000)
{
@ -367,4 +367,4 @@ TEST_F(TestDhtBucket, TestBucketRandomized_1000)
ASSERT_NE(result ^ target, expect ^ target);
}
}
};
}

@ -120,4 +120,4 @@ TEST(TestDhtKey, TestBucketOperators)
ASSERT_NE(one, three);
ASSERT_FALSE(one == three);
ASSERT_EQ(one ^ three, three ^ one);
};
}

@ -33,7 +33,7 @@ TEST_F(DNSLibTest, TestPTR)
llarp::huint32_t expected = llarp::ipaddr_ipv4_bits(10, 10, 10, 1);
ASSERT_TRUE(llarp::dns::DecodePTR("1.10.10.10.in-addr.arpa.", ip));
ASSERT_EQ(ip, expected);
};
}
TEST_F(DNSLibTest, TestSerializeHeader)
{
@ -51,7 +51,7 @@ TEST_F(DNSLibTest, TestSerializeHeader)
ASSERT_TRUE(hdr == other);
ASSERT_TRUE(other.id == 0x1234);
ASSERT_TRUE(other.fields == (1 << 15));
};
}
TEST_F(DNSLibTest, TestSerializeName)
{
@ -77,7 +77,7 @@ TEST_F(DNSLibTest, TestSerializeName)
ASSERT_EQ(buf.base[13], 0);
ASSERT_TRUE(llarp::dns::DecodeName(&buf, other));
ASSERT_EQ(expected, other);
};
}
TEST_F(DNSLibTest, TestSerializeQuestion)
{
@ -93,7 +93,7 @@ TEST_F(DNSLibTest, TestSerializeQuestion)
ASSERT_EQ(other.qname, expected_name);
ASSERT_EQ(q.qclass, other.qclass);
ASSERT_EQ(q.qtype, other.qtype);
};
}
TEST_F(DNSLibTest, TestSerializeMessage)
{
@ -133,7 +133,7 @@ TEST_F(DNSLibTest, TestSerializeMessage)
ASSERT_TRUE(expected_question == other.questions[0]);
ASSERT_EQ(other.answers.size(), 1U);
ASSERT_EQ(other.answers[0].rData.size(), 4U);
};
}
TEST_F(DNSLibTest, TestEncodeDecode_RData)
{
@ -148,4 +148,4 @@ TEST_F(DNSLibTest, TestEncodeDecode_RData)
Rewind();
ASSERT_TRUE(llarp::dns::DecodeRData(&buf, other_rdata));
ASSERT_TRUE(rdata == other_rdata);
};
}

@ -132,4 +132,4 @@ TEST_F(EventLoopTest, PipeWrite1K)
ASSERT_TRUE(loop->add_ev(testpipe, false));
testpipe->PumpIt();
RunLoop();
};
}

@ -28,4 +28,4 @@ TEST_F(ExitTest, AddMultipleIP)
ASSERT_TRUE(r.exitContext().ObtainNewExit(pk, secondPath, true));
ASSERT_TRUE(r.exitContext().FindEndpointForPath(firstPath)->LocalIP()
== r.exitContext().FindEndpointForPath(secondPath)->LocalIP());
};
}

@ -107,7 +107,7 @@ struct LinkLayerTest : public ::testing::Test
bool success = false;
llarp_ev_loop_ptr netLoop;
std::unique_ptr< llarp::Logic > logic;
std::unique_ptr< llarp::Logic > m_logic;
llarp_time_t oldRCLifetime;
@ -122,7 +122,7 @@ struct LinkLayerTest : public ::testing::Test
llarp::RouterContact::IgnoreBogons = true;
llarp::RouterContact::Lifetime = 500;
netLoop = llarp_make_ev_loop();
logic.reset(new llarp::Logic());
m_logic.reset(new llarp::Logic());
}
void
@ -130,7 +130,7 @@ struct LinkLayerTest : public ::testing::Test
{
Alice.TearDown();
Bob.TearDown();
logic.reset();
m_logic.reset();
netLoop.reset();
llarp::RouterContact::IgnoreBogons = false;
llarp::RouterContact::Lifetime = oldRCLifetime;
@ -147,8 +147,8 @@ struct LinkLayerTest : public ::testing::Test
void
RunMainloop()
{
logic->call_later({5000, this, &OnTimeout});
llarp_ev_loop_run_single_process(netLoop, logic->thread, logic.get());
m_logic->call_later({5000, this, &OnTimeout});
llarp_ev_loop_run_single_process(netLoop, m_logic->thread, m_logic.get());
}
void
@ -247,8 +247,8 @@ TEST_F(LinkLayerTest, TestUTPAliceRenegWithBob)
},
[&](llarp::RouterID router) { ASSERT_EQ(router, Alice.GetRouterID()); });
ASSERT_TRUE(Alice.Start(logic.get(), netLoop, AlicePort));
ASSERT_TRUE(Bob.Start(logic.get(), netLoop, BobPort));
ASSERT_TRUE(Alice.Start(m_logic.get(), netLoop, AlicePort));
ASSERT_TRUE(Bob.Start(m_logic.get(), netLoop, BobPort));
ASSERT_TRUE(Alice.link->TryEstablishTo(Bob.GetRC()));
@ -313,18 +313,18 @@ TEST_F(LinkLayerTest, TestUTPAliceConnectToBob)
if(s->GetRemoteRC().pubkey != Alice.GetRC().pubkey)
return false;
llarp::LogInfo("bob established with alice");
logic->queue_job({s, [](void* u) {
llarp::ILinkSession* self =
static_cast< llarp::ILinkSession* >(u);
std::array< byte_t, 32 > tmp;
llarp_buffer_t otherBuf(tmp);
llarp::DiscardMessage discard;
if(!discard.BEncode(&otherBuf))
return;
otherBuf.sz = otherBuf.cur - otherBuf.base;
otherBuf.cur = otherBuf.base;
self->SendMessageBuffer(otherBuf);
}});
m_logic->queue_job({s, [](void* u) {
llarp::ILinkSession* self =
static_cast< llarp::ILinkSession* >(u);
std::array< byte_t, 32 > tmp;
llarp_buffer_t otherBuf(tmp);
llarp::DiscardMessage discard;
if(!discard.BEncode(&otherBuf))
return;
otherBuf.sz = otherBuf.cur - otherBuf.base;
otherBuf.cur = otherBuf.base;
self->SendMessageBuffer(otherBuf);
}});
return true;
},
[&](llarp::RouterContact, llarp::RouterContact) -> bool { return true; },
@ -336,8 +336,8 @@ TEST_F(LinkLayerTest, TestUTPAliceConnectToBob)
},
[&](llarp::RouterID router) { ASSERT_EQ(router, Alice.GetRouterID()); });
ASSERT_TRUE(Alice.Start(logic.get(), netLoop, AlicePort));
ASSERT_TRUE(Bob.Start(logic.get(), netLoop, BobPort));
ASSERT_TRUE(Alice.Start(m_logic.get(), netLoop, AlicePort));
ASSERT_TRUE(Bob.Start(m_logic.get(), netLoop, BobPort));
ASSERT_TRUE(Alice.link->TryEstablishTo(Bob.GetRC()));
@ -424,8 +424,8 @@ TEST_F(LinkLayerTest, TestIWPAliceConnectToBob)
},
[&](llarp::RouterID router) { ASSERT_EQ(router, Alice.GetRouterID()); });
ASSERT_TRUE(Alice.Start(logic.get(), netLoop, AlicePort));
ASSERT_TRUE(Bob.Start(logic.get(), netLoop, BobPort));
ASSERT_TRUE(Alice.Start(m_logic.get(), netLoop, AlicePort));
ASSERT_TRUE(Bob.Start(m_logic.get(), netLoop, BobPort));
ASSERT_TRUE(Alice.link->TryEstablishTo(Bob.GetRC()));

@ -29,32 +29,32 @@ TEST_F(TestNet, TestIPv4Netmask)
{
ASSERT_TRUE(llarp::netmask_ipv4_bits(8) == llarp::huint32_t{0xFF000000});
ASSERT_TRUE(llarp::netmask_ipv4_bits(24) == llarp::huint32_t{0xFFFFFF00});
};
}
TEST_F(TestNet, TestBogon_10_8)
{
ASSERT_TRUE(llarp::IsIPv4Bogon(llarp::ipaddr_ipv4_bits(10, 40, 11, 6)));
};
}
TEST_F(TestNet, TestBogon_192_168_16)
{
ASSERT_TRUE(llarp::IsIPv4Bogon(llarp::ipaddr_ipv4_bits(192, 168, 1, 111)));
};
}
TEST_F(TestNet, TestBogon_DoD_8)
{
ASSERT_TRUE(llarp::IsIPv4Bogon(llarp::ipaddr_ipv4_bits(21, 3, 37, 70)));
};
}
TEST_F(TestNet, TestBogon_127_8)
{
ASSERT_TRUE(llarp::IsIPv4Bogon(llarp::ipaddr_ipv4_bits(127, 0, 0, 1)));
};
}
TEST_F(TestNet, TestBogon_0_8)
{
ASSERT_TRUE(llarp::IsIPv4Bogon(llarp::ipaddr_ipv4_bits(0, 0, 0, 0)));
};
}
TEST_F(TestNet, TestBogon_NonBogon)
{

@ -13,7 +13,7 @@ TEST_F(TransferTrafficTest, TestPutBufferOverflow)
std::array< byte_t, llarp::routing::MaxExitMTU* 2 > tmp = {{0}};
llarp_buffer_t buf(tmp);
ASSERT_FALSE(msg.PutBuffer(buf, 1));
};
}
TEST_F(TransferTrafficTest, TestPutBuffer)
{
@ -21,4 +21,4 @@ TEST_F(TransferTrafficTest, TestPutBuffer)
std::array< byte_t, llarp::routing::MaxExitMTU > tmp = {{0}};
llarp_buffer_t buf(tmp);
ASSERT_TRUE(msg.PutBuffer(buf, 1));
};
}

@ -39,4 +39,4 @@ TEST_F(ObtainExitTest, TestSignVerify)
EXPECT_TRUE(msg.I == llarp::PubKey(llarp::seckey_topublic(alice)));
EXPECT_FALSE(msg.version != LLARP_PROTO_VERSION);
EXPECT_FALSE(msg.Z.IsZero());
};
}

@ -49,7 +49,7 @@ TEST_F(HiddenServiceTest, TestGenerateIntroSet)
}
ASSERT_TRUE(ident.SignIntroSet(I, Crypto(), now));
ASSERT_TRUE(I.Verify(Crypto(), now));
};
}
TEST_F(HiddenServiceTest, TestAddressToFromString)
{

@ -190,4 +190,4 @@ TEST_F(AbyssTest, TestClientAndServer)
AsyncFlush();
RunLoop();
ASSERT_TRUE(called);
};
}

@ -63,4 +63,4 @@ TEST_F(FrameTest, TestFrameCrypto)
LRCR otherRecord;
ASSERT_TRUE(otherRecord.BDecode(buf));
ASSERT_TRUE(otherRecord == record);
};
}

@ -6,4 +6,4 @@ TEST(TestMD5, TestMD5)
std::string str("The quick brown fox jumps over the lazy dog");
auto H = MD5::SumHex(str);
ASSERT_EQ(H, "9e107d9d372bb6826bd81d3542a419d6");
};
}

@ -222,4 +222,4 @@ TYPED_TEST(AlignedBufferTest, TestHash)
EXPECT_FALSE(m.emplace(k_copy, 2).second);
EXPECT_FALSE(m[k_copy] == 2);
EXPECT_TRUE(m[k_copy] == 1);
};
}

@ -450,4 +450,4 @@ TEST(TestBencode, ReadDictEmptyBuffer)
reader.on_key = [](dict_reader*, llarp_buffer_t*) -> bool { return true; };
reader.user = nullptr;
ASSERT_FALSE(bencode_read_dict(&buf, &reader));
};
}

@ -18,4 +18,4 @@ TEST_F(Base32Test, Serialize)
std::string encoded = llarp::Base32Encode(addr, tmp);
ASSERT_TRUE(llarp::Base32Decode(tmp, otherAddr));
ASSERT_TRUE(otherAddr == addr);
};
}

@ -85,7 +85,7 @@ bool
waitFunc(CondArgs* a)
{
return a->first->count != a->second;
};
}
void
popFrontTester(Args& args)

Loading…
Cancel
Save