Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet2: daemon-specific proxy for the wallet-rpc #9160

Merged

Conversation

0xFFFC0000
Copy link
Collaborator

@0xFFFC0000 0xFFFC0000 commented Feb 9, 2024

  1. Daemon-specific proxy is exclusive with global proxy (--proxy).
  2. If you set global proxy (--proxy) you cannot set daemon-specific proxy.
  3. If you don't set a global proxy, you can set (or not set) a proxy for each daemon connection with the proxy field in jsonrpc to the wallet-rpc.

@jeffro256
Copy link
Contributor

Why would you want a daemon-specific proxy?

@selsta
Copy link
Collaborator

selsta commented Feb 10, 2024

@jeffro256 ofrnxmr asked for it on IRC

For example when you initially connect to a clearnet node and then want to use set_daemon to connect to a tor node, you need a proxy for this. We also support it on the daemon side with set_bootstrap_daemon so it made sense to add it here too.

@jeffro256
Copy link
Contributor

Ah. I misinterpreted the OP. I thought that wallet2 would be running two proxies lol

Comment on lines 1270 to 1273
bool wallet2::has_proxy_option(const boost::program_options::variables_map& vm)
{
return command_line::has_arg(vm, options().proxy);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool wallet2::has_proxy_option(const boost::program_options::variables_map& vm)
{
return command_line::has_arg(vm, options().proxy);
}
bool wallet2::has_proxy_option() const
{
return !m_proxy.empty();
}

I'd recommend this approach since it reflects the value per wallet2 instance, even if it wasn't initiated by a CLI.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What you are suggesting makes more sense. I fixed it in a new push. Thanks.

1. Daemon-specific proxy is exclusive with global proxy (--proxy).
2. If you set global proxy (--proxy) you cannot set daemon-specific proxy.
3. If you don't set global proxy, you can set proxy (or not set) proxy for
each daemon connection with the proxy field in jsonrpc to the wallet-rpc.
{
boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);

if(m_http_client->is_connected())
m_http_client->disconnect();
CHECK_AND_ASSERT_MES2(m_proxy.empty() || proxy.empty() , "It is not possible to set global proxy (--proxy) and daemon specific proxy together.");
if(m_proxy.empty())
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be if (!proxy.empty())?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I see your point and that actually the way I wrote it at first. But I am trying to exactly mimic the way the code base already is. If you look at init method [1], we are setting proxy using set_proxy method regardless of what the value is. And set_proxy does simply sets direct connection when proxy is empty [2].

  1. CHECK_AND_ASSERT_MES(set_proxy(proxy_address), false, "failed to set proxy address");

  2. set_connector(epee::net_utils::direct_connect{});

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it depends if we want to behavior to be to reset the proxy when proxy is an empty string or not. I actually change my mind and like this behavior better. Let's keep it so that it resets every time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By the way. Keep in mind the global proxy is not changeable. That is kind of security requirement in a sense when user sets global proxy via --proxy flag. We should not be able to touch/change it, even if user asks.

But the daemon specific proxy is daemon specific. Meaning you set proxy via RPC, to only that daemon. Later if you change daemon you have to set proxy to new daemon too.

@luigi1111 luigi1111 merged commit 72d87cd into monero-project:master Feb 24, 2024
18 checks passed
@0xFFFC0000 0xFFFC0000 changed the title Daemon-specific proxy for the wallet-rpc. wallet2: daemon-specific proxy for the wallet-rpc Mar 9, 2024
@0xFFFC0000
Copy link
Collaborator Author

PR is already merged. Changing the title to reflect the PR name rules we have [1].

  1. https://github.com/monero-project/monero/pull/9210/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants