mirror of https://github.com/oxen-io/lokinet
Fix gcc trunk warnings
This commit is contained in:
parent
4763888d2c
commit
f9e9227e19
|
@ -70,6 +70,9 @@ endif(WIN32)
|
|||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_EXTENSIONS OFF)
|
||||
|
||||
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND SHADOW)
|
||||
message( FATAL_ERROR "shadow-framework is Linux only" )
|
||||
|
|
|
@ -416,7 +416,7 @@ namespace abyss
|
|||
bool
|
||||
JSONRPC::RunAsync(llarp_ev_loop_ptr loop, const std::string& remote)
|
||||
{
|
||||
strncpy(m_connect.remote, remote.c_str(), sizeof(m_connect.remote));
|
||||
strncpy(m_connect.remote, remote.c_str(), sizeof(m_connect.remote) - 1);
|
||||
// TODO: ipv6
|
||||
m_connect.connected = &JSONRPC::OnConnected;
|
||||
m_connect.error = &JSONRPC::OnConnectFail;
|
||||
|
|
|
@ -83,10 +83,9 @@ struct UTPSocketKey
|
|||
uint32 recv_id; // "conn_seed", "conn_id"
|
||||
|
||||
UTPSocketKey(const PackedSockAddr &_addr, uint32 _recv_id)
|
||||
: addr(_addr)
|
||||
, recv_id(_recv_id)
|
||||
{
|
||||
memset(this, 0, sizeof(*this));
|
||||
addr = _addr;
|
||||
recv_id = _recv_id;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -16,12 +16,12 @@ namespace llarp
|
|||
{
|
||||
}
|
||||
|
||||
explicit Key_t(const Data& val) : AlignedBuffer< SIZE >(val)
|
||||
explicit Key_t(const Data& data) : AlignedBuffer< SIZE >(data)
|
||||
{
|
||||
}
|
||||
|
||||
explicit Key_t(const AlignedBuffer< SIZE >& val)
|
||||
: AlignedBuffer< SIZE >(val)
|
||||
explicit Key_t(const AlignedBuffer< SIZE >& data)
|
||||
: AlignedBuffer< SIZE >(data)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ namespace llarp
|
|||
namespace dht
|
||||
{
|
||||
LocalRouterLookup::LocalRouterLookup(const PathID_t &path, uint64_t txid,
|
||||
const RouterID &target,
|
||||
const RouterID &_target,
|
||||
AbstractContext *ctx)
|
||||
: RecursiveRouterLookup(TXOwner{ctx->OurKey(), txid}, target, ctx,
|
||||
: RecursiveRouterLookup(TXOwner{ctx->OurKey(), txid}, _target, ctx,
|
||||
nullptr)
|
||||
, localPath(path)
|
||||
{
|
||||
|
|
|
@ -11,9 +11,9 @@ namespace llarp
|
|||
namespace dht
|
||||
{
|
||||
LocalTagLookup::LocalTagLookup(const PathID_t &path, uint64_t txid,
|
||||
const service::Tag &target,
|
||||
const service::Tag &_target,
|
||||
AbstractContext *ctx)
|
||||
: TagLookup(TXOwner{ctx->OurKey(), txid}, target, ctx, 0)
|
||||
: TagLookup(TXOwner{ctx->OurKey(), txid}, _target, ctx, 0)
|
||||
, localPath(path)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@ namespace llarp
|
|||
{
|
||||
namespace dht
|
||||
{
|
||||
RecursiveRouterLookup::RecursiveRouterLookup(const TXOwner &whoasked,
|
||||
const RouterID &target,
|
||||
RecursiveRouterLookup::RecursiveRouterLookup(const TXOwner &_whoasked,
|
||||
const RouterID &_target,
|
||||
AbstractContext *ctx,
|
||||
RouterLookupHandler result)
|
||||
: TX< RouterID, RouterContact >(whoasked, target, ctx)
|
||||
: TX< RouterID, RouterContact >(_whoasked, _target, ctx)
|
||||
, resultHandler(result)
|
||||
|
||||
{
|
||||
|
|
|
@ -538,8 +538,8 @@ namespace llarp
|
|||
}
|
||||
|
||||
/// inbound
|
||||
tcp_conn(llarp_ev_loop* loop, int fd)
|
||||
: ev_io(fd, new LosslessWriteQueue_t{}), _conn(nullptr)
|
||||
tcp_conn(llarp_ev_loop* loop, int _fd)
|
||||
: ev_io(_fd, new LosslessWriteQueue_t{}), _conn(nullptr)
|
||||
{
|
||||
tcp.impl = this;
|
||||
tcp.loop = loop;
|
||||
|
@ -551,9 +551,9 @@ namespace llarp
|
|||
}
|
||||
|
||||
/// outbound
|
||||
tcp_conn(llarp_ev_loop* loop, int fd, const sockaddr* addr,
|
||||
tcp_conn(llarp_ev_loop* loop, int _fd, const sockaddr* addr,
|
||||
llarp_tcp_connecter* conn)
|
||||
: ev_io(fd, new LosslessWriteQueue_t{}), _conn(conn)
|
||||
: ev_io(_fd, new LosslessWriteQueue_t{}), _conn(conn)
|
||||
{
|
||||
socklen_t slen = sizeof(sockaddr_in);
|
||||
if(addr->sa_family == AF_INET6)
|
||||
|
@ -645,8 +645,8 @@ namespace llarp
|
|||
{
|
||||
llarp_ev_loop* loop;
|
||||
llarp_tcp_acceptor* tcp;
|
||||
tcp_serv(llarp_ev_loop* l, int fd, llarp_tcp_acceptor* t)
|
||||
: ev_io(fd), loop(l), tcp(t)
|
||||
tcp_serv(llarp_ev_loop* l, int _fd, llarp_tcp_acceptor* t)
|
||||
: ev_io(_fd), loop(l), tcp(t)
|
||||
{
|
||||
tcp->impl = this;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "ev_libuv.hpp"
|
||||
#include "net/net_addr.hpp"
|
||||
#include <ev/ev_libuv.hpp>
|
||||
#include <net/net_addr.hpp>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace libuv
|
||||
{
|
||||
|
@ -517,7 +519,9 @@ namespace libuv
|
|||
bool
|
||||
Init(uv_loop_t* loop)
|
||||
{
|
||||
strncpy(m_Device->if_name, m_Tun->ifname, sizeof(m_Device->if_name));
|
||||
std::copy(std::begin(m_Tun->ifname), std::end(m_Tun->ifname),
|
||||
m_Device->if_name);
|
||||
memcpy(m_Device->if_name, m_Tun->ifname, sizeof(m_Device->if_name));
|
||||
if(tuntap_start(m_Device, TUNTAP_MODE_TUNNEL, 0) == -1)
|
||||
{
|
||||
llarp::LogError("failed to start up ", m_Tun->ifname);
|
||||
|
|
|
@ -12,11 +12,11 @@ namespace llarp
|
|||
namespace exit
|
||||
{
|
||||
BaseSession::BaseSession(
|
||||
const llarp::RouterID& router,
|
||||
const llarp::RouterID& routerId,
|
||||
std::function< bool(const llarp_buffer_t&) > writepkt,
|
||||
AbstractRouter* r, size_t numpaths, size_t hoplen, bool bundleRC)
|
||||
: llarp::path::Builder(r, numpaths, hoplen)
|
||||
, m_ExitRouter(router)
|
||||
, m_ExitRouter(routerId)
|
||||
, m_WritePacket(writepkt)
|
||||
, m_Counter(0)
|
||||
, m_LastUse(0)
|
||||
|
@ -82,7 +82,7 @@ namespace llarp
|
|||
{
|
||||
if(db->Get(m_ExitRouter, cur))
|
||||
return true;
|
||||
router->LookupRouter(m_ExitRouter, nullptr);
|
||||
m_router->LookupRouter(m_ExitRouter, nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ namespace llarp
|
|||
llarp::LogError("Failed to sign exit request");
|
||||
return;
|
||||
}
|
||||
if(p->SendExitRequest(obtain, router))
|
||||
if(p->SendExitRequest(obtain, m_router))
|
||||
llarp::LogInfo("asking ", m_ExitRouter, " for exit");
|
||||
else
|
||||
llarp::LogError("failed to send exit request");
|
||||
|
@ -128,7 +128,7 @@ namespace llarp
|
|||
bool
|
||||
BaseSession::HandleGotExit(llarp::path::Path_ptr p, llarp_time_t b)
|
||||
{
|
||||
m_LastUse = router->Now();
|
||||
m_LastUse = m_router->Now();
|
||||
if(b == 0)
|
||||
{
|
||||
llarp::LogInfo("obtained an exit via ", p->Endpoint());
|
||||
|
@ -164,7 +164,7 @@ namespace llarp
|
|||
{
|
||||
llarp::LogInfo(p->Name(), " closing exit path");
|
||||
routing::CloseExitMessage msg;
|
||||
if(msg.Sign(m_ExitIdentity) && p->SendExitClose(msg, router))
|
||||
if(msg.Sign(m_ExitIdentity) && p->SendExitClose(msg, m_router))
|
||||
{
|
||||
p->ClearRoles(roles);
|
||||
}
|
||||
|
@ -185,12 +185,12 @@ namespace llarp
|
|||
{
|
||||
LogInfo(p->Name(), " closing exit path");
|
||||
routing::CloseExitMessage msg;
|
||||
if(!(msg.Sign(m_ExitIdentity) && p->SendExitClose(msg, router)))
|
||||
if(!(msg.Sign(m_ExitIdentity) && p->SendExitClose(msg, m_router)))
|
||||
LogWarn(p->Name(), " failed to send exit close message");
|
||||
}
|
||||
};
|
||||
ForEachPath(sendExitClose);
|
||||
router->pathContext().RemovePathSet(shared_from_this());
|
||||
m_router->pathContext().RemovePathSet(shared_from_this());
|
||||
return path::Builder::Stop();
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ namespace llarp
|
|||
if(!pkt.Load(buf))
|
||||
return false;
|
||||
m_Downstream.emplace(counter, pkt);
|
||||
m_LastUse = router->Now();
|
||||
m_LastUse = m_router->Now();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ namespace llarp
|
|||
{
|
||||
llarp::LogError("dropped traffic on exit ", m_ExitRouter, " S=", s,
|
||||
" P=", path);
|
||||
p->EnterState(path::ePathIgnore, router->Now());
|
||||
p->EnterState(path::ePathIgnore, m_router->Now());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ namespace llarp
|
|||
bool
|
||||
BaseSession::FlushUpstream()
|
||||
{
|
||||
auto now = router->Now();
|
||||
auto now = m_router->Now();
|
||||
auto path = PickRandomEstablishedPath(llarp::path::ePathRoleExit);
|
||||
if(path)
|
||||
{
|
||||
|
@ -282,7 +282,7 @@ namespace llarp
|
|||
if(path)
|
||||
{
|
||||
msg.S = path->NextSeqNo();
|
||||
if(path->SendRoutingMessage(msg, router))
|
||||
if(path->SendRoutingMessage(msg, m_router))
|
||||
m_LastUse = now;
|
||||
}
|
||||
queue.pop_front();
|
||||
|
@ -302,7 +302,7 @@ namespace llarp
|
|||
m_Upstream.clear();
|
||||
if(numHops == 1)
|
||||
{
|
||||
auto r = router;
|
||||
auto r = m_router;
|
||||
RouterContact rc;
|
||||
if(r->nodedb()->Get(m_ExitRouter, rc))
|
||||
r->TryConnectAsync(rc, 5);
|
||||
|
|
|
@ -125,7 +125,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
RouterContact rc;
|
||||
if(!router->nodedb()->Get(connect, rc))
|
||||
if(!m_router->nodedb()->Get(connect, rc))
|
||||
{
|
||||
LogError(Name(), " we don't have the RC for ", v,
|
||||
" so we can't use it in strict-connect");
|
||||
|
@ -152,8 +152,8 @@ namespace llarp
|
|||
}
|
||||
m_Exit = std::make_shared< llarp::exit::ExitSession >(
|
||||
exitRouter,
|
||||
util::memFn(&TunEndpoint::QueueInboundPacketForExit, this), router,
|
||||
numPaths, numHops, ShouldBundleRC());
|
||||
util::memFn(&TunEndpoint::QueueInboundPacketForExit, this),
|
||||
m_router, numPaths, numHops, ShouldBundleRC());
|
||||
llarp::LogInfo(Name(), " using exit at ", exitRouter);
|
||||
}
|
||||
if(k == "local-dns")
|
||||
|
|
|
@ -23,12 +23,6 @@ namespace llarp
|
|||
{
|
||||
}
|
||||
|
||||
Addr::Addr(const Addr& other)
|
||||
{
|
||||
memcpy(&_addr, &other._addr, sizeof(sockaddr_in6));
|
||||
memcpy(&_addr4, &other._addr4, sizeof(sockaddr_in));
|
||||
}
|
||||
|
||||
void
|
||||
Addr::port(uint16_t port)
|
||||
{
|
||||
|
|
|
@ -21,8 +21,6 @@ namespace llarp
|
|||
|
||||
Addr();
|
||||
|
||||
Addr(const Addr& other);
|
||||
|
||||
Addr(string_view str);
|
||||
|
||||
Addr(string_view str, const uint16_t p_port);
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace llarp
|
|||
namespace path
|
||||
{
|
||||
Builder::Builder(AbstractRouter* p_router, size_t pathNum, size_t hops)
|
||||
: path::PathSet(pathNum), _run(true), router(p_router), numHops(hops)
|
||||
: path::PathSet(pathNum), _run(true), m_router(p_router), numHops(hops)
|
||||
{
|
||||
CryptoManager::instance()->encryption_keygen(enckey);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ namespace llarp
|
|||
ExpirePaths(now);
|
||||
if(ShouldBuildMore(now))
|
||||
BuildOne();
|
||||
TickPaths(now, router);
|
||||
TickPaths(now, m_router);
|
||||
if(m_BuildStats.attempts > 50)
|
||||
{
|
||||
if(m_BuildStats.SuccsessRatio() <= BuildStats::MinGoodRatio
|
||||
|
@ -204,14 +204,14 @@ namespace llarp
|
|||
size_t tries = 10;
|
||||
if(hop == 0)
|
||||
{
|
||||
if(router->NumberOfConnectedRouters() == 0)
|
||||
if(m_router->NumberOfConnectedRouters() == 0)
|
||||
{
|
||||
// persist connection
|
||||
router->ConnectToRandomRouters(1);
|
||||
m_router->ConnectToRandomRouters(1);
|
||||
return false;
|
||||
}
|
||||
bool got = false;
|
||||
router->ForEachPeer(
|
||||
m_router->ForEachPeer(
|
||||
[&](const ILinkSession* s, bool isOutbound) {
|
||||
if(s && s->IsEstablished() && isOutbound && !got)
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ namespace llarp
|
|||
if(db->select_random_hop_excluding(cur, excluding))
|
||||
{
|
||||
excluding.insert(cur.pubkey);
|
||||
if(!router->routerProfiling().IsBadForPath(cur.pubkey))
|
||||
if(!m_router->routerProfiling().IsBadForPath(cur.pubkey))
|
||||
return true;
|
||||
}
|
||||
} while(tries > 0);
|
||||
|
@ -285,7 +285,7 @@ namespace llarp
|
|||
Builder::BuildOne(PathRole roles)
|
||||
{
|
||||
std::vector< RouterContact > hops(numHops);
|
||||
if(SelectHops(router->nodedb(), hops, roles))
|
||||
if(SelectHops(m_router->nodedb(), hops, roles))
|
||||
Build(hops, roles);
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ namespace llarp
|
|||
std::vector< RouterContact >& hops)
|
||||
{
|
||||
const auto aligned =
|
||||
router->pathContext().FindOwnedPathsWithEndpoint(remote);
|
||||
m_router->pathContext().FindOwnedPathsWithEndpoint(remote);
|
||||
/// pick the lowest latency path that aligns to remote
|
||||
/// note: peer exhaustion is made worse happen here
|
||||
Path_ptr p;
|
||||
|
@ -332,7 +332,7 @@ namespace llarp
|
|||
std::set< RouterID > routers{remote};
|
||||
hops.resize(numHops);
|
||||
|
||||
auto nodedb = router->nodedb();
|
||||
auto nodedb = m_router->nodedb();
|
||||
for(size_t idx = 0; idx < hops.size(); idx++)
|
||||
{
|
||||
hops[idx].Clear();
|
||||
|
@ -341,7 +341,7 @@ namespace llarp
|
|||
// last hop
|
||||
if(!nodedb->Get(remote, hops[idx]))
|
||||
{
|
||||
router->LookupRouter(remote, nullptr);
|
||||
m_router->LookupRouter(remote, nullptr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ namespace llarp
|
|||
{
|
||||
std::vector< RouterContact > hops;
|
||||
/// if we really need this path build it "dangerously"
|
||||
if(UrgentBuild(router->Now()))
|
||||
if(UrgentBuild(m_router->Now()))
|
||||
{
|
||||
if(!DoUrgentBuildAlignedTo(remote, hops))
|
||||
{
|
||||
|
@ -411,7 +411,7 @@ namespace llarp
|
|||
llarp_time_t
|
||||
Builder::Now() const
|
||||
{
|
||||
return router->Now();
|
||||
return m_router->Now();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -422,13 +422,13 @@ namespace llarp
|
|||
lastBuild = Now();
|
||||
// async generate keys
|
||||
auto ctx = std::make_shared< AsyncPathKeyExchangeContext >();
|
||||
ctx->router = router;
|
||||
ctx->router = m_router;
|
||||
ctx->pathset = GetSelf();
|
||||
auto path = std::make_shared< path::Path >(hops, this, roles);
|
||||
LogInfo(Name(), " build ", path->HopsString());
|
||||
path->SetBuildResultHook(
|
||||
[this](Path_ptr p) { this->HandlePathBuilt(p); });
|
||||
ctx->AsyncGenerateKeys(path, router->logic(), router->threadpool(),
|
||||
ctx->AsyncGenerateKeys(path, m_router->logic(), m_router->threadpool(),
|
||||
&PathBuilderKeysGenerated);
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ namespace llarp
|
|||
Builder::HandlePathBuilt(Path_ptr p)
|
||||
{
|
||||
buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;
|
||||
router->routerProfiling().MarkPathSuccess(p.get());
|
||||
m_router->routerProfiling().MarkPathSuccess(p.get());
|
||||
LogInfo(p->Name(), " built latency=", p->intro.latency);
|
||||
m_BuildStats.success++;
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ namespace llarp
|
|||
void
|
||||
Builder::HandlePathBuildTimeout(Path_ptr p)
|
||||
{
|
||||
router->routerProfiling().MarkPathFail(p.get());
|
||||
m_router->routerProfiling().MarkPathFail(p.get());
|
||||
PathSet::HandlePathBuildTimeout(p);
|
||||
DoPathBuildBackoff();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace llarp
|
|||
std::vector< RouterContact >& hops);
|
||||
|
||||
public:
|
||||
AbstractRouter* router;
|
||||
AbstractRouter* m_router;
|
||||
SecretKey enckey;
|
||||
size_t numHops;
|
||||
llarp_time_t lastBuild = 0;
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace llarp
|
|||
|
||||
size_t attemptCount = 0;
|
||||
|
||||
PendingSession(const RouterContact &rc, LinkLayer_ptr link)
|
||||
: rc(rc), link(link)
|
||||
PendingSession(const RouterContact &_rc, LinkLayer_ptr _link)
|
||||
: rc(_rc), link(_link)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -10,11 +10,11 @@ namespace llarp
|
|||
bool
|
||||
DHTMessage::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val)
|
||||
{
|
||||
llarp::dht::Key_t from;
|
||||
from.Zero();
|
||||
llarp::dht::Key_t fromKey;
|
||||
fromKey.Zero();
|
||||
if(key == "M")
|
||||
{
|
||||
return llarp::dht::DecodeMesssageList(from, val, M, true);
|
||||
return llarp::dht::DecodeMesssageList(fromKey, val, M, true);
|
||||
}
|
||||
if(key == "S")
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace llarp
|
|||
IDataHandler* h, const ConvoTag& t,
|
||||
ProtocolType proto)
|
||||
: logic(l)
|
||||
, remote(r)
|
||||
, m_remote(r)
|
||||
, m_LocalIdentity(localident)
|
||||
, introPubKey(introsetPubKey)
|
||||
, remoteIntro(remote)
|
||||
|
@ -32,7 +32,7 @@ namespace llarp
|
|||
{
|
||||
AsyncKeyExchange* self = static_cast< AsyncKeyExchange* >(user);
|
||||
// put values
|
||||
self->handler->PutSenderFor(self->msg.tag, self->remote, false);
|
||||
self->handler->PutSenderFor(self->msg.tag, self->m_remote, false);
|
||||
self->handler->PutCachedSessionKeyFor(self->msg.tag, self->sharedKey);
|
||||
self->handler->PutIntroFor(self->msg.tag, self->remoteIntro);
|
||||
self->handler->PutReplyIntroFor(self->msg.tag, self->msg.introReply);
|
||||
|
@ -55,7 +55,7 @@ namespace llarp
|
|||
SharedSecret sharedSecret;
|
||||
path_dh_func dh_client = util::memFn(&Crypto::dh_client, crypto);
|
||||
if(!self->m_LocalIdentity.KeyExchange(dh_client, sharedSecret,
|
||||
self->remote, self->frame.N))
|
||||
self->m_remote, self->frame.N))
|
||||
{
|
||||
LogError("failed to derive x25519 shared key component");
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace llarp
|
|||
{
|
||||
std::shared_ptr< Logic > logic;
|
||||
SharedSecret sharedKey;
|
||||
ServiceInfo remote;
|
||||
ServiceInfo m_remote;
|
||||
const Identity& m_LocalIdentity;
|
||||
ProtocolMessage msg;
|
||||
ProtocolFrame frame;
|
||||
|
|
|
@ -191,8 +191,8 @@ namespace llarp
|
|||
{
|
||||
if(!EnsurePathToService(
|
||||
addr,
|
||||
[](ABSL_ATTRIBUTE_UNUSED Address addr,
|
||||
ABSL_ATTRIBUTE_UNUSED OutboundContext* ctx) {},
|
||||
[](ABSL_ATTRIBUTE_UNUSED Address _addr,
|
||||
ABSL_ATTRIBUTE_UNUSED OutboundContext* _ctx) {},
|
||||
10000))
|
||||
{
|
||||
LogWarn("failed to ensure path to ", addr);
|
||||
|
@ -893,7 +893,7 @@ namespace llarp
|
|||
Endpoint::OnLookup(const Address& addr, const IntroSet* introset,
|
||||
const RouterID& endpoint)
|
||||
{
|
||||
const auto now = router->Now();
|
||||
const auto now = Router()->Now();
|
||||
auto& fails = m_state->m_ServiceLookupFails;
|
||||
auto& lookups = m_state->m_PendingServiceLookups;
|
||||
if(introset == nullptr || introset->IsExpired(now))
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace llarp
|
|||
if(k == "paths")
|
||||
{
|
||||
const auto val = atoi(v.c_str());
|
||||
if(val >= 1 && val <= static_cast<int>(path::PathSet::max_paths))
|
||||
if(val >= 1 && val <= static_cast< int >(path::PathSet::max_paths))
|
||||
{
|
||||
ep.numPaths = val;
|
||||
LogInfo(name, " set number of paths to ", ep.numHops);
|
||||
|
@ -56,7 +56,7 @@ namespace llarp
|
|||
if(k == "hops")
|
||||
{
|
||||
const auto val = atoi(v.c_str());
|
||||
if(val >= 1 && val <= static_cast<int>(path::max_len))
|
||||
if(val >= 1 && val <= static_cast< int >(path::max_len))
|
||||
{
|
||||
ep.numHops = val;
|
||||
LogInfo(name, " set number of hops to ", ep.numHops);
|
||||
|
|
|
@ -66,18 +66,6 @@ namespace llarp
|
|||
return !(*this == other);
|
||||
}
|
||||
|
||||
ServiceInfo&
|
||||
operator=(const ServiceInfo& other)
|
||||
{
|
||||
enckey = other.enckey;
|
||||
signkey = other.signkey;
|
||||
version = other.version;
|
||||
vanity = other.vanity;
|
||||
version = other.version;
|
||||
UpdateAddr();
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool
|
||||
operator<(const ServiceInfo& other) const
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace llarp
|
|||
{
|
||||
IServiceLookup::IServiceLookup(ILookupHolder *p, uint64_t tx,
|
||||
const std::string &n)
|
||||
: parent(p), txid(tx), name(n)
|
||||
: m_parent(p), txid(tx), name(n)
|
||||
{
|
||||
m_created = time_now_ms();
|
||||
p->PutLookup(this, tx);
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace llarp
|
|||
bool
|
||||
SendRequestViaPath(path::Path_ptr p, AbstractRouter* r);
|
||||
|
||||
ILookupHolder* parent;
|
||||
ILookupHolder* m_parent;
|
||||
uint64_t txid;
|
||||
const std::string name;
|
||||
RouterID endpoint;
|
||||
|
|
|
@ -405,10 +405,10 @@ namespace llarp
|
|||
LogError("failed to decrypt message");
|
||||
return false;
|
||||
}
|
||||
msg->handler = handler;
|
||||
const PathID_t from = F;
|
||||
msg->handler = handler;
|
||||
const PathID_t fromPath = F;
|
||||
logic->queue_func(
|
||||
[=]() { ProtocolMessage::ProcessAsync(recvPath, from, msg); });
|
||||
[=]() { ProtocolMessage::ProcessAsync(recvPath, fromPath, msg); });
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,7 @@ namespace llarp
|
|||
}
|
||||
|
||||
bool
|
||||
ProtocolFrame::Verify(const ServiceInfo& from) const
|
||||
ProtocolFrame::Verify(const ServiceInfo& svc) const
|
||||
{
|
||||
ProtocolFrame copy(*this);
|
||||
// save signature
|
||||
|
@ -439,7 +439,7 @@ namespace llarp
|
|||
buf.sz = buf.cur - buf.base;
|
||||
buf.cur = buf.base;
|
||||
// verify
|
||||
return from.Verify(buf, Z);
|
||||
return svc.Verify(buf, Z);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace llarp
|
|||
bool
|
||||
CachedTagResult::HandleResponse(const std::set< IntroSet >& introsets)
|
||||
{
|
||||
auto now = parent->Now();
|
||||
auto now = m_parent->Now();
|
||||
|
||||
for(const auto& introset : introsets)
|
||||
if(result.insert(introset).second)
|
||||
|
@ -47,7 +47,7 @@ namespace llarp
|
|||
{
|
||||
auto msg = std::make_shared< routing::DHTMessage >();
|
||||
msg->M.emplace_back(std::make_unique< dht::FindIntroMessage >(tag, txid));
|
||||
lastRequest = parent->Now();
|
||||
lastRequest = m_parent->Now();
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ namespace llarp
|
|||
llarp_time_t lastModified = 0;
|
||||
std::set< IntroSet > result;
|
||||
Tag tag;
|
||||
Endpoint* parent;
|
||||
Endpoint* m_parent;
|
||||
|
||||
CachedTagResult(const Tag& t, Endpoint* p) : tag(t), parent(p)
|
||||
CachedTagResult(const Tag& t, Endpoint* p) : tag(t), m_parent(p)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -33,13 +33,13 @@ namespace llarp
|
|||
|
||||
AlignedBuffer()
|
||||
{
|
||||
new(&val) Data;
|
||||
new(&m_val) Data;
|
||||
Zero();
|
||||
}
|
||||
|
||||
explicit AlignedBuffer(const byte_t* data)
|
||||
{
|
||||
new(&val) Data;
|
||||
new(&m_val) Data;
|
||||
auto& b = as_array();
|
||||
for(size_t idx = 0; idx < sz; ++idx)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ namespace llarp
|
|||
|
||||
explicit AlignedBuffer(const Data& buf)
|
||||
{
|
||||
new(&val) Data;
|
||||
new(&m_val) Data;
|
||||
std::copy(buf.begin(), buf.end(), begin());
|
||||
}
|
||||
|
||||
|
@ -164,13 +164,13 @@ namespace llarp
|
|||
Data&
|
||||
as_array()
|
||||
{
|
||||
return reinterpret_cast< Data& >(val);
|
||||
return reinterpret_cast< Data& >(m_val);
|
||||
}
|
||||
|
||||
const Data&
|
||||
as_array() const
|
||||
{
|
||||
return reinterpret_cast< const Data& >(val);
|
||||
return reinterpret_cast< const Data& >(m_val);
|
||||
}
|
||||
|
||||
byte_t*
|
||||
|
@ -282,7 +282,7 @@ namespace llarp
|
|||
using AlignedStorage = typename std::aligned_storage< sizeof(Data),
|
||||
alignof(uint64_t) >::
|
||||
type; // why did we align to the nearest double-precision float
|
||||
AlignedStorage val;
|
||||
AlignedStorage m_val;
|
||||
};
|
||||
} // namespace llarp
|
||||
|
||||
|
|
|
@ -569,10 +569,10 @@ namespace llarp
|
|||
print(std::ostream &stream, int level, int spaces) const
|
||||
{
|
||||
Printer::PrintFunction< absl::Duration > durationPrinter =
|
||||
[](std::ostream &stream, const absl::Duration &duration, int,
|
||||
[](std::ostream &os, const absl::Duration &duration, int,
|
||||
int) -> std::ostream & {
|
||||
stream << duration;
|
||||
return stream;
|
||||
os << duration;
|
||||
return os;
|
||||
};
|
||||
Printer printer(stream, level, spaces);
|
||||
printer.printAttribute("records", m_records);
|
||||
|
|
|
@ -35,10 +35,10 @@ struct TestTx final : public dht::TX< dht::Key_t, Val_t >
|
|||
struct TestDhtTx : public Test
|
||||
{
|
||||
dht::TXOwner asker;
|
||||
dht::Key_t key;
|
||||
dht::Key_t m_key;
|
||||
TestTx tx;
|
||||
|
||||
TestDhtTx() : tx(asker, key, nullptr)
|
||||
TestDhtTx() : tx(asker, m_key, nullptr)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -75,22 +75,22 @@ TEST(Catalog, Iterator)
|
|||
for(size_t i = 0; i < THREAD_COUNT; ++i)
|
||||
{
|
||||
threads[i] = std::thread(
|
||||
[](Barrier *barrier, Cat *catalog, int32_t id) {
|
||||
barrier->Block();
|
||||
for(size_t i = 0; i < ITERATION_COUNT; ++i)
|
||||
[](Barrier *b, Cat *cat, int32_t id) {
|
||||
b->Block();
|
||||
for(size_t j = 0; j < ITERATION_COUNT; ++j)
|
||||
{
|
||||
int32_t handle = catalog->add(id);
|
||||
absl::optional< int32_t > res = catalog->find(handle);
|
||||
int32_t handle = cat->add(id);
|
||||
absl::optional< int32_t > res = cat->find(handle);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_EQ(res.value(), id);
|
||||
ASSERT_TRUE(catalog->replace(MAX - id, handle));
|
||||
res = catalog->find(handle);
|
||||
ASSERT_TRUE(cat->replace(MAX - id, handle));
|
||||
res = cat->find(handle);
|
||||
ASSERT_TRUE(res);
|
||||
ASSERT_EQ(MAX - id, res.value());
|
||||
int32_t removed = 0;
|
||||
ASSERT_TRUE(catalog->remove(handle, &removed));
|
||||
ASSERT_TRUE(cat->remove(handle, &removed));
|
||||
ASSERT_EQ(removed, MAX - id);
|
||||
ASSERT_FALSE(catalog->find(handle));
|
||||
ASSERT_FALSE(cat->find(handle));
|
||||
}
|
||||
},
|
||||
&barrier, &catalog, i);
|
||||
|
@ -98,11 +98,11 @@ TEST(Catalog, Iterator)
|
|||
|
||||
// Verify the length constraint is never violated
|
||||
threads[THREAD_COUNT] = std::thread(
|
||||
[](Barrier *barrier, Cat *catalog) {
|
||||
barrier->Block();
|
||||
[](Barrier *b, Cat *cat) {
|
||||
b->Block();
|
||||
for(size_t i = 0; i < ITERATION_COUNT; ++i)
|
||||
{
|
||||
size_t size = catalog->size();
|
||||
size_t size = cat->size();
|
||||
ASSERT_LE(size, THREAD_COUNT);
|
||||
}
|
||||
},
|
||||
|
@ -110,13 +110,13 @@ TEST(Catalog, Iterator)
|
|||
|
||||
// Verify that iteration always produces a valid state
|
||||
threads[THREAD_COUNT + 1] = std::thread(
|
||||
[](Barrier *barrier, Cat *catalog) {
|
||||
barrier->Block();
|
||||
[](Barrier *b, Cat *cat) {
|
||||
b->Block();
|
||||
for(size_t i = 0; i < ITERATION_COUNT; ++i)
|
||||
{
|
||||
int32_t arr[100];
|
||||
size_t size = 0;
|
||||
for(Iterator it(catalog); it; ++it)
|
||||
for(Iterator it(cat); it; ++it)
|
||||
{
|
||||
arr[size++] = it().second;
|
||||
}
|
||||
|
@ -133,6 +133,8 @@ TEST(Catalog, Iterator)
|
|||
}
|
||||
}
|
||||
|
||||
(void)present;
|
||||
|
||||
// no duplicate should be there
|
||||
for(size_t k = j + 1; k < size; k++)
|
||||
{
|
||||
|
@ -145,11 +147,11 @@ TEST(Catalog, Iterator)
|
|||
|
||||
// And that we don't have an invalid catalog
|
||||
threads[THREAD_COUNT + 2] = std::thread(
|
||||
[](Barrier *barrier, Cat *catalog) {
|
||||
barrier->Block();
|
||||
[](Barrier *b, Cat *cat) {
|
||||
b->Block();
|
||||
for(size_t i = 0; i < ITERATION_COUNT; ++i)
|
||||
{
|
||||
catalog->verify();
|
||||
cat->verify();
|
||||
}
|
||||
},
|
||||
&barrier, &catalog);
|
||||
|
|
|
@ -272,41 +272,41 @@ TEST(TimerQueue, ThreadSafety)
|
|||
info[i].first = i;
|
||||
info[i].second = &items[i];
|
||||
threads[i] = std::thread(
|
||||
[](Info* info, absl::Barrier* barrier, StringQueue* queue) {
|
||||
const int THREAD_ID = info->first;
|
||||
std::vector< StringItem >* vPtr = info->second;
|
||||
[](Info* nfo, absl::Barrier* b, StringQueue* q) {
|
||||
const int THREAD_ID = nfo->first;
|
||||
std::vector< StringItem >* vPtr = nfo->second;
|
||||
|
||||
// We stagger the removeAll steps among the threads.
|
||||
const int STEP_REMOVE_ALL = THREAD_ID * NUM_REMOVE_ALL / NUM_THREADS;
|
||||
const unsigned int STEP_REMOVE_ALL = THREAD_ID * NUM_REMOVE_ALL / NUM_THREADS;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << THREAD_ID;
|
||||
Data V(oss.str());
|
||||
|
||||
barrier->Block();
|
||||
b->Block();
|
||||
|
||||
size_t newSize;
|
||||
absl::Time newMinTime;
|
||||
StringItem item;
|
||||
for(size_t i = 0; i < NUM_ITERATIONS; ++i)
|
||||
for(size_t j = 0; j < NUM_ITERATIONS; ++j)
|
||||
{
|
||||
const absl::Time TIME =
|
||||
absl::Time() + absl::Seconds((i * (i + 3)) % NUM_ITERATIONS);
|
||||
int h = queue->add(TIME, V);
|
||||
queue->update(h, TIME);
|
||||
if(queue->popFront(&item, &newSize, &newMinTime))
|
||||
absl::Time() + absl::Seconds((j * (j + 3)) % NUM_ITERATIONS);
|
||||
int h = q->add(TIME, V);
|
||||
q->update(h, TIME);
|
||||
if(q->popFront(&item, &newSize, &newMinTime))
|
||||
{
|
||||
vPtr->push_back(item);
|
||||
}
|
||||
h = queue->add(newMinTime, V);
|
||||
queue->popLess(newMinTime, vPtr);
|
||||
if(queue->remove(h, &item, &newSize, &newMinTime))
|
||||
h = q->add(newMinTime, V);
|
||||
q->popLess(newMinTime, vPtr);
|
||||
if(q->remove(h, &item, &newSize, &newMinTime))
|
||||
{
|
||||
vPtr->push_back(item);
|
||||
}
|
||||
if(i % NUM_REMOVE_ALL == STEP_REMOVE_ALL)
|
||||
if(j % NUM_REMOVE_ALL == STEP_REMOVE_ALL)
|
||||
{
|
||||
queue->removeAll(vPtr);
|
||||
q->removeAll(vPtr);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -314,11 +314,11 @@ TEST(TimerQueue, ThreadSafety)
|
|||
}
|
||||
|
||||
threads[NUM_THREADS] = std::thread(
|
||||
[](absl::Barrier* barrier, StringQueue* queue) {
|
||||
barrier->Block();
|
||||
[](absl::Barrier* b, StringQueue* q) {
|
||||
b->Block();
|
||||
for(size_t i = 0; i < NUM_ITERATIONS; ++i)
|
||||
{
|
||||
size_t size = queue->size();
|
||||
size_t size = q->size();
|
||||
ASSERT_GE(size, 0);
|
||||
ASSERT_LE(size, NUM_THREADS);
|
||||
}
|
||||
|
|
|
@ -36,10 +36,10 @@
|
|||
int
|
||||
tuntap_sys_start(struct device *dev, int mode, int tun)
|
||||
{
|
||||
|
||||
|
||||
int fd;
|
||||
int persist;
|
||||
char *ifname;
|
||||
char *ifname = NULL;
|
||||
struct ifreq ifr;
|
||||
|
||||
/* Get the persistence bit */
|
||||
|
@ -92,7 +92,7 @@ tuntap_sys_start(struct device *dev, int mode, int tun)
|
|||
}
|
||||
return fd;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/* Open the clonable interface */
|
||||
if((fd = open("/dev/net/tun", O_RDWR)) == -1)
|
||||
|
@ -202,7 +202,7 @@ tuntap_sys_set_ipv6(struct device *dev, t_tun_in6_addr *s6, uint32_t bits)
|
|||
{
|
||||
struct ifreq ifr;
|
||||
struct sockaddr_in6 sai;
|
||||
int sockfd;
|
||||
int sockfd;
|
||||
struct in6_ifreq ifr6;
|
||||
|
||||
sockfd = socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP);
|
||||
|
|
|
@ -157,7 +157,7 @@ tuntap_set_ifname(struct device *dev, const char *ifname)
|
|||
}
|
||||
|
||||
len = strlen(ifname);
|
||||
if(len > IF_NAMESIZE)
|
||||
if(len >= IF_NAMESIZE)
|
||||
{
|
||||
tuntap_log(TUNTAP_LOG_ERR, "Parameter 'ifname' is too long");
|
||||
return -1;
|
||||
|
@ -169,7 +169,7 @@ tuntap_set_ifname(struct device *dev, const char *ifname)
|
|||
}
|
||||
|
||||
(void)memset(dev->if_name, 0, IF_NAMESIZE);
|
||||
(void)strncpy(dev->if_name, ifname, len);
|
||||
(void)strncpy(dev->if_name, ifname, len + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue