upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/selftest.cpp
diff options
context:
space:
mode:
authorBitflash <admin@bitflash.network>2026-08-12 10:22:23 -0300
committerBitflash <admin@bitflash.network>2026-08-12 10:22:23 -0300
commitd0ebe648f333def99fababd65f6b929448616d56 (patch)
treec7ccaa28b9f83abd077ba90c031632deda83c80a /src/selftest.cpp
parentc330b8e5e1c057049b5b361908c94f41344dff80 (diff)
parenta0a300c240c91fa0c1cd1dc60ff5420a89cc33f8 (diff)
Merge pull request 'net: add Tor mode for outbound discovery' (#28) from tor-mode into main
Diffstat (limited to 'src/selftest.cpp')
-rw-r--r--src/selftest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp
index aa4e528..cca5335 100644
--- a/src/selftest.cpp
+++ b/src/selftest.cpp
@@ -1474,6 +1474,11 @@ static int RunSocks5ProxySelfTest()
1474 "rejects overflowing port") ? 0 : 1; 1474 "rejects overflowing port") ? 0 : 1;
1475 nFail += Check(!BtfParseSocks5Proxy("user:pass@localhost:9050", host, port, err), 1475 nFail += Check(!BtfParseSocks5Proxy("user:pass@localhost:9050", host, port, err),
1476 "rejects unsupported authenticated proxy syntax") ? 0 : 1; 1476 "rejects unsupported authenticated proxy syntax") ? 0 : 1;
1477 nFail += Check(BtfIsTorOnionHost("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd.onion") &&
1478 BtfIsTorOnionHost("Relay.Example.ONION.") &&
1479 !BtfIsTorOnionHost("relay.example") &&
1480 !BtfIsTorOnionHost(".onion"),
1481 "detects .onion hosts without accepting lookalikes") ? 0 : 1;
1477 1482
1478 BtfClearSocks5Proxy(); 1483 BtfClearSocks5Proxy();
1479 nFail += Check(!BtfSocks5ProxyEnabled(), "starts disabled after clear") ? 0 : 1; 1484 nFail += Check(!BtfSocks5ProxyEnabled(), "starts disabled after clear") ? 0 : 1;
@@ -1490,6 +1495,26 @@ static int RunSocks5ProxySelfTest()
1490 "enables bracketed IPv6 proxy endpoint") ? 0 : 1; 1495 "enables bracketed IPv6 proxy endpoint") ? 0 : 1;
1491 BtfClearSocks5Proxy(); 1496 BtfClearSocks5Proxy();
1492 1497
1498 nFail += Check(BtfEnableTorProxy("", err) &&
1499 BtfSocks5ProxyEnabled() &&
1500 BtfTorProxyEnabled() &&
1501 BtfSocks5ProxyName() == "127.0.0.1:9050",
1502 "enables Tor mode on the default local SOCKS5 endpoint") ? 0 : 1;
1503 BtfClearSocks5Proxy();
1504
1505 nFail += Check(BtfEnableTorProxy("[::1]:9050", err) &&
1506 BtfSocks5ProxyEnabled() &&
1507 BtfTorProxyEnabled() &&
1508 BtfSocks5ProxyName() == "[::1]:9050",
1509 "enables Tor mode on a custom IPv6 endpoint") ? 0 : 1;
1510 BtfClearSocks5Proxy();
1511
1512 nFail += Check(BtfSetSocks5Proxy("127.0.0.1:9051", err) &&
1513 BtfSocks5ProxyEnabled() &&
1514 !BtfTorProxyEnabled(),
1515 "plain SOCKS5 mode is distinct from Tor mode") ? 0 : 1;
1516 BtfClearSocks5Proxy();
1517
1493 std::string handshakeErr; 1518 std::string handshakeErr;
1494 bool fHandshakeOk = RunSocks5HandshakeProbe(handshakeErr); 1519 bool fHandshakeOk = RunSocks5HandshakeProbe(handshakeErr);
1495 nFail += Check(fHandshakeOk, handshakeErr.empty() ? 1520 nFail += Check(fHandshakeOk, handshakeErr.empty() ?