Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Dec 4, 2024
1 parent 10b60c5 commit 2ab4294
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
21 changes: 6 additions & 15 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bloom-filters = "0.1"
ckb-spawn = { path = "../util/spawn", version = "= 0.120.0-pre" }
bitflags = "1.0"
p2p = { path = "/home/exec/Projects/github.com/nervosnetwork/tentacle/tentacle", package = "tentacle", default-features = false }
url = "2.5.4"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
p2p = { path = "/home/exec/Projects/github.com/nervosnetwork/tentacle/tentacle", package = "tentacle", default-features = false, features = [
Expand Down
1 change: 1 addition & 0 deletions network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub mod peer_registry;
pub mod peer_store;
mod protocols;
mod services;
mod proxy;

#[cfg(test)]
mod tests;
Expand Down
20 changes: 20 additions & 0 deletions network/src/proxy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
fn parse(proxy_url: &str) -> url::Url {
todo!()
}

#[test]
fn parse_socks5_url() {
let result = url::Url::parse("socks5://username:password@localhost:1080");
assert!(result.is_ok());
let parsed_url = result.unwrap();
dbg!(&parsed_url);
assert_eq!(parsed_url.scheme(), "socks5");
// username
assert_eq!(parsed_url.username(), "username");
// password
assert_eq!(parsed_url.password(), Some("password"));
// host
assert_eq!(parsed_url.host_str(), Some("localhost"));
// port
assert_eq!(parsed_url.port(), Some(1080));
}
1 change: 1 addition & 0 deletions util/app-config/src/configs/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ pub struct Config {
#[derive(Clone, Debug, Serialize, Deserialize, Default)]
pub struct ProxyConfig {
pub enable: bool,
// like: socks5://username:[email protected]:1080
pub proxy_url: String,
}

Expand Down

0 comments on commit 2ab4294

Please sign in to comment.