Skip to content

Commit 8d85c96

Browse files
committed
Remove nightly things
1 parent 502759c commit 8d85c96

File tree

6 files changed

+46
-17
lines changed

6 files changed

+46
-17
lines changed

Makefile.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ dependencies = [
309309
################################################################################
310310

311311
[tasks.linux]
312-
toolchain = "nightly"
312+
#toolchain = "nightly"
313313
command = "cargo"
314314
# CS:S binaries are now at 2.29 according to this:
315315
# objdump -T bin/*.so | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu
@@ -320,7 +320,7 @@ args = ["zigbuild", "--release", "--target", "${TARGETARCH}-unknown-linux-gnu.2.
320320
dependencies = ["windows"]
321321

322322
[tasks.windows]
323-
toolchain = "nightly"
323+
#toolchain = "nightly"
324324
command = "cargo"
325325
#env = { "CARGO_LOG" = "cargo::core::compiler::fingerprint=info" }
326326
args = ["build", "--release", "--target", "${TARGETARCH}-pc-windows-msvc"]
@@ -336,12 +336,12 @@ args = ["build", "--release", "--target", "${TARGETARCH}-pc-windows-msvc"]
336336
################################################################################
337337

338338
[tasks.rustup-linux]
339-
toolchain = "nightly"
339+
#toolchain = "nightly"
340340
command = "rustup"
341341
args = ["target", "add", "${TARGETARCH}-unknown-linux-gnu"]
342342

343343
[tasks.rustup-windows]
344-
toolchain = "nightly"
344+
#toolchain = "nightly"
345345
command = "rustup"
346346
args = ["target", "add", "${TARGETARCH}-pc-windows-msvc"]
347347

rust-toolchain.toml

Lines changed: 0 additions & 6 deletions
This file was deleted.

srcwrhttp/src/ip_addr.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
// Copyright (c) The Rust Project Contributors/Developers
3+
4+
// Snipped out of https://github.com/rust-lang/rust/blob/master/library/core/src/net/ip_addr.rs
5+
6+
// TODO: Wait for the `ip` feature to stablize: https://github.com/rust-lang/rust/issues/27709
7+
8+
use std::net::Ipv4Addr;
9+
10+
pub const fn is_shared(addr: &Ipv4Addr) -> bool {
11+
addr.octets()[0] == 100 && (addr.octets()[1] & 0b1100_0000 == 0b0100_0000)
12+
}
13+
14+
pub const fn is_benchmarking(addr: &Ipv4Addr) -> bool {
15+
addr.octets()[0] == 198 && (addr.octets()[1] & 0xfe) == 18
16+
}
17+
18+
pub const fn is_reserved(addr: &Ipv4Addr) -> bool {
19+
addr.octets()[0] & 240 == 240 && !addr.is_broadcast()
20+
}
21+
22+
pub const fn is_global(addr: &Ipv4Addr) -> bool {
23+
!(addr.octets()[0] == 0 // "This network"
24+
|| addr.is_private()
25+
|| is_shared(addr)
26+
|| addr.is_loopback()
27+
|| addr.is_link_local()
28+
// addresses reserved for future protocols (`192.0.0.0/24`)
29+
// .9 and .10 are documented as globally reachable so they're excluded
30+
|| (
31+
addr.octets()[0] == 192 && addr.octets()[1] == 0 && addr.octets()[2] == 0
32+
&& addr.octets()[3] != 9 && addr.octets()[3] != 10
33+
)
34+
|| addr.is_documentation()
35+
|| is_benchmarking(addr)
36+
|| is_reserved(addr)
37+
|| addr.is_broadcast())
38+
}

srcwrhttp/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
// This file is part of srcwrtimer (https://github.com/srcwr/srcwrtimer/)
44

55
#![allow(non_snake_case)]
6-
#![feature(ip)]
7-
#![feature(let_chains)]
8-
// TODO: >the feature `option_get_or_insert_default` has been stable since 1.83.0-nightly and no longer requires an attribute to enable
9-
#![allow(stable_features)]
10-
#![feature(option_get_or_insert_default)]
116

127
mod http_thread;
8+
mod ip_addr;
139
mod natives_http;
1410
mod reqwest_text_with_charset;
1511
mod server_ip;

srcwrhttp/src/server_ip.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use std::net::IpAddr;
1515
use std::net::Ipv4Addr;
1616
use std::str::FromStr;
1717

18+
use crate::ip_addr;
19+
1820
unsafe extern "C" {
1921
pub fn SteamWorks_GetPublicIP() -> u32;
2022
}
@@ -34,7 +36,7 @@ pub fn commandline_bindip() -> Option<IpAddr> {
3436
for a in std::env::args() {
3537
if next_is_ip {
3638
let ip = Ipv4Addr::from_str(&a).ok()?;
37-
return if ip.is_global() { Some(ip.into()) } else { None };
39+
return if ip_addr::is_global(&ip) { Some(ip.into()) } else { None };
3840
}
3941
next_is_ip = a == "-ip" || a == "+ip";
4042
}

srcwrjson/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// This file is part of srcwrtimer (https://github.com/srcwr/srcwrtimer/)
44

55
#![allow(non_snake_case)]
6-
#![feature(let_chains)]
76

87
mod natives_json;
98

0 commit comments

Comments
 (0)