[grade=B] rpcnet: allow .b32.i2p addresses in addnode RPC

Triangles is dual-network Tor + I2P, but the addnode RPC rejected any
non-.onion address with HTTP 500 'Only .onion addresses are supported on
this network.'. This prevented runtime addition of I2P peers via the
admin RPC.

Fix: extend the address check to accept both .onion and .b32.i2p
substrings, mirroring the existing pattern. Update the help/error text
to reflect dual-network support.

Codex grade: B (urn:ump:pe5crd53udgv7quryi4n3vqke6y6ndwfj4s2plq4lyabskhybpuq)

Polish deferred: substring matching accepts malformed values
(e.g. 'attacker.onion.invalid'). Existing .onion check has the same
limitation. Future improvement: validate hostname suffixes properly.
This commit is contained in:
Krystie
2026-08-05 08:51:00 -07:00
parent 9f0ce13abc
commit 717f0d07cd
+4 -4
View File
@@ -143,13 +143,13 @@ Value addnode(const Array& params, bool fHelp)
"addnode <node> <add|remove|onetry>\n" "addnode <node> <add|remove|onetry>\n"
"Attempts to add or remove a node from the addnode list,\n" "Attempts to add or remove a node from the addnode list,\n"
"or try a connection to a node once.\n" "or try a connection to a node once.\n"
"<node> must be a .onion address (Tor-native network)."); "<node> must be a .onion or .b32.i2p address (Tor+I2P dual-network).");
string strNode = params[0].get_str(); string strNode = params[0].get_str();
// Tor-native: require .onion addresses // Triangles is dual-network Tor + I2P. Allow both .onion and .b32.i2p addresses.
if (strNode.find(".onion") == string::npos) if (strNode.find(".onion") == string::npos && strNode.find(".b32.i2p") == string::npos)
throw runtime_error("Only .onion addresses are supported on this network."); throw runtime_error("Only .onion or .b32.i2p addresses are supported on this network.");
if (strCommand == "onetry") if (strCommand == "onetry")
{ {