- fixes #14722
- only use default tor ip:port (127.0.0.1:9050) if -onion and -proxy not set
I’m not sure if this is done correctly, but it does fix the behavior in my tests. I will not be offended if this gets rejected for a more appropriate method.
I’m not sure if this is done correctly, but it does fix the behavior in my tests. I will not be offended if this gets rejected for a more appropriate method.
- fixes #14722
- only use default tor ip:port (127.0.0.1:9050) if -onion and -proxy not set
- fix comment to reflect new behavior
521@@ -522,9 +522,9 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
522 if (reply.code == 250) {
523 LogPrint(BCLog::TOR, "tor: Authentication successful\n");
524
525- // Now that we know Tor is running setup the proxy for onion addresses
526- // if -onion isn't set to something else.
527- if (gArgs.GetArg("-onion", "") == "") {
528+ // Now that we know Tor is running, setup the proxy for onion addresses
529+ // if -onion and -proxy isn't set to something else.
530+ if (gArgs.GetArg("-onion", "-proxy") == "") {
@MarcoFalke I noticed in another spots this was handled differently. Would it be more preferable like this:
0 // Now that we know Tor is running setup the proxy for onion addresses
1 // if -onion isn't set to something else.
2 std::string onion = gArgs.GetArg("-onion", "");
3 std::string proxy = gArgs.GetArg("-proxy", "");
4 if (onion.empty() && proxy.empty()) {
Thank you for reviewing.
I think I may have done this the correct way now. If not, I will stop wasting your time and close this so someone more suited can take it up.
521@@ -522,9 +522,9 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
522 if (reply.code == 250) {
523 LogPrint(BCLog::TOR, "tor: Authentication successful\n");
524
525- // Now that we know Tor is running setup the proxy for onion addresses
526- // if -onion isn't set to something else.
527- if (gArgs.GetArg("-onion", "") == "") {
528+ // Now that we know Tor is running, setup the proxy for onion addresses
529+ // if -onion and -proxy isn't set to something else.
530+ if (gArgs.GetArg("-onion", "") == "" && gArgs.GetArg("-proxy", "") == "") {
I guess this will work in most cases.
Though ideally we’d query Net’s state directly here for “is there a proxy for onion already” instead of indirectly divising it from the arguments. This would really solve the problem of the current code here.
I guess this will work in most cases.
Though ideally we’d query Net’s state directly here for “is there a proxy for onion already” instead of indirectly divising it from the arguments. This would really solve the problem of the current code here.
Hi, @qubenix
0
1diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
2index bec64fbf2..b632513c3 100644
3--- a/src/torcontrol.cpp
4+++ b/src/torcontrol.cpp
5@@ -524,7 +524,8 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
6
7 // Now that we know Tor is running, setup the proxy for onion addresses
8 // if -onion and -proxy isn't set to something else.
9- if (gArgs.GetArg("-onion", "") == "" && gArgs.GetArg("-proxy", "") == "") {
10+ proxyType addrOnion;
11+ if (gArgs.GetArg("-onion", "") == "" && !GetProxy(NET_ONION, addrOnion)) {
12 CService resolved(LookupNumeric("127.0.0.1", 9050));
13 proxyType addrOnion = proxyType(resolved, true);
14 SetProxy(NET_ONION, addrOnion);
This litle patch should do the trick and fix the problem and that should be in line what @laanwj suggested, please feel free to copy paste. ;-)
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
@luke-jr Could be better to listen to the control port, just don’t forget about situations where onion-grater
is used and the response from the Tor controller intentionally lies to the application. Onion-grater use is considered a Tor best practice and is being used in Whonix and TAILS.
In Whonix there is a dedicated port for Bitcoin traffic, <gateway-ip>:9111
, but if you rely on the control port you get a response like this:
0user@host:~$ nc -nv 127.0.0.1 9051
1(UNKNOWN) [127.0.0.1] 9051 (?) open
2AUTHENTICATE
3250 OK
4GETINFO net/listeners/socks
5250-net/listeners/socks="127.0.0.1:9150"
6250 OK
Probably best to rely on the controller and systems using onion-grater
can use a profile. Maybe an example one can be included in this repo for such systems.
This PR was only meant to correct the defined behavior of defaulting to -proxy
:
0-onion=ip:port
1Use separate SOCKS5 proxy to reach peers via Tor hidden services, set -noonion to disable (default: -proxy)
Though ideally we’d query Net’s state directly here for “is there a proxy for onion already” instead of indirectly divising it from the arguments. This would really solve the problem of the current code here.
Sorry, I’m not sure how to do that. I only wanted to help, but I’m afraid the existence of this PR may be keeping others from doing it the ideal way which you suggested. Just let me know if closing this is more help.
@adamjonas I don’t what I can/should be doing to push this forward. This PR fixes the bug, but if it’s not done in an acceptable way then there’s nothing more I can do. I’m not a coder by trade, I just found a bug and offered a solution that I was able to figure out. That being said, I’m happy to do whatever is expected of me here as long as it’s within my ability. I’m just not sure what that is.
Hi @qubenix might take a look at #19358? I run in the same problem and found that other settings are also ignored by this footgun proxy fallback, so i took the freedom and pushed this alternative fix.