Open sullivan-sean opened 2 years ago
It would be nice to be able to access the path of a unix socket from
SockAddr
similar tovsock_address
Do you mean https://docs.rs/socket2/latest/socket2/struct.SockAddr.html#method.unix? I think we simply forgot to expose it in https://github.com/rust-lang/socket2/pull/249.
socket2
is being considered as a backend for UDS on windows inmio
/tokio
(tokio-rs/mio#1610 (comment)) and, if used, would need to expose the address of unix sockets fromSocketAddr
to mirror the implementation of SocketAddr inmio
for unix
It's not ;)
I meant more going the other way from SockAddr
-> Path
. Right now the SockAddr
struct has private fields and there are no methods for Unix sockets exposing the Path
which means once you have a SockAddr
object (e.g. as returned from accept
) you cannot get the corresponding Path
back out, or tell whether a SockAddr
is an unnamed or abstract Unix socket (i.e. the SockAddr
here can't provide this functionality https://github.com/tokio-rs/mio/blob/master/src/sys/unix/uds/socketaddr.rs#L76-L96)
We could add SocketAddr::as_pathname() -> Option<Path>
.
What is the desired behavior for abstract unix sockets where there is a name associated with the SockAddr
struct but this name has no connection with filesystem pathnames? (https://manpages.ubuntu.com/manpages/trusty/man7/unix.7.html)
Unnamed unix sockets would presumably return None
from as_pathname
, and normal sockets would return a Path
as expected.
I think we can match the std::os::unix::net::SocketAddr
type and match the is_unnamed
, as_pathname
and as_abstract_namespace
functions.
Okay, I think I have a good understanding of the desired API then -- I can take a stab at this and open a PR?
Okay, I think I have a good understanding of the desired API then -- I can take a stab at this and open a PR?
Sounds good.
Hey, this seems inactive and we need it for https://github.com/metalbear-co/mirrord/issues/1105 . I read the comments and will follow the desired design.
Hey, this seems inactive and we need it for metalbear-co/mirrord#1105 . I read the comments and will follow the desired design.
Pr would be welcome 👍
This has been done in https://github.com/rust-lang/socket2/pull/403.
This has been done in #403.
Only on unix though, so maybe there should still be an open issue for Windows.
Reopening for Windows
It would be nice to be able to access the path of a unix socket from
SockAddr
similar tovsock_address
socket2
is being considered as a backend for UDS on windows inmio
/tokio
(https://github.com/tokio-rs/mio/pull/1610#issuecomment-1218388105) and, if used, would need to expose the address of unix sockets fromSocketAddr
to mirror the implementation of SocketAddr inmio
for unix