-
Notifications
You must be signed in to change notification settings - Fork 55
cuprated: Generic SOCKS5 proxy support + ClearNet over Daemon
#549
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: main
Are you sure you want to change the base?
Conversation
cuprated: Generic SOCKS5 proxy support + ClearNet over Daemon
| impl TryFrom<ProxySettings> for SocksClientConfig { | ||
| type Error = anyhow::Error; | ||
|
|
||
| fn try_from(value: ProxySettings) -> Result<Self, Self::Error> { | ||
| let ProxySettings::Socks(url) = value else { | ||
| panic!("Tor proxy setting should not be parsed!") | ||
| }; | ||
|
|
||
| let Some((_, url)) = url.split_once("socks5://") else { | ||
| return Err(anyhow!("Invalid proxy url header.")); | ||
| }; | ||
|
|
||
| let (authentication, addr) = url | ||
| .split_once('@') | ||
| .map(|(up, ad)| { | ||
| ( | ||
| up.split_once(':') | ||
| .map(|(a, b)| (a.to_string(), b.to_string())), | ||
| ad, | ||
| ) | ||
| }) | ||
| .unwrap_or((None, url)); | ||
|
|
||
| Ok(Self { | ||
| proxy: addr.parse()?, | ||
| authentication, | ||
| }) | ||
| } | ||
| } |
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 this be a free function that takes a proxy string?
| /// Gets the transport config for [`ClearNet`] over [`Socks`]. | ||
| pub fn socks_transport_config(&self) -> TransportConfig<ClearNet, Socks> { | ||
| TransportConfig { | ||
| client_config: self.proxy.clone().try_into().unwrap(), | ||
| server_config: None, | ||
| } | ||
| } |
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.
making that other function a free function means we don't need this
| context_svc.clone(), | ||
| txpool_read_handle.clone(), | ||
| config.clearnet_p2p_config(), | ||
| config.p2p.clear_net.socks_transport_config(), |
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.
we can just call the free function here
What
Add support to pass P2P traffic to a specific SOCKS5 proxy. Authentication is supported. This is also used to implement
ClearNetoverDaemontor anonymization of clearnet traffic.Follows: #509
Changelog
In
cuprate-p2p-transport:socks.rsfile containingSocksthatimpl Transport<ClearNet>. As well asSocksClientConfig(socks5 proxy settings).In
cuprated:TryFrom<ProxySettings> for SocksClientConfigto parse socks5 URL in user configuration. The urls are in the form of:socks5://username:password@host:port.socks_transport_configandtransport_clearnet_daemon_confighelpers.initialize_zones_p2paccordingly.