diff --git a/Cargo.lock b/Cargo.lock index 947b74becf..c64ea553ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -704,8 +704,8 @@ dependencies = [ "serde", "serde_json", "tempfile", - "tentacle-multiaddr 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tentacle-secio 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tentacle-multiaddr", + "tentacle-secio", "toml", "ubyte", "url", @@ -4074,7 +4074,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -6566,7 +6566,6 @@ dependencies = [ [[package]] name = "tentacle" version = "0.6.4" -source = "git+https://github.com/eval-exec/tentacle.git?branch=exec/proxy#5146d4d9ff2dfa629789b3b5155dee7b32ccd9bc" dependencies = [ "async-trait", "bytes", @@ -6583,8 +6582,8 @@ dependencies = [ "shadowsocks", "shadowsocks-service", "socket2", - "tentacle-multiaddr 0.3.4 (git+https://github.com/eval-exec/tentacle.git?branch=exec/proxy)", - "tentacle-secio 0.6.3 (git+https://github.com/eval-exec/tentacle.git?branch=exec/proxy)", + "tentacle-multiaddr", + "tentacle-secio", "thiserror", "tokio", "tokio-tungstenite", @@ -6598,20 +6597,6 @@ dependencies = [ [[package]] name = "tentacle-multiaddr" version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9e71b28bf0bbf274b92f47cb2c5b42755d84a11e2246cf7bcb7b65c89483b9" -dependencies = [ - "bs58", - "bytes", - "serde", - "sha2", - "unsigned-varint", -] - -[[package]] -name = "tentacle-multiaddr" -version = "0.3.4" -source = "git+https://github.com/eval-exec/tentacle.git?branch=exec/proxy#5146d4d9ff2dfa629789b3b5155dee7b32ccd9bc" dependencies = [ "bs58", "bytes", @@ -6623,34 +6608,6 @@ dependencies = [ [[package]] name = "tentacle-secio" version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99df015b8649588f2958d4853eee221860f95d2721995857e9dde1462ceb3dc4" -dependencies = [ - "bs58", - "bytes", - "chacha20poly1305", - "futures", - "getrandom 0.2.15", - "hmac", - "log", - "molecule", - "openssl", - "openssl-sys", - "rand 0.8.5", - "rand_core 0.6.4", - "ring", - "secp256k1", - "sha2", - "tokio", - "tokio-util", - "unsigned-varint", - "x25519-dalek", -] - -[[package]] -name = "tentacle-secio" -version = "0.6.3" -source = "git+https://github.com/eval-exec/tentacle.git?branch=exec/proxy#5146d4d9ff2dfa629789b3b5155dee7b32ccd9bc" dependencies = [ "bs58", "bytes", @@ -6973,7 +6930,6 @@ dependencies = [ [[package]] name = "tokio-yamux" version = "0.3.9" -source = "git+https://github.com/eval-exec/tentacle.git?branch=exec/proxy#5146d4d9ff2dfa629789b3b5155dee7b32ccd9bc" dependencies = [ "bytes", "futures", diff --git a/network/Cargo.toml b/network/Cargo.toml index 4ed949321a..c653ddf17e 100644 --- a/network/Cargo.toml +++ b/network/Cargo.toml @@ -34,10 +34,10 @@ serde_json = "1.0" bloom-filters = "0.1" ckb-spawn = { path = "../util/spawn", version = "= 0.120.0-pre" } bitflags = "1.0" -p2p = { git="https://github.com/eval-exec/tentacle.git", branch="exec/proxy", package = "tentacle", default-features = false } +p2p = { path = "/home/exec/Projects/github.com/nervosnetwork/tentacle/tentacle", package = "tentacle", default-features = false } [target.'cfg(not(target_family = "wasm"))'.dependencies] -p2p = { git="https://github.com/eval-exec/tentacle.git", branch="exec/proxy", package = "tentacle", default-features = false, features = [ +p2p = { path = "/home/exec/Projects/github.com/nervosnetwork/tentacle/tentacle", package = "tentacle", default-features = false, features = [ "upnp", "parking_lot", "openssl-vendored", @@ -48,7 +48,7 @@ p2p = { git="https://github.com/eval-exec/tentacle.git", branch="exec/proxy", pa socket2 = "0.5" [target.'cfg(target_family = "wasm")'.dependencies] -p2p = { git="https://github.com/eval-exec/tentacle.git", branch="exec/proxy", package = "tentacle", default-features = false, features = [ +p2p = { path = "/home/exec/Projects/github.com/nervosnetwork/tentacle/tentacle", package = "tentacle", default-features = false, features = [ "wasm-timer", ] } idb = "0.6" diff --git a/network/src/network.rs b/network/src/network.rs index 6134e7cb12..3215965daf 100644 --- a/network/src/network.rs +++ b/network/src/network.rs @@ -28,6 +28,7 @@ use ckb_systemtime::{Duration, Instant}; use ckb_util::{Condvar, Mutex, RwLock}; use futures::{channel::mpsc::Sender, Future}; use ipnetwork::IpNetwork; +use p2p::service::ProxyConfig; use p2p::{ async_trait, builder::ServiceBuilder, @@ -1015,6 +1016,14 @@ impl NetworkService { }; init.transform(TransportType::Tcp); service_builder = service_builder.tcp_config(bind_fn); + + if config.proxy_config.enable { + let proxy_config = Some(ProxyConfig { + proxy_url: config.proxy_config.proxy_url.clone(), + }); + service_builder = + service_builder.tcp_proxy_config(proxy_config); + } } } TransportType::Ws => { diff --git a/util/app-config/Cargo.toml b/util/app-config/Cargo.toml index 5acccab4bd..7f86de1783 100644 --- a/util/app-config/Cargo.toml +++ b/util/app-config/Cargo.toml @@ -22,8 +22,8 @@ ckb-pow = { path = "../../pow", version = "= 0.120.0-pre" } ckb-resource = { path = "../../resource", version = "= 0.120.0-pre" } ckb-build-info = { path = "../build-info", version = "= 0.120.0-pre" } ckb-types = { path = "../types", version = "= 0.120.0-pre" } -secio = { version = "0.6", package = "tentacle-secio" } -multiaddr = { version = "0.3.0", package = "tentacle-multiaddr" } +secio = { path="/home/exec/Projects/github.com/nervosnetwork/tentacle/secio", package = "tentacle-secio" } +multiaddr = { path="/home/exec/Projects/github.com/nervosnetwork/tentacle/multiaddr", package = "tentacle-multiaddr" } rand = "0.8" sentry = { version = "0.34.0", optional = true } ckb-systemtime = { path = "../systemtime", version = "= 0.120.0-pre" } diff --git a/util/app-config/src/configs/network.rs b/util/app-config/src/configs/network.rs index 70d8cb3550..bcfcd7048a 100644 --- a/util/app-config/src/configs/network.rs +++ b/util/app-config/src/configs/network.rs @@ -92,6 +92,16 @@ pub struct Config { #[cfg(target_family = "wasm")] #[serde(skip)] pub secret_key: [u8; 32], + + #[serde(default)] + pub proxy_config: ProxyConfig, +} + +/// Proxy related config options +#[derive(Clone, Debug, Serialize, Deserialize, Default)] +pub struct ProxyConfig { + pub enable: bool, + pub proxy_url: String, } /// Chain synchronization config options.