-
Notifications
You must be signed in to change notification settings - Fork 36
VPN-4633: SOCKS5 proxy is not shutting-down correctly. #4148
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
815b9aa
VPN-4633: Failing to remove SOCKS5 directory should not be fatal.
trojanfoe eb0f087
Remove empty line.
trojanfoe 51a4321
Formatting.
trojanfoe 40a557e
Add support in `nym-vpnc` and improve some conversions.
trojanfoe c8fba46
Fix vpnd client.
trojanfoe 98526c0
Rebase on `develop`.
trojanfoe d826480
Formatting.
trojanfoe dca9e25
Update change log.
trojanfoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| // Copyright 2025 - Nym Technologies SA <[email protected]> | ||
| // SPDX-License-Identifier: GPL-3.0-only | ||
|
|
||
| use nym_vpn_lib_types::{HttpRpcSettings, Socks5Settings, Socks5State, Socks5Status}; | ||
| use nym_vpn_lib_types::{ | ||
| EnableSocks5Request, ExitPoint, HttpRpcSettings, Socks5Settings, Socks5State, Socks5Status, | ||
| }; | ||
| use std::net::SocketAddr; | ||
|
|
||
| use crate::{conversions::ConversionError, proto}; | ||
|
|
||
|
|
@@ -13,19 +16,19 @@ impl TryFrom<proto::Socks5Status> for Socks5Status { | |
| .map_err(|e| ConversionError::Decode("Socks5Status.state", e)) | ||
| .map(Socks5State::from)?; | ||
|
|
||
| let socks5_settings = value | ||
| let socks5_settings: Socks5Settings = value | ||
| .socks5_settings | ||
| .map(Socks5Settings::from) | ||
| .unwrap_or_else(|| Socks5Settings { | ||
| listen_address: String::new(), | ||
| }); | ||
| .ok_or(ConversionError::NoValueSet( | ||
| "EnableSocks5Request.socks5_settings", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, good spot |
||
| ))? | ||
| .try_into()?; | ||
|
|
||
| let http_rpc_settings = value | ||
| let http_rpc_settings: HttpRpcSettings = value | ||
| .http_rpc_settings | ||
| .map(HttpRpcSettings::from) | ||
| .unwrap_or_else(|| HttpRpcSettings { | ||
| listen_address: String::new(), | ||
| }); | ||
| .ok_or(ConversionError::NoValueSet( | ||
| "EnableSocks5Request.http_rpc_settings", | ||
| ))? | ||
| .try_into()?; | ||
|
|
||
| Ok(Self { | ||
| state, | ||
|
|
@@ -48,19 +51,73 @@ impl From<proto::socks5_status::State> for Socks5State { | |
| } | ||
| } | ||
|
|
||
| impl From<proto::Socks5Settings> for Socks5Settings { | ||
| fn from(value: proto::Socks5Settings) -> Self { | ||
| Self { | ||
| listen_address: value.listen_address, | ||
| } | ||
| impl TryFrom<proto::EnableSocks5Request> for EnableSocks5Request { | ||
| type Error = ConversionError; | ||
|
|
||
| fn try_from(value: proto::EnableSocks5Request) -> Result<Self, Self::Error> { | ||
| let socks5_settings: Socks5Settings = value | ||
| .socks5_settings | ||
| .ok_or(ConversionError::NoValueSet( | ||
| "EnableSocks5Request.socks5_settings", | ||
| ))? | ||
| .try_into()?; | ||
|
|
||
| let http_rpc_settings: HttpRpcSettings = value | ||
| .http_rpc_settings | ||
| .ok_or(ConversionError::NoValueSet( | ||
| "EnableSocks5Request.http_rpc_settings", | ||
| ))? | ||
| .try_into()?; | ||
|
|
||
| let exit_point = value | ||
| .exit | ||
| .map(ExitPoint::try_from) | ||
| .transpose()? | ||
| .ok_or(ConversionError::NoValueSet("VpnServiceConfig.exit_point"))?; | ||
|
|
||
| Ok(Self { | ||
| socks5_settings, | ||
| http_rpc_settings, | ||
| exit_point, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| impl From<proto::HttpRpcSettings> for HttpRpcSettings { | ||
| fn from(value: proto::HttpRpcSettings) -> Self { | ||
| Self { | ||
| listen_address: value.listen_address, | ||
| } | ||
| impl TryFrom<proto::Socks5Settings> for Socks5Settings { | ||
| type Error = ConversionError; | ||
|
|
||
| fn try_from(value: proto::Socks5Settings) -> Result<Self, Self::Error> { | ||
| let listen_address: Option<SocketAddr> = if !value.listen_address.is_empty() { | ||
| Some( | ||
| value | ||
| .listen_address | ||
| .parse::<SocketAddr>() | ||
| .map_err(|e| ConversionError::ParseAddr("Socks5Settings.listen_address", e))?, | ||
| ) | ||
| } else { | ||
| None | ||
| }; | ||
|
|
||
| Ok(Self { listen_address }) | ||
| } | ||
| } | ||
|
|
||
| impl TryFrom<proto::HttpRpcSettings> for HttpRpcSettings { | ||
| type Error = ConversionError; | ||
|
|
||
| fn try_from(value: proto::HttpRpcSettings) -> Result<Self, Self::Error> { | ||
| let listen_address: Option<SocketAddr> = if !value.listen_address.is_empty() { | ||
| Some( | ||
| value | ||
| .listen_address | ||
| .parse::<SocketAddr>() | ||
| .map_err(|e| ConversionError::ParseAddr("HttpRpcSettings.listen_address", e))?, | ||
| ) | ||
| } else { | ||
| None | ||
| }; | ||
|
|
||
| Ok(Self { listen_address }) | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -79,17 +136,23 @@ impl From<Socks5State> for proto::socks5_status::State { | |
|
|
||
| impl From<Socks5Settings> for proto::Socks5Settings { | ||
| fn from(value: Socks5Settings) -> Self { | ||
| Self { | ||
| listen_address: value.listen_address, | ||
| } | ||
| let listen_address = match value.listen_address { | ||
| Some(addr) => addr.to_string(), | ||
| None => String::new(), | ||
| }; | ||
|
|
||
| Self { listen_address } | ||
| } | ||
| } | ||
|
|
||
| impl From<HttpRpcSettings> for proto::HttpRpcSettings { | ||
| fn from(value: HttpRpcSettings) -> Self { | ||
| Self { | ||
| listen_address: value.listen_address, | ||
| } | ||
| let listen_address = match value.listen_address { | ||
| Some(addr) => addr.to_string(), | ||
| None => String::new(), | ||
| }; | ||
|
|
||
| Self { listen_address } | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -9,4 +9,5 @@ pub mod lan; | |
| pub mod network; | ||
| pub mod network_stats; | ||
| pub mod sentry; | ||
| pub mod socks5; | ||
| pub mod tunnel; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What needs to be changed?