Merge remote-tracking branch 'origin/master' into ipv6-tun

pull/686/head
Jeff Becker 5 years ago
commit 1fd6b5ae74
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -0,0 +1,2 @@
HeaderFilterRegex: 'llarp/.*'
Checks: 'readability-else-after-return,clang-analyzer-core-*'

2
.gitignore vendored

@ -29,6 +29,8 @@ callgrind.*
shadow.data
shadow.config.xml
*.log
*.pdf
*.xz
testnet_tmp

@ -19,6 +19,7 @@ option(DEBIAN "build for debian" )
option(TESTNET "testnet build" )
option(WITH_SHARED "build shared library")
option(WITH_COVERAGE "generate coverage data")
option(WITH_SHELLHOOKS "enable shell hooks on compile time (dangerous)" OFF)
option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for development, on for release" OFF)
include(cmake/target_link_libraries_system.cmake)
@ -94,6 +95,10 @@ if(NON_PC_TARGET)
set(WITH_STATIC ON)
endif(NON_PC_TARGET)
if(WITH_SHELLHOOKS)
add_definitions(-DENABLE_SHELLHOOKS)
endif(WITH_SHELLHOOKS)
add_compile_options(${OPTIMIZE_FLAGS} ${CRYPTO_FLAGS})
set(ABSEIL_DIR vendor/abseil-cpp)

@ -61,6 +61,8 @@ NON_PC_TARGET ?= OFF
STATIC_LINK ?= OFF
# enable network namespace isolation
NETNS ?= OFF
# enable shell hooks callbacks
SHELL_HOOKS ?= OFF
# cross compile?
CROSS ?= OFF
# build liblokinet-shared.so
@ -86,13 +88,13 @@ SCAN_BUILD ?= scan-build
UNAME = $(shell which uname)
ifeq ($(shell $(UNAME)),SunOS)
CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_SHELLHOOKS=$(SHELL_HOOKS) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
ANALYZE_CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
COVERAGE_CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DWITH_COVERAGE=yes -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
else
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_SHELLHOOKS=$(SHELL_HOOKS) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")

@ -367,8 +367,8 @@ namespace llarp
if(c.VisitSection(name.c_str(), visitor))
return ret;
else
return {};
return {};
}
bool

@ -275,8 +275,8 @@ __ ___ ____ _ _ ___ _ _ ____
f << std::to_string(getpid());
return f.good();
}
else
return true;
return true;
}
void

@ -79,8 +79,8 @@ namespace llarp
firstKey = false;
return msg != nullptr;
}
else
return msg->DecodeKey(*key, buffer);
return msg->DecodeKey(*key, buffer);
}
};
@ -117,8 +117,8 @@ namespace llarp
l.emplace_back(std::move(msg));
return true;
}
else
return false;
return false;
}
};

