about summary refs log tree commit diff
path: root/library/std/src/net
AgeCommit message (Collapse)AuthorLines
2022-11-09`IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation.Abhijit Gadgil-0/+9
Added documentation for IPv6 Addresses `IN6ADDR_ANY_INIT` also known as `in6addr_any` and `IN6ADDR_LOOPBACK_INIT` also known as `in6addr_loopback` similar to `INADDR_ANY` for IPv4 Addresses.
2022-10-31Update mod.rstyggja-1/+1
2022-09-12Simplify `clippy` fix.Markus Reiter-2/+0
2022-09-12Add `rustc_diagnostic_item` for IP addresses.Markus Reiter-0/+5
2022-09-12Flatten `net` module again.Markus Reiter-9/+7
2022-09-12Move `net::parser` into `net::addr` module.Markus Reiter-3/+3
2022-09-12Add tests for `SockAddr` `Display`.Markus Reiter-0/+69
2022-09-12Use `DisplayBuffer` for socket addresses.Markus Reiter-46/+34
2022-08-29Rollup merge of #94890 - marmeladema:ip-addr-try-from-bytes, r=joshtriplettMatthias Krüger-13/+125
Support parsing IP addresses from a byte string Fixes #94821 The goal is to be able to parse addresses from a byte string without requiring to do any utf8 validation. Since internally the parser already works on byte strings, this should be possible and I personally already needed this in the past too. ~~I used the proposed approach from the issue by implementing `TryFrom<&'a [u8]>` for all 6 address types (3 ip address types and 3 socket address types). I believe implementing stable traits for stable types is insta-stable so this will probably need an FCP?~~ Switched to an unstable inherent method approach called `parse_ascii` as requested. cc ``````@jyn514``````
2022-08-28Auto merge of #96324 - berendjan:set_tcp_quickack, r=dtolnaybors-1/+1
Add setter and getter for TCP_QUICKACK on TcpStream for Linux Reference issue #96256 Setting TCP_QUICKACK on TcpStream for Linux
2022-08-26Support parsing IP addresses from a byte stringmarmeladema-13/+125
2022-08-22Rollup merge of #99957 - chotchki:ip-globally-reachable_rebase, ↵Dylan DPC-85/+217
r=Mark-Simulacrum Rework Ipv6Addr::is_global to check for global reachability rather than global scope - rebase Rebasing of pull request #86634 off of master to try and get the feature "ip" stabilized. I also found a test failure in the rebase that is_global was considering the benchmark space to be globally reachable. This is related to my other rebasing pull request #99947
2022-08-16Simplify `IpDisplayBuffer` API.Markus Reiter-6/+10
2022-08-16Use `MaybeUninit<u8>` for `IpDisplayBuffer`.Markus Reiter-6/+12
2022-08-16Move `IpDisplayBuffer` into submodule.Markus Reiter-32/+36
2022-08-16Add `IpDisplayBuffer` helper struct.Markus Reiter-31/+48
2022-08-13created tcpstream quickack traitBerend-Jan Lange-1/+1
for linux and android
2022-07-31Auto merge of #78802 - faern:simplify-socketaddr, r=joshtriplettbors-224/+120
Implement network primitives with ideal Rust layout, not C system layout This PR is the result of this internals forum thread: https://internals.rust-lang.org/t/why-are-socketaddrv4-socketaddrv6-based-on-low-level-sockaddr-in-6/13321. Instead of basing `std:::net::{Ipv4Addr, Ipv6Addr, SocketAddrV4, SocketAddrV6}` on system (C) structs, they are encoded in a more optimal and idiomatic Rust way. This changes the public API of std by introducing structural equality impls for all four types here, which means that `match ipv4addr { SOME_CONSTANT => ... }` will now compile, whereas previously this was an error. No other intentional changes are introduced to public API. It's possible to observe the current layout of these types (e.g., by pointer casting); most but not all libraries which were found by Crater to do this have had updates issued and affected versions yanked. See report below. ### Benefits of this change - It will become possible to move these fundamental network types from `std` into `core` ([RFC](https://github.com/rust-lang/rfcs/pull/2832)). - Some methods that can't be made `const fn`s today can be made `const fn`s with this change. - `SocketAddrV4` only occupies 6 bytes instead of 16 bytes. - These simple primitives become easier to read and uses less `unsafe`. - Makes these types support structural equality, which means you can now (for instance) match an `Ipv4Addr` against a constant ### ~Remaining~ Previous problems This change obviously changes the memory layout of the types. And it turns out some libraries invalidly assumes the memory layout and does very dangerous pointer casts to convert them. These libraries will have undefined behaviour and perform invalid memory access until patched. - [x] - `mio` - Issue: https://github.com/tokio-rs/mio/issues/1386. - [x] `0.7` branch https://github.com/tokio-rs/mio/pull/1388 - [x] `0.7.6` published https://github.com/tokio-rs/mio/pull/1398 - [x] Yank all `0.7` versions older than `0.7.6` - [x] Report `<0.7.6` to RustSec Advisory Database https://rustsec.org/advisories/RUSTSEC-2020-0081.html - [x] - `socket2` - Issue: https://github.com/rust-lang/socket2-rs/issues/119. - [x] `0.3.x` branch https://github.com/rust-lang/socket2-rs/pull/120 - [x] `0.3.16` published - [x] `master` branch https://github.com/rust-lang/socket2-rs/pull/122 - [x] Yank all `0.3` versions older than `0.3.16` - [x] Report `<0.3.16` to RustSec Advisory Database https://rustsec.org/advisories/RUSTSEC-2020-0079.html - [x] - `net2` - Issue: https://github.com/deprecrated/net2-rs/issues/105 - [x] https://github.com/deprecrated/net2-rs/pull/106 - [x] `0.2.36` published - [x] Yank all `0.2` versions older than `0.2.36` - [x] Report `<0.2.36` to RustSec Advisory Database https://rustsec.org/advisories/RUSTSEC-2020-0078.html - [x] - `miow` - Issue: https://github.com/yoshuawuyts/miow/issues/38 - [x] `0.3.x` - https://github.com/yoshuawuyts/miow/pull/39 - [x] `0.3.6` published - [x] `0.2.x` - https://github.com/yoshuawuyts/miow/pull/40 - [x] `0.2.2` published - [x] Yanked all `0.2` versions older than `0.2.2` - [x] Yanked all `0.3` versions older than `0.3.6` - [x] Report `<0.2.2` and `<0.3.6` to RustSec Advisory Database https://rustsec.org/advisories/RUSTSEC-2020-0080.html - [x] - `quinn master` (aka what became 0.7) - https://github.com/quinn-rs/quinn/issues/968 https://github.com/quinn-rs/quinn/pull/987 - [x] - `quinn 0.6` - https://github.com/quinn-rs/quinn/pull/1045 - [x] - `quinn 0.5` - https://github.com/quinn-rs/quinn/pull/1046 - [x] - Release `0.7.0`, `0.6.2` and `0.5.4` - [x] - `nb-connect` - https://github.com/smol-rs/nb-connect/issues/1 - [x] - Release `1.0.3` - [x] - Yank all versions older than `1.0.3` - [x] - `shadowsocks-rust` - https://github.com/shadowsocks/shadowsocks-rust/issues/462 - [ ] - `rio` - https://github.com/spacejam/rio/issues/44 - [ ] - `seaslug` - https://github.com/spacejam/seaslug/issues/1 #### Fixed crate versions All crates I have found that assumed the memory layout have been fixed and published. The crates and versions that will continue working even as/if this PR is merged is (please upgrade these to help unblock this PR): * `net2 0.2.36` * `socket2 0.3.16` * `miow 0.2.2` * `miow 0.3.6` * `mio 0.7.6` * `mio 0.6.23` - Never had the invalid assumption itself, but has now been bumped to only allow fixed dependencies (`net2` + `miow`) * `nb-connect 1.0.3` * `quinn 0.5.4` * `quinn 0.6.2` ### Release notes draft This release changes the memory layout of `Ipv4Addr`, `Ipv6Addr`, `SocketAddrV4` and `SocketAddrV6`. The standard library no longer implements these as the corresponding `libc` structs (`sockaddr_in`, `sockaddr_in6` etc.). This internal representation was never exposed, but some crates relied on it anyway by unsafely transmuting. This change will cause those crates to make invalid memory accesses. Notably `net2 <0.2.36`, `socket2 <0.3.16`, `mio <0.7.6`, `miow <0.3.6` and a few other crates are affected. All known affected crates have been patched and have had fixed versions published over a year ago. If any affected crate is still in your dependency tree, you need to upgrade them before using this version of Rust.
2022-07-30Original branch seems to have missed excluding the benchmark range from the ↵Christopher Hotchkiss-8/+3
globally reachable change
2022-07-30Reincorporated changes from #87689Christopher Hotchkiss-7/+2
2022-07-30Change `Ipv4Addr::is_global` to be in line with `Ipv6Addr::is_global`Christiaan Dirkx-59/+60
Rebasing off master
2022-07-30Fix `Ipv6Addr::is_global` to check for global reachability rather than ↵Christiaan Dirkx-27/+168
global scope
2022-07-17Move SocketAddrCRepr to sys_commonLinus Färnstrand-31/+0
2022-07-05Rollup merge of #97300 - ChayimFriedman2:patch-1, r=dtolnayDylan DPC-0/+7
Implement `FusedIterator` for `std::net::[Into]Incoming` They never return `None`, so they trivially fulfill the contract. What should I put for the stability attribute of `Incoming`?
2022-07-02Bump std::net::Incoming FusedIterator impl to Rust 1.64David Tolnay-1/+1
2022-06-23Remove invalid doc comment on the size of an IP structLinus Färnstrand-9/+0
2022-06-23Assign issue number to the new const_socketaddrLinus Färnstrand-3/+3
2022-06-23Add IP structural_match testsLinus Färnstrand-0/+23
2022-06-23Remove ntohs/htons in favor of to_be/from_beLinus Färnstrand-14/+5
2022-06-23Implement IpV{4,6}Addr structs with native Rust encodingLinus Färnstrand-111/+38
2022-06-23Represent SocketAddrV4 and SocketAddrV6 as Rust native encodingLinus Färnstrand-91/+86
2022-05-24Fix stabilization version of `Ipv6Addr::to_ipv4_mapped`Tobias Bucher-1/+1
2022-05-23Implement `FusedIterator` for `std::net::[Into]Incoming`Chayim Refael Friedman-0/+7
They never return `None`, so they trivially fulfill the contract.
2022-05-23Auto merge of #96906 - tbu-:pr_stabilize_to_ipv4_mapped, r=dtolnaybors-5/+5
Stabilize `Ipv6Addr::to_ipv4_mapped` CC https://github.com/rust-lang/rust/issues/27709 (tracking issue for the `ip` feature which contains more functions) The function `Ipv6Addr::to_ipv4` is bad because it also returns an IPv4 address for the IPv6 loopback address `::1`. Stabilize `Ipv6Addr::to_ipv4_mapped` so we can recommend that function instead.
2022-05-10Recommend `Ipv6Addr::to_ipv4_mapped` over `Ipv6Addr::to_ipv4`Tobias Bucher-2/+4
Fixes #96718.
2022-05-10Stabilize `Ipv6Addr::to_ipv4_mapped`Tobias Bucher-3/+1
CC #27709 (tracking issue for the `ip` feature which contains more functions) The function `Ipv6Addr::to_ipv4` is bad because it also returns an IPv4 address for the IPv6 loopback address `::1`. Stabilize `Ipv6Addr::to_ipv4_mapped` so we can recommend that function instead.
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-2/+0
2022-05-09Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errorsbors-8/+2
Remove `#[rustc_deprecated]` This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`. I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-05-05Make it clear that `to_ipv4` returns an IPv4 address for the IPv6 loopbackTobias Bucher-1/+4
2022-04-19Improve AddrParseError descriptionChris Morgan-11/+28
The existing description was incorrect for socket addresses, and misleading: users would see “invalid IP address syntax” and suppose they were supposed to provide an IP address rather than a socket address. I contemplated making it two variants (IP, socket), but realised we can do still better for the IPv4 and IPv6 types, so here it is as six. I contemplated more precise error descriptions (e.g. “invalid IPv6 socket address syntax: expected a decimal scope ID after %”), but that’s a more invasive change, and probably not worthwhile anyway.
2022-04-14Remove use of `#[rustc_deprecated]`Jacob Pratt-8/+2
2022-03-31Adjust feature names that disagree on const stabilization versionDavid Tolnay-23/+23
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-36/+35
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-03-09Ignore `close_read_wakes_up` test on SGX platformRaoul Strackx-0/+1
2022-03-07Enable `close_read_wakes_up` on WindowsChris Denton-1/+0
2022-03-04Rollup merge of #88805 - krhancoc:master, r=dtolnayDylan DPC-0/+4
Clarification of default socket flags This PR outlines the decision to disable inheritance of socket objects when possible to child processes in the documentation.
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-4/+6
2022-02-01Fix incorrect panic message in exampleTheVoid-1/+1
2022-01-13fix stability attribute for `tcp::IntoIncoming`Ibraheem Ahmed-1/+3
2022-01-08export `tcp::IntoIncoming`Ibraheem Ahmed-1/+1