-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TcpSocketConfig bind_fn should take aware of SocketContext
Signed-off-by: Eval EXEC <[email protected]>
- Loading branch information
Showing
8 changed files
with
85 additions
and
250 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
pub(crate) fn check_proxy_url(proxy_url: &str) -> Result<(), String> { | ||
let parsed_url = url::Url::parse(proxy_url).map_err(|e| e.to_string())?; | ||
if parsed_url.host_str().is_none() { | ||
return Err(format!("missing host in proxy url: {}", proxy_url)); | ||
} | ||
let scheme = parsed_url.scheme(); | ||
if scheme.ne("socks5") { | ||
return Err(format!("CKB doesn't support proxy scheme: {}", scheme)); | ||
} | ||
Ok(()) | ||
} | ||
|
||
#[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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,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, | ||
} | ||
|
||
|