@ -98,105 +98,98 @@ namespace llarp
replies.emplace_back(new GotIntroMessage({i}, T));
return true;
}
else
if(R == 0)
{
if(R == 0)
{
// we don't have it
Key_t target = S.ToKey();
Key_t closer;
// find closer peer
if(!dht.Nodes()->FindClosest(target, closer))
return false;
if(relayed)
dht.LookupIntroSetForPath(S, T, pathID, closer);
else
replies.emplace_back(new GotIntroMessage(From, closer, T));
return true;
}
// we don't have it
Key_t target = S.ToKey();
Key_t closer;
// find closer peer
if(!dht.Nodes()->FindClosest(target, closer))
return false;
if(relayed)
dht.LookupIntroSetForPath(S, T, pathID, closer);
else
replies.emplace_back(new GotIntroMessage(From, closer, T));
return true;
}
Key_t us = dht.OurKey();
Key_t target = S.ToKey();
// we are recursive
if(dht.Nodes()->FindCloseExcluding(target, peer, exclude))
{
if(relayed)
dht.LookupIntroSetForPath(S, T, pathID, peer);
else
{
Key_t us = dht.OurKey();
Key_t target = S.ToKey();
// we are recursive
if(dht.Nodes()->FindCloseExcluding(target, peer, exclude))
{
if(relayed)
dht.LookupIntroSetForPath(S, T, pathID, peer);
else
{
if((us ^ target) < (peer ^ target))
{
// we are not closer than our peer to the target so don't
// recurse farther
replies.emplace_back(new GotIntroMessage({}, T));
return true;
}
else if(R > 0)
dht.LookupIntroSetRecursive(S, From, T, peer, R - 1);
else
dht.LookupIntroSetIterative(S, From, T, peer);
}
return true;
}
else
if((us ^ target) < (peer ^ target))
{
// no more closer peers
// we are not closer than our peer to the target so don't
// recurse farther
replies.emplace_back(new GotIntroMessage({}, T));
return true;
}
if(R > 0)
dht.LookupIntroSetRecursive(S, From, T, peer, R - 1);
else
dht.LookupIntroSetIterative(S, From, T, peer);
}
return true;
}
// no more closer peers
replies.emplace_back(new GotIntroMessage({}, T));
return true;
}
if(relayed)
{
// tag lookup
if(dht.Nodes()->GetRandomNodeExcluding(peer, exclude))
{
dht.LookupTagForPath(N, T, pathID, peer);
}
else
{
// no more closer peers
replies.emplace_back(new GotIntroMessage({}, T));
return true;
}
}
else
{
if(relayed)
if(R == 0)
{
// base case
auto introsets = dht.FindRandomIntroSetsWithTagExcluding(N, 2, {});
std::vector< service::IntroSet > reply;
for(const auto& introset : introsets)
{
reply.push_back(introset);
}
replies.emplace_back(new GotIntroMessage(reply, T));
return true;
}
if(R < 5)
{
// tag lookup
if(dht.Nodes()->GetRandomNodeExcluding(peer, exclude))
{
dht.LookupTagForPath(N, T, pathID, peer);
dht.LookupTagRecursive(N, From, T, peer, R - 1);
}
else
{
// no more closer peers
replies.emplace_back(new GotIntroMessage({}, T));
return true;
}
}
else
{
if(R == 0)
{
// base case
auto introsets = dht.FindRandomIntroSetsWithTagExcluding(N, 2, {});
std::vector< service::IntroSet > reply;
for(const auto& introset : introsets)
{
reply.push_back(introset);
}
replies.emplace_back(new GotIntroMessage(reply, T));
return true;
}
else if(R < 5)
{
// tag lookup
if(dht.Nodes()->GetRandomNodeExcluding(peer, exclude))
{
dht.LookupTagRecursive(N, From, T, peer, R - 1);
}
else
{
replies.emplace_back(new GotIntroMessage({}, T));
}
}
else
{
// too big R value
replies.emplace_back(new GotIntroMessage({}, T));
}
// too big R value
replies.emplace_back(new GotIntroMessage({}, T));
}
}
return true;
}
} // namespace dht

@ -172,13 +172,13 @@ namespace llarp
Key_t k{K};
if(exploritory)
return dht.HandleExploritoryRouterLookup(From, txid, K, replies);
else if(!dht.GetRouter()->ConnectionToRouterAllowed(K))
if(!dht.GetRouter()->ConnectionToRouterAllowed(K))
{
// explicitly disallowed by network
replies.emplace_back(new GotRouterMessage(k, txid, {}, false));
return true;
}
else if(dht.Nodes()->HasNode(k))
if(dht.Nodes()->HasNode(k))
{
found = dht.Nodes()->nodes[k].rc;
replies.emplace_back(new GotRouterMessage(k, txid, {found}, false));

@ -45,10 +45,8 @@ namespace llarp
{
return nodes->FindCloseExcluding(k, next, exclude);
}
else
{
return false;
}
return false;
}
void

@ -105,10 +105,8 @@ namespace llarp
{
return nullptr;
}
else
{
return itr->second.get();
}
return itr->second.get();
}
template < typename K, typename V, typename K_Hash,

@ -125,8 +125,8 @@ namespace llarp
}
return true;
}
else
return false;
return false;
}
} // namespace dns

