Merge pull request #29

23aa36a indicate that IPv4/IPv6 proxy use SOCKS5 protocol (Jonas Schnelli)
134a393 add support for IPV6 proxy (Jonas Schnelli)
1d9d182 add support for IPV4 proxy (Jonas Schnelli)
6e5a391 avoid connecting to non valid ipv4 ranges (>=240.0.0.0) (Jonas Schnelli)
This commit is contained in:
Pieter Wuille 2015-07-29 14:54:12 +02:00
commit 589fcd6ee2
No known key found for this signature in database
GPG key ID: 57896D2FF8F0B657
3 changed files with 39 additions and 3 deletions

View file

@ -27,6 +27,8 @@ public:
const char *ns;
const char *host;
const char *tor;
const char *ipv4_proxy;
const char *ipv6_proxy;
CDnsSeedOpts() : nThreads(96), nDnsThreads(4), nPort(53), mbox(NULL), ns(NULL), host(NULL), tor(NULL), fUseTestNet(false), fWipeBan(false), fWipeIgnore(false) {}
@ -42,6 +44,8 @@ public:
"-d <threads> Number of DNS server threads (default 4)\n"
"-p <port> UDP port to listen on (default 53)\n"
"-o <ip:port> Tor proxy IP/Port\n"
"-i <ip:port> IPV4 SOCKS5 proxy IP/Port\n"
"-k <ip:port> IPV6 SOCKS5 proxy IP/Port\n"
"--testnet Use testnet\n"
"--wipeban Wipe list of banned nodes\n"
"--wipeignore Wipe list of ignored nodes\n"
@ -58,6 +62,8 @@ public:
{"dnsthreads", required_argument, 0, 'd'},
{"port", required_argument, 0, 'p'},
{"onion", required_argument, 0, 'o'},
{"proxyipv4", required_argument, 0, 'i'},
{"proxyipv6", required_argument, 0, 'k'},
{"testnet", no_argument, &fUseTestNet, 1},
{"wipeban", no_argument, &fWipeBan, 1},
{"wipeignore", no_argument, &fWipeBan, 1},
@ -65,7 +71,7 @@ public:
{0, 0, 0, 0}
};
int option_index = 0;
int c = getopt_long(argc, argv, "h:n:m:t:p:d:o:", long_options, &option_index);
int c = getopt_long(argc, argv, "h:n:m:t:p:d:o:i:k:", long_options, &option_index);
if (c == -1) break;
switch (c) {
case 'h': {
@ -100,12 +106,22 @@ public:
if (p > 0 && p < 65536) nPort = p;
break;
}
case 'o': {
tor = optarg;
break;
}
case 'i': {
ipv4_proxy = optarg;
break;
}
case 'k': {
ipv6_proxy = optarg;
break;
}
case '?': {
showHelp = true;
break;
@ -375,6 +391,20 @@ int main(int argc, char **argv) {
SetProxy(NET_TOR, service);
}
}
if (opts.ipv4_proxy) {
CService service(opts.ipv4_proxy, 9050);
if (service.IsValid()) {
printf("Using IPv4 proxy at %s\n", service.ToStringIPPort().c_str());
SetProxy(NET_IPV4, service);
}
}
if (opts.ipv6_proxy) {
CService service(opts.ipv6_proxy, 9050);
if (service.IsValid()) {
printf("Using IPv6 proxy at %s\n", service.ToStringIPPort().c_str());
SetProxy(NET_IPV6, service);
}
}
bool fDNS = true;
if (opts.fUseTestNet) {
printf("Using testnet.\n");

View file

@ -624,6 +624,11 @@ bool CNetAddr::IsRFC1918() const
(GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31)));
}
bool CNetAddr::IsReserved() const
{
return IsIPv4() && (GetByte(3) >= 240);
}
bool CNetAddr::IsRFC3927() const
{
return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254);
@ -740,7 +745,7 @@ bool CNetAddr::IsValid() const
bool CNetAddr::IsRoutable() const
{
return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor() && !IsI2P()) || IsRFC4843() || IsLocal());
return IsValid() && !(IsReserved() || IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor() && !IsI2P()) || IsRFC4843() || IsLocal());
}
enum Network CNetAddr::GetNetwork() const

View file

@ -47,6 +47,7 @@ class CNetAddr
bool SetSpecial(const std::string &strName); // for Tor and I2P addresses
bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor/I2P)
bool IsReserved() const; // Against Hetzners Abusal/Netscan Bot
bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32)
bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16)