about summary refs log tree commit diff
path: root/library/std/src/os/unix/net
AgeCommit message (Collapse)AuthorLines
2023-03-27socket ancillary data implementation for FreeBSD (from 13 and above).David CARLIER-21/+194
introducing new build config as well.
2023-03-18Stabilise `unix_socket_abstract`John Millikin-12/+7
Fixes https://github.com/rust-lang/rust/issues/85410
2023-03-02Make std tests pass on newer AndroidPeter Collingbourne-0/+18
Newer versions of Android forbid the creation of hardlinks as well as Unix domain sockets in the /data filesystem via SELinux rules, which causes several tests depending on this behavior to fail. So let's skip these tests on Android with an #[ignore] directive.
2023-02-28Add QNX Neutrino support to libstdFlorian Bartels-2/+5
Co-authored-by: gh-tr <troach@qnx.com>
2023-01-04relax reference requirement on from_abstract_namemllken-1/+1
2022-09-18Move `unix_socket_abstract` feature API to `SocketAddrExt`.John Millikin-83/+46
2022-09-12Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726Dylan DPC-14/+2
Remove manual <[u8]>::escape_ascii `@rustbot` label: +C-cleanup
2022-08-29Rollup merge of #96334 - devnexen:socket_mark, r=dtolnayMatthias Krüger-0/+50
socket `set_mark` addition. to be able to set a marker/id on the socket for network filtering (iptables/ipfw here) purpose.
2022-08-23Rollup merge of #100835 - devnexen:listener_followups, r=devnexenDylan DPC-4/+2
net listen backlog update, follow-up from #97963. FreeBSD and using system limit instead for others.
2022-08-22net listen backlog update, follow-up from #97963.David CARLIER-4/+2
FreeBSD and using system limit instead for others.
2022-08-21Rollup merge of #100822 - WaffleLapkin:no_offset_question_mark, r=scottmcmMatthias Krüger-1/+1
Replace most uses of `pointer::offset` with `add` and `sub` As PR title says, it replaces `pointer::offset` in compiler and standard library with `pointer::add` and `pointer::sub`. This generally makes code cleaner, easier to grasp and removes (or, well, hides) integer casts. This is generally trivially correct, `.offset(-constant)` is just `.sub(constant)`, `.offset(usized as isize)` is just `.add(usized)`, etc. However in some cases we need to be careful with signs of things. r? ````@scottmcm```` _split off from #100746_
2022-08-21Replace most uses of `pointer::offset` with `add` and `sub`Maybe Waffle-1/+1
2022-08-20Rollup merge of #97963 - devnexen:net_listener_neg, r=the8472Matthias Krüger-2/+10
net listen backlog set to negative on Linux. it will be 4076 (from 5.4) or 128.
2022-08-19use <[u8]>::escape_ascii instead of core::ascii::escape_defaultKaDiWa-14/+2
2022-07-20Rollup merge of #98101 - vladimir-ea:stdlib_watch_os, r=thomccDylan DPC-0/+3
stdlib support for Apple WatchOS This is a follow-up to https://github.com/rust-lang/rust/pull/95243 (Add Apple WatchOS compiler targets) that adds stdlib support for Apple WatchOS. `@deg4uss3r` `@nagisa`
2022-07-20Library changes for Apple WatchOSVladimir Michael Eatwell-0/+3
2022-07-07Fix doc build on unsupported osesDavid CARLIER-2/+16
2022-07-06changes from feedbackDavid Carlier-6/+4
2022-07-06doc additionsDavid Carlier-1/+33
2022-07-06socket `set_mark` addition.David Carlier-0/+6
to be able to set a marker/id on the socket for network filtering (iptables/ipfw here) purpose.
2022-06-21update ioslice docs to use shared slicesConrad Ludgate-2/+2
2022-06-14Implement stabilization of `#[feature(io_safety)]`.Dan Gohman-9/+9
Implement stabilization of [I/O safety], aka `#[feature(io_safety)]`. Fixes #87074. [I/O safety]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
2022-06-10net listen backlog set to negative on Linux.David Carlier-2/+10
it will be 4076 (from 5.4) or 128.
2022-05-25Disable unix::net::ancillary on BSD.Mara Bos-155/+31
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-2/+0
2022-04-04ScmCredentials netbsd implementation.David Carlier-13/+92
2022-03-29fix unix typedefAria Beingessner-1/+1
2022-03-29Make some linux/unix APIs better conform to strict provenance.Alexis Beingessner-2/+2
This largely makes the stdlib conform to strict provenance on Ubuntu. Some hairier things have been left alone for now.
2022-03-11Rollup merge of #94356 - Thomasdezeeuw:stabilize_unix_socket_creation, r=dtolnayDylan DPC-6/+4
Rename unix::net::SocketAddr::from_path to from_pathname and stabilize it Stabilizes `unix_socket_creation`. Closes https://github.com/rust-lang/rust/issues/93423 r? `@m-ou-se`
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-36/+36
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-02-27Stabilize unix_socket_creationThomas de Zeeuw-3/+1
2022-02-25Rename unix::net::SocketAddr::from_path to from_pathnameThomas de Zeeuw-3/+3
Matching SocketAddr::as_pathname.
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-8/+8
2022-01-28Update tracking issue for unix_socket_creationThomas de Zeeuw-1/+1
2022-01-27Use sockaddr_un in unix SocketAddr::from_pathThomas de Zeeuw-35/+1
2022-01-27Make sockaddr_un safe and use copy_nonoverlappingThomas de Zeeuw-8/+11
The creation of libc::sockaddr_un is a safe operation, no need for it to be unsafe. This also uses the more performant copy_nonoverlapping instead of an iterator.
2022-01-24Rename SocketAddr::unix to from_pathThomas de Zeeuw-16/+20
And change it to disallow NULL bytes.
2022-01-23Add os::unix::net::SocketAddr::unixThomas de Zeeuw-1/+68
Creates a new SocketAddr from a path, supports both regular paths and abstract namespaces.
2021-12-16Revert "socket ancillary data implementation for dragonflybsd."David CARLIER-90/+6
2021-12-11Rollup merge of #91553 - devnexen:anc_data_dfbsd, r=yaahcMatthias Krüger-6/+90
socket ancillary data implementation for dragonflybsd.
2021-12-09Auto merge of #81156 - DrMeepster:read_buf, r=joshtriplettbors-11/+1
Implement most of RFC 2930, providing the ReadBuf abstraction This replaces the `Initializer` abstraction for permitting reading into uninitialized buffers, closing #42788. This leaves several APIs described in the RFC out of scope for the initial implementation: * read_buf_vectored * `ReadBufs` Closes #42788, by removing the relevant APIs.
2021-12-05socket ancillary data implementation for dragonflybsd.David Carlier-6/+90
2021-11-06use matches!() macro in more placesMatthias Krüger-1/+1
2021-11-02read_bufDrMeepster-11/+1
2021-10-31Rollup merge of #90431 - jkugelman:must-use-std-o-through-z, r=joshtriplettMatthias Krüger-0/+7
Add #[must_use] to remaining std functions (O-Z) I've run out of compelling reasons to group functions together across crates so I'm just going to go module-by-module. This is half of the remaining items from the `std` crate, from O-Z. `panicking::take_hook` has a side effect: it unregisters the current panic hook, returning it. I almost ignored it, but the documentation example shows `let _ = panic::take_hook();`, so following suit I went ahead and added a `#[must_use]`. ```rust std::panicking fn take_hook() -> Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>; ``` I added these functions that clippy did not flag: ```rust std::path::Path fn starts_with<P: AsRef<Path>>(&self, base: P) -> bool; std::path::Path fn ends_with<P: AsRef<Path>>(&self, child: P) -> bool; std::path::Path fn with_file_name<S: AsRef<OsStr>>(&self, file_name: S) -> PathBuf; std::path::Path fn with_extension<S: AsRef<OsStr>>(&self, extension: S) -> PathBuf; ``` Parent issue: #89692 r? `@joshtriplett`
2021-10-31Rollup merge of #89786 - jkugelman:must-use-len-and-is_empty, r=joshtriplettMatthias Krüger-0/+2
Add #[must_use] to len and is_empty Parent issue: #89692 r? `@joshtriplett`
2021-10-30Add #[must_use] to remaining std functions (O-Z)John Kugelman-0/+7
2021-10-30Add #[must_use] to len and is_emptyJohn Kugelman-0/+2
2021-10-15Auto merge of #85379 - mdaverde:uds-abstract, r=joshtriplettbors-4/+416
Add abstract namespace support for Unix domain sockets Hello! The other day I wanted to mess around with UDS in Rust and found that abstract namespaces ([unix(7)](https://man7.org/linux/man-pages/man7/unix.7.html)) on Linux still needed development. I took the approach of adding `_addr` specific public functions to reduce conflicts. Feature name: `unix_socket_abstract` Tracking issue: #85410 Further context: #42048 ## Non-platform specific additions `UnixListener::bind_addr(&SocketAddr) -> Result<UnixListener>` `UnixStream::connect_addr(&SocketAddr) -> Result<()>` `UnixDatagram::bind_addr(&SocketAddr) -> Result<UnixDatagram>` `UnixDatagram::connect_addr(&SocketAddr) -> Result<()>` `UnixDatagram::send_to_addr(&self, &[u8], &SocketAddr) -> Result<usize>` ## Platform-specific (Linux) additions `SocketAddr::from_abstract_namespace(&[u8]) -> SocketAddr` `SockerAddr::as_abstract_namespace() -> Option<&[u8]>` ## Example ```rust #![feature(unix_socket_abstract)] use std::os::unix::net::{UnixListener, SocketAddr}; fn main() -> std::io::Result<()> { let addr = SocketAddr::from_abstract_namespace(b"namespace")?; // Linux only let listener = match UnixListener::bind_addr(&addr) { Ok(sock) => sock, Err(err) => { println!("Couldn't bind: {:?}", err); return Err(err); } }; Ok(()) } ``` ## Further Details The main inspiration for the implementation came from the [nix-rust](https://github.com/nix-rust/nix/blob/master/src/sys/socket/addr.rs#L558) crate but there are also other [historical](https://github.com/rust-lang/rust/commit/c4db0685b181f12c4285dac3d932f1859bba74f5) [attempts](https://github.com/tormol/uds/blob/master/src/addr.rs#L324) with similar approaches. A comment I did have was with this change, we now allow a `SocketAddr` to be constructed explicitly rather than just used almost as a handle for the return of `peer_addr` and `local_addr`. We could consider adding other explicit constructors (e.g. `SocketAddr::from_pathname`, `SockerAddr::from_unnamed`). Cheers!
2021-10-12Rollup merge of #89797 - jkugelman:must-use-is_condition-tests, r=joshtriplettthe8472-0/+1
Add #[must_use] to is_condition tests I threw in `std::path::Path::has_root` for funsies. A continuation of #89718. Parent issue: #89692 r? ```@joshtriplett```