replace LLARP_PROTO_VERSION macro

pull/1923/head
Jeff 2 years ago
parent 0331db494e
commit 1eba0f836e
No known key found for this signature in database
GPG Key ID: 025C02EE3A092F2D

@ -1,13 +1,9 @@
#pragma once #pragma once
#ifndef LLARP_PROTO_VERSION namespace llarp::constants
#define LLARP_PROTO_VERSION (0) {
#endif /// current network wide protocol version
// TODO: enum class
constexpr auto proto_version = 0;
#ifndef LLARP_ETH_PROTO } // namespace llarp::constants
#define LLARP_ETH_PROTO (0xD1CE)
#endif
#ifndef LLARP_KEYFILE_VERSION
#define LLARP_KEYFILE_VERSION (1)
#endif

@ -16,7 +16,7 @@ namespace llarp
{ {
// clang-format off // clang-format off
const std::array<uint16_t, 3> VERSION{{LLARP_VERSION_MAJOR, LLARP_VERSION_MINOR, LLARP_VERSION_PATCH}}; const std::array<uint16_t, 3> VERSION{{LLARP_VERSION_MAJOR, LLARP_VERSION_MINOR, LLARP_VERSION_PATCH}};
const std::array<uint64_t, 4> ROUTER_VERSION{{LLARP_PROTO_VERSION, LLARP_VERSION_MAJOR, LLARP_VERSION_MINOR, LLARP_VERSION_PATCH}}; const std::array<uint64_t, 4> ROUTER_VERSION{{llarp::constants::proto_version, LLARP_VERSION_MAJOR, LLARP_VERSION_MINOR, LLARP_VERSION_PATCH}};
const char* const VERSION_STR = LLARP_VERSION_STR; const char* const VERSION_STR = LLARP_VERSION_STR;
const char* const VERSION_TAG = "@VERSIONTAG@"; const char* const VERSION_TAG = "@VERSIONTAG@";
const char* const VERSION_FULL = LLARP_NAME "-" LLARP_VERSION_STR "-@VERSIONTAG@"; const char* const VERSION_FULL = LLARP_NAME "-" LLARP_VERSION_STR "-@VERSIONTAG@";

@ -34,7 +34,7 @@ namespace llarp
Key_t From; Key_t From;
PathID_t pathID; PathID_t pathID;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
}; };
IMessage::Ptr_t IMessage::Ptr_t

@ -28,7 +28,7 @@ namespace llarp
if (!BEncodeMaybeReadDictInt("T", txID, read, k, val)) if (!BEncodeMaybeReadDictInt("T", txID, read, k, val))
return false; return false;
if (!BEncodeMaybeVerifyVersion("V", version, LLARP_PROTO_VERSION, read, k, val)) if (!BEncodeMaybeVerifyVersion("V", version, llarp::constants::proto_version, read, k, val))
return false; return false;
return read; return read;
@ -66,7 +66,7 @@ namespace llarp
if (!BEncodeWriteDictInt("T", txID, buf)) if (!BEncodeWriteDictInt("T", txID, buf))
return false; return false;
// protocol version // protocol version
if (!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf)) if (!BEncodeWriteDictInt("V", llarp::constants::proto_version, buf))
return false; return false;
return bencode_end(buf); return bencode_end(buf);

@ -73,7 +73,7 @@ namespace llarp
return bencode_read_integer(val, &txid); return bencode_read_integer(val, &txid);
} }
bool read = false; bool read = false;
if (!BEncodeMaybeVerifyVersion("V", version, LLARP_PROTO_VERSION, read, key, val)) if (!BEncodeMaybeVerifyVersion("V", version, llarp::constants::proto_version, read, key, val))
return false; return false;
return read; return read;

