Apply rule of zero to code base

pull/611/head
Michael 5 years ago
parent 65766a501f
commit dd8a93a400
No known key found for this signature in database
GPG Key ID: 2D51757B47E2434C

@ -42,7 +42,7 @@ namespace abyss
struct BaseReqHandler
{
BaseReqHandler(llarp_time_t req_timeout);
~BaseReqHandler();
virtual ~BaseReqHandler();
bool
ServeAsync(llarp_ev_loop_ptr loop, llarp::Logic* logic,

@ -54,9 +54,7 @@ namespace abyss
m_State = eReadHTTPMethodLine;
}
~ConnImpl()
{
}
~ConnImpl() = default;
bool
FeedLine(std::string& line)

@ -3167,7 +3167,8 @@ utp_connect(utp_socket *conn, const struct sockaddr *to, socklen_t tolen)
"UTP_Connect conn_seed:%u packet_size:%u (B) "
"target_delay:%u (ms) delay_history:%u "
"delay_base_history:%u (minutes)",
conn->conn_seed, PACKET_SIZE, conn->target_delay / 1000,
conn->conn_seed, PACKET_SIZE,
static_cast< unsigned int >(conn->target_delay / 1000),
CUR_DELAY_SIZE, DELAY_BASE_HISTORY);
// Setup initial timeout timer.

