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

[WIP] Add proxy support for ckb #4733

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add proxy support for ckb
Signed-off-by: Eval EXEC <[email protected]>
eval-exec committed Dec 4, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
darmiel Daniel
commit 10b60c5aae2a3bb7d1e6eb961373bf730d79e20f
59 changes: 8 additions & 51 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions network/src/network.rs
Original file line number Diff line number Diff line change
@@ -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 => {
4 changes: 2 additions & 2 deletions util/app-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
10 changes: 10 additions & 0 deletions util/app-config/src/configs/network.rs
Original file line number Diff line number Diff line change
@@ -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.