@ -30,7 +30,7 @@ namespace llarp
/// gossip message /// gossip message
GotRouterMessage(const RouterContact rc) : IMessage({}), foundRCs({rc}), txid(0) GotRouterMessage(const RouterContact rc) : IMessage({}), foundRCs({rc}), txid(0)
{ {
version = LLARP_PROTO_VERSION; version = llarp::constants::proto_version;
} }
GotRouterMessage(const GotRouterMessage& other) GotRouterMessage(const GotRouterMessage& other)

@ -195,7 +195,7 @@ namespace llarp
return false; return false;
if (!BEncodeWriteDictInt("T", txID, buf)) if (!BEncodeWriteDictInt("T", txID, buf))
return false; return false;
if (!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf)) if (!BEncodeWriteDictInt("V", llarp::constants::proto_version, buf))
return false; return false;
return bencode_end(buf); return bencode_end(buf);
} }

@ -11,7 +11,7 @@ namespace llarp
uint64_t proto = 0; uint64_t proto = 0;
uint64_t port = 0; uint64_t port = 0;
uint64_t drop = 0; uint64_t drop = 0;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
bool bool
BDecode(llarp_buffer_t* buf) BDecode(llarp_buffer_t* buf)

@ -24,7 +24,7 @@ namespace llarp
} }
// randomize nounce // randomize nounce
CryptoManager::instance()->randbytes(pkt.data() + HMACSIZE, TUNNONCESIZE); CryptoManager::instance()->randbytes(pkt.data() + HMACSIZE, TUNNONCESIZE);
pkt[PacketOverhead] = LLARP_PROTO_VERSION; pkt[PacketOverhead] = llarp::constants::proto_version;
pkt[PacketOverhead + 1] = cmd; pkt[PacketOverhead + 1] = cmd;
return pkt; return pkt;
} }
@ -653,10 +653,13 @@ namespace llarp
LogError("failed to decrypt session data from ", m_RemoteAddr); LogError("failed to decrypt session data from ", m_RemoteAddr);
continue; continue;
} }
if (pkt[PacketOverhead] != LLARP_PROTO_VERSION) if (pkt[PacketOverhead] != llarp::constants::proto_version)
{ {
LogError( LogError(
"protocol version mismatch ", int(pkt[PacketOverhead]), " != ", LLARP_PROTO_VERSION); "protocol version mismatch ",
int(pkt[PacketOverhead]),
" != ",
llarp::constants::proto_version);
itr = msgs.erase(itr); itr = msgs.erase(itr);
continue; continue;
} }

@ -20,7 +20,7 @@ namespace llarp
{ {
if (!bencode_read_integer(buf, &version)) if (!bencode_read_integer(buf, &version))
return false; return false;
return version == LLARP_PROTO_VERSION; return version == llarp::constants::proto_version;
} }
// bad key // bad key
return false; return false;
@ -54,7 +54,7 @@ namespace llarp
return false; return false;
// protocol version // protocol version
if (!bencode_write_uint64_entry(buf, "v", 1, LLARP_PROTO_VERSION)) if (!bencode_write_uint64_entry(buf, "v", 1, llarp::constants::proto_version))
return false; return false;
return bencode_end(buf); return bencode_end(buf);

@ -69,7 +69,7 @@ namespace llarp
DataDiscardMessage(const PathID_t& dst, uint64_t s) : P(dst) DataDiscardMessage(const PathID_t& dst, uint64_t s) : P(dst)
{ {
S = s; S = s;
version = LLARP_PROTO_VERSION; version = llarp::constants::proto_version;
} }
void void

