Skip to content

Commit

Permalink
Justify Socks5Local::new
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Oct 18, 2023
1 parent de050f8 commit 8578d47
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions mullvad-types/src/access_method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,20 +255,8 @@ impl Shadowsocks {
}

impl Socks5Local {
pub fn new(peer: SocketAddr, port: u16) -> Self {
Self::new_with_transport_protocol(peer, port, TransportProtocol::Tcp)
}

pub fn new_with_transport_protocol(
peer: SocketAddr,
local_port: u16,
transport_protocol: TransportProtocol,
) -> Self {
let peer = Endpoint::from_socket_address(peer, transport_protocol);
Self {
peer,
port: local_port,
}
pub fn new(peer: Endpoint, port: u16) -> Self {
Self { peer, port }
}

/// Like [new()], but tries to parse `ip` and `port` into a [`std::net::SocketAddr`] for you.
Expand All @@ -279,11 +267,9 @@ impl Socks5Local {
transport_protocol: TransportProtocol,
local_port: u16,
) -> Option<Self> {
Some(Self::new_with_transport_protocol(
SocketAddr::new(remote_ip.parse().ok()?, remote_port),
local_port,
transport_protocol,
))
let peer = SocketAddr::new(remote_ip.parse().ok()?, remote_port);
let peer = Endpoint::from_socket_address(peer, transport_protocol);
Some(Self::new(peer, local_port))
}
}

Expand Down

0 comments on commit 8578d47

Please sign in to comment.