-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add Tor SOCKS option to ASB for registering to Tor Rendezvous servers and for Electrum client #1420
base: master
Are you sure you want to change the base?
Conversation
I just realized the Tor client stuff is right above where the swarm is created, which I suppose could be used instead, though the port option during launch is much easier than configuring the Tor control port and permissions and whatnot. |
hey thanks for the PR, i’ll only get a chance to review during the week |
Sounds good. I've cleaned it up a bit so that it uses the port option from the config file, and also made it so when Tor is running the Electrum client will also use the Tor proxy, and made it so the ElectrumBlockchain client takes into account the config. I have my own fork that also removes the Kraken price websocket in favor of the Feather price websocket, with Tor support for that as well, but I don't think it's as stable. I'm not sure whether it's on my end or Feather's end, but it keeps disconnecting and having to back off and try again. |
Any chance for a re-review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, see if you agree with my feedback and take a stab at it
@@ -140,29 +170,13 @@ async fn main() -> Result<()> { | |||
} | |||
} | |||
|
|||
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?; | |||
let bitcoin_wallet = | |||
init_bitcoin_wallet(&config, &seed, env_config, proxy_string).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i suggest instead adding the tor port to env_config, then this additional argument is not necessary
let tor_client = | ||
tor::Client::new(config.tor.socks5_port).with_control_port(config.tor.control_port); | ||
let _ac = match tor_client.assert_tor_running().await { | ||
Ok(_) => { | ||
tracing::info!("Setting up Tor hidden service"); | ||
let ac = | ||
register_tor_services(config.network.clone().listen, tor_client, &seed).await?; | ||
Some(ac) | ||
} | ||
Err(_) => { | ||
tracing::warn!("Tor not found. Running on clear net"); | ||
None | ||
} | ||
}; | ||
let tor_port = if _ac.is_some() { | ||
config.tor.socks5_port | ||
} else { | ||
0u16 | ||
}; | ||
let proxy_string = if tor_port != 0u16 { | ||
format!("127.0.0.1:{}", tor_port) | ||
} else { | ||
"".to_string() | ||
}; | ||
if proxy_string.is_empty() { | ||
tracing::info!(%proxy_string, "Not using SOCKS5 proxy"); | ||
} else { | ||
tracing::info!(%proxy_string, "Using SOCKS5 proxy at"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be cleaned up into 1 match statement that returns an Option for the tor port, and do the logging there too
pushed a commit to fix the fmt. there is a test compilation error |
Sounds good. Will work on it this weekend! |
Allows user to specify the Tor SOCKS5 port exactly like the cli equivalent command so that registration over Tor is possible for clearnet or onion Rendezvous servers.
Example Tor Rendezvous server:
/onion3/yn5wziq6coomwvk2regzvwmjc2hvbw3z2w35bdfersr3kdqat6jwh6ad:8888/p2p/12D3KooWDgGZKJHbHfaUFMoQHj4zEA8xcXW7tdw7rtQDMU7zoXVE