Skip to content

net: Only use TorControl connection as proxy if proxy is not set yet - #25688

Closed
fjahr wants to merge 1 commit into
bitcoin:masterfrom
fjahr:2022-07-torcontrol
Closed

fjahr wants to merge 1 commit into
bitcoin:masterfrom
fjahr:2022-07-torcontrol

Conversation

@fjahr

@fjahr fjahr commented Jul 24, 2022

Copy link
Copy Markdown
Contributor

Should close #25265

The onion proxy can be set either via -onion or via -proxy (grep init.cpp for onion_proxy). Additionally, when TorControl is configured and successfully connected, there is a fallback that tries to setup the onion proxy via that connection. This fallback was only checking if -onion was set but if -proxy was set it was still running and overwriting the existing onion proxy configured in -proxy.

Instead of using gArgs I am checking if a valid proxy is set already. This should not make a difference in behavior since init error are thrown if -onion or -proxy are set but not valid. There is also another check if -onion or -proxy are explicitly disabled. I think this is the most reasonable behavior for such corner cases, though I am not sure if there are valid use cases for such a configuration.

This also adds some more explicit logging that should help users better understand what is happening.

@fjahr

fjahr commented Jul 24, 2022

Copy link
Copy Markdown
Contributor Author

@kroese could you check if this solves your problem from #25688?

@kroese

kroese commented Jul 24, 2022

Copy link
Copy Markdown

Yes, this fixes it!

@ghost

ghost commented Jul 24, 2022

Copy link
Copy Markdown

Concept ACK

@DrahtBot DrahtBot added the P2P label Jul 24, 2022
@luke-jr

luke-jr commented Jul 26, 2022

Copy link
Copy Markdown
Contributor

Concept NACK. -torcontrol should override -proxy. (Plus, using GetProxy for the check will fail to update it when/if it changes during runtime.)

@fjahr

fjahr commented Jul 26, 2022

Copy link
Copy Markdown
Contributor Author

Concept NACK. -torcontrol should override -proxy. (Plus, using GetProxy for the check will fail to update it when/if it changes during runtime.)

For anyone interested in following, I answered here. I would say let's keep the conceptual discussion about parameter interaction in the issue @luke-jr, so we don't have to argue the same things in two places.

Comment thread src/torcontrol.cpp
} else {
if (gArgs.GetArg("-onion", "") != "0" && gArgs.GetArg("-proxy", "") != "0") {
// Don't do this if -onion or -proxy are explicitly disabled
LogPrint(BCLog::TOR, "Onion proxy not configured yet. Trying to use TorControl connection to set proxy.\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "to set proxy" sounds like it will set the proxy for all, ie -proxy. Maybe "... to set the onion proxy" or "... to set it" would be better?

Comment thread src/torcontrol.cpp
Comment on lines +449 to +450
} else {
if (gArgs.GetArg("-onion", "") != "0" && gArgs.GetArg("-proxy", "") != "0") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can use } else if (...) { which would reduce the indentation of the block below

@fjahr

fjahr commented Aug 28, 2022

Copy link
Copy Markdown
Contributor Author

Closing this, see discussion in #25265.

@fjahr fjahr closed this Aug 28, 2022
@bitcoin bitcoin locked and limited conversation to collaborators Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting torcontrol overrides proxy address

5 participants