@ -59,10 +59,6 @@ namespace llarp
{
}
~Encrypted()
{
}
bool
BEncode(llarp_buffer_t* buf) const
{

@ -27,16 +27,6 @@ namespace llarp
: Encrypted< EncryptedFrameSize >(std::min(sz, EncryptedFrameBodySize)
+ EncryptedFrameOverheadSize)
{
UpdateBuffer();
}
EncryptedFrame&
operator=(const EncryptedFrame& other)
{
_sz = other._sz;
memcpy(data(), other.data(), size());
UpdateBuffer();
return *this;
}
void

@ -39,12 +39,6 @@ namespace llarp
bool
FromString(const std::string &str);
friend std::ostream &
operator<<(std::ostream &out, const PubKey &k)
{
return out << k.ToString();
}
operator RouterID() const
{
return RouterID(as_array());
@ -58,6 +52,12 @@ namespace llarp
}
};
inline std::ostream &
operator<<(std::ostream &out, const PubKey &k)
{
return out << k.ToString();
}
inline bool
operator==(const PubKey &lhs, const PubKey &rhs)
{
@ -82,22 +82,10 @@ namespace llarp
{
}
explicit SecretKey(const SecretKey &k) : AlignedBuffer< SECKEYSIZE >(k)
{
}
explicit SecretKey(const byte_t *ptr) : AlignedBuffer< SECKEYSIZE >(ptr)
{
}
friend std::ostream &
operator<<(std::ostream &out, const SecretKey &)
{
// return out << k.ToHex();
// make sure we never print out secret keys
return out << "[secretkey]";
}
std::ostream &
print(std::ostream &stream, int level, int spaces) const
{
@ -117,15 +105,16 @@ namespace llarp
bool
SaveToFile(const char *fname) const;
SecretKey &
operator=(const byte_t *ptr)
{
std::copy(ptr, ptr + SIZE, begin());
return *this;
}
};
inline std::ostream &
operator<<(std::ostream &out, const SecretKey &)
{
// return out << k.ToHex();
// make sure we never print out secret keys
return out << "[secretkey]";
}
/// IdentitySecret is a secret key from a service node secret seed
struct IdentitySecret final : public AlignedBuffer< 32 >
{
@ -133,14 +122,6 @@ namespace llarp
{
}
friend std::ostream &
operator<<(std::ostream &out, const IdentitySecret &)
{
// return out << k.ToHex();
// make sure we never print out secret keys
return out << "[secretkey]";
}
/// no copy constructor
explicit IdentitySecret(const IdentitySecret &) = delete;
// no byte data constructor
@ -151,6 +132,13 @@ namespace llarp
LoadFromFile(const char *fname);
};
inline std::ostream &
operator<<(std::ostream &out, const IdentitySecret &)
{
// make sure we never print out secret keys
return out << "[IdentitySecret]";
}
using ShortHash = AlignedBuffer< SHORTHASHSIZE >;
using LongHash = AlignedBuffer< HASHSIZE >;

@ -66,16 +66,6 @@ namespace llarp
return c->sign(Z, sk, buf);
}
CloseExitMessage&
CloseExitMessage::operator=(const CloseExitMessage& other)
{
S = other.S;
version = other.version;
Y = other.Y;
Z = other.Z;
return *this;
}
bool
CloseExitMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const
{

@ -71,17 +71,6 @@ namespace llarp
return c->sign(Z, sk, buf);
}
GrantExitMessage&
GrantExitMessage::operator=(const GrantExitMessage& other)
{
S = other.S;
T = other.T;
version = other.version;
Y = other.Y;
Z = other.Z;
return *this;
}
bool
GrantExitMessage::HandleMessage(IMessageHandler* h, AbstractRouter* r) const
{

@ -52,19 +52,6 @@ namespace llarp
return read;
}
RejectExitMessage&
RejectExitMessage::operator=(const RejectExitMessage& other)
{
B = other.B;
R = other.R;
S = other.S;
T = other.T;
version = other.version;
Y = other.Y;
Z = other.Z;
return *this;
}
bool
RejectExitMessage::Sign(llarp::Crypto* c, const llarp::SecretKey& sk)
{

@ -7,15 +7,6 @@ namespace llarp
{
namespace routing
{
TransferTrafficMessage&
TransferTrafficMessage::operator=(const TransferTrafficMessage& other)
{
S = other.S;
version = other.version;
X = other.X;
return *this;
}
bool
TransferTrafficMessage::PutBuffer(const llarp_buffer_t& buf,
uint64_t counter)

@ -59,18 +59,6 @@ namespace llarp
return c->verify(pk, buf, Z);
}
UpdateExitMessage&
UpdateExitMessage::operator=(const UpdateExitMessage& other)
{
P = other.P;
S = other.S;
T = other.T;
version = other.version;
Y = other.Y;
Z = other.Z;
return *this;
}
bool
UpdateExitMessage::Sign(llarp::Crypto* c, const llarp::SecretKey& sk)
{

@ -62,19 +62,10 @@ namespace llarp
struct GrantExitMessage final : public IMessage
{
using Nonce_t = llarp::AlignedBuffer< 16 >;
uint64_t T;
Nonce_t Y;
llarp::Signature Z;
GrantExitMessage() : IMessage()
{
}
~GrantExitMessage()
{
}
GrantExitMessage&
operator=(const GrantExitMessage& other);
bool
BEncode(llarp_buffer_t* buf) const override;
@ -109,14 +100,6 @@ namespace llarp
Nonce_t Y;
llarp::Signature Z;
RejectExitMessage() : IMessage()
{
}
~RejectExitMessage()
{
}
void
Clear() override
{
@ -127,9 +110,6 @@ namespace llarp
Z.Zero();
}
RejectExitMessage&
operator=(const RejectExitMessage& other);
bool
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
@ -196,17 +176,6 @@ namespace llarp
Nonce_t Y;
llarp::Signature Z;
UpdateExitMessage() : IMessage()
{
}
~UpdateExitMessage()
{
}
UpdateExitMessage&
operator=(const UpdateExitMessage& other);
bool
Sign(llarp::Crypto* c, const llarp::SecretKey& sk);
@ -239,17 +208,6 @@ namespace llarp
Nonce_t Y;
llarp::Signature Z;
CloseExitMessage() : IMessage()
{
}
~CloseExitMessage()
{
}
CloseExitMessage&
operator=(const CloseExitMessage& other);
bool
BEncode(llarp_buffer_t* buf) const override;

@ -8,10 +8,6 @@
namespace llarp
{
LinkIntroMessage::~LinkIntroMessage()
{
}
bool
LinkIntroMessage::DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf)
{
@ -104,17 +100,6 @@ namespace llarp
return bencode_end(buf);
}
LinkIntroMessage&
LinkIntroMessage::operator=(const LinkIntroMessage& msg)
{
version = msg.version;
Z = msg.Z;
rc = msg.rc;
N = msg.N;
P = msg.P;
return *this;
}
bool
LinkIntroMessage::HandleMessage(AbstractRouter* router) const
{

@ -17,16 +17,11 @@ namespace llarp
{
}
~LinkIntroMessage();
RouterContact rc;
KeyExchangeNonce N;
Signature Z;
uint64_t P;
LinkIntroMessage&
operator=(const LinkIntroMessage& msg);
bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* buf) override;

@ -31,9 +31,6 @@ namespace llarp
return _size;
}
TransferTrafficMessage&
operator=(const TransferTrafficMessage& other);
/// append buffer to X
bool
PutBuffer(const llarp_buffer_t& buf, uint64_t counter);

@ -91,6 +91,7 @@ namespace llarp
break;
}
assert(false && "Invalid publication type");
return {};
}
std::string

@ -14,42 +14,6 @@
#define inet_aton(x, y) inet_pton(AF_INET, x, y)
#endif
llarp::Addr::operator const sockaddr*() const
{
if(af() == AF_INET)
return (const sockaddr*)&_addr4;
else
return (const sockaddr*)&_addr;
}
llarp::Addr::operator sockaddr*() const
{
if(af() == AF_INET)
return (sockaddr*)&_addr4;
else
return (sockaddr*)&_addr;
}
bool
llarp::Addr::operator<(const Addr& other) const
{
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();
}
bool
llarp::Addr::operator==(const Addr& other) const
{
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();
}
namespace llarp
{
Addr::Addr()
@ -112,9 +76,8 @@ namespace llarp
Addr::Addr(string_view addr_str, string_view port_str)
{
this->from_char_array(llarp::string_view_string(addr_str).c_str());
this->port(
std::strtoul(llarp::string_view_string(port_str).c_str(), nullptr, 10));
this->from_char_array(string_view_string(addr_str).c_str());
this->port(std::strtoul(string_view_string(port_str).c_str(), nullptr, 10));
}
bool
@ -129,16 +92,16 @@ namespace llarp
char buf[6];
snprintf(buf, 6, "%s", pPosition + 1);
uint16_t port = std::atoi(buf);
llarp::LogDebug("Setting port ", std::to_string(port));
LogDebug("Setting port ", std::to_string(port));
this->port(port);
// trim str
// can't VLA
str = strdup(in); // copy it
str[pPosition - in] = '\0'; // nul terminate it early
llarp::LogDebug("Truncating to ", str);
LogDebug("Truncating to ", str);
freeStr = true;
}
llarp::Zero(&_addr, sizeof(sockaddr_in6));
Zero(&_addr, sizeof(sockaddr_in6));
struct addrinfo hint, *res = NULL;
int ret;
@ -150,7 +113,7 @@ namespace llarp
ret = getaddrinfo(str, NULL, &hint, &res);
if(ret)
{
llarp::LogError("failed to determine address family: ", str);
LogError("failed to determine address family: ", str);
if(freeStr)
free(str);
return false;
@ -158,14 +121,14 @@ namespace llarp
if(res->ai_family == AF_INET6)
{
llarp::LogError("IPv6 address not supported yet", str);
LogError("IPv6 address not supported yet", str);
if(freeStr)
free(str);
return false;
}
else if(res->ai_family != AF_INET)
{
llarp::LogError("Address family not supported yet", str);
LogError("Address family not supported yet", str);
if(freeStr)
free(str);
return false;
@ -175,7 +138,7 @@ namespace llarp
struct in_addr* addr = &_addr4.sin_addr;
if(inet_aton(str, addr) == 0)
{
llarp::LogError("failed to parse ", str);
LogError("failed to parse ", str);
if(freeStr)
free(str);
return false;
@ -208,7 +171,7 @@ namespace llarp
Addr::from_4int(const uint8_t one, const uint8_t two, const uint8_t three,
const uint8_t four)
{
llarp::Zero(&_addr, sizeof(sockaddr_in6));
Zero(&_addr, sizeof(sockaddr_in6));
struct in_addr* addr = &_addr4.sin_addr;
unsigned char* ip = (unsigned char*)&(addr->s_addr);
@ -264,7 +227,7 @@ namespace llarp
Addr::Addr(const sockaddr_in& other)
{
llarp::Zero(&_addr, sizeof(sockaddr_in6));
Zero(&_addr, sizeof(sockaddr_in6));
_addr.sin6_family = AF_INET;
uint8_t* addrptr = _addr.sin6_addr.s6_addr;
uint16_t* port = &_addr.sin6_port;
@ -300,7 +263,7 @@ namespace llarp
Addr::Addr(const sockaddr& other)
{
llarp::Zero(&_addr, sizeof(sockaddr_in6));
Zero(&_addr, sizeof(sockaddr_in6));
_addr.sin6_family = other.sa_family;
uint8_t* addrptr = _addr.sin6_addr.s6_addr;
uint16_t* port = &_addr.sin6_port;
@ -406,10 +369,46 @@ namespace llarp
return ntohs(_addr.sin6_port);
}
Addr::operator const sockaddr*() const
{
if(af() == AF_INET)
return (const sockaddr*)&_addr4;
else
return (const sockaddr*)&_addr;
}
Addr::operator sockaddr*() const
{
if(af() == AF_INET)
return (sockaddr*)&_addr4;
else
return (sockaddr*)&_addr;
}
bool
Addr::operator<(const Addr& other) const
{
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();
}
bool
Addr::operator==(const Addr& other) const
{
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();
}
Addr&
Addr::operator=(const sockaddr& other)
{
llarp::Zero(&_addr, sizeof(sockaddr_in6));
Zero(&_addr, sizeof(sockaddr_in6));
_addr.sin6_family = other.sa_family;
uint8_t* addrptr = _addr.sin6_addr.s6_addr;
uint16_t* port = &_addr.sin6_port;

@ -53,7 +53,6 @@ namespace llarp
struct TransitHopInfo
{
TransitHopInfo() = default;
TransitHopInfo(const TransitHopInfo& other);
TransitHopInfo(const RouterID& down, const LR_CommitRecord& record);
PathID_t txID, rxID;
@ -158,8 +157,6 @@ namespace llarp
{
TransitHop();
TransitHop(const TransitHop& other);
TransitHopInfo info;
SharedSecret pathKey;
ShortHash nonceXOR;

@ -253,7 +253,7 @@ namespace llarp
return true;
}
} while(tries > 0);
return tries > 0;
return false;
}
bool

@ -32,14 +32,6 @@ namespace llarp
return started + lifetime;
}
TransitHopInfo::TransitHopInfo(const TransitHopInfo& other)
: txID(other.txID)
, rxID(other.rxID)
, upstream(other.upstream)
, downstream(other.downstream)
{
}
TransitHopInfo::TransitHopInfo(const RouterID& down,
const LR_CommitRecord& record)
: txID(record.txid)
@ -49,15 +41,6 @@ namespace llarp
{
}
TransitHop::TransitHop(const TransitHop& other)
: info(other.info)
, pathKey(other.pathKey)
, started(other.started)
, lifetime(other.lifetime)
, version(other.version)
{
}
bool
TransitHop::SendRoutingMessage(const routing::IMessage& msg,
AbstractRouter* r)

@ -17,18 +17,9 @@ namespace llarp
PubKey router;
PathID_t pathID;
uint64_t latency = 0;
uint64_t version = 0;
uint64_t expiresAt = 0;
Introduction() = default;
Introduction(const Introduction& other) : IBEncodeMessage(other.version)
{
router = other.router;
pathID = other.pathID;
latency = other.latency;
version = other.version;
expiresAt = other.expiresAt;
}
util::StatusObject
ExtractStatus() const;

@ -36,13 +36,6 @@ namespace llarp
begin());
}
Tag&
operator=(const Tag& other)
{
as_array() = other.as_array();
return *this;
}
Tag&
operator=(const std::string& str)
{

@ -178,7 +178,7 @@ namespace llarp
QueueManager::~QueueManager()
{
delete m_states;
delete[] m_states;
}
QueueReturn

Loading…
Cancel
Save