@ -55,8 +55,8 @@ namespace llarp
// does other have a . at the end?
if(other.find_last_of('.') == (other.size() - 1))
return other == qname;
else // no, add it and retry
return IsName(other + ".");
// no, add it and retry
return IsName(other + ".");
}
std::string

@ -400,7 +400,7 @@ generic_handle_dnsc_recvfrom(dnsc_answer_request *request,
request->resolved(request);
return;
}
else if(rcode == 3)
if(rcode == 3)
{
llarp::LogWarn("nameserver ", upstreamAddr,
" returned NXDOMAIN for: ", request->question.name);

@ -608,8 +608,6 @@ llarp_dnsd_init(struct dnsd_context *const dnsd, llarp::Logic *const logic,
(const sockaddr *)dnsd_sockaddr)
!= -1;
}
else
{
return true;
}
return true;
}

@ -226,7 +226,7 @@ namespace llarp
::shutdown(fd, SHUT_RDWR);
return false;
}
else if(tcp.tick)
if(tcp.tick)
tcp.tick(&tcp);
return true;
}

@ -407,13 +407,13 @@ namespace llarp
m_LossyWriteQueue->Emplace(buf, sz);
return true;
}
else if(m_BlockingWriteQueue)
if(m_BlockingWriteQueue)
{
m_BlockingWriteQueue->emplace_back(buf, sz);
return true;
}
else
return false;
return false;
}
virtual void

@ -1,5 +1,7 @@
#include <ev/ev_win32.hpp>
#ifdef _WIN32
// a single event queue for the TUN interface
static HANDLE tun_event_queue = INVALID_HANDLE_VALUE;
@ -683,3 +685,5 @@ llarp_win32_loop::stop()
upollfd = nullptr;
llarp::LogDebug("destroy upoll");
}
#endif

@ -1,5 +1,6 @@
#ifndef EV_WIN32_H
#define EV_WIN32_H
#ifdef _WIN32
#include <ev/ev.hpp>
#include <net/net.h>
#include <net/net.hpp>
@ -151,3 +152,4 @@ struct llarp_win32_loop : public llarp_ev_loop
};
#endif
#endif

@ -98,7 +98,7 @@ namespace llarp
auto lastPing = path->LastRemoteActivityAt();
if(lastPing == 0 || (now > lastPing && now - lastPing > timeout))
return now > m_LastActive && now - m_LastActive > timeout;
else if(lastPing)
else if(lastPing) // NOLINT
return now > lastPing && now - lastPing > timeout;
return lastPing > 0;
}
@ -171,8 +171,8 @@ namespace llarp
queue.emplace_back();
return queue.back().PutBuffer(pktbuf, m_Counter++);
}
else
return msg.PutBuffer(pktbuf, m_Counter++);
return msg.PutBuffer(pktbuf, m_Counter++);
}
bool

@ -85,8 +85,8 @@ namespace llarp
router->LookupRouter(m_ExitRouter, nullptr);
return false;
}
else
return path::Builder::SelectHop(db, exclude, cur, hop, roles);
return path::Builder::SelectHop(db, exclude, cur, hop, roles);
}
bool
@ -241,8 +241,8 @@ namespace llarp
queue.emplace_back();
return queue.back().PutBuffer(buf, m_Counter++);
}
else
return back.PutBuffer(buf, m_Counter++);
return back.PutBuffer(buf, m_Counter++);
}
bool

