diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-09-07 14:03:16 +0200 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-09-13 07:32:26 +0200 |
| commit | fe619d9db7b891b9c92a327ccac6e3913261fca2 (patch) | |
| tree | e33ddb77db68f025eef493f922c12864c3d5abfc /talpid-core/src | |
| parent | 2bc13231538133ad452b1b72ac4bbfe67235df02 (diff) | |
| download | mullvadvpn-fe619d9db7b891b9c92a327ccac6e3913261fca2.tar.xz mullvadvpn-fe619d9db7b891b9c92a327ccac6e3913261fca2.zip | |
Add set_custom_relay API endpoint
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/net.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/talpid-core/src/net.rs b/talpid-core/src/net.rs index ba8a3fe665..9a75859d61 100644 --- a/talpid-core/src/net.rs +++ b/talpid-core/src/net.rs @@ -1,4 +1,5 @@ use std::net::{IpAddr, SocketAddr}; +use std::str::FromStr; /// Represents a network layer IP address together with the transport layer protocol and port. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -27,3 +28,15 @@ pub enum TransportProtocol { /// Represents the TCP transport protocol. Tcp, } + +impl FromStr for TransportProtocol { + type Err = (); + + fn from_str(s: &str) -> ::std::result::Result<TransportProtocol, Self::Err> { + match s { + "udp" => Ok(TransportProtocol::Udp), + "tcp" => Ok(TransportProtocol::Tcp), + _ => Err(()), + } + } +} |
