clang-tidy modernize pass

This commit is contained in:
Michael 2019-07-31 00:42:13 +01:00
parent d4eef2747a
commit 16cdfbd5f0
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C
157 changed files with 562 additions and 691 deletions

View File

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

View File

@ -8,6 +8,10 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
if (MSVC OR MSVC_VERSION)
add_compile_options(/EHca /arch:AVX2 /MD)
add_definitions(-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
add_compile_options(-Wno-nonportable-system-include-path)
endif()
endif()
if(NOT MSVC_VERSION)

View File

@ -27,11 +27,9 @@ namespace llarp
{
return ptr;
}
else
{
return val;
}
}
template <>
inline int
@ -43,11 +41,9 @@ namespace llarp
{
return std::atoi(ptr);
}
else
{
return val;
}
}
template <>
inline uint16_t
@ -59,11 +55,9 @@ namespace llarp
{
return std::atoi(ptr);
}
else
{
return val;
}
}
template <>
inline size_t
@ -75,11 +69,9 @@ namespace llarp
{
return std::atoll(ptr);
}
else
{
return val;
}
}
template <>
inline absl::optional< bool >
@ -92,11 +84,9 @@ namespace llarp
{
return IsTrueValue(ptr);
}
else
{
return val;
}
}
class RouterConfig
{

View File

@ -2,7 +2,7 @@
#define LLARP_LINK_LAYER_HPP
#include <util/types.hpp>
#include <stdlib.h>
#include <cstdlib>
constexpr size_t MAX_LINK_MSG_SIZE = 8192;
constexpr llarp_time_t DefaultLinkSessionLifetime = 60 * 1000;

View File

@ -19,7 +19,7 @@
#include <absl/strings/str_split.h>
#include <cxxopts.hpp>
#include <signal.h>
#include <csignal>
#if(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
#include <pthread_np.h>
@ -27,9 +27,7 @@
namespace llarp
{
Context::Context()
{
}
Context::Context() = default;
Context::~Context()
{
@ -421,7 +419,7 @@ extern "C"
{
cSetLogLevel(eLogDebug);
}
llarp_main *m = new llarp_main;
auto *m = new llarp_main;
m->ctx = std::make_unique< llarp::Context >();
if(!m->ctx->LoadConfig(fname))
{

View File

@ -1,7 +1,7 @@
#ifndef LLARP_CRYPTO_CONSTANTS_HPP
#define LLARP_CRYPTO_CONSTANTS_HPP
#include <stdint.h>
#include <cstdint>
#include <libntrup/ntru.h>

View File

@ -8,8 +8,8 @@
#include <absl/base/optimization.h>
#include <functional>
#include <stdbool.h>
#include <stdint.h>
#include <cstdint>
/**
* crypto.hpp
@ -89,9 +89,7 @@ namespace llarp
pqe_encrypt(PQCipherBlock &, SharedSecret &, const PQPubKey &) = 0;
};
inline Crypto::~Crypto()
{
}
inline Crypto::~Crypto() = default;
/// return random 64bit unsigned interger
uint64_t

View File

@ -5,7 +5,7 @@
#include <sodium/crypto_stream_xchacha20.h>
#include <util/mem.hpp>
#include <assert.h>
#include <cassert>
extern "C"
{

View File

@ -11,9 +11,7 @@ namespace llarp
{
CryptoLibSodium();
~CryptoLibSodium()
{
}
~CryptoLibSodium() override = default;
/// xchacha symmetric cipher
bool

View File

@ -20,7 +20,7 @@ namespace llarp
{
}
~NoOpCrypto() = default;
~NoOpCrypto() override = default;
bool
xchacha20(const llarp_buffer_t &, const SharedSecret &,

View File

@ -4,6 +4,7 @@
#include <crypto/encrypted.hpp>
#include <crypto/types.hpp>
#include <util/buffer.hpp>
#include <utility>
#include <util/mem.h>
#include <util/threadpool.h>
@ -60,8 +61,7 @@ namespace llarp
static void
Decrypt(void* user)
{
AsyncFrameDecrypter< User >* ctx =
static_cast< AsyncFrameDecrypter< User >* >(user);
auto* ctx = static_cast< AsyncFrameDecrypter< User >* >(user);
if(ctx->target.DecryptInPlace(ctx->seckey))
{
@ -75,7 +75,7 @@ namespace llarp
}
AsyncFrameDecrypter(const SecretKey& secretkey, DecryptHandler h)
: result(h), seckey(secretkey)
: result(std::move(h)), seckey(secretkey)
{
}

View File

@ -19,7 +19,8 @@ namespace llarp
using BucketStorage_t = std::map< Key_t, Val_t, XorMetric >;
using Random_t = std::function< uint64_t() >;
Bucket(const Key_t& us, Random_t r) : nodes(XorMetric(us)), random(r)
Bucket(const Key_t& us, Random_t r)
: nodes(XorMetric(us)), random(std::move(r))
{
}

View File

@ -26,17 +26,13 @@ namespace llarp
{
namespace dht
{
AbstractContext::~AbstractContext()
{
}
AbstractContext::~AbstractContext() = default;
struct Context final : public AbstractContext
{
Context();
~Context()
{
}
~Context() override = default;
util::StatusObject
ExtractStatus() const override;
@ -167,7 +163,7 @@ namespace llarp
void
Explore(size_t N = 3);
llarp::AbstractRouter* router;
llarp::AbstractRouter* router{nullptr};
// for router contacts
std::unique_ptr< Bucket< RCNode > > _nodes;
@ -180,7 +176,7 @@ namespace llarp
return _services.get();
}
bool allowTransit;
bool allowTransit{false};
bool&
AllowTransit() override
@ -308,7 +304,7 @@ namespace llarp
Key_t ourKey;
};
Context::Context() : router(nullptr), allowTransit(false)
Context::Context()
{
randombytes((byte_t*)&ids, sizeof(uint64_t));
}
@ -346,7 +342,7 @@ namespace llarp
{
if(left)
return;
Context* ctx = static_cast< Context* >(u);
auto* ctx = static_cast< Context* >(u);
const auto num =
std::min(ctx->router->NumberOfConnectedRouters(), size_t(4));
if(num)
@ -361,7 +357,7 @@ namespace llarp
{
if(left)
return;
Context* ctx = static_cast< Context* >(u);
auto* ctx = static_cast< Context* >(u);
// clean up transactions
ctx->CleanupTX();

View File

@ -33,7 +33,7 @@ llarp_dht_context_start(struct llarp_dht_context* ctx, const byte_t* key);
// remove this? dns needs it atm
struct llarp_router_lookup_job;
typedef void (*llarp_router_lookup_handler)(struct llarp_router_lookup_job*);
using llarp_router_lookup_handler = void (*)(struct llarp_router_lookup_job*);
struct llarp_router_lookup_job
{

View File

@ -1,5 +1,6 @@
#include <dht/context.hpp>
#include <memory>
#include <util/bencode.hpp>
#include <dht/messages/findintro.hpp>
#include <dht/messages/findrouter.hpp>
@ -46,29 +47,29 @@ namespace llarp
switch(*strbuf.base)
{
case 'F':
msg.reset(new FindIntroMessage(From, relayed));
msg = std::make_unique< FindIntroMessage >(From, relayed);
break;
case 'R':
if(relayed)
msg.reset(new RelayedFindRouterMessage(From));
msg = std::make_unique< RelayedFindRouterMessage >(From);
else
msg.reset(new FindRouterMessage(From));
msg = std::make_unique< FindRouterMessage >(From);
break;
case 'S':
msg.reset(new GotRouterMessage(From, relayed));
msg = std::make_unique< GotRouterMessage >(From, relayed);
break;
case 'I':
msg.reset(new PublishIntroMessage());
msg = std::make_unique< PublishIntroMessage >();
break;
case 'G':
if(relayed)
{
msg.reset(new RelayedGotIntroMessage());
msg = std::make_unique< RelayedGotIntroMessage >();
break;
}
else
{
msg.reset(new GotIntroMessage(From));
msg = std::make_unique< GotIntroMessage >(From);
break;
}
default:

View File

@ -16,9 +16,7 @@ namespace llarp
struct IMessage
{
virtual ~IMessage()
{
}
virtual ~IMessage() = default;
/// construct
IMessage(const Key_t& from) : From(from)

View File

@ -7,9 +7,7 @@ namespace llarp
{
namespace dht
{
FindIntroMessage::~FindIntroMessage()
{
}
FindIntroMessage::~FindIntroMessage() = default;
bool
FindIntroMessage::DecodeKey(const llarp_buffer_t& k, llarp_buffer_t* val)

View File

@ -45,7 +45,7 @@ namespace llarp
R = 1;
}
~FindIntroMessage();
~FindIntroMessage() override;
bool
BEncode(llarp_buffer_t* buf) const override;

View File

@ -57,9 +57,7 @@ namespace llarp
return true;
}
FindRouterMessage::~FindRouterMessage()
{
}
FindRouterMessage::~FindRouterMessage() = default;
bool
FindRouterMessage::BEncode(llarp_buffer_t *buf) const
@ -183,7 +181,7 @@ namespace llarp
replies.emplace_back(new GotRouterMessage(k, txid, {found}, false));
return true;
}
else
dht.LookupRouterRelayed(From, txid, k, !iterative, replies);
return true;
}

View File

@ -25,7 +25,7 @@ namespace llarp
K.Randomize();
}
~FindRouterMessage();
~FindRouterMessage() override;
bool
BEncode(llarp_buffer_t* buf) const override;
@ -33,7 +33,7 @@ namespace llarp
bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
bool
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
@ -55,7 +55,7 @@ namespace llarp
/// handle a relayed FindRouterMessage, do a lookup on the dht and inform
/// the path of the result
/// TODO: smart path expiration logic needs to be implemented
virtual bool
bool
HandleMessage(llarp_dht_context* ctx,
std::vector< IMessage::Ptr_t >& replies) const override;
};

View File

@ -1,29 +1,27 @@
#include <dht/messages/gotintro.hpp>
#include <dht/context.hpp>
#include <memory>
#include <path/path_context.hpp>
#include <router/abstractrouter.hpp>
#include <routing/dht_message.hpp>
#include <utility>
namespace llarp
{
namespace dht
{
GotIntroMessage::GotIntroMessage(
const std::vector< llarp::service::IntroSet > &results, uint64_t tx)
: IMessage({}), I(results), T(tx)
{
}
GotIntroMessage::~GotIntroMessage()
GotIntroMessage::GotIntroMessage(std::vector< service::IntroSet > results,
uint64_t tx)
: IMessage({}), I(std::move(results)), T(tx)
{
}
bool
GotIntroMessage::HandleMessage(
llarp_dht_context *ctx,
__attribute__((unused))
std::vector< std::unique_ptr< IMessage > > &replies) const
ABSL_ATTRIBUTE_UNUSED std::vector< std::unique_ptr< IMessage > >
&replies) const
{
auto &dht = *ctx->impl;
@ -31,7 +29,7 @@ namespace llarp
{
if(!introset.Verify(dht.Now()))
{
llarp::LogWarn(
LogWarn(
"Invalid introset while handling direct GotIntro "
"from ",
From);
@ -59,7 +57,7 @@ namespace llarp
}
return true;
}
llarp::LogError("no pending TX for GIM from ", From, " txid=", T);
LogError("no pending TX for GIM from ", From, " txid=", T);
return false;
}
@ -77,7 +75,7 @@ namespace llarp
auto copy = std::make_shared< const RelayedGotIntroMessage >(*this);
return pathset->HandleGotIntroMessage(copy);
}
llarp::LogWarn("No path for got intro message pathid=", pathID);
LogWarn("No path for got intro message pathid=", pathID);
return false;
}
@ -92,7 +90,7 @@ namespace llarp
{
if(K) // duplicate key?
return false;
K.reset(new dht::Key_t());
K = std::make_unique< dht::Key_t >();
return K->BDecode(buf);
}
bool read = false;

View File

@ -15,7 +15,7 @@ namespace llarp
struct GotIntroMessage : public IMessage
{
/// the found introsets
std::vector< llarp::service::IntroSet > I;
std::vector< service::IntroSet > I;
/// txid
uint64_t T = 0;
/// the key of a router closer in keyspace if iterative lookup
@ -41,10 +41,9 @@ namespace llarp
}
/// for recursive reply
GotIntroMessage(const std::vector< llarp::service::IntroSet >& results,
uint64_t txid);
GotIntroMessage(std::vector< service::IntroSet > results, uint64_t txid);
~GotIntroMessage();
~GotIntroMessage() override = default;
bool
BEncode(llarp_buffer_t* buf) const override;
@ -52,7 +51,7 @@ namespace llarp
bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
bool
HandleMessage(llarp_dht_context* ctx,
std::vector< IMessage::Ptr_t >& replies) const override;
};

View File

@ -1,6 +1,7 @@
#include <dht/context.hpp>
#include <dht/messages/gotrouter.hpp>
#include <memory>
#include <path/path_context.hpp>
#include <router/abstractrouter.hpp>
@ -8,9 +9,7 @@ namespace llarp
{
namespace dht
{
GotRouterMessage::~GotRouterMessage()
{
}
GotRouterMessage::~GotRouterMessage() = default;
bool
GotRouterMessage::BEncode(llarp_buffer_t *buf) const
@ -56,7 +55,7 @@ namespace llarp
{
if(K) // duplicate key?
return false;
K.reset(new dht::Key_t());
K = std::make_unique< dht::Key_t >();
return K->BDecode(val);
}
if(key == "N")

View File

@ -1,8 +1,11 @@
#ifndef LLARP_DHT_MESSAGES_GOT_ROUTER_HPP
#define LLARP_DHT_MESSAGES_GOT_ROUTER_HPP
#include <dht/message.hpp>
#include <router_contact.hpp>
#include <util/copy_or_nullptr.hpp>
#include <utility>
#include <vector>
namespace llarp
{
@ -15,9 +18,8 @@ namespace llarp
{
}
GotRouterMessage(const Key_t& from, uint64_t id,
const std::vector< RouterContact >& results,
bool tunneled)
: IMessage(from), R(results), txid(id), relayed(tunneled)
std::vector< RouterContact > results, bool tunneled)
: IMessage(from), R(std::move(results)), txid(id), relayed(tunneled)
{
}
@ -27,9 +29,9 @@ namespace llarp
{
}
GotRouterMessage(uint64_t id, const std::vector< RouterID >& near,
GotRouterMessage(uint64_t id, std::vector< RouterID > _near,
bool tunneled)
: IMessage({}), N(near), txid(id), relayed(tunneled)
: IMessage({}), N(std::move(_near)), txid(id), relayed(tunneled)
{
}
@ -44,7 +46,7 @@ namespace llarp
version = other.version;
}
~GotRouterMessage();
~GotRouterMessage() override;
bool
BEncode(llarp_buffer_t* buf) const override;
@ -52,7 +54,7 @@ namespace llarp
bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
bool
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;

View File

@ -10,9 +10,7 @@ namespace llarp
{
namespace dht
{
PublishIntroMessage::~PublishIntroMessage()
{
}
PublishIntroMessage::~PublishIntroMessage() = default;
bool
PublishIntroMessage::DecodeKey(const llarp_buffer_t &key,

View File

@ -3,6 +3,7 @@
#include <dht/message.hpp>
#include <service/intro_set.hpp>
#include <utility>
#include <vector>
namespace llarp
@ -22,14 +23,14 @@ namespace llarp
}
PublishIntroMessage(const llarp::service::IntroSet& i, uint64_t tx,
uint64_t s, const std::vector< Key_t >& exclude = {})
: IMessage({}), E(exclude), txID(tx)
uint64_t s, std::vector< Key_t > exclude = {})
: IMessage({}), E(std::move(exclude)), txID(tx)
{
I = i;
S = s;
}
~PublishIntroMessage();
~PublishIntroMessage() override;
bool
BEncode(llarp_buffer_t* buf) const override;
@ -37,7 +38,7 @@ namespace llarp
bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
bool
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;

View File

@ -4,6 +4,7 @@
#include <dht/key.hpp>
#include <router_contact.hpp>
#include <service/intro_set.hpp>
#include <utility>
namespace llarp
{
@ -47,7 +48,7 @@ namespace llarp
ID.Zero();
}
ISNode(const service::IntroSet& other) : introset(other)
ISNode(service::IntroSet other) : introset(std::move(other))
{
introset.A.CalculateAddress(ID.as_array());
}

View File

@ -2,6 +2,7 @@
#include <dht/context.hpp>
#include <dht/messages/pubintro.hpp>
#include <utility>
namespace llarp
{
@ -10,11 +11,11 @@ namespace llarp
PublishServiceJob::PublishServiceJob(const TXOwner &asker,
const service::IntroSet &introset,
AbstractContext *ctx, uint64_t s,
const std::set< Key_t > &exclude)
std::set< Key_t > exclude)
: TX< service::Address, service::IntroSet >(asker, introset.A.Addr(),
ctx)
, S(s)
, dontTell(exclude)
, dontTell(std::move(exclude))
, I(introset)
{
}

View File

@ -20,7 +20,7 @@ namespace llarp
PublishServiceJob(const TXOwner &asker, const service::IntroSet &introset,
AbstractContext *ctx, uint64_t s,
const std::set< Key_t > &exclude);
std::set< Key_t > exclude);
bool
Validate(const service::IntroSet &introset) const override;

View File

@ -3,6 +3,7 @@
#include <dht/context.hpp>
#include <dht/messages/findrouter.hpp>
#include <dht/messages/gotrouter.hpp>
#include <utility>
namespace llarp
{
@ -13,7 +14,7 @@ namespace llarp
AbstractContext *ctx,
RouterLookupHandler result)
: TX< RouterID, RouterContact >(_whoasked, _target, ctx)
, resultHandler(result)
, resultHandler(std::move(result))
{
peersAsked.insert(ctx->OurKey());

View File

@ -28,7 +28,7 @@ namespace llarp
void
Start(const TXOwner &peer) override;
virtual void
void
SendReply() override;
};
} // namespace dht

View File

@ -3,6 +3,7 @@
#include <dht/context.hpp>
#include <dht/messages/findintro.hpp>
#include <dht/messages/gotintro.hpp>
#include <utility>
namespace llarp
{
@ -13,7 +14,7 @@ namespace llarp
AbstractContext *ctx, uint64_t r,
service::IntroSetLookupHandler handler)
: TX< service::Address, service::IntroSet >(asker, addr, ctx)
, handleResult(handler)
, handleResult(std::move(handler))
, R(r)
{
peersAsked.insert(ctx->OurKey());

View File

@ -34,7 +34,7 @@ namespace llarp
void
DoNextRequest(const Key_t &ask) override;
virtual void
void
SendReply() override;
};
} // namespace dht

View File

@ -29,9 +29,7 @@ namespace llarp
{
}
virtual ~TX()
{
}
virtual ~TX() = default;
void
OnFound(const Key_t& askedPeer, const V& value);

View File

@ -96,7 +96,7 @@ getDNSstring(const char *const buffer, uint32_t *pos)
}
void
code_domain(char *&buffer, const std::string &domain) throw()
code_domain(char *&buffer, const std::string &domain) noexcept
{
std::string::size_type start(0);
std::string::size_type end; // indexes
@ -124,7 +124,7 @@ code_domain(char *&buffer, const std::string &domain) throw()
}
void
vcode_domain(std::vector< byte_t > &bytes, const std::string &domain) throw()
vcode_domain(std::vector< byte_t > &bytes, const std::string &domain) noexcept
{
std::string::size_type start(0);
std::string::size_type end; // indexes
@ -153,7 +153,7 @@ vcode_domain(std::vector< byte_t > &bytes, const std::string &domain) throw()
// expects host order
void
vput16bits(std::vector< byte_t > &bytes, uint16_t value) throw()
vput16bits(std::vector< byte_t > &bytes, uint16_t value) noexcept
{
char buf[2] = {0};
char *write_buffer = buf;
@ -164,7 +164,7 @@ vput16bits(std::vector< byte_t > &bytes, uint16_t value) throw()
// expects host order
void
vput32bits(std::vector< byte_t > &bytes, uint32_t value) throw()
vput32bits(std::vector< byte_t > &bytes, uint32_t value) noexcept
{
char buf[4] = {0};
char *write_buffer = buf;
@ -178,7 +178,7 @@ vput32bits(std::vector< byte_t > &bytes, uint32_t value) throw()
void
dns_writeType(std::vector< byte_t > &bytes, llarp::dns::record *record)
{
llarp::dns::type_1a *type1a = dynamic_cast< llarp::dns::type_1a * >(record);
auto *type1a = dynamic_cast< llarp::dns::type_1a * >(record);
if(type1a)
{
std::vector< byte_t > more_bytes = type1a->to_bytes();
@ -186,8 +186,7 @@ dns_writeType(std::vector< byte_t > &bytes, llarp::dns::record *record)
bytes.insert(bytes.end(), more_bytes.begin(), more_bytes.end());
}
llarp::dns::type_2ns *type2ns =
dynamic_cast< llarp::dns::type_2ns * >(record);
auto *type2ns = dynamic_cast< llarp::dns::type_2ns * >(record);
if(type2ns)
{
std::vector< byte_t > more_bytes = type2ns->to_bytes();
@ -195,8 +194,7 @@ dns_writeType(std::vector< byte_t > &bytes, llarp::dns::record *record)
bytes.insert(bytes.end(), more_bytes.begin(), more_bytes.end());
}
llarp::dns::type_5cname *type5cname =
dynamic_cast< llarp::dns::type_5cname * >(record);
auto *type5cname = dynamic_cast< llarp::dns::type_5cname * >(record);
if(type5cname)
{
std::vector< byte_t > more_bytes = type5cname->to_bytes();
@ -204,24 +202,21 @@ dns_writeType(std::vector< byte_t > &bytes, llarp::dns::record *record)
bytes.insert(bytes.end(), more_bytes.begin(), more_bytes.end());
}
llarp::dns::type_12ptr *type12ptr =
dynamic_cast< llarp::dns::type_12ptr * >(record);
auto *type12ptr = dynamic_cast< llarp::dns::type_12ptr * >(record);
if(type12ptr)
{
std::vector< byte_t > more_bytes = type12ptr->to_bytes();
llarp::LogDebug("[12]Adding ", more_bytes.size());
bytes.insert(bytes.end(), more_bytes.begin(), more_bytes.end());
}
llarp::dns::type_15mx *type15mx =
dynamic_cast< llarp::dns::type_15mx * >(record);
auto *type15mx = dynamic_cast< llarp::dns::type_15mx * >(record);
if(type15mx)
{
std::vector< byte_t > more_bytes = type15mx->to_bytes();
llarp::LogDebug("[15]Adding ", more_bytes.size());
bytes.insert(bytes.end(), more_bytes.begin(), more_bytes.end());
}
llarp::dns::type_16txt *type16txt =
dynamic_cast< llarp::dns::type_16txt * >(record);
auto *type16txt = dynamic_cast< llarp::dns::type_16txt * >(record);
if(type16txt)
{
std::vector< byte_t > more_bytes = type16txt->to_bytes();
@ -292,7 +287,7 @@ packet2bytes(dns_packet &in)
extern "C"
{
uint16_t
get16bits(const char *&buffer) throw()
get16bits(const char *&buffer) noexcept
{
uint16_t value = bufbe16toh(buffer);
buffer += 2;
@ -300,7 +295,7 @@ extern "C"
}
uint32_t
get32bits(const char *&buffer) throw()
get32bits(const char *&buffer) noexcept
{
uint32_t value = bufbe32toh(buffer);
buffer += 4;
@ -350,7 +345,7 @@ extern "C"
dns_msg_question *
decode_question(const char *buffer, uint32_t *pos)
{
dns_msg_question *question = new dns_msg_question;
auto *question = new dns_msg_question;
std::string m_qName = getDNSstring(buffer, pos);
llarp::LogDebug("Got question name: ", m_qName);
@ -369,7 +364,7 @@ extern "C"
dns_msg_answer *
decode_answer(const char *const buffer, uint32_t *pos)
{
dns_msg_answer *answer = new dns_msg_answer;
auto *answer = new dns_msg_answer;
/*
llarp_buffer_t bob;
bob.base = (unsigned char *)buffer;
@ -589,14 +584,14 @@ extern "C"
}
void
put16bits(char *&buffer, uint16_t value) throw()
put16bits(char *&buffer, uint16_t value) noexcept
{
htobe16buf(buffer, value);
buffer += 2;
}
void
put32bits(char *&buffer, uint32_t value) throw()
put32bits(char *&buffer, uint32_t value) noexcept
{
htobe32buf(buffer, value);
buffer += 4;

View File

@ -14,7 +14,7 @@ extern "C"
// fwd declr
struct dnsc_answer_request;
typedef void (*dnsc_answer_hook_func)(dnsc_answer_request *request);
using dnsc_answer_hook_func = void (*)(dnsc_answer_request *);
#ifdef __cplusplus
}

View File

@ -111,24 +111,24 @@ std::string
getDNSstring(const char *const buffer, uint32_t *pos);
void
code_domain(char *&buffer, const std::string &domain) throw();
code_domain(char *&buffer, const std::string &domain) noexcept;
void
vcode_domain(std::vector< byte_t > &bytes, const std::string &domain) throw();
vcode_domain(std::vector< byte_t > &bytes, const std::string &domain) noexcept;
void
vput16bits(std::vector< byte_t > &bytes, uint16_t value) throw();
vput16bits(std::vector< byte_t > &bytes, uint16_t value) noexcept;
void
vput32bits(std::vector< byte_t > &bytes, uint32_t value) throw();
vput32bits(std::vector< byte_t > &bytes, uint32_t value) noexcept;
extern "C"
{
uint16_t
get16bits(const char *&buffer) throw();
get16bits(const char *&buffer) noexcept;
uint32_t
get32bits(const char *&buffer) throw();
get32bits(const char *&buffer) noexcept;
bool
decode_hdr(llarp_buffer_t *buffer, dns_msg_header *hdr);
@ -140,10 +140,10 @@ extern "C"
decode_answer(const char *const buffer, uint32_t *pos);
void
put16bits(char *&buffer, uint16_t value) throw();
put16bits(char *&buffer, uint16_t value) noexcept;
void
put32bits(char *&buffer, uint32_t value) throw();
put32bits(char *&buffer, uint32_t value) noexcept;
void
llarp_handle_dns_recvfrom(struct llarp_udp_io *udp,

View File

@ -1,7 +1,7 @@
#ifndef LLARP_DNS_DNS_HPP
#define LLARP_DNS_DNS_HPP
#include <stdint.h>
#include <cstdint>
namespace llarp
{

View File

@ -107,11 +107,11 @@ namespace llarp
ip = net::IPPacket::ExpandV4(llarp::ipaddr_ipv4_bits(a, b, c, d));
return true;
}
else if(numdots == 32 && isV6)
if(numdots == 32 && isV6)
{
size_t idx = 0;
uint8_t lo, hi;
uint8_t* ptr = (uint8_t*)&ip.h;
auto* ptr = (uint8_t*)&ip.h;
while(idx < 16)
{
pos = sub.find('.');

View File

@ -5,9 +5,7 @@ namespace llarp
{
namespace dns
{
record::~record()
{
}
record::~record() = default;
bool
record::parse(std::vector< byte_t > bytes)

View File

@ -13,9 +13,7 @@ namespace llarp
struct record
{
virtual ~record() = 0;
record()
{
}
record() = default;
virtual bool
parse(std::vector< byte_t > bytes) = 0;
@ -28,9 +26,7 @@ namespace llarp
{
huint32_t ipaddr;
virtual ~type_1a()
{
}
~type_1a() override = default;
type_1a();
bool
@ -44,9 +40,7 @@ namespace llarp
{
std::string ns;
virtual ~type_2ns()
{
}
~type_2ns() override = default;
type_2ns();
bool
@ -66,9 +60,7 @@ namespace llarp
uint32_t expire;
uint32_t minimum;
virtual ~type_6soa()
{
}
~type_6soa() override = default;
type_6soa();
bool
@ -82,9 +74,7 @@ namespace llarp
{
std::string cname;
virtual ~type_5cname()
{
}
~type_5cname() override = default;
type_5cname();
bool
@ -98,9 +88,7 @@ namespace llarp
{
std::string revname;
virtual ~type_12ptr()
{
}
~type_12ptr() override = default;
type_12ptr();
bool
@ -115,9 +103,7 @@ namespace llarp
std::string mx;
uint16_t priority;
virtual ~type_15mx()
{
}
~type_15mx() override = default;
type_15mx();
bool
@ -131,9 +117,7 @@ namespace llarp
{
std::string txt;
virtual ~type_16txt()
{
}
~type_16txt() override = default;
type_16txt();
bool

View File

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

View File

@ -3,6 +3,7 @@
#include <crypto/crypto.hpp>
#include <util/logic.hpp>
#include <array>
#include <utility>
namespace llarp
{
@ -11,10 +12,10 @@ namespace llarp
Proxy::Proxy(llarp_ev_loop_ptr serverLoop, Logic_ptr serverLogic,
llarp_ev_loop_ptr clientLoop, Logic_ptr clientLogic,
IQueryHandler* h)
: m_ServerLoop(serverLoop)
, m_ClientLoop(clientLoop)
, m_ServerLogic(serverLogic)
, m_ClientLogic(clientLogic)
: m_ServerLoop(std::move(serverLoop))
, m_ClientLoop(std::move(clientLoop))
, m_ServerLogic(std::move(serverLogic))
, m_ClientLogic(std::move(clientLogic))
, m_QueryHandler(h)
{
m_Client.user = this;

View File

@ -16,9 +16,7 @@ namespace llarp
/// handler of dns query hooking
struct IQueryHandler
{
virtual ~IQueryHandler()
{
}
virtual ~IQueryHandler() = default;
/// return true if we should hook this message
virtual bool

View File

@ -10,12 +10,12 @@
#include <unistd.h> /* close */
#endif
#include <stdlib.h> /* exit */
#include <string.h> /* memset */
#include <cstdlib> /* exit */
#include <cstring> /* memset */
#include <sys/types.h>
#include <algorithm> // for std::find_if
#include <stdio.h> // sprintf
#include <cstdio> // sprintf
dns_tracker dns_udp_tracker;
@ -36,7 +36,7 @@ struct dns_query
struct dns_query *
build_dns_packet(char *url, uint16_t id, uint16_t reqType)
{
dns_query *dnsQuery = new dns_query;
auto *dnsQuery = new dns_query;
dnsQuery->length = 12;
// ID
// buffer[0] = (value & 0xFF00) >> 8;
@ -505,7 +505,7 @@ generic_handle_dnsc_recvfrom(dnsc_answer_request *request,
}
else if(answer->type == 15)
{
llarp::dns::type_15mx *record =
auto *record =
dynamic_cast< llarp::dns::type_15mx * >(answer->record.get());
llarp::LogDebug("Resolving MX ", record->mx, "@", record->priority);
request->found = true;
@ -639,7 +639,7 @@ raw_resolve_host(struct dnsc_context *const dnsc, const char *url,
llarp::LogInfo("response header says it belongs to id #", hdr.id);
// if we sent this out, then there's an id
struct dns_tracker *tracker = (struct dns_tracker *)dnsc->tracker;
auto *tracker = (struct dns_tracker *)dnsc->tracker;
struct dnsc_answer_request *request = tracker->client_request[hdr.id].get();
if(request)
@ -675,7 +675,7 @@ llarp_handle_dnsc_recvfrom(struct llarp_udp_io *const udp,
llarp::LogDebug("Header got client responses for id: ", hdr.id);
// if we sent this out, then there's an id
struct dns_tracker *tracker = (struct dns_tracker *)udp->user;
auto *tracker = (struct dns_tracker *)udp->user;
struct dnsc_answer_request *request = tracker->client_request[hdr.id].get();
// sometimes we'll get double responses
@ -766,7 +766,7 @@ llarp_resolve_host(struct dnsc_context *const dnsc, const char *url,
void
llarp_host_resolved(dnsc_answer_request *const request)
{
dns_tracker *tracker = (dns_tracker *)request->context->tracker;
auto *tracker = (dns_tracker *)request->context->tracker;
auto val = std::find_if(
tracker->client_request.begin(), tracker->client_request.end(),
[request](

View File

@ -26,7 +26,7 @@ build_dns_packet(char *url, uint16_t id, uint16_t reqType);
/// hook function to handle an dns client request
// should we pass by llarp::Addr
// not as long as we're supporting raw
typedef void (*dnsc_answer_hook_func)(dnsc_answer_request *request);
using dnsc_answer_hook_func = void (*)(dnsc_answer_request *);
/// struct for dns client requests
struct dnsc_answer_request

View File

@ -27,7 +27,7 @@ ssize_t
llarp_sendto_dns_hook_func(void *sock, const struct sockaddr *from,
ManagedBuffer buf)
{
struct llarp_udp_io *udp = (struct llarp_udp_io *)sock;
auto *udp = (struct llarp_udp_io *)sock;
if(!udp)
{
llarp::LogWarn("couldnt cast to udp");
@ -333,8 +333,7 @@ writesend_dnss_txtresponse(std::string txt, const struct sockaddr *from,
void
handle_dnsc_result(dnsc_answer_request *client_request)
{
dnsd_question_request *server_request =
(dnsd_question_request *)client_request->user;
auto *server_request = (dnsd_question_request *)client_request->user;
if(!server_request)
{
llarp::LogError("Couldn't map client requser user to a server request");
@ -522,7 +521,7 @@ llarp_handle_dnsd_recvfrom(struct llarp_udp_io *udp,
return;
}
// create new request
dnsd_question_request *llarp_dns_request = new dnsd_question_request;
auto *llarp_dns_request = new dnsd_question_request;
llarp_dns_request->context = dns_udp_tracker.dnsd; // set context
llarp_dns_request->from =
new sockaddr(*saddr); // make a copy of the sockaddr
@ -543,7 +542,7 @@ raw_handle_recvfrom(int *sockfd, const struct sockaddr *saddr,
llarp::LogError("No tracker set in dnsd context");
return;
}
dnsd_question_request *llarp_dns_request = new dnsd_question_request;
auto *llarp_dns_request = new dnsd_question_request;
llarp_dns_request->context = dns_udp_tracker.dnsd; // set context
llarp_dns_request->from =
new sockaddr(*saddr); // make a copy of the sockaddr

View File

@ -23,9 +23,9 @@ typedef SSIZE_T ssize_t;
#endif
#include <memory>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <cstdint>
#include <cstdlib>
#if !defined(WIN32)
#include <uv.h>

View File

@ -16,6 +16,7 @@
#include <deque>
#include <list>
#include <future>
#include <utility>
#ifdef _WIN32
#include <win32/win32_up.h>
@ -305,7 +306,7 @@ namespace llarp
struct GetNow
{
llarp_ev_loop_ptr loop;
GetNow(llarp_ev_loop_ptr l) : loop(l)
GetNow(llarp_ev_loop_ptr l) : loop(std::move(l))
{
}
@ -319,7 +320,7 @@ namespace llarp
struct PutTime
{
llarp_ev_loop_ptr loop;
PutTime(llarp_ev_loop_ptr l) : loop(l)
PutTime(llarp_ev_loop_ptr l) : loop(std::move(l))
{
}
void
@ -570,9 +571,7 @@ namespace llarp
tcp.close = &DoClose;
}
virtual ~tcp_conn()
{
}
~tcp_conn() override = default;
/// start connecting
void
@ -631,10 +630,10 @@ namespace llarp
errno = 0;
}
virtual ssize_t
ssize_t
do_write(void* buf, size_t sz) override;
virtual int
int
read(byte_t* buf, size_t sz) override;
bool
@ -652,7 +651,7 @@ namespace llarp
}
bool
tick()
tick() override
{
if(tcp->tick)
tcp->tick(tcp);
@ -660,8 +659,8 @@ namespace llarp
}
/// actually does accept() :^)
virtual int
read(byte_t*, size_t);
int
read(byte_t*, size_t) override;
};
} // namespace llarp
@ -784,9 +783,7 @@ struct llarp_ev_loop
return conn && add_ev(conn, true);
}
virtual ~llarp_ev_loop()
{
}
virtual ~llarp_ev_loop() = default;
std::list< std::unique_ptr< llarp::ev_io > > handlers;

View File

@ -1,7 +1,7 @@
#include <ev/ev_libuv.hpp>
#include <net/net_addr.hpp>
#include <string.h>
#include <cstring>
namespace libuv
{
@ -65,7 +65,7 @@ namespace libuv
static void
OnOutboundConnect(uv_connect_t* c, int status)
{
conn_glue* self = static_cast< conn_glue* >(c->data);
auto* self = static_cast< conn_glue* >(c->data);
self->HandleConnectResult(status);
c->data = nullptr;
}
@ -182,7 +182,7 @@ namespace libuv
m_WriteQueue.emplace_back(sz);
std::copy_n(data, sz, m_WriteQueue.back().begin());
auto buf = uv_buf_init(m_WriteQueue.back().data(), sz);
uv_write_t* req = new uv_write_t();
auto* req = new uv_write_t();
req->data = this;
return uv_write(req, Stream(), &buf, 1, &OnWritten) == 0 ? sz : 0;
}
@ -196,7 +196,7 @@ namespace libuv
static void
FullClose(uv_handle_t* h)
{
conn_glue* self = static_cast< conn_glue* >(h->data);
auto* self = static_cast< conn_glue* >(h->data);
h->data = nullptr;
delete self;
llarp::LogInfo("deleted");
@ -225,7 +225,7 @@ namespace libuv
OnShutdown(uv_shutdown_t* shut, int code)
{
llarp::LogDebug("shut down ", code);
conn_glue* self = static_cast< conn_glue* >(shut->data);
auto* self = static_cast< conn_glue* >(shut->data);
uv_close((uv_handle_t*)&self->m_Handle, &OnClosed);
delete shut;
}
@ -236,7 +236,7 @@ namespace libuv
llarp::LogDebug("close tcp connection");
uv_check_stop(&m_Ticker);
uv_read_stop(Stream());
uv_shutdown_t* shut = new uv_shutdown_t();
auto* shut = new uv_shutdown_t();
shut->data = this;
uv_shutdown(shut, Stream(), &OnShutdown);
}
@ -285,7 +285,7 @@ namespace libuv
{
if(m_Accept && m_Accept->accepted)
{
conn_glue* child = new conn_glue(this);
auto* child = new conn_glue(this);
llarp::LogDebug("accepted new connection");
child->m_Conn.impl = child;
child->m_Conn.loop = m_Accept->loop;
@ -375,7 +375,7 @@ namespace libuv
static int
SendTo(llarp_udp_io* udp, const sockaddr* to, const byte_t* ptr, size_t sz)
{
udp_glue* self = static_cast< udp_glue* >(udp->impl);
auto* self = static_cast< udp_glue* >(udp->impl);
if(self == nullptr)
return -1;
uv_buf_t buf = uv_buf_init((char*)ptr, sz);
@ -410,7 +410,7 @@ namespace libuv
static void
OnClosed(uv_handle_t* h)
{
udp_glue* glue = static_cast< udp_glue* >(h->data);
auto* glue = static_cast< udp_glue* >(h->data);
if(glue)
{
h->data = nullptr;
@ -443,7 +443,7 @@ namespace libuv
readpkt = false;
}
~tun_glue()
~tun_glue() override
{
tuntap_destroy(m_Device);
}
@ -488,7 +488,7 @@ namespace libuv
static void
OnClosed(uv_handle_t* h)
{
tun_glue* self = static_cast< tun_glue* >(h->data);
auto* self = static_cast< tun_glue* >(h->data);
if(self)
{
self->m_Tun->impl = nullptr;
@ -597,7 +597,7 @@ namespace libuv
bool
Loop::tcp_connect(llarp_tcp_connecter* tcp, const sockaddr* addr)
{
conn_glue* impl = new conn_glue(m_Impl.get(), tcp, addr);
auto* impl = new conn_glue(m_Impl.get(), tcp, addr);
tcp->impl = impl;
if(impl->ConnectAsync())
return true;
@ -656,7 +656,7 @@ namespace libuv
bool
Loop::udp_listen(llarp_udp_io* udp, const sockaddr* src)
{
udp_glue* impl = new udp_glue(m_Impl.get(), udp, src);
auto* impl = new udp_glue(m_Impl.get(), udp, src);
udp->impl = impl;
if(impl->Bind())
{
@ -671,7 +671,7 @@ namespace libuv
{
if(udp == nullptr)
return false;
udp_glue* glue = static_cast< udp_glue* >(udp->impl);
auto* glue = static_cast< udp_glue* >(udp->impl);
if(glue == nullptr)
return false;
glue->Close();
@ -681,7 +681,7 @@ namespace libuv
bool
Loop::tun_listen(llarp_tun_io* tun)
{
tun_glue* glue = new tun_glue(tun);
auto* glue = new tun_glue(tun);
tun->impl = glue;
if(glue->Init(m_Impl.get()))
{
@ -694,7 +694,7 @@ namespace libuv
bool
Loop::tcp_listen(llarp_tcp_acceptor* tcp, const sockaddr* addr)
{
conn_glue* glue = new conn_glue(m_Impl.get(), tcp, addr);
auto* glue = new conn_glue(m_Impl.get(), tcp, addr);
tcp->impl = glue;
if(glue->Server())
return true;

View File

@ -1,4 +1,5 @@
#include <ev/pipe.hpp>
#include <utility>
#ifndef _MSC_VER
#include <unistd.h>
@ -6,7 +7,7 @@
#include <fcntl.h>
llarp_ev_pkt_pipe::llarp_ev_pkt_pipe(llarp_ev_loop_ptr loop)
: llarp::ev_io(-1, new LosslessWriteQueue_t()), m_Loop(loop)
: llarp::ev_io(-1, new LosslessWriteQueue_t()), m_Loop(std::move(loop))
{
}

View File

@ -25,7 +25,7 @@ struct llarp_ev_pkt_pipe : public llarp::ev_io
ssize_t
do_write(void* buf, size_t sz) override;
virtual bool
bool
tick() override;
int

View File

@ -1,4 +1,5 @@
#include <exit/context.hpp>
#include <memory>
namespace llarp
{
@ -7,9 +8,7 @@ namespace llarp
Context::Context(AbstractRouter* r) : m_Router(r)
{
}
Context::~Context()
{
}
Context::~Context() = default;
void
Context::Tick(llarp_time_t now)
@ -112,7 +111,7 @@ namespace llarp
}
std::unique_ptr< handlers::ExitEndpoint > endpoint;
// make new endpoint
endpoint.reset(new handlers::ExitEndpoint(name, m_Router));
endpoint = std::make_unique< handlers::ExitEndpoint >(name, m_Router);
// configure
{
auto itr = conf.begin();

View File

@ -14,20 +14,18 @@ namespace llarp
struct ObtainExitMessage final : public IMessage
{
std::vector< llarp::exit::Policy > B;
uint64_t E;
uint64_t E{0};
llarp::PubKey I;
uint64_t T;
uint64_t T{0};
std::vector< llarp::exit::Policy > W;
llarp_time_t X;
llarp_time_t X{0};
llarp::Signature Z;
ObtainExitMessage() : IMessage(), E(0), T(0), X(0)
ObtainExitMessage() : IMessage()
{
}
~ObtainExitMessage()
{
}
~ObtainExitMessage() override = default;
void
Clear() override
@ -132,7 +130,7 @@ namespace llarp
Nonce_t Y;
llarp::Signature Z;
~UpdateExitVerifyMessage() = default;
~UpdateExitVerifyMessage() override = default;
void
Clear() override

View File

@ -6,6 +6,7 @@
#include <path/path.hpp>
#include <router/abstractrouter.hpp>
#include <util/memfn.hpp>
#include <utility>
namespace llarp
{
@ -17,7 +18,7 @@ namespace llarp
AbstractRouter* r, size_t numpaths, size_t hoplen, bool bundleRC)
: llarp::path::Builder(r, numpaths, hoplen)
, m_ExitRouter(routerId)
, m_WritePacket(writepkt)
, m_WritePacket(std::move(writepkt))
, m_Counter(0)
, m_LastUse(0)
, m_BundleRC(bundleRC)
@ -25,9 +26,7 @@ namespace llarp
CryptoManager::instance()->identity_keygen(m_ExitIdentity);
}
BaseSession::~BaseSession()
{
}
BaseSession::~BaseSession() = default;
void
BaseSession::HandlePathDied(path::Path_ptr p)

View File

@ -31,7 +31,7 @@ namespace llarp
AbstractRouter* r, size_t numpaths, size_t hoplen,
bool bundleRC);
virtual ~BaseSession();
~BaseSession() override;
std::shared_ptr< path::PathSet >
GetSelf() override
@ -51,7 +51,7 @@ namespace llarp
return m_BundleRC;
}
virtual void
void
ResetInternalState() override;
bool UrgentBuild(llarp_time_t) const override;
@ -175,13 +175,13 @@ namespace llarp
{
}
~ExitSession() = default;
~ExitSession() override = default;
std::string
Name() const override;
protected:
virtual void
void
PopulateRequest(llarp::routing::ObtainExitMessage& msg) const override
{
// TODO: set expiration time
@ -197,7 +197,7 @@ namespace llarp
AbstractRouter* r, size_t numpaths, size_t hoplen,
bool useRouterSNodeKey, bool bundleRC);
~SNodeSession() = default;
~SNodeSession() override = default;
std::string
Name() const override;

View File

@ -29,7 +29,8 @@ namespace llarp
, m_Resolver(std::make_shared< dns::Proxy >(
r->netloop(), r->logic(), r->netloop(), r->logic(), this))
, m_Name(name)
, m_Tun{{0}, 0, {0}, 0, 0, 0, 0, 0, 0, 0, 0}
, m_Tun{{0}, 0, {0}, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr, nullptr}
, m_LocalResolverAddr("127.0.0.1", 53)
, m_InetToNetwork(name + "_exit_rx", r->netloop(), r->netloop())
@ -40,9 +41,7 @@ namespace llarp
m_ShouldInitTun = true;
}
ExitEndpoint::~ExitEndpoint()
{
}
ExitEndpoint::~ExitEndpoint() = default;
util::StatusObject
ExitEndpoint::ExtractStatus() const

View File

@ -14,7 +14,7 @@ namespace llarp
struct ExitEndpoint : public dns::IQueryHandler
{
ExitEndpoint(const std::string& name, AbstractRouter* r);
~ExitEndpoint();
~ExitEndpoint() override;
void
Tick(llarp_time_t now);

View File

@ -31,7 +31,7 @@ namespace llarp
static void
tunifTick(llarp_tun_io *tun)
{
TunEndpoint *self = static_cast< TunEndpoint * >(tun->user);
auto *self = static_cast< TunEndpoint * >(tun->user);
self->Flush();
}
@ -412,7 +412,7 @@ namespace llarp
}
else
{
dns::Message *replyMsg = new dns::Message(std::move(msg));
auto *replyMsg = new dns::Message(std::move(msg));
using service::Address;
using service::OutboundContext;
return EnsurePathToService(
@ -432,7 +432,7 @@ namespace llarp
}
else
{
dns::Message *replyMsg = new dns::Message(std::move(msg));
auto *replyMsg = new dns::Message(std::move(msg));
EnsurePathToSNode(addr.as_array(),
[=](const RouterID &, exit::BaseSession_ptr s) {
SendDNSReply(addr, s, replyMsg, reply, true,
@ -577,7 +577,7 @@ namespace llarp
return false;
}
struct addrinfo hint, *res = NULL;
struct addrinfo hint, *res = nullptr;
int ret;
memset(&hint, 0, sizeof hint);
@ -585,7 +585,7 @@ namespace llarp
hint.ai_family = PF_UNSPEC;
hint.ai_flags = AI_NUMERICHOST;
ret = getaddrinfo(tunif.ifaddr, NULL, &hint, &res);
ret = getaddrinfo(tunif.ifaddr, nullptr, &hint, &res);
if(ret)
{
llarp::LogError(Name(),
@ -909,7 +909,7 @@ namespace llarp
TunEndpoint::tunifBeforeWrite(llarp_tun_io *tun)
{
// called in the isolated network thread
TunEndpoint *self = static_cast< TunEndpoint * >(tun->user);
auto *self = static_cast< TunEndpoint * >(tun->user);
// flush user to network
self->FlushSend();
// flush exit traffic queues if it's there
@ -928,15 +928,13 @@ namespace llarp
TunEndpoint::tunifRecvPkt(llarp_tun_io *tun, const llarp_buffer_t &b)
{
// called for every packet read from user in isolated network thread
TunEndpoint *self = static_cast< TunEndpoint * >(tun->user);
auto *self = static_cast< TunEndpoint * >(tun->user);
const ManagedBuffer buf(b);
self->m_UserToNetworkPktQueue.EmplaceIf(
[&buf](net::IPPacket &pkt) -> bool { return pkt.Load(buf); });
}
TunEndpoint::~TunEndpoint()
{
}
TunEndpoint::~TunEndpoint() = default;
} // namespace handlers
} // namespace llarp

View File

@ -21,7 +21,7 @@ namespace llarp
{
TunEndpoint(const std::string& nickname, AbstractRouter* r,
llarp::service::Context* parent);
~TunEndpoint();
~TunEndpoint() override;
path::PathSet_ptr
GetSelf() override
@ -29,10 +29,10 @@ namespace llarp
return shared_from_this();
}
virtual bool
bool
SetOption(const std::string& k, const std::string& v) override;
virtual void
void
Tick(llarp_time_t now) override;
util::StatusObject
@ -165,7 +165,7 @@ namespace llarp
void
Flush();
virtual void
void
ResetInternalState() override;
protected:

View File

@ -26,9 +26,7 @@ namespace llarp
using Backend_ptr = std::shared_ptr< IBackend >;
inline IBackend::~IBackend()
{
}
inline IBackend::~IBackend() = default;
} // namespace hooks
} // namespace llarp

View File

@ -13,9 +13,7 @@ namespace llarp
m_FlowCookie.Randomize();
}
LinkLayer::~LinkLayer()
{
}
LinkLayer::~LinkLayer() = default;
void
LinkLayer::Pump()

View File

@ -19,7 +19,7 @@ namespace llarp
SessionRenegotiateHandler reneg, SignBufferFunc sign,
TimeoutHandler timeout, SessionClosedHandler closed);
~LinkLayer();
~LinkLayer() override;
bool
Start(std::shared_ptr< Logic > l) override;

View File

@ -1,4 +1,5 @@
#include <iwp/outermessage.hpp>
#include <memory>
namespace llarp
{
@ -15,9 +16,7 @@ namespace llarp
Clear();
}
OuterMessage::~OuterMessage()
{
}
OuterMessage::~OuterMessage() = default;
void
OuterMessage::Clear()
@ -131,7 +130,7 @@ namespace llarp
return false;
if(buf->size_left() == Zsig.size() + 32)
{
A.reset(new AlignedBuffer< 32 >());
A = std::make_unique< AlignedBuffer< 32 > >();
if(!buf->read_into(A->begin(), A->end()))
return false;
}

View File

@ -18,7 +18,7 @@ namespace llarp
struct LinkManager final : public ILinkManager
{
public:
~LinkManager() = default;
~LinkManager() override = default;
LinkLayer_ptr
GetCompatibleLink(const RouterContact &rc) const override;
@ -71,7 +71,7 @@ namespace llarp
void
CheckPersistingSessions(llarp_time_t now) override;
virtual util::StatusObject
util::StatusObject
ExtractStatus() const override;
void

View File

@ -2,6 +2,7 @@
#include <crypto/crypto.hpp>
#include <util/fs.hpp>
#include <utility>
namespace llarp
{
@ -12,20 +13,18 @@ namespace llarp
SessionEstablishedHandler establishedSession,
SessionRenegotiateHandler reneg,
TimeoutHandler timeout, SessionClosedHandler closed)
: HandleMessage(handler)
, HandleTimeout(timeout)
, Sign(signbuf)
, GetOurRC(getrc)
, SessionEstablished(establishedSession)
, SessionClosed(closed)
, SessionRenegotiate(reneg)
: HandleMessage(std::move(handler))
, HandleTimeout(std::move(timeout))
, Sign(std::move(signbuf))
, GetOurRC(std::move(getrc))
, SessionEstablished(std::move(establishedSession))
, SessionClosed(std::move(closed))
, SessionRenegotiate(std::move(reneg))
, m_RouterEncSecret(routerEncSecret)
{
}
ILinkLayer::~ILinkLayer()
{
}
ILinkLayer::~ILinkLayer() = default;
bool
ILinkLayer::HasSessionTo(const RouterID& id)

View File

@ -16,9 +16,7 @@ namespace llarp
struct ILinkSession
{
virtual ~ILinkSession()
{
}
virtual ~ILinkSession() = default;
/// delivery status of a message
enum class DeliveryStatus

View File

@ -11,7 +11,7 @@ namespace llarp
struct DHTImmediateMessage final : public ILinkMessage
{
DHTImmediateMessage() = default;
~DHTImmediateMessage() = default;
~DHTImmediateMessage() override = default;
std::vector< std::unique_ptr< dht::IMessage > > msgs;

View File

@ -31,7 +31,7 @@ namespace llarp
{
return bencode_read_integer(buf, &P);
}
else if(key == "r")
if(key == "r")
{
if(rc.BDecode(buf))
return true;
@ -39,7 +39,7 @@ namespace llarp
llarp::DumpBuffer(*buf);
return false;
}
else if(key == "v")
if(key == "v")
{
if(!bencode_read_integer(buf, &version))
return false;
@ -52,16 +52,14 @@ namespace llarp
llarp::LogDebug("LIM version ", version);
return true;
}
else if(key == "z")
if(key == "z")
{
return Z.BDecode(buf);
}
else
{
llarp::LogWarn("invalid LIM key: ", *key.cur);
return false;
}
}
bool
LinkIntroMessage::BEncode(llarp_buffer_t* buf) const

View File

@ -37,9 +37,7 @@ namespace llarp
{
}
LinkMessageParser::~LinkMessageParser()
{
}
LinkMessageParser::~LinkMessageParser() = default;
bool
LinkMessageParser::operator()(llarp_buffer_t* buffer, llarp_buffer_t* key)

View File

@ -171,9 +171,9 @@ namespace llarp
struct LRCMFrameDecrypt
{
typedef llarp::path::PathContext Context;
typedef llarp::path::TransitHop Hop;
typedef AsyncFrameDecrypter< LRCMFrameDecrypt > Decrypter;
using Context = llarp::path::PathContext;
using Hop = llarp::path::TransitHop;
using Decrypter = AsyncFrameDecrypter< LRCMFrameDecrypt >;
using Decrypter_ptr = std::unique_ptr< Decrypter >;
Decrypter_ptr decrypter;
std::array< EncryptedFrame, 8 > frames;
@ -193,9 +193,7 @@ namespace llarp
hop->info.downstream = commit->session->GetPubKey();
}
~LRCMFrameDecrypt()
{
}
~LRCMFrameDecrypt() = default;
static void
OnForwardLRCMResult(AbstractRouter* router, const PathID_t pathid,

View File

@ -9,6 +9,7 @@
#include <array>
#include <memory>
#include <utility>
namespace llarp
{
@ -49,14 +50,14 @@ namespace llarp
{
std::array< EncryptedFrame, 8 > frames;
LR_CommitMessage(const std::array< EncryptedFrame, 8 > &_frames)
: ILinkMessage(), frames(_frames)
LR_CommitMessage(std::array< EncryptedFrame, 8 > _frames)
: ILinkMessage(), frames(std::move(_frames))
{
}
LR_CommitMessage() = default;
~LR_CommitMessage() = default;
~LR_CommitMessage() override = default;
void
Clear() override;

View File

@ -12,6 +12,7 @@
#include <util/memfn.hpp>
#include <functional>
#include <utility>
namespace llarp
{
@ -25,10 +26,12 @@ namespace llarp
HopHandler_ptr path;
AbstractRouter* router;
LRSM_AsyncHandler(const std::array< EncryptedFrame, 8 >& _frames,
uint64_t _status, HopHandler_ptr _path,
AbstractRouter* _router)
: frames(_frames), status(_status), path(_path), router(_router)
LRSM_AsyncHandler(std::array< EncryptedFrame, 8 > _frames, uint64_t _status,
HopHandler_ptr _path, AbstractRouter* _router)
: frames(std::move(_frames))
, status(_status)
, path(std::move(_path))
, router(_router)
{
}
@ -57,7 +60,7 @@ namespace llarp
{
return BEncodeReadArray(frames, buf);
}
else if(key == "p")
if(key == "p")
{
if(!BEncodeMaybeReadDictEntry("p", pathid, read, key, buf))
{

View File

@ -9,6 +9,7 @@
#include <array>
#include <memory>
#include <utility>
namespace llarp
{
@ -56,14 +57,14 @@ namespace llarp
uint64_t status = 0;
LR_StatusMessage(const std::array< EncryptedFrame, 8 > &_frames)
: ILinkMessage(), frames(_frames)
LR_StatusMessage(std::array< EncryptedFrame, 8 > _frames)
: ILinkMessage(), frames(std::move(_frames))
{
}
LR_StatusMessage() = default;
~LR_StatusMessage() = default;
~LR_StatusMessage() override = default;
void
Clear() override;

View File

@ -8,6 +8,7 @@
#include <functional>
#include <iosfwd>
#include <utility>
namespace llarp
{
@ -22,13 +23,11 @@ namespace llarp
PublishFunction m_publish;
public:
JsonPublisher(const PublishFunction& publish) : m_publish(publish)
JsonPublisher(PublishFunction publish) : m_publish(std::move(publish))
{
}
~JsonPublisher()
{
}
~JsonPublisher() override = default;
void
publish(const Sample& values) override;

View File

@ -9,6 +9,7 @@
#include <string>
#include <thread>
#include <tuple>
#include <utility>
#include <vector>
namespace llarp
@ -32,9 +33,7 @@ namespace llarp
{
}
~MetricTankPublisherInterface()
{
}
~MetricTankPublisherInterface() override = default;
static std::string
makeSuffix(const Tags& tags);
@ -66,16 +65,16 @@ namespace llarp
work();
public:
MetricTankPublisher(const Tags& tags, const std::string& host, short port)
MetricTankPublisher(const Tags& tags, std::string host, short port)
: MetricTankPublisherInterface(tags)
, m_host(host)
, m_host(std::move(host))
, m_port(port)
, m_queue(100)
, m_worker(&MetricTankPublisher::work, this)
{
}
~MetricTankPublisher()
~MetricTankPublisher() override
{
// Push back a signal value onto the queue
m_queue.pushBack(StopStruct());

View File

@ -18,7 +18,7 @@ namespace llarp
{
}
~StreamPublisher() = default;
~StreamPublisher() override = default;
void
publish(const Sample& values) override;

View File

@ -8,7 +8,7 @@
#include <util/mem.h>
#include <util/printer.hpp>
#include <string.h>
#include <cstring>
namespace llarp
{

View File

@ -8,7 +8,6 @@
#include <string>
#include <vector>
#include <stdbool.h>
/**
* address_info.hpp

View File

@ -8,7 +8,7 @@
#include <util/mem.h>
#include <list>
#include <string.h>
#include <cstring>
namespace llarp
{

View File

@ -23,9 +23,7 @@ namespace llarp
PubKey pubkey;
uint64_t version = LLARP_PROTO_VERSION;
ExitInfo()
{
}
ExitInfo() = default;
ExitInfo(const PubKey &pk, const nuint32_t &ipv4_exit) : pubkey(pk)
{

View File

@ -71,7 +71,7 @@ namespace llarp
{
if(IsV6())
return In6ToHUInt(HeaderV6()->srcaddr);
else
return ExpandV4(srcv4());
}
@ -80,7 +80,7 @@ namespace llarp
{
if(IsV6())
return In6ToHUInt(HeaderV6()->dstaddr);
else
return ExpandV4(dstv4());
}

View File

@ -88,6 +88,7 @@ struct ipv6_header
#include <memory>
#include <service/protocol.hpp>
#include <utility>
struct llarp_ev_loop;
@ -136,7 +137,7 @@ namespace llarp
struct PutTime
{
llarp_ev_loop_ptr loop;
PutTime(llarp_ev_loop_ptr evloop) : loop(evloop)
PutTime(llarp_ev_loop_ptr evloop) : loop(std::move(evloop))
{
}
void
@ -149,7 +150,7 @@ namespace llarp
struct GetNow
{
llarp_ev_loop_ptr loop;
GetNow(llarp_ev_loop_ptr evloop) : loop(evloop)
GetNow(llarp_ev_loop_ptr evloop) : loop(std::move(evloop))
{
}
llarp_time_t
@ -224,9 +225,9 @@ namespace llarp
{
if(IsV4())
return service::eProtocolTrafficV4;
else if(IsV6())
if(IsV6())
return service::eProtocolTrafficV6;
else
return service::eProtocolControl;
}

View File

@ -786,7 +786,7 @@ llarp_getifaddr(const char* ifname, int af, struct sockaddr* addr)
if(af == AF_INET6)
{
// set scope id
sockaddr_in6* ip6addr = (sockaddr_in6*)addr;
auto* ip6addr = (sockaddr_in6*)addr;
ip6addr->sin6_scope_id = if_nametoindex(ifname);
ip6addr->sin6_flowinfo = 0;
}
@ -861,8 +861,8 @@ namespace llarp
const auto fam = i->ifa_addr->sa_family;
if(fam != AF_INET)
return;
sockaddr_in* addr = (sockaddr_in*)i->ifa_addr;
sockaddr_in* mask = (sockaddr_in*)i->ifa_netmask;
auto* addr = (sockaddr_in*)i->ifa_addr;
auto* mask = (sockaddr_in*)i->ifa_netmask;
nuint32_t ifaddr{addr->sin_addr.s_addr};
nuint32_t ifmask{mask->sin_addr.s_addr};
currentRanges.emplace_back(
@ -926,7 +926,7 @@ namespace llarp
GetIFAddr(const std::string& ifname, Addr& addr, int af)
{
sockaddr_storage s;
sockaddr* sptr = (sockaddr*)&s;
auto* sptr = (sockaddr*)&s;
if(!llarp_getifaddr(ifname.c_str(), af, sptr))
return false;
addr = *sptr;

View File

@ -25,7 +25,7 @@ typedef unsigned int in_addr_t;
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#include <stdbool.h>
#include <sys/types.h>
bool

View File

@ -11,7 +11,7 @@
#include <util/bits.hpp>
#include <functional>
#include <stdlib.h> // for itoa
#include <cstdlib> // for itoa
#include <vector>
// for addrinfo

View File

@ -16,12 +16,8 @@
namespace llarp
{
Addr::Addr()
{
}
Addr::~Addr()
{
}
Addr::Addr() = default;
Addr::~Addr() = default;
void
Addr::port(uint16_t port)
@ -87,7 +83,7 @@ namespace llarp
this->port(port);
}
Zero(&_addr, sizeof(sockaddr_in6));
struct addrinfo hint, *res = NULL;
struct addrinfo hint, *res = nullptr;
int ret;
memset(&hint, '\0', sizeof hint);
@ -98,11 +94,11 @@ namespace llarp
if(pPosition != string_view::npos)
{
ret = getaddrinfo(std::string(in.begin(), in.begin() + pPosition).c_str(),
NULL, &hint, &res);
nullptr, &hint, &res);
}
else
{
ret = getaddrinfo(std::string(in).c_str(), NULL, &hint, &res);
ret = getaddrinfo(std::string(in).c_str(), nullptr, &hint, &res);
}
if(ret)
@ -152,7 +148,7 @@ namespace llarp
{
Zero(&_addr, sizeof(sockaddr_in6));
struct in_addr* addr = &_addr4.sin_addr;
unsigned char* ip = (unsigned char*)&(addr->s_addr);
auto* ip = (unsigned char*)&(addr->s_addr);
_addr.sin6_family = AF_INET; // set ipv4 mode
_addr4.sin_family = AF_INET;
@ -311,7 +307,7 @@ namespace llarp
{
case AF_INET:
{
sockaddr_in* ipv4_dst = (sockaddr_in*)other;
auto* ipv4_dst = (sockaddr_in*)other;
dst = (void*)&ipv4_dst->sin_addr.s_addr;
src = (void*)&_addr4.sin_addr.s_addr;
ptr = &((sockaddr_in*)other)->sin_port;

View File

@ -32,7 +32,7 @@ namespace llarp
this->reset();
// maybe refactor the family detection out
struct addrinfo hint, *res = NULL;
struct addrinfo hint, *res = nullptr;
int ret;
memset(&hint, '\0', sizeof hint);
@ -40,7 +40,7 @@ namespace llarp
hint.ai_family = PF_UNSPEC;
hint.ai_flags = AI_NUMERICHOST;
ret = getaddrinfo(str, NULL, &hint, &res);
ret = getaddrinfo(str, nullptr, &hint, &res);
if(ret)
{
llarp::LogError("failed to determine address family: ", str);

View File

@ -14,7 +14,7 @@
#include <net/net.h>
#include <stdlib.h> // for itoa
#include <cstdlib> // for itoa
#include <iostream>
#include <util/endian.hpp>
#include <vector>

View File

@ -12,12 +12,13 @@
#include <fstream>
#include <unordered_map>
#include <utility>
static const char skiplist_subdirs[] = "0123456789abcdef";
static const std::string RC_FILE_EXT = ".signed";
llarp_nodedb::NetDBEntry::NetDBEntry(const llarp::RouterContact &value)
: rc(value), inserted(llarp::time_now_ms())
llarp_nodedb::NetDBEntry::NetDBEntry(llarp::RouterContact value)
: rc(std::move(value)), inserted(llarp::time_now_ms())
{
}
@ -151,7 +152,7 @@ llarp_nodedb::UpdateAsyncIfNewer(llarp::RouterContact rc,
InsertAsync(rc, logic, completionHandler);
return true;
}
else if(itr != entries.end())
if(itr != entries.end())
{
// insertion time is set on...insertion. But it should be updated here
// even if there is no insertion of a new RC, to show that the existing one
@ -362,8 +363,7 @@ llarp_nodedb::Save()
void
logic_threadworker_callback(void *user)
{
llarp_async_verify_rc *verify_request =
static_cast< llarp_async_verify_rc * >(user);
auto *verify_request = static_cast< llarp_async_verify_rc * >(user);
if(verify_request->hook)
verify_request->hook(verify_request);
}
@ -382,8 +382,7 @@ disk_threadworker_setRC(llarp_async_verify_rc *verify_request)
void
crypto_threadworker_verifyrc(void *user)
{
llarp_async_verify_rc *verify_request =
static_cast< llarp_async_verify_rc * >(user);
auto *verify_request = static_cast< llarp_async_verify_rc * >(user);
llarp::RouterContact rc = verify_request->rc;
verify_request->valid = rc.Verify(llarp::time_now_ms());
// if it's valid we need to set it
@ -404,14 +403,14 @@ crypto_threadworker_verifyrc(void *user)
void
nodedb_inform_load_rc(void *user)
{
llarp_async_load_rc *job = static_cast< llarp_async_load_rc * >(user);
auto *job = static_cast< llarp_async_load_rc * >(user);
job->hook(job);
}
void
nodedb_async_load_rc(void *user)
{
llarp_async_load_rc *job = static_cast< llarp_async_load_rc * >(user);
auto *job = static_cast< llarp_async_load_rc * >(user);
auto fpath = job->nodedb->getRCFilePath(job->pubkey);
job->loaded = job->nodedb->loadfile(fpath);

View File

@ -10,6 +10,7 @@
#include <absl/base/thread_annotations.h>
#include <set>
#include <utility>
#ifdef _MSC_VER
#include <BaseTsd.h>
@ -45,7 +46,7 @@ struct llarp_nodedb_iter
struct llarp_nodedb
{
explicit llarp_nodedb(std::shared_ptr< llarp::thread::ThreadPool > diskworker)
: disk(diskworker)
: disk(std::move(diskworker))
{
}
@ -62,7 +63,7 @@ struct llarp_nodedb
const llarp::RouterContact rc;
llarp_time_t inserted;
NetDBEntry(const llarp::RouterContact &data);
NetDBEntry(llarp::RouterContact data);
};
using NetDBMap_t =

View File

@ -22,9 +22,7 @@ namespace llarp
{
struct IHopHandler
{
virtual ~IHopHandler()
{
}
virtual ~IHopHandler() = default;
virtual bool
Expired(llarp_time_t now) const = 0;

View File

@ -215,7 +215,7 @@ namespace llarp
m_PathSet->HandlePathBuildFailed(shared_from_this());
return;
}
else if(st == ePathExpired && _status == ePathBuilding)
if(st == ePathExpired && _status == ePathBuilding)
{
_status = st;
m_PathSet->HandlePathBuildTimeout(shared_from_this());

View File

@ -53,18 +53,18 @@ namespace llarp
util::StatusObject
ExtractStatus() const;
virtual bool
bool
SelectHop(llarp_nodedb* db, const std::set< RouterID >& prev,
RouterContact& cur, size_t hop, PathRole roles) override;
virtual bool
bool
ShouldBuildMore(llarp_time_t now) const override;
/// should we bundle RCs in builds?
virtual bool
ShouldBundleRC() const = 0;
virtual void
void
ResetInternalState() override;
/// return true if we hit our soft limit for building paths too fast
@ -78,7 +78,7 @@ namespace llarp
return ePathRoleAny;
}
virtual bool
bool
Stop() override;
bool
@ -90,7 +90,7 @@ namespace llarp
llarp_time_t
Now() const override;
virtual void
void
Tick(llarp_time_t now) override;
void
@ -113,13 +113,13 @@ namespace llarp
virtual const SecretKey&
GetTunnelEncryptionSecretKey() const;
virtual void
void
HandlePathBuilt(Path_ptr p) override;
virtual void
void
HandlePathBuildTimeout(Path_ptr p) override;
virtual void
void
HandlePathBuildFailed(Path_ptr p) override;
};

View File

@ -31,9 +31,7 @@ namespace llarp
return stream;
}
TransitHop::TransitHop()
{
}
TransitHop::TransitHop() = default;
bool
TransitHop::Expired(llarp_time_t now) const

View File

@ -7,9 +7,7 @@
namespace llarp
{
PoW::~PoW()
{
}
PoW::~PoW() = default;
bool
PoW::DecodeKey(ABSL_ATTRIBUTE_UNUSED const llarp_buffer_t& k,

View File

@ -22,7 +22,7 @@ namespace llarp
struct OutboundMessageHandler final : public IOutboundMessageHandler
{
public:
~OutboundMessageHandler() = default;
~OutboundMessageHandler() override = default;
bool
QueueMessage(const RouterID &remote, const ILinkMessage *msg,

View File

@ -10,6 +10,7 @@
#include <util/threading.hpp>
#include <util/status.hpp>
#include <crypto/crypto.hpp>
#include <utility>
namespace llarp
{
@ -22,8 +23,8 @@ namespace llarp
size_t attemptCount = 0;
PendingSession(const RouterContact &_rc, LinkLayer_ptr _link)
: rc(_rc), link(_link)
PendingSession(RouterContact _rc, LinkLayer_ptr _link)
: rc(std::move(_rc)), link(std::move(_link))
{
}
};

View File

@ -26,7 +26,7 @@ namespace llarp
using CallbacksQueue = std::list< RouterCallback >;
public:
~OutboundSessionMaker() = default;
~OutboundSessionMaker() override = default;
bool
OnSessionEstablished(ILinkSession *session) override;

View File

@ -28,7 +28,7 @@ namespace llarp
public:
using CallbacksQueue = std::list< RCRequestCallback >;
~RCLookupHandler() = default;
~RCLookupHandler() override = default;
void
AddValidRouter(const RouterID &router) override LOCKS_EXCLUDED(_mutex);

Some files were not shown because too many files have changed in this diff Show More