(extends #1141 (proxy improvements) and #1021 (ipv6 support)
Adds support for running as and connecting to Tor hidden services. *.onion addresses are mapped into the IPv6 range in the same way as OnionCat does.
See doc/Tor.txt for more information.
Cool!
Can you add a doc/Tor.txt with “how to run your bitcoin node as a hidden service” info in it?
Couple of questions. Why do I get:
Cannot connect to a57qr3ydpnyntf5k.onion:8333: unsupported network
whereas other onion address work? (the above onion address is the one you mentioned in this pull).
Also, re:-
receive version message: version 50200, blocks=178423, us=127.0.0.1:47146, them=106.187.36.183:28333, peer=siqdznszjf4e6v5j.onion:8333
Does this mean bitcoin exposes nodes’ actual IP address, despite them thinking they’re running an anonymous onion service?
Also, in the above example, what does it do with the “us” address? Shouldn’t it be using my .onion address instead…?
That “unsupported network” error means you’re trying to connect to an onion address directly (not through a proxy). Is it possible you didn’t use -proxy?
That received version message means that you connected to siqdznszjf4e6v5j.onion:8333, and thereby reached a peer who thinks you are 127.0.0.1 (so it came from their Tor proxy), and believes he has address 106.187.36.183. Which version was the peer running? Recent versions shouldn’t announce 127.0.0.1 as their own address, and if the other node also ran this torhs branch, if it was running using -externalip=….onion, it should report its onion address instead.
Edit: obviously, the peer is running 0.5.2 (as it reports protocol version 50200). If you’d connect to a 0.6.0 or torhs node, you’ll see different behaviour.
receive version message: version 60000, blocks=178480, us=127.0.0.1:56334, them=24.7.178.63:8333, peer=p2hwc26zdsrqxiix.onion:8333
Seems pretty similar for a 0.6.0 too….
This passes my initial testing. It’s perhaps a little too easy to leak your IP when trying to run as a hidden service. E.g. if you -listen=1 without setting -externalip … still better than what people would get if trying to run a hidden service today, but of course more support will encourage more people to do it. Also, I the fact that proxydns ran when connect was set was kind of surprising, but I guess thats really independent of this pull: connect should probably imply dnsseed=0.
The effective deactivation of anti-dos for incoming onion peers is kind of unfortunate. I wonder if we could do anything about that?
@rebroad the anti-DoS system registers IP addresses which engage in incorrect behavior, and prevents them from connecting or being connected to. In combination with Tor hidden services, you don’t know the source IP, so it cannot be banned.
Mental note: make sure the proxy is never banned.
Here’s a proposal for a revamping of the relevant command line arguments: https://gist.github.com/2763381
It removes the special casing of :9050 as tor port, and defines more convenient defaults for several options.
I’m not the one, who can give an ACK, but are you sure this is rebased on current master? At least ApplyProxySettings() in optionsmodel.cpp seems weird, as I know this function is already there.
It would be also nice, to get a) #1433 in before this (no testing comments currently) or b) I need some infos, what needs to be done for the Tor thing to have all options in the GUI available, so I can update #1433.
933-// 0 - unroutable            // 0 - unroutable                 // 0 - unroutable
934-// 1 - teredo                // 1 - teredo                     // 1 - ipv4
935-// 2 - tunneled ipv6         // 2 - tunneled ipv6
936-// 3 - ipv4                  // 3 - ipv6
937-// 4 - ipv6                  // 4 - ipv4
938+// C++ doesn't allow us to inherit from enums
Wouldn’t it be saner to just extend the enum? The reason that enums can’t be extended later is that the compiler and programmer can make assumptions on what values to expect. This breaks that assumption.
If there’s a good reason to do it this way (I suppose so) please add a comment describing that.
Regarding not extending enums: it’s perfectly sane from a language semantics point of view, in my opinion. enum A { B, C}, enum D : A { E, F } could define B and C as of type enum A, and E and F as of type D, with an implicit conversion between values of enum A to values of enum D.
Reason for not extending the enum here: I prefer not to clutter the public list of networks because one function needs some special cases to deal with.
Yes, it’s ok as long as the values from D do not end up in places where A is supposed to be used. C++ cannot guarantee this, and it wasn’t clear to me on first reading the code that the extended values were local to one function.
Anyway, it seems that you have a good reason, and the extended values are local to that function, please add this in the comment. Just “c++ does not allow this” looks like you’re hacking around something :)
Well it is - if C++ would allow extending enums, it wouldn’t need this :)
That said, updated the comment.
ACK if you make the following edit to doc/Tor.txt:
REPLACE: In a typical situation, this suffices to run behind a Tor proxy:
WITH: These instructions assume that Tor is listening as a SOCKS proxy on port 9050; if you use the Tor Browser Bundle, then it (by default) picks a random port every time it starts. See https://www.torproject.org/docs/faq.html.en#TBBSocksPort for how to properly configure Tor.
Once Tor is configured and running, this suffices to run behind a Tor proxy:
…
make test_bitcoin is giving me:
test/netbase_tests.cpp:37: error: ‘class CNetAddr’ has no member named ‘IsOnionCat’
This commit adds support for .onion addresses (mapped into the IPv6
by using OnionCat's range and encoding), and the ability to connect
to them via a SOCKS5 proxy.
Add support for Tor/I2P networks, and make code more readable.