- 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.
Pushed a fix to the comment to reflect the new behavior and rebased.
- 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") == "") {
The default must be set to a value, not the name of the arg it should default to.
I think I might have fixed it now.
@MarcoFalke I noticed in another spots this was handled differently. Would it be more preferable like this:
// Now that we know Tor is running setup the proxy for onion addresses
// if -onion isn't set to something else.
std::string onion = gArgs.GetArg("-onion", "");
std::string proxy = gArgs.GetArg("-proxy", "");
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
diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp
index bec64fbf2..b632513c3 100644
--- a/src/torcontrol.cpp
+++ b/src/torcontrol.cpp
@@ -524,7 +524,8 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
// Now that we know Tor is running, setup the proxy for onion addresses
// if -onion and -proxy isn't set to something else.
- if (gArgs.GetArg("-onion", "") == "" && gArgs.GetArg("-proxy", "") == "") {
+ proxyType addrOnion;
+ if (gArgs.GetArg("-onion", "") == "" && !GetProxy(NET_ONION, addrOnion)) {
CService resolved(LookupNumeric("127.0.0.1", 9050));
proxyType addrOnion = proxyType(resolved, true);
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. ;-)
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
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:
user@host:~$ nc -nv 127.0.0.1 9051
(UNKNOWN) [127.0.0.1] 9051 (?) open
AUTHENTICATE
250 OK
GETINFO net/listeners/socks
250-net/listeners/socks="127.0.0.1:9150"
250 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:
-onion=ip:port
Use 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.
<!--5d09a71f8925f3f132321140b44b946d-->The last travis run for this pull request was 273 days ago and is thus outdated. To trigger a fresh travis build, this pull request should be closed and re-opened.
@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.
@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.