diff options
Diffstat (limited to 'src/selftest.cpp')
| -rw-r--r-- | src/selftest.cpp | 25 |
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() ? |