@ -77,9 +77,9 @@ namespace llarp
return false;
return m_OurRange.Contains(ip);
}
else if(msg.questions[0].qtype == dns::qTypeA
|| msg.questions[0].qtype == dns::qTypeCNAME
|| msg.questions[0].qtype == dns::qTypeAAAA)
if(msg.questions[0].qtype == dns::qTypeA
|| msg.questions[0].qtype == dns::qTypeCNAME
|| msg.questions[0].qtype == dns::qTypeAAAA)
{
if(msg.questions[0].IsName("localhost.loki"))
return true;

@ -1,7 +1,6 @@
#include <hook/shell.hpp>
#if defined(_WIN32)
/** put win32 stuff here */
#else
#if defined(ENABLE_SHELLHOOKS)
#include <util/thread_pool.hpp>
#include <util/logger.hpp>
#include <sys/wait.h>
@ -10,21 +9,16 @@
// Not all systems declare this variable
extern char **environ;
#endif
#endif
#if defined(Darwin)
#include <crt_externs.h>
#endif
#endif
namespace llarp
{
namespace hooks
{
#if defined(_WIN32)
Backend_ptr ExecShellBackend(std::string)
{
return nullptr;
}
#else
#if defined(ENABLE_SHELLHOOKS)
struct ExecShellHookBackend
: public IBackend,
public std::enable_shared_from_this< ExecShellHookBackend >
@ -157,6 +151,11 @@ namespace llarp
return nullptr;
return ptr;
}
#else
Backend_ptr ExecShellBackend(std::string)
{
return nullptr;
}
#endif
} // namespace hooks
} // namespace llarp

@ -20,14 +20,14 @@ namespace llarp
return false;
return *strbuf.cur == 'i';
}
else if(key == "n")
if(key == "n")
{
if(N.BDecode(buf))
return true;
llarp::LogWarn("failed to decode nonce in LIM");
return false;
}
else if(key == "p")
if(key == "p")
{
return bencode_read_integer(buf, &P);
}

@ -74,6 +74,7 @@ namespace llarp
}
break;
}
return {};
}
template < typename Value >

@ -38,10 +38,8 @@ namespace llarp
{
return {};
}
else
{
return std::to_string(d);
}
return std::to_string(d);
}
absl::optional< std::string >

@ -945,7 +945,7 @@ namespace llarp
result = addr;
return true;
}
else if(af == AF_INET6)
if(af == AF_INET6)
{
sockaddr_in6 addr6;
addr6.sin6_family = AF_INET6;
@ -954,10 +954,9 @@ namespace llarp
result = addr6;
return true;
}
else
{
// TODO: implement sockaddr_ll
}
// TODO: implement sockaddr_ll
return false;
}

@ -123,7 +123,7 @@ namespace llarp
LogError("IPv6 address not supported yet", str);
return false;
}
else if(res->ai_family != AF_INET)
if(res->ai_family != AF_INET)
{
LogError("Address family not supported yet", str);
return false;
@ -359,16 +359,16 @@ namespace llarp
{
if(af() == AF_INET)
return (const sockaddr*)&_addr4;
else
return (const sockaddr*)&_addr;
return (const sockaddr*)&_addr;
}
Addr::operator sockaddr*() const
{
if(af() == AF_INET)
return (sockaddr*)&_addr4;
else
return (sockaddr*)&_addr;
return (sockaddr*)&_addr;
}
bool
@ -376,9 +376,9 @@ namespace llarp
{
if(af() == AF_INET && other.af() == AF_INET)
return port() < other.port() || addr4()->s_addr < other.addr4()->s_addr;
else
return port() < other.port() || *addr6() < *other.addr6()
|| af() < other.af();
return port() < other.port() || *addr6() < *other.addr6()
|| af() < other.af();
}
bool
@ -386,9 +386,9 @@ namespace llarp
{
if(af() == AF_INET && other.af() == AF_INET)
return port() == other.port() && addr4()->s_addr == other.addr4()->s_addr;
else
return af() == other.af() && memcmp(addr6(), other.addr6(), 16) == 0
&& port() == other.port();
return af() == other.af() && memcmp(addr6(), other.addr6(), 16) == 0
&& port() == other.port();
}
Addr&
@ -471,8 +471,8 @@ namespace llarp
{
if(af() == AF_INET)
return sizeof(sockaddr_in);
else
return sizeof(sockaddr_in6);
return sizeof(sockaddr_in6);
}
bool

@ -84,11 +84,9 @@ namespace llarp
llarp::LogWarn("Not in presentation format");
return false;
}
else
{
llarp::LogWarn("inet_pton failure");
return false;
}
llarp::LogWarn("inet_pton failure");
return false;
}
return true;
}

