-
Notifications
You must be signed in to change notification settings - Fork 243
Add proxy and onion support for ckb-network
#4733
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
base: develop
Are you sure you want to change the base?
Conversation
fe5d648 to
e55f631
Compare
de239fd to
f9f0733
Compare
587e905 to
865759d
Compare
260c2fe to
c0f57bb
Compare
6169766 to
12e27f6
Compare
|
Just rebased onto develop branch. |
Add Tor package installation to macOS and Windows CI workflows for Tor integration testing.
Add Go toolchain installation to macOS and Ubuntu CI workflows for building obfs4 proxy.
Add obfs4 submodule for obfuscation proxy support and Makefile targets for building obfs4proxy.
Add ckb-onion crate and torut dependency for Tor integration, and update tentacle dependencies.
Add NetworkAddresses struct to manage onion addresses alongside regular network addresses.
Add proxy module with URL validation for Tor proxy configuration and error handling.
Add onion service configuration options to network configuration for Tor integration.
Update network service builder to support proxy and onion service configuration.
Add ckb-onion crate for managing onion service integration with Tor network.
Update peer store to properly handle and store onion addresses for Tor network peers.
Update identify protocol to properly advertise and discover onion addresses for Tor network peers.
Update network state to manage public addresses including onion addresses for Tor integration.
Add onion service configuration options to network configuration and update ckb.toml template.
Signed-off-by: Eval EXEC <[email protected]>
Signed-off-by: Eval EXEC <[email protected]>
738892a to
149d2ce
Compare
|
I removed the struct NetworkAddresses because it was unnecessary. Then I rebased onto develop branch. Invite @driftluo @quake @zhangsoledad @doitian @chenyukang review again. |
| )) | ||
| })?; | ||
| file.write_all( | ||
| &base64::engine::general_purpose::STANDARD |
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.
can we write the key as binary directly to the file, why need base64 encoding/decoding here?
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.
Yes we can.
I use base64 encoding/decoding, because bitcoin use base64 encoding/decoding, I followed bitcoin's style:
❯ cat ~/.bitcoin/onion_v3_private_key
ED25519-V3:aCSgwUGBquFBdiQ5S3DN3ZZ64O7tMqrtkwji7huY702sFmZNiVqsyAc4f53xF9ecDX7QrcM2PxuJePn72jFFnw==%| loop { | ||
| tokio::select! { | ||
| _ = ticker.tick() => { | ||
| let uptime = tor_controller.get_uptime().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.
it looks like you are using get_uptime as a heartbeat, since the Tor control connection is just a TCP stream, you can rely on TCP keepalive instead. Once keepalive is enabled, the OS will automatically detect when the Tor control port goes down, whether Tor crashes, restarts, or the connection drops.
Keepalive related code may be put in TorController::new.
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.
it looks like you are using get_uptime as a heartbeat
Yes.
you can rely on TCP keepalive instead
If we rely solely on TCP keep-alive, we’d still need to keep reading or writing the socket to detect failure — and doing so may interfere with the Tor control-port protocol by consuming unexpected data. Hence I prefer an application-level heartbeat via tor_contoller.get_uptime().
| listen_addrs.push(Multiaddr::try_from(addr.bytes().raw_data().to_vec()).ok()?) | ||
| match Multiaddr::try_from(addr.bytes().raw_data().to_vec()) { | ||
| Ok(multi_addr) => { | ||
| listen_addrs.push(multi_addr); |
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.
any specific reason for ignore this error?
| ### the user should start a Tor server and set proxy_url to the Tor server's address. | ||
| ### then MUST set [network.proxy.proxy_url] to tor server's address. |
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 two line have duplicated meanning?
|
|
||
| # [network.proxy] | ||
| ### The proxy_url is user-specified SOCKS5 address, like: socks5://127.0.0.1:7891 | ||
| # proxy_url = "socks5://127.0.0.1:9050" |
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 option will be ignored if user already set onion_server?
| "{} --bin {} --obfs4proxy-bin {} --port {} {}", | ||
| canonicalize_path(env::args().next().unwrap_or_else(|| "ckb-test".to_string())).display(), | ||
| canonicalize_path(global::binary()).display(), | ||
| canonicalize_path(global::obfs4proxy_binary()).display(), |
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.
have you checked out https://github.com/jmwample/ptrs ?
I'm not sure, it's just a crate and may need more investigation on it.
What problem does this PR solve?
This PR want to add socks5 proxy and onion support for ckb.
Add
network.proxyandnetwork.onionconfig:Start a tor server:
tor --SocksPort 9050 --ControlPort 9051, finaly, start the ckb node, ifnetwork.onion.listen_on_onionis true, it will auto connect to the tor server, and use tor control port to create onion service.Related changes
ProxyConfigandOnionConfigto network configsocks5://<username>:<password>@server_host:portonionckb node, and listen on the onion hidden networkckb-onion[network.proxy]via a normalsocks5proxyckb-onionrelated configuration's documentation inckb.tomlNote:
Need to setup promethues for tor process: https://gitlab.torproject.org/tpo/onion-services/onionprobe
Check List
Tests
Side effects
Release note