We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
impl From<SocketAddr> for Socket
1 parent 525bc13 commit 500e82bCopy full SHA for 500e82b
src/port_forwarding.rs
@@ -6,7 +6,7 @@ use std::ffi::OsStr;
6
7
use std::borrow::Cow;
8
use std::fmt;
9
-use std::net::{self, SocketAddr};
+use std::net::{self, IpAddr, SocketAddr};
10
use std::path::{Path, PathBuf};
11
12
/// Type of forwarding
@@ -53,8 +53,12 @@ pub enum Socket<'a> {
53
54
impl From<SocketAddr> for Socket<'static> {
55
fn from(addr: SocketAddr) -> Self {
56
+ let host = match addr.ip() {
57
+ IpAddr::V4(v4) => v4.to_string(),
58
+ IpAddr::V6(v6) => format!("[{v6}]"),
59
+ };
60
Socket::TcpSocket {
- host: addr.ip().to_string().into(),
61
+ host: host.into(),
62
port: addr.port(),
63
}
64
0 commit comments