@ -178,6 +178,7 @@ namespace llarp
break;
case ePathIgnore:
obj.Put("status", "ignored");
break;
default:
obj.Put("status", "unknown");
break;
@ -272,10 +273,10 @@ namespace llarp
{
if(_status == ePathEstablished || _status == ePathTimeout)
return now >= ExpireTime();
else if(_status == ePathBuilding)
if(_status == ePathBuilding)
return false;
else
return true;
return true;
}
std::string
@ -435,11 +436,9 @@ namespace llarp
LogDebug("path latency is now ", intro.latency, " for ", Name());
return true;
}
else
{
LogWarn("unwarranted path latency message via ", Upstream());
return false;
}
LogWarn("unwarranted path latency message via ", Upstream());
return false;
}
bool
@ -467,8 +466,8 @@ namespace llarp
_role &= ~ePathRoleExit;
return true;
}
else
LogError(Name(), " CXM from exit with bad signature");
LogError(Name(), " CXM from exit with bad signature");
}
else
LogError(Name(), " unwarranted CXM");

@ -364,8 +364,8 @@ namespace llarp
{
return established[randint() % sz];
}
else
return nullptr;
return nullptr;
}
} // namespace path

@ -109,17 +109,15 @@ namespace llarp
m_LastActivity = r->Now();
return r->ParseRoutingMessageBuffer(buf, this, info.rxID);
}
else
{
RelayUpstreamMessage msg;
msg.pathid = info.txID;
msg.Y = Y ^ nonceXOR;
msg.X = buf;
llarp::LogDebug("relay ", msg.X.size(), " bytes upstream from ",
info.downstream, " to ", info.upstream);
return r->SendToOrQueue(info.upstream, &msg);
}
RelayUpstreamMessage msg;
msg.pathid = info.txID;
msg.Y = Y ^ nonceXOR;
msg.X = buf;
llarp::LogDebug("relay ", msg.X.size(), " bytes upstream from ",
info.downstream, " to ", info.upstream);
return r->SendToOrQueue(info.upstream, &msg);
}
bool
@ -283,8 +281,8 @@ namespace llarp
}
return sent;
}
else
llarp::LogError("No exit endpoint on ", info);
llarp::LogError("No exit endpoint on ", info);
// discarded
llarp::routing::DataDiscardMessage discard(info.rxID, msg.S);
return SendRoutingMessage(discard, r);

@ -193,10 +193,8 @@ namespace llarp
_logic->queue_func(std::bind(&on_try_connecting, job));
return true;
}
else
{
itr.first->second->Attempt();
}
itr.first->second->Attempt();
}
return false;
}
@ -444,8 +442,8 @@ namespace llarp
return false;
if(usingSNSeed)
return llarp_loadServiceNodeIdentityKey(ident_keyfile, _identity);
else
return llarp_findOrCreateIdentity(ident_keyfile, _identity);
return llarp_findOrCreateIdentity(ident_keyfile, _identity);
}
bool
@ -603,10 +601,10 @@ namespace llarp
{
if(strictConnectPubkeys.size() && strictConnectPubkeys.count(router) == 0)
return false;
else if(IsServiceNode() && whitelistRouters)
if(IsServiceNode() && whitelistRouters)
return lokinetRouters.find(router) != lokinetRouters.end();
else
return true;
return true;
}
void

@ -16,11 +16,11 @@ namespace llarp
{
return llarp::dht::DecodeMesssageList(from, val, M, true);
}
else if(key == "S")
if(key == "S")
{
return bencode_read_integer(val, &S);
}
else if(key == "V")
if(key == "V")
{
return bencode_read_integer(val, &V);
}

@ -108,10 +108,8 @@ namespace llarp
firstKey = false;
return msg != nullptr;
}
else
{
return msg->DecodeKey(*key, buffer);
}
return msg->DecodeKey(*key, buffer);
}
bool

