diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml
index 88775f9a3..7262d978a 100644
--- a/.github/workflows/book.yml
+++ b/.github/workflows/book.yml
@@ -20,17 +20,17 @@ jobs:
with:
python-version: 3.9
- - name: Install Rust (nightly)
+ - name: Install Rust
uses: actions-rs/toolchain@v1
with:
- toolchain: nightly-2025-04-10
+ toolchain: stable
components: rustfmt, clippy
override: true
- name: Install Rust (wasm32)
uses: actions-rs/toolchain@v1
with:
- toolchain: nightly-2025-04-10
+ toolchain: stable
target: wasm32-unknown-unknown
override: true
@@ -56,7 +56,7 @@ jobs:
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "bookworm"
cd doc
- make CARGO="cargo +nightly-2025-04-10" github
+ make github
git checkout gh-pages
- name: Push changes
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0b1e7dd3f..c934cbbf2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -13,11 +13,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
- toolchain: nightly-2025-04-10
+ toolchain: stable
override: true
- uses: actions-rs/toolchain@v1
with:
- toolchain: nightly-2025-04-10
+ toolchain: stable
target: wasm32-unknown-unknown
override: true
- uses: actions/setup-python@v1
@@ -37,11 +37,11 @@ jobs:
- name: Run test units
run: |
- make CARGO="cargo +nightly-2025-04-10" test
+ make test
- name: Compile all bins
run: |
- make CARGO="cargo +nightly-2025-04-10"
+ make
feature-powerset:
name: Test crate feature powerset on ${{ matrix.os }}
@@ -54,11 +54,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
- toolchain: nightly-2025-04-10
+ toolchain: stable
override: true
- uses: actions-rs/toolchain@v1
with:
- toolchain: nightly-2025-04-10
+ toolchain: stable
target: wasm32-unknown-unknown
override: true
- uses: taiki-e/install-action@cargo-hack
@@ -75,7 +75,7 @@ jobs:
- name: Run feature powerset builds
run: |
- make CARGO="cargo +nightly-2025-04-10" check
+ make check
fmt:
name: rustfmt
@@ -85,8 +85,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
- toolchain: nightly-2025-04-10
+ toolchain: nightly
components: rustfmt
override: true
- run: |
- cargo +nightly-2025-04-10 fmt -- --check
+ cargo +nightly fmt -- --check
diff --git a/.github/workflows/lints-nightly.yml b/.github/workflows/lints.yml
similarity index 80%
rename from .github/workflows/lints-nightly.yml
rename to .github/workflows/lints.yml
index 3d1302ec3..5d5cc569f 100644
--- a/.github/workflows/lints-nightly.yml
+++ b/.github/workflows/lints.yml
@@ -1,23 +1,23 @@
-name: Nightly lints
+name: Lints
# We only run these on trial-merges of PRs to reduce noise.
on: pull_request
jobs:
clippy:
- name: Clippy (nightly)
+ name: Clippy
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
- toolchain: nightly-2025-04-10
+ toolchain: stable
components: clippy
override: true
- name: Run Clippy
uses: actions-rs/clippy-check@v1
with:
- name: Clippy (stable)
+ name: Clippy
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --release -- -D warnings
diff --git a/Makefile b/Makefile
index 57803e49e..ab80f9350 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target for system binaries
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
@@ -149,7 +149,7 @@ fu:
# -- END OF BINS --
fmt:
- $(CARGO) fmt --all
+ $(CARGO) +nightly fmt --all
# cargo install cargo-hack
check: explorerd_bundle_contracts_src $(PROOFS_BIN)
diff --git a/README.md b/README.md
index 266795b98..e8128f699 100644
--- a/README.md
+++ b/README.md
@@ -44,17 +44,12 @@ This project requires the Rust compiler to be installed.
Please visit [Rustup](https://rustup.rs/) for instructions.
You have to install a native toolchain, which is set up during Rust installation,
-nightly toolchain and wasm32 target.
-To install nightly toolchain, execute:
-```shell
-% rustup toolchain install nightly
-```
+and wasm32 target.
To install wasm32 target, execute:
```shell
% rustup target add wasm32-unknown-unknown
-% rustup target add wasm32-unknown-unknown --toolchain nightly
```
-Minimum Rust version supported is **1.77.0 (nightly)**.
+Minimum Rust version supported is **1.77.0**.
The following dependencies are also required:
@@ -110,34 +105,6 @@ If you want to hack on the source code, make sure to read some
introductory advice in the
[DarkFi book](https://darkrenaissance.github.io/darkfi/dev/dev.html).
-### Living on the cutting edge
-
-Since the project uses the nightly toolchain, breaking changes are bound
-to happen from time to time. As a workaround, we can configure an older
-nightly version, which was known to work:
-
-```shell
-% rustup toolchain install nightly-2025-04-10
-% rustup target add wasm32-unknown-unknown --toolchain nightly-2025-04-10
-```
-
-Now we can use that toolchain in `make` directly:
-
-```shell
-% make CARGO="cargo +nightly-2025-04-10" {target}
-```
-
-Or, if we are lazy, we can modify the `Makefile` to always use that:
-
-```shell
-% sed -i Makefile -e "s|nightly|nightly-2025-04-10|g"
-```
-
-Under no circumstances commit or push the Makefile change.
-
-When using `cargo` directly, you have to add the `+nightly-2025-04-10` flag,
-in order for it to use the older nightly version.
-
## Install
This will install the binaries on your system (`/usr/local` by
diff --git a/bin/darkfi-mmproxy/Makefile b/bin/darkfi-mmproxy/Makefile
index dbdadc8fd..8264a8f6c 100644
--- a/bin/darkfi-mmproxy/Makefile
+++ b/bin/darkfi-mmproxy/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/darkfid/Makefile b/bin/darkfid/Makefile
index c5a759666..9e15582a6 100644
--- a/bin/darkfid/Makefile
+++ b/bin/darkfid/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/darkirc/Makefile b/bin/darkirc/Makefile
index 45434ad3a..85fa83c25 100644
--- a/bin/darkirc/Makefile
+++ b/bin/darkirc/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/drk/Makefile b/bin/drk/Makefile
index c9e4a9310..95ac377df 100644
--- a/bin/drk/Makefile
+++ b/bin/drk/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/explorer/explorerd/Makefile b/bin/explorer/explorerd/Makefile
index b193f4efb..a412de3f4 100644
--- a/bin/explorer/explorerd/Makefile
+++ b/bin/explorer/explorerd/Makefile
@@ -7,7 +7,7 @@ MAKEFLAGS += --no-print-directory
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/genev/genev-cli/Makefile b/bin/genev/genev-cli/Makefile
index f292a2271..e89e21213 100644
--- a/bin/genev/genev-cli/Makefile
+++ b/bin/genev/genev-cli/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/genev/genevd/Makefile b/bin/genev/genevd/Makefile
index 2a15600cf..ab86e7243 100644
--- a/bin/genev/genevd/Makefile
+++ b/bin/genev/genevd/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/lilith/Makefile b/bin/lilith/Makefile
index 5ac277d8b..9cbc1efd2 100644
--- a/bin/lilith/Makefile
+++ b/bin/lilith/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/minerd/Makefile b/bin/minerd/Makefile
index b9b4f9011..57b2978e2 100644
--- a/bin/minerd/Makefile
+++ b/bin/minerd/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/tau/taud/Makefile b/bin/tau/taud/Makefile
index 2a15600cf..ab86e7243 100644
--- a/bin/tau/taud/Makefile
+++ b/bin/tau/taud/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/vanityaddr/Makefile b/bin/vanityaddr/Makefile
index 5909809e1..b3e053d58 100644
--- a/bin/vanityaddr/Makefile
+++ b/bin/vanityaddr/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/bin/zkas/Makefile b/bin/zkas/Makefile
index 44ad65c4d..ae4836022 100644
--- a/bin/zkas/Makefile
+++ b/bin/zkas/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/doc/src/dev/contrib/contrib.md b/doc/src/dev/contrib/contrib.md
index fdb7f46b8..51301d7aa 100644
--- a/doc/src/dev/contrib/contrib.md
+++ b/doc/src/dev/contrib/contrib.md
@@ -123,7 +123,7 @@ if there is a version mismatch.
$ sh contrib/dependency_setup.sh
```
-* Ensure that you are using the nightly toolchain and are building for `wasm32-unknown-unknown`.
+* Ensure that you are building for `wasm32-unknown-unknown`.
Check `README.md` for instructions.
* When running a `cargo` command, use the flag `--all-features`.
diff --git a/doc/src/dev/dev.md b/doc/src/dev/dev.md
index 13e81f1fe..fe2e43a7b 100644
--- a/doc/src/dev/dev.md
+++ b/doc/src/dev/dev.md
@@ -41,6 +41,10 @@ exit 0
Inside the darkfi project repo, place this script in `.git/hooks/pre-commit`
and make sure it's executable by running `chmod +x .git/hooks/pre-commit`.
+Code style formatting(rustfmt) requires a nightly rust toolchain. To install nightly toolchain, execute:
+```
+$ rustup toolchain install nightly
+```
## Testing crate features
@@ -101,8 +105,8 @@ binaries from our codebase. A short setup using a Debian system and
```
Inside the container, once attached, we have to install the required
-dependencies. We will have to use `rustup` to get the latest rust
-nightly, and we also have to compile `sqlcipher` on our own.
+dependencies. We will have to use `rustup` to get the latest rust,
+and we also have to compile `sqlcipher` on our own.
```
# apk add rustup git musl-dev make gcc openssl-dev openssl-libs-static tcl-dev zlib-static
@@ -113,9 +117,9 @@ nightly, and we also have to compile `sqlcipher` on our own.
# make -j$(nproc)
# make install
# cd ~
-# rustup-init --default-toolchain nightly -y
+# rustup-init --default-toolchain stable -y
# source ~/.cargo/env
-# rustup target add wasm32-unknown-unknown --toolchain nightly
+# rustup target add wasm32-unknown-unknown --toolchain stable
```
And now we should be able to build a statically linked binary:
@@ -134,7 +138,7 @@ In certain cases, it might also be possible to build natively by
installing the musl toolchain:
```
-$ rustup target add x86_64-unknown-linux-musl --toolchain nightly
+$ rustup target add x86_64-unknown-linux-musl --toolchain stable
## Uncomment RUSTFLAGS in the main Makefile
$ sed -e 's,^#RUSTFLAGS ,RUSTFLAGS ,' -i Makefile
$ make RUST_TARGET=x86_64-unknown-linux-musl darkirc
diff --git a/doc/src/misc/network-troubleshooting.md b/doc/src/misc/network-troubleshooting.md
index 1da404bef..47293f917 100644
--- a/doc/src/misc/network-troubleshooting.md
+++ b/doc/src/misc/network-troubleshooting.md
@@ -199,16 +199,11 @@ interacts within the network. dnet log information is created in
You can ping any node to make sure it's online by using the provided
`ping` tool located at `${DARKFI_REPO}/script/ping`. Select a peer from
your hostlist file. You can now use the `ping` tool by
-running this command (assuming nightly is default):
+running this command:
```
$ cargo run -- tcp+tls://example_peer:26661
```
-If nightly isn't default, use this command:
-
-```
-$ cargo +nightly run -- tcp+tls://example_peer:26661
-```
If the peers are reachable, you'll receive a `Connected!` output.
diff --git a/example/wasm-hello-world/Makefile b/example/wasm-hello-world/Makefile
index 83809cc0f..d4cefc9f5 100644
--- a/example/wasm-hello-world/Makefile
+++ b/example/wasm-hello-world/Makefile
@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# wasm build target
WASM_TARGET = wasm32-unknown-unknown
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 5d56faf9a..292fe499e 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -1,2 +1,2 @@
[toolchain]
-channel = "nightly"
+channel = "stable"
diff --git a/script/evgrd/Makefile b/script/evgrd/Makefile
index 27b228aeb..1f679e23d 100644
--- a/script/evgrd/Makefile
+++ b/script/evgrd/Makefile
@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
BIN = evgrd
diff --git a/script/research/dam/dam-cli/Makefile b/script/research/dam/dam-cli/Makefile
index 7635c6669..521fff826 100644
--- a/script/research/dam/dam-cli/Makefile
+++ b/script/research/dam/dam-cli/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
@@ -24,7 +24,7 @@ $(BIN): $(SRC)
cp -f target/$(RUST_TARGET)/release/$@ $@
fmt:
- $(CARGO) fmt --all
+ $(CARGO) +nightly fmt --all
clippy:
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
diff --git a/script/research/dam/damd/Makefile b/script/research/dam/damd/Makefile
index 7635c6669..521fff826 100644
--- a/script/research/dam/damd/Makefile
+++ b/script/research/dam/damd/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
@@ -24,7 +24,7 @@ $(BIN): $(SRC)
cp -f target/$(RUST_TARGET)/release/$@ $@
fmt:
- $(CARGO) fmt --all
+ $(CARGO) +nightly fmt --all
clippy:
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
diff --git a/script/research/gg/Makefile b/script/research/gg/Makefile
index 7635c6669..521fff826 100644
--- a/script/research/gg/Makefile
+++ b/script/research/gg/Makefile
@@ -4,7 +4,7 @@
PREFIX = $(HOME)/.cargo
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
@@ -24,7 +24,7 @@ $(BIN): $(SRC)
cp -f target/$(RUST_TARGET)/release/$@ $@
fmt:
- $(CARGO) fmt --all
+ $(CARGO) +nightly fmt --all
clippy:
RUSTFLAGS="$(RUSTFLAGS)" $(CARGO) clippy --target=$(RUST_TARGET) \
diff --git a/script/research/rln/rlnv1/Makefile b/script/research/rln/rlnv1/Makefile
index fc8f84610..c487c7f26 100644
--- a/script/research/rln/rlnv1/Makefile
+++ b/script/research/rln/rlnv1/Makefile
@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/script/research/rln/rlnv2/Makefile b/script/research/rln/rlnv2/Makefile
index fc8f84610..c487c7f26 100644
--- a/script/research/rln/rlnv2/Makefile
+++ b/script/research/rln/rlnv2/Makefile
@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/src/contract/dao/Makefile b/src/contract/dao/Makefile
index c33f0f17d..29af4d3bd 100644
--- a/src/contract/dao/Makefile
+++ b/src/contract/dao/Makefile
@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target for system binaries
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/src/contract/deployooor/Makefile b/src/contract/deployooor/Makefile
index 00fe880a2..f7a4bf424 100644
--- a/src/contract/deployooor/Makefile
+++ b/src/contract/deployooor/Makefile
@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target for system binaries
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/src/contract/money/Makefile b/src/contract/money/Makefile
index 5686f1045..3ca939570 100644
--- a/src/contract/money/Makefile
+++ b/src/contract/money/Makefile
@@ -1,7 +1,7 @@
.POSIX:
# Cargo binary
-CARGO = cargo +nightly
+CARGO = cargo
# Compile target for system binaries
RUST_TARGET = $(shell rustc -Vv | grep '^host: ' | cut -d' ' -f2)
diff --git a/src/event_graph/tests.rs b/src/event_graph/tests.rs
index ecf744bd1..7a2dcc0b3 100644
--- a/src/event_graph/tests.rs
+++ b/src/event_graph/tests.rs
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-// cargo +nightly test --release --features=event-graph --lib eventgraph_propagation -- --include-ignored
+// cargo test --release --features=event-graph --lib eventgraph_propagation -- --include-ignored
use std::sync::Arc;
diff --git a/src/lib.rs b/src/lib.rs
index 1105faf37..ef0bf5d51 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,8 +16,6 @@
* along with this program. If not, see .
*/
-#![feature(ip)]
-
pub mod error;
pub use error::{ClientFailed, ClientResult, Error, Result};
diff --git a/src/net/hosts.rs b/src/net/hosts.rs
index 676bd5450..0318ad393 100644
--- a/src/net/hosts.rs
+++ b/src/net/hosts.rs
@@ -23,7 +23,7 @@ use std::{
collections::HashMap,
fmt, fs,
fs::File,
- net::{IpAddr, Ipv6Addr},
+ net::{IpAddr, Ipv4Addr, Ipv6Addr},
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex as SyncMutex, RwLock,
@@ -1177,12 +1177,12 @@ impl Hosts {
// Filter private IP ranges
match url.host().unwrap() {
url::Host::Ipv4(ip) => {
- if !ip.is_global() {
+ if !ip.unstable_is_global() {
return true
}
}
url::Host::Ipv6(ip) => {
- if !ip.is_global() {
+ if !ip.unstable_is_global() {
return true
}
}
@@ -1592,6 +1592,76 @@ impl Hosts {
}
}
+/// We need a convenience method from Rust's unstable feature "ip".
+/// When is stablized we can remove this.
+trait UnstableFeatureIp {
+ fn unstable_is_global(&self) -> bool;
+}
+
+impl UnstableFeatureIp for Ipv4Addr {
+ // Copied from: https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L839
+ #[inline]
+ fn unstable_is_global(&self) -> bool {
+ !(self.octets()[0] == 0 // "This network"
+ || self.is_private()
+ // is_shared https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L875
+ || self.octets()[0] == 100 && (self.octets()[1] & 0b1100_0000 == 0b0100_0000)
+ || self.is_loopback()
+ || self.is_link_local()
+ // addresses reserved for future protocols (`192.0.0.0/24`)
+ // .9 and .10 are documented as globally reachable so they're excluded
+ || (
+ self.octets()[0] == 192 && self.octets()[1] == 0 && self.octets()[2] == 0
+ && self.octets()[3] != 9 && self.octets()[3] != 10
+ )
+ || self.is_documentation()
+ // is_benchmarking https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L902
+ || self.octets()[0] == 198 && (self.octets()[1] & 0xfe) == 18
+ // is_reserved https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L938
+ || self.octets()[0] & 240 == 240 && !self.is_broadcast()
+ || self.is_broadcast())
+ }
+}
+
+impl UnstableFeatureIp for Ipv6Addr {
+ // Copied from: https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L1598
+ #[inline]
+ fn unstable_is_global(&self) -> bool {
+ !(self.is_unspecified()
+ || self.is_loopback()
+ // IPv4-mapped Address (`::ffff:0:0/96`)
+ || matches!(self.segments(), [0, 0, 0, 0, 0, 0xffff, _, _])
+ // IPv4-IPv6 Translat. (`64:ff9b:1::/48`)
+ || matches!(self.segments(), [0x64, 0xff9b, 1, _, _, _, _, _])
+ // Discard-Only Address Block (`100::/64`)
+ || matches!(self.segments(), [0x100, 0, 0, 0, _, _, _, _])
+ // IETF Protocol Assignments (`2001::/23`)
+ || (matches!(self.segments(), [0x2001, b, _, _, _, _, _, _] if b < 0x200)
+ && !(
+ // Port Control Protocol Anycast (`2001:1::1`)
+ u128::from_be_bytes(self.octets()) == 0x2001_0001_0000_0000_0000_0000_0000_0001
+ // Traversal Using Relays around NAT Anycast (`2001:1::2`)
+ || u128::from_be_bytes(self.octets()) == 0x2001_0001_0000_0000_0000_0000_0000_0002
+ // AMT (`2001:3::/32`)
+ || matches!(self.segments(), [0x2001, 3, _, _, _, _, _, _])
+ // AS112-v6 (`2001:4:112::/48`)
+ || matches!(self.segments(), [0x2001, 4, 0x112, _, _, _, _, _])
+ // ORCHIDv2 (`2001:20::/28`)
+ // Drone Remote ID Protocol Entity Tags (DETs) Prefix (`2001:30::/28`)`
+ || matches!(self.segments(), [0x2001, b, _, _, _, _, _, _] if (0x20..=0x3F).contains(&b))
+ ))
+ // 6to4 (`2002::/16`) – it's not explicitly documented as globally reachable,
+ // IANA says N/A.
+ || matches!(self.segments(), [0x2002, _, _, _, _, _, _, _])
+ // is_documentation https://github.com/rust-lang/rust/blob/ea99e81485ff5d82cabba9af5d1c21293737cc16/library/core/src/net/ip_addr.rs#L1754
+ || matches!(self.segments(), [0x2001, 0xdb8, ..] | [0x3fff, 0..=0x0fff, ..])
+ // Segment Routing (SRv6) SIDs (`5f00::/16`)
+ || matches!(self.segments(), [0x5f00, ..])
+ || self.is_unique_local()
+ || self.is_unicast_link_local())
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/src/net/tests.rs b/src/net/tests.rs
index 55302e873..65bc04549 100644
--- a/src/net/tests.rs
+++ b/src/net/tests.rs
@@ -16,7 +16,7 @@
* along with this program. If not, see .
*/
-// cargo +nightly test --release --features=net --lib p2p -- --include-ignored
+// cargo test --release --features=net --lib p2p -- --include-ignored
use std::{collections::HashSet, net::TcpListener, panic, sync::Arc};