Review fixes

- cleaned up include-what-you-use errors (mostly quoted includes)
- misc fixes
This commit is contained in:
dr7ana 2023-10-24 12:25:42 -07:00
parent 3d44e58e34
commit 57393ea740
13 changed files with 10 additions and 118 deletions

View File

@ -639,7 +639,7 @@ main(int argc, char* argv[])
static const char* text = "Don't run lokinet in wine, aborting startup";
static const char* title = "Lokinet Wine Error";
MessageBoxA(NULL, text, title, MB_ICONHAND);
abort();
std::abort();
}
}

View File

@ -98,7 +98,6 @@ lokinet_add_library(lokinet-time-place
net/ip_range.cpp
net/net_int.cpp
net/sock_addr.cpp
pow.cpp # only intro_set
router_contact.cpp
router_id.cpp
router_version.cpp # to be deleted shortly

View File

@ -238,7 +238,7 @@ namespace llarp
size_t
NodeDB::num_loaded() const
{
return router.loop()->call_get([this]() -> size_t { return entries.size(); });
return router.loop()->call_get([this]() { return entries.size(); });
}
void

View File

@ -1,56 +0,0 @@
#include "pow.hpp"
#include "crypto/crypto.hpp"
#include <cmath>
namespace llarp
{
PoW::~PoW() = default;
bool
PoW::decode_key(const llarp_buffer_t& /*k*/, llarp_buffer_t* /*val*/)
{
// TODO: implement me
return false;
}
std::string
PoW::bt_encode() const
{
return ""s;
}
bool
PoW::IsValid(llarp_time_t now) const
{
if (now - timestamp > extendedLifetime)
return false;
ShortHash digest;
auto buf = bt_encode();
// hash
if (!crypto::shorthash(digest, reinterpret_cast<uint8_t*>(buf.data()), buf.size()))
return false;
// check bytes required
uint32_t required = std::floor(std::log(extendedLifetime.count()));
for (uint32_t idx = 0; idx < required; ++idx)
{
if (digest[idx])
return false;
}
return true;
}
std::string
PoW::ToString() const
{
return fmt::format(
"[PoW timestamp={} lifetime={} nonce={}]",
timestamp.count(),
extendedLifetime.count(),
nonce);
}
} // namespace llarp

View File

@ -1,48 +0,0 @@
#pragma once
#include "router_id.hpp"
#include "util/buffer.hpp"
namespace llarp
{
/// proof of work
struct PoW
{
static constexpr size_t MaxSize = 128;
llarp_time_t timestamp = 0s;
llarp_time_t extendedLifetime = 0s;
AlignedBuffer<32> nonce;
uint64_t version = llarp::constants::proto_version;
~PoW();
bool
IsValid(llarp_time_t now) const;
bool
decode_key(const llarp_buffer_t& k, llarp_buffer_t* val);
std::string
bt_encode() const;
bool
operator==(const PoW& other) const
{
return timestamp == other.timestamp && version == other.version
&& extendedLifetime == other.extendedLifetime && nonce == other.nonce;
}
bool
operator!=(const PoW& other) const
{
return !(*this == other);
}
std::string
ToString() const;
};
template <>
constexpr inline bool IsToStringFormattable<PoW> = true;
} // namespace llarp

View File

@ -106,10 +106,7 @@ namespace llarp
if (callback)
callback(result.router_id(), result, true);
else
{
r.node_db()->put_rc_if_newer(result);
// r.connect_to(result);
}
}
else
{

View File

@ -184,6 +184,7 @@ namespace llarp::service
IntroSet::ExtractStatus() const
{
util::StatusObject obj{{"published", to_json(time_signed)}};
// TODO: this
// std::vector<util::StatusObject> introsObjs;
// std::transform(
// intros.begin(),

View File

@ -9,7 +9,6 @@
#include <llarp/dns/srv_data.hpp>
#include <llarp/net/ip_range.hpp>
#include <llarp/net/traffic_policy.hpp>
#include <llarp/pow.hpp>
#include <llarp/util/bencode.hpp>
#include <llarp/util/status.hpp>
#include <llarp/util/time.hpp>

View File

@ -489,7 +489,7 @@ namespace llarp::service
}
void
OutboundContext::Tick(std::chrono::milliseconds now)
OutboundContext::Tick(llarp_time_t now)
{
path::Builder::Tick(now);

View File

@ -79,7 +79,7 @@ namespace llarp::service
send_auth_async(std::function<void(std::string, bool)> resultHandler);
void
Tick(std::chrono::milliseconds now) override;
Tick(llarp_time_t now) override;
util::StatusObject
ExtractStatus() const;

View File

@ -39,8 +39,7 @@ namespace llarp::service
ProtocolMessage::decode_key(const llarp_buffer_t& k, llarp_buffer_t* buf)
{
bool read = false;
// if (!BEncodeMaybeReadDictInt("a", proto, read, k, buf))
// return false;
if (k.startswith("d"))
{
llarp_buffer_t strbuf;

View File

@ -5,9 +5,10 @@
#include <llarp.hpp>
#include <stdio.h>
#include <unistd.h>
#include <cstdio>
namespace llarp::vpn
{
class AndroidInterface : public NetworkInterface

View File

@ -1,8 +1,8 @@
#include "common.hpp"
#include <llarp/router/router.hpp>
#include <llarp/tooling/hive_router.hpp>
#include <common.hpp>
namespace llarp
{
void