@ -41,14 +41,12 @@ namespace llarp
{
return HandleJSONResult({});
}
else if(itr.value().is_object())
if(itr.value().is_object())
{
return HandleJSONResult(itr.value());
}
else
{
return false;
}
return false;
}
void
@ -277,11 +275,11 @@ namespace llarp
{
return ListNeighboors();
}
else if(method == "llarp.admin.exit.list")
if(method == "llarp.admin.exit.list")
{
return ListExitLevels();
}
else if(method == "llarp.admin.dumpstate")
if(method == "llarp.admin.dumpstate")
{
return DumpState();
}

@ -247,12 +247,10 @@ namespace llarp
LogError("failed to start hidden service endpoint ", conf.first);
return false;
}
else
{
LogInfo("added hidden service endpoint ", service->Name());
m_Endpoints.emplace(conf.first, service);
return true;
}
LogInfo("added hidden service endpoint ", service->Name());
m_Endpoints.emplace(conf.first, service);
return true;
}
} // namespace service
} // namespace llarp

@ -114,8 +114,8 @@ namespace llarp
{
if(m_IsolatedNetLoop)
return m_IsolatedNetLoop;
else
return m_Router->netloop();
return m_Router->netloop();
}
bool
@ -396,10 +396,8 @@ namespace llarp
IntroSetPublished();
return true;
}
else
{
remote.insert(introset);
}
remote.insert(introset);
}
auto itr = m_PendingLookups.find(msg->T);
if(itr == m_PendingLookups.end())
@ -900,7 +898,7 @@ namespace llarp
m_InboundTrafficQueue.emplace(msg);
return true;
}
else if(msg->proto == eProtocolControl)
if(msg->proto == eProtocolControl)
{
// TODO: implement me (?)
// right now it's just random noise
@ -986,8 +984,8 @@ namespace llarp
}
return false;
}
else
PutNewOutboundContext(*introset);
PutNewOutboundContext(*introset);
return true;
}

@ -41,8 +41,8 @@ namespace llarp
pq = str.base;
return true;
}
else
return false;
return false;
}
if(!BEncodeMaybeReadDictEntry("s", signkey, read, key, buf))
return false;

@ -150,7 +150,7 @@ namespace llarp
{
return false;
}
else if(!W.has_value())
if(!W.has_value())
{
LogWarn("intro has too high expire time");
return false;

@ -357,20 +357,18 @@ namespace llarp
BuildOneAlignedTo(m_NextIntro.router);
return true;
}
else
// we didn't shift check if we should update introset
if(now - lastShift >= MIN_SHIFT_INTERVAL
|| currentIntroSet.HasExpiredIntros(now)
|| currentIntroSet.IsExpired(now))
{
// we didn't shift check if we should update introset
if(now - lastShift >= MIN_SHIFT_INTERVAL
|| currentIntroSet.HasExpiredIntros(now)
|| currentIntroSet.IsExpired(now))
{
// update introset
LogInfo(Name(), " updating introset");
UpdateIntroSet(true);
return true;
}
return false;
// update introset
LogInfo(Name(), " updating introset");
UpdateIntroSet(true);
return true;
}
return false;
}
bool

@ -12,8 +12,8 @@ llarp_buffer_t::size_left() const
{
return 0;
}
else
return sz - diff;
return sz - diff;
}
bool
@ -110,8 +110,8 @@ llarp_buffer_t::read_until(char delim, byte_t* result, size_t resultsize)
if(size_left())
return read;
else
return 0;
return 0;
}
bool

@ -132,11 +132,9 @@ namespace llarp
nextTickAt = start + nextTickInterval;
return;
}
else
{
nextTickInterval = initialIntervalMs;
dropNum = 0;
}
nextTickInterval = initialIntervalMs;
dropNum = 0;
}
visitor(*item);
item->~T();

@ -13,10 +13,10 @@ namespace llarp
{
if(left && right)
return Compare()(*left, *right);
else
return Compare()(left, right);
return Compare()(left, right);
}
};
} // namespace llarp
#endif
#endif