@ -43,9 +43,10 @@ namespace llarp
{ {
if (!bencode_read_integer(buf, &version)) if (!bencode_read_integer(buf, &version))
return false; return false;
if (version != LLARP_PROTO_VERSION) if (version != llarp::constants::proto_version)
{ {
llarp::LogWarn("llarp protocol version mismatch ", version, " != ", LLARP_PROTO_VERSION); llarp::LogWarn(
"llarp protocol version mismatch ", version, " != ", llarp::constants::proto_version);
return false; return false;
} }
llarp::LogDebug("LIM version ", version); llarp::LogDebug("LIM version ", version);
@ -86,7 +87,7 @@ namespace llarp
if (!rc.BEncode(buf)) if (!rc.BEncode(buf))
return false; return false;
if (!bencode_write_uint64_entry(buf, "v", 1, LLARP_PROTO_VERSION)) if (!bencode_write_uint64_entry(buf, "v", 1, llarp::constants::proto_version))
return false; return false;
if (!bencode_write_bytestring(buf, "z", 1)) if (!bencode_write_bytestring(buf, "z", 1))

@ -17,7 +17,7 @@ namespace llarp
{ {
/// who did this message come from or is going to /// who did this message come from or is going to
ILinkSession* session = nullptr; ILinkSession* session = nullptr;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
PathID_t pathid; PathID_t pathid;

@ -25,7 +25,7 @@ namespace llarp
if (!BEncodeWriteDictEntry("p", pathid, buf)) if (!BEncodeWriteDictEntry("p", pathid, buf))
return false; return false;
if (!BEncodeWriteDictInt("v", LLARP_PROTO_VERSION, buf)) if (!BEncodeWriteDictInt("v", llarp::constants::proto_version, buf))
return false; return false;
if (!BEncodeWriteDictEntry("x", X, buf)) if (!BEncodeWriteDictEntry("x", X, buf))
return false; return false;
@ -40,7 +40,7 @@ namespace llarp
bool read = false; bool read = false;
if (!BEncodeMaybeReadDictEntry("p", pathid, read, key, buf)) if (!BEncodeMaybeReadDictEntry("p", pathid, read, key, buf))
return false; return false;
if (!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, key, buf)) if (!BEncodeMaybeVerifyVersion("v", version, llarp::constants::proto_version, read, key, buf))
return false; return false;
if (!BEncodeMaybeReadDictEntry("x", X, read, key, buf)) if (!BEncodeMaybeReadDictEntry("x", X, read, key, buf))
return false; return false;
@ -79,7 +79,7 @@ namespace llarp
if (!BEncodeWriteDictEntry("p", pathid, buf)) if (!BEncodeWriteDictEntry("p", pathid, buf))
return false; return false;
if (!BEncodeWriteDictInt("v", LLARP_PROTO_VERSION, buf)) if (!BEncodeWriteDictInt("v", llarp::constants::proto_version, buf))
return false; return false;
if (!BEncodeWriteDictEntry("x", X, buf)) if (!BEncodeWriteDictEntry("x", X, buf))
return false; return false;
@ -94,7 +94,7 @@ namespace llarp
bool read = false; bool read = false;
if (!BEncodeMaybeReadDictEntry("p", pathid, read, key, buf)) if (!BEncodeMaybeReadDictEntry("p", pathid, read, key, buf))
return false; return false;
if (!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, key, buf)) if (!BEncodeMaybeVerifyVersion("v", version, llarp::constants::proto_version, read, key, buf))
return false; return false;
if (!BEncodeMaybeReadDictEntry("x", X, read, key, buf)) if (!BEncodeMaybeReadDictEntry("x", X, read, key, buf))
return false; return false;

@ -29,7 +29,7 @@ namespace llarp
return BEncodeReadArray(frames, buf); return BEncodeReadArray(frames, buf);
} }
bool read = false; bool read = false;
if (!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, key, buf)) if (!BEncodeMaybeVerifyVersion("v", version, llarp::constants::proto_version, read, key, buf))
return false; return false;
return read; return read;
@ -54,7 +54,7 @@ namespace llarp
if (!BEncodeWriteDictArray("c", frames, buf)) if (!BEncodeWriteDictArray("c", frames, buf))
return false; return false;
// version // version
if (!bencode_write_uint64_entry(buf, "v", 1, LLARP_PROTO_VERSION)) if (!bencode_write_uint64_entry(buf, "v", 1, llarp::constants::proto_version))
return false; return false;
return bencode_end(buf); return bencode_end(buf);
@ -102,9 +102,10 @@ namespace llarp
if (!BEncodeWriteDictEntry("u", *nextRC, buf)) if (!BEncodeWriteDictEntry("u", *nextRC, buf))
return false; return false;
} }
if (!bencode_write_uint64_entry(buf, "v", 1, LLARP_PROTO_VERSION))
if (not bencode_write_uint64_entry(buf, "v", 1, llarp::constants::proto_version))
return false; return false;
if (work && !BEncodeWriteDictEntry("w", *work, buf)) if (work and not BEncodeWriteDictEntry("w", *work, buf))
return false; return false;
return bencode_end(buf); return bencode_end(buf);
@ -135,7 +136,8 @@ namespace llarp
nextRC = std::make_unique<RouterContact>(); nextRC = std::make_unique<RouterContact>();
return nextRC->BDecode(buffer); return nextRC->BDecode(buffer);
} }
if (!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, *key, buffer)) if (!BEncodeMaybeVerifyVersion(
"v", version, llarp::constants::proto_version, read, *key, buffer))
return false; return false;
if (*key == "w") if (*key == "w")
{ {

@ -80,7 +80,7 @@ namespace llarp
} }
else if (key == "v") else if (key == "v")
{ {
if (!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, key, buf)) if (!BEncodeMaybeVerifyVersion("v", version, llarp::constants::proto_version, read, key, buf))
{ {
return false; return false;
} }
@ -115,7 +115,7 @@ namespace llarp
if (!BEncodeWriteDictInt("s", status, buf)) if (!BEncodeWriteDictInt("s", status, buf))
return false; return false;
// version // version
if (!bencode_write_uint64_entry(buf, "v", 1, LLARP_PROTO_VERSION)) if (!bencode_write_uint64_entry(buf, "v", 1, llarp::constants::proto_version))
return false; return false;
return bencode_end(buf); return bencode_end(buf);
@ -190,7 +190,7 @@ namespace llarp
LR_StatusRecord record; LR_StatusRecord record;
record.status = newStatus; record.status = newStatus;
record.version = LLARP_PROTO_VERSION; record.version = llarp::constants::proto_version;
llarp_buffer_t buf(frame.data(), frame.size()); llarp_buffer_t buf(frame.data(), frame.size());
buf.cur = buf.base + EncryptedFrameOverheadSize; buf.cur = buf.base + EncryptedFrameOverheadSize;
@ -256,7 +256,8 @@ namespace llarp
LR_StatusRecord::BEncode(llarp_buffer_t* buf) const LR_StatusRecord::BEncode(llarp_buffer_t* buf) const
{ {
return bencode_start_dict(buf) && BEncodeWriteDictInt("s", status, buf) return bencode_start_dict(buf) && BEncodeWriteDictInt("s", status, buf)
&& bencode_write_uint64_entry(buf, "v", 1, LLARP_PROTO_VERSION) && bencode_end(buf); && bencode_write_uint64_entry(buf, "v", 1, llarp::constants::proto_version)
&& bencode_end(buf);
} }
bool bool
@ -269,7 +270,8 @@ namespace llarp
if (!BEncodeMaybeReadDictInt("s", status, read, *key, buffer)) if (!BEncodeMaybeReadDictInt("s", status, read, *key, buffer))
return false; return false;
if (!BEncodeMaybeVerifyVersion("v", version, LLARP_PROTO_VERSION, read, *key, buffer)) if (!BEncodeMaybeVerifyVersion(
"v", version, llarp::constants::proto_version, read, *key, buffer))
return false; return false;
return read; return read;

@ -105,7 +105,7 @@ namespace llarp
{ {
if (!bencode_read_integer(buf, &i)) if (!bencode_read_integer(buf, &i))
return false; return false;
return i == LLARP_PROTO_VERSION; return i == llarp::constants::proto_version;
} }
// bad key // bad key
@ -149,7 +149,7 @@ namespace llarp
return false; return false;
/** version */ /** version */
if (!bencode_write_uint64_entry(buff, "v", 1, LLARP_PROTO_VERSION)) if (!bencode_write_uint64_entry(buff, "v", 1, llarp::constants::proto_version))
return false; return false;
/** end */ /** end */
return bencode_end(buff); return bencode_end(buff);

@ -27,7 +27,7 @@ namespace llarp
llarp::PubKey pubkey; llarp::PubKey pubkey;
in6_addr ip = {}; in6_addr ip = {};
uint16_t port; uint16_t port;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
bool bool
BDecode(llarp_buffer_t* buf) BDecode(llarp_buffer_t* buf)

@ -21,7 +21,7 @@ namespace llarp
IpAddress ipAddress; IpAddress ipAddress;
IpAddress netmask; IpAddress netmask;
PubKey pubkey; PubKey pubkey;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
ExitInfo() = default; ExitInfo() = default;

@ -646,7 +646,7 @@ namespace llarp
llarp_buffer_t buf(tmp); llarp_buffer_t buf(tmp);
// should help prevent bad paths with uninitialized members // should help prevent bad paths with uninitialized members
// FIXME: Why would we get uninitialized IMessages? // FIXME: Why would we get uninitialized IMessages?
if (msg.version != LLARP_PROTO_VERSION) if (msg.version != llarp::constants::proto_version)
return false; return false;
if (!msg.BEncode(&buf)) if (!msg.BEncode(&buf))
{ {

@ -68,7 +68,7 @@ namespace llarp
} }
// build record // build record
record.lifetime = path::default_lifetime; record.lifetime = path::default_lifetime;
record.version = LLARP_PROTO_VERSION; record.version = llarp::constants::proto_version;
record.txid = hop.txID; record.txid = hop.txID;
record.rxid = hop.rxID; record.rxid = hop.rxID;
record.tunnelNonce = hop.nonce; record.tunnelNonce = hop.nonce;

@ -12,7 +12,7 @@ namespace llarp
llarp_time_t timestamp = 0s; llarp_time_t timestamp = 0s;
llarp_time_t extendedLifetime = 0s; llarp_time_t extendedLifetime = 0s;
AlignedBuffer<32> nonce; AlignedBuffer<32> nonce;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
~PoW(); ~PoW();

@ -20,7 +20,7 @@ namespace llarp
uint64_t pathTimeoutCount = 0; uint64_t pathTimeoutCount = 0;
llarp_time_t lastUpdated = 0s; llarp_time_t lastUpdated = 0s;
llarp_time_t lastDecay = 0s; llarp_time_t lastDecay = 0s;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
bool bool
BEncode(llarp_buffer_t* buf) const; BEncode(llarp_buffer_t* buf) const;

@ -1210,7 +1210,7 @@ namespace llarp
// set router version if service node // set router version if service node
if (IsServiceNode()) if (IsServiceNode())
{ {
_rc.routerVersion = RouterVersion(llarp::VERSION, LLARP_PROTO_VERSION); _rc.routerVersion = RouterVersion(llarp::VERSION, llarp::constants::proto_version);
} }
_linkManager.ForEachInboundLink([&](LinkLayer_ptr link) { _linkManager.ForEachInboundLink([&](LinkLayer_ptr link) {

@ -221,7 +221,7 @@ namespace llarp
routerVersion = std::optional<RouterVersion>{}; routerVersion = std::optional<RouterVersion>{};
last_updated = 0s; last_updated = 0s;
srvRecords.clear(); srvRecords.clear();
version = LLARP_PROTO_VERSION; version = llarp::constants::proto_version;
} }
util::StatusObject util::StatusObject

@ -101,7 +101,7 @@ namespace llarp
llarp::AlignedBuffer<NICKLEN> nickname; llarp::AlignedBuffer<NICKLEN> nickname;
llarp_time_t last_updated = 0s; llarp_time_t last_updated = 0s;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
std::optional<RouterVersion> routerVersion; std::optional<RouterVersion> routerVersion;
/// should we serialize the exit info? /// should we serialize the exit info?
const static bool serializeExit = true; const static bool serializeExit = true;

@ -57,7 +57,7 @@ namespace llarp
private: private:
Version_t m_Version = {{0, 0, 0}}; Version_t m_Version = {{0, 0, 0}};
int64_t m_ProtoVersion = LLARP_PROTO_VERSION; int64_t m_ProtoVersion = llarp::constants::proto_version;
}; };
inline std::ostream& inline std::ostream&

@ -39,7 +39,7 @@ namespace llarp
return false; return false;
if (!BEncodeWriteDictInt("S", S, buf)) if (!BEncodeWriteDictInt("S", S, buf))
return false; return false;
if (!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf)) if (!BEncodeWriteDictInt("V", llarp::constants::proto_version, buf))
return false; return false;
return bencode_end(buf); return bencode_end(buf);

