disable exits in RCs

pull/1319/head
jeff 4 years ago committed by Jeff Becker
parent 0ee1c4a60a
commit 2aaed895f3
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -953,15 +953,15 @@ namespace llarp
return;
LogInfo("adding address: ", ai);
_rc.addrs.push_back(ai);
if (ExitEnabled())
{
const IpAddress address = ai.toIpAddress();
_rc.exits.emplace_back(_rc.pubkey, address);
LogInfo("Exit relay started, advertised as exiting at: ", address);
}
}
});
if (ExitEnabled() and IsServiceNode())
{
LogError("exit mode not supported while service node");
return false;
}
if (IsServiceNode() and not _rc.IsPublicRouter())
{
LogError("we are configured as relay but have no reachable addresses");

@ -140,12 +140,16 @@ namespace llarp
if (!bencode_write_uint64_entry(buf, "v", 1, version))
return false;
/* write xi if they exist */
if (!bencode_write_bytestring(buf, "x", 1))
return false;
if (!BEncodeWriteList(exits.begin(), exits.end(), buf))
return false;
if (serializeExit)
{
/* write xi if they exist */
if (!bencode_write_bytestring(buf, "x", 1))
return false;
/* no exits anymore in RCs */
const std::vector<AlignedBuffer<8>> exits{};
if (!BEncodeWriteList(exits.begin(), exits.end(), buf))
return false;
}
/* write signature */
if (!bencode_write_bytestring(buf, "z", 1))
return false;
@ -158,7 +162,6 @@ namespace llarp
RouterContact::Clear()
{
addrs.clear();
exits.clear();
signature.Zero();
nickname.Zero();
enckey.Zero();
@ -171,7 +174,6 @@ namespace llarp
RouterContact::ExtractStatus() const
{
util::StatusObject obj{{"lastUpdated", last_updated.count()},
{"exit", IsExit()},
{"publicRouter", IsPublicRouter()},
{"identity", pubkey.ToString()},
{"addresses", addrs}};
@ -234,8 +236,10 @@ namespace llarp
if (!BEncodeMaybeReadDictInt("v", version, read, key, buf))
return false;
if (!BEncodeMaybeReadDictList("x", exits, read, key, buf))
return false;
if (key == "x" and serializeExit)
{
return bencode_discard(buf);
}
if (!BEncodeMaybeReadDictEntry("z", signature, read, key, buf))
return false;
@ -342,16 +346,6 @@ namespace llarp
return false;
}
}
for (const auto& exit : exits)
{
// TODO: see if exit's range overlaps with bogon...?
// e.g. "IsBogonRange(address, netmask)"
if (exit.ipAddress.isBogon())
{
llarp::LogError("bogon exit: ", exit);
return false;
}
}
if (!VerifySignature())
{
llarp::LogError("invalid signature: ", *this);
@ -434,7 +428,6 @@ namespace llarp
printer.printAttribute("netid", netID);
printer.printAttribute("v", version);
printer.printAttribute("ai", addrs);
printer.printAttribute("xi", exits);
printer.printAttribute("e", enckey);
printer.printAttribute("z", signature);

@ -96,8 +96,6 @@ namespace llarp
llarp::PubKey enckey;
// public signing public key
llarp::PubKey pubkey;
// advertised exits
std::vector<ExitInfo> exits;
// signature
llarp::Signature signature;
/// node nickname, yw kee
@ -106,6 +104,8 @@ namespace llarp
llarp_time_t last_updated = 0s;
uint64_t version = LLARP_PROTO_VERSION;
std::optional<RouterVersion> routerVersion;
/// should we serialize the exit info?
const static bool serializeExit = true;
util::StatusObject
ExtractStatus() const;
@ -151,7 +151,7 @@ namespace llarp
bool
IsExit() const
{
return !exits.empty();
return false;
}
bool

@ -38,7 +38,6 @@ TEST_F(RCTest, TestSignVerify)
rc.enckey = encr.toPublic();
rc.pubkey = sign.toPublic();
rc.exits.emplace_back(rc.pubkey, IpAddress("1.1.1.1"));
ASSERT_TRUE(rc.netID == netid);
ASSERT_TRUE(rc.netID == NetID::DefaultValue());

Loading…
Cancel
Save