@ -236,15 +236,13 @@ namespace llarp
}
return {result, now - manager.m_createTime};
}
else
auto tmp = now - it->second;
if(clear)
{
auto tmp = now - it->second;
if(clear)
{
it->second = now;
}
return {result, tmp};
it->second = now;
}
return {result, tmp};
}
template < typename Type >
@ -723,10 +721,8 @@ namespace llarp
{
return {};
}
else
{
return it->second;
}
return it->second;
}
absl::optional< absl::Duration >
@ -738,10 +734,8 @@ namespace llarp
{
return {};
}
else
{
return m_defaultInterval;
}
return m_defaultInterval;
}
std::vector< std::pair< const Category *, absl::Duration > >

@ -39,11 +39,9 @@ namespace llarp
stream << "Bad format " << format.m_format << " applied to " << data;
return stream;
}
else
{
stream << vec.data();
return stream;
}
stream << vec.data();
return stream;
}
string_view

@ -335,10 +335,8 @@ namespace llarp
return m_description->toString();
;
}
else
{
return "INVALID_METRIC";
}
return "INVALID_METRIC";
}
std::ostream &

@ -136,14 +136,12 @@ namespace llarp
{
return difference - modulo;
}
else if(difference < -static_cast< int32_t >(modulo / 2))
if(difference < -static_cast< int32_t >(modulo / 2))
{
return difference + modulo;
}
else
{
return difference;
}
return difference;
}
uint32_t

@ -14,28 +14,26 @@ namespace llarp
{
return true;
}
else if(lhs.size() > rhs.size())
if(lhs.size() > rhs.size())
{
return false;
}
else
for(size_t i = 0; i < lhs.size(); ++i)
{
for(size_t i = 0; i < lhs.size(); ++i)
{
auto l = std::tolower(lhs[i]);
auto r = std::tolower(rhs[i]);
auto l = std::tolower(lhs[i]);
auto r = std::tolower(rhs[i]);
if(l < r)
{
return true;
}
else if(l > r)
{
return false;
}
if(l < r)
{
return true;
}
if(l > r)
{
return false;
}
return false;
}
return false;
}
bool
@ -65,7 +63,7 @@ namespace llarp
{
return strncmp(s1, s2, sz1) == 0;
}
else
return false;
return false;
}
} // namespace llarp

@ -182,10 +182,8 @@ namespace llarp
{
return m_threads.size() - m_idleThreads.load(std::memory_order_relaxed);
}
else
{
return 0;
}
return 0;
}
inline size_t

@ -4,6 +4,9 @@
#ifdef POSIX
#include <pthread.h>
#if defined(__FreeBSD__)
#include <pthread_np.h>
#endif
#endif
namespace llarp
@ -14,16 +17,23 @@ namespace llarp
SetThreadName(const std::string& name)
{
#ifdef POSIX
#ifdef __MACH__
const int rc = pthread_setname_np(name.c_str());
#if defined(__FreeBSD__)
/* on free bsd this function has void return type */
pthread_set_name_np(pthread_self(), name.c_str());
#else
#if defined(__MACH__)
const int rc = pthread_setname_np(name.c_str());
#elif defined(__linux__)
const int rc = pthread_setname_np(pthread_self(), name.c_str());
#else
#error "unsupported platform"
#endif
if(rc)
{
LogError("Failed to set thread name to ", name, " errno = ", rc,
" errstr = ", strerror(rc));
}
#endif
#else
LogInfo("Thread name setting not supported on this platform");
(void)name;

@ -43,8 +43,8 @@ struct llarp_threadpool
{
if(impl)
return impl->tryAddJob(f);
else
return jobs->tryPushBack(f) == llarp::thread::QueueReturn::Success;
return jobs->tryPushBack(f) == llarp::thread::QueueReturn::Success;
}
};

@ -63,6 +63,11 @@ public:
path(const char*);
template< typename Iterator >
path(Iterator first, Iterator last) : s(first, last)
{
}
/// Copy constructor
path(const path&);

Loading…
Cancel
Save