@ -16,7 +16,7 @@ namespace llarp
{ {
PathID_t from; PathID_t from;
uint64_t S{0}; uint64_t S{0};
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
IMessage() = default; IMessage() = default;

@ -40,7 +40,7 @@ namespace llarp
if (!BEncodeWriteDictEntry("T", T, buf)) if (!BEncodeWriteDictEntry("T", T, buf))
return false; return false;
if (!BEncodeWriteDictInt("V", LLARP_PROTO_VERSION, buf)) if (!BEncodeWriteDictInt("V", llarp::constants::proto_version, buf))
return false; return false;
if (!BEncodeWriteDictEntry("Y", Y, buf)) if (!BEncodeWriteDictEntry("Y", Y, buf))
return false; return false;

@ -70,7 +70,7 @@ namespace llarp
// set sender // set sender
self->msg.sender = self->m_LocalIdentity.pub; self->msg.sender = self->m_LocalIdentity.pub;
// set version // set version
self->msg.version = LLARP_PROTO_VERSION; self->msg.version = llarp::constants::proto_version;
// encrypt and sign // encrypt and sign
if (frame->EncryptAndSign(self->msg, K, self->m_LocalIdentity)) if (frame->EncryptAndSign(self->msg, K, self->m_LocalIdentity))
self->loop->call([self, frame] { AsyncKeyExchange::Result(self, frame); }); self->loop->call([self, frame] { AsyncKeyExchange::Result(self, frame); });

@ -22,7 +22,7 @@ namespace llarp
SecretKey signkey; SecretKey signkey;
PrivateKey derivedSignKey; PrivateKey derivedSignKey;
PQKeyPair pq; PQKeyPair pq;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
VanityNonce vanity; VanityNonce vanity;
// public service info // public service info

@ -56,7 +56,7 @@ namespace llarp
return false; return false;
if (!BEncodeWriteDictEntry("s", signkey, buf)) if (!BEncodeWriteDictEntry("s", signkey, buf))
return false; return false;
if (!BEncodeWriteDictInt("v", LLARP_PROTO_VERSION, buf)) if (!BEncodeWriteDictInt("v", llarp::constants::proto_version, buf))
return false; return false;
if (!vanity.IsZero()) if (!vanity.IsZero())
{ {

@ -20,7 +20,7 @@ namespace llarp
public: public:
VanityNonce vanity; VanityNonce vanity;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
void void
RandomizeVanity() RandomizeVanity()

@ -17,7 +17,7 @@ namespace llarp
PathID_t pathID; PathID_t pathID;
llarp_time_t latency = 0s; llarp_time_t latency = 0s;
llarp_time_t expiresAt = 0s; llarp_time_t expiresAt = 0s;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
util::StatusObject util::StatusObject
ExtractStatus() const; ExtractStatus() const;

@ -49,7 +49,7 @@ namespace llarp
std::optional<net::TrafficPolicy> exitTrafficPolicy; std::optional<net::TrafficPolicy> exitTrafficPolicy;
Signature signature; Signature signature;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
bool bool
OtherIsNewer(const IntroSet& other) const OtherIsNewer(const IntroSet& other) const

@ -191,7 +191,7 @@ namespace llarp
return false; return false;
if (!BEncodeMaybeReadDictEntry("T", T, read, key, val)) if (!BEncodeMaybeReadDictEntry("T", T, read, key, val))
return false; return false;
if (!BEncodeMaybeVerifyVersion("V", version, LLARP_PROTO_VERSION, read, key, val)) if (!BEncodeMaybeVerifyVersion("V", version, llarp::constants::proto_version, read, key, val))
return false; return false;
if (!BEncodeMaybeReadDictEntry("Z", Z, read, key, val)) if (!BEncodeMaybeReadDictEntry("Z", Z, read, key, val))
return false; return false;

@ -45,7 +45,7 @@ namespace llarp
Endpoint* handler = nullptr; Endpoint* handler = nullptr;
ConvoTag tag; ConvoTag tag;
uint64_t seqno = 0; uint64_t seqno = 0;
uint64_t version = LLARP_PROTO_VERSION; uint64_t version = llarp::constants::proto_version;
/// encode metainfo for lmq endpoint auth /// encode metainfo for lmq endpoint auth
std::vector<char> std::vector<char>
@ -155,7 +155,7 @@ namespace llarp
N.Zero(); N.Zero();
Z.Zero(); Z.Zero();
R = 0; R = 0;
version = LLARP_PROTO_VERSION; version = llarp::constants::proto_version;
} }
bool bool

@ -24,14 +24,14 @@ TEST_CASE("Compatibility when protocol unequal", "[RouterVersion]")
TEST_CASE("Empty compatibility", "[RouterVersion]") TEST_CASE("Empty compatibility", "[RouterVersion]")
{ {
llarp::RouterVersion v1({0, 0, 1}, LLARP_PROTO_VERSION); llarp::RouterVersion v1({0, 0, 1}, llarp::constants::proto_version);
CHECK_FALSE(v1.IsCompatableWith(llarp::emptyRouterVersion)); CHECK_FALSE(v1.IsCompatableWith(llarp::emptyRouterVersion));
} }
TEST_CASE("IsEmpty", "[RouterVersion]") TEST_CASE("IsEmpty", "[RouterVersion]")
{ {
llarp::RouterVersion notEmpty({0, 0, 1}, LLARP_PROTO_VERSION); llarp::RouterVersion notEmpty({0, 0, 1}, llarp::constants::proto_version);
CHECK_FALSE(notEmpty.IsEmpty()); CHECK_FALSE(notEmpty.IsEmpty());
CHECK(llarp::emptyRouterVersion.IsEmpty()); CHECK(llarp::emptyRouterVersion.IsEmpty());
@ -39,7 +39,7 @@ TEST_CASE("IsEmpty", "[RouterVersion]")
TEST_CASE("Clear", "[RouterVersion]") TEST_CASE("Clear", "[RouterVersion]")
{ {
llarp::RouterVersion version({0, 0, 1}, LLARP_PROTO_VERSION); llarp::RouterVersion version({0, 0, 1}, llarp::constants::proto_version);
CHECK_FALSE(version.IsEmpty()); CHECK_FALSE(version.IsEmpty());
version.Clear(); version.Clear();

@ -28,6 +28,6 @@ TEST_CASE_METHOD(LlarpTest<>, "Sign-verify")
CHECK(msg.Sign(alice)); CHECK(msg.Sign(alice));
CHECK(msg.Verify()); CHECK(msg.Verify());
CHECK(msg.I == PubKey{seckey_topublic(alice)}); CHECK(msg.I == PubKey{seckey_topublic(alice)});
CHECK(msg.version == LLARP_PROTO_VERSION); CHECK(msg.version == llarp::constants::proto_version);
CHECK_FALSE(msg.Z.IsZero()); CHECK_FALSE(msg.Z.IsZero());
} }

Loading…
Cancel
Save