make netid configurable on runtime

bump version to 0.4.0

subscribe to pewdiepie
This commit is contained in:
Jeff Becker 2018-12-21 08:08:01 -05:00
parent 7350120a8a
commit 0fd36d3b79
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
7 changed files with 27 additions and 8 deletions

View File

@ -391,6 +391,8 @@ struct llarp_epoll_loop : public llarp_ev_loop
llarp::ev_io* ev = static_cast< llarp::ev_io* >(events[idx].data.ptr);
if(ev)
{
llarp::LogDebug(idx, " of ", result,
" events=", std::to_string(events[idx].events));
if(events[idx].events & EPOLLERR)
{
ev->error();

View File

@ -1430,6 +1430,20 @@ namespace llarp
}
else if(StrEq(section, "router"))
{
if(StrEq(key, "netid"))
{
if(strlen(val) <= self->_rc.netID.size())
{
llarp::LogWarn("!!!! you have manually set netid to be '", val,
"' which does not equal '", LLARP_NET_ID,
"' you will run as a different network, good luck and "
"don't forget: something something MUH traffic shape "
"correlation !!!!");
llarp::NetID::DefaultValue = (const byte_t *)strdup(val);
}
else
llarp::LogError("invalid netid '", val, "', is too long");
}
if(StrEq(key, "nickname"))
{
self->_rc.SetNick(val);

View File

@ -12,6 +12,8 @@
namespace llarp
{
const byte_t *NetID::DefaultValue = (const byte_t *)LLARP_NET_ID;
bool RouterContact::IgnoreBogons = false;
#ifdef TESTNET
@ -21,7 +23,7 @@ namespace llarp
/// 1 day for real network
llarp_time_t RouterContact::Lifetime = 24 * 60 * 60 * 1000;
#endif
NetID::NetID() : AlignedBuffer< 8 >((const byte_t *)LLARP_NET_ID)
NetID::NetID() : AlignedBuffer< 8 >(DefaultValue)
{
}
@ -74,9 +76,8 @@ namespace llarp
/* write netid */
if(!bencode_write_bytestring(buf, "i", 1))
return false;
if(!bencode_write_bytestring(buf, netID.data(), netID.size()))
if(!netID.BEncode(buf))
return false;
/* write signing pubkey */
if(!bencode_write_bytestring(buf, "k", 1))
return false;
@ -238,7 +239,7 @@ namespace llarp
bool
RouterContact::Verify(llarp::Crypto *crypto, llarp_time_t now) const
{
if(netID.ToString() != LLARP_NET_ID)
if(netID != NetID())
return false;
if(IsExpired(now))
return false;

View File

@ -17,6 +17,8 @@ namespace llarp
/// NetID
struct NetID final : public AlignedBuffer< 8 >
{
static const byte_t *DefaultValue;
NetID();
bool

View File

@ -6,11 +6,11 @@
#endif
#ifndef LLARP_VERSION_MIN
#define LLARP_VERSION_MIN "3"
#define LLARP_VERSION_MIN "4"
#endif
#ifndef LLARP_VERSION_PATCH
#define LLARP_VERSION_PATCH "1"
#define LLARP_VERSION_PATCH "0"
#endif
#ifndef LLARP_VERSION_NUM

View File

@ -1 +1 @@
kuz yolo
subscribe to pewdiepie

View File

@ -61,7 +61,7 @@ struct UTPTest : public ::testing::Test
|| (__APPLE__ && __MACH__)
return "lo0";
#else
return "lo"
return "lo";
#endif
}