diff --git a/.github/workflows/build-msrv.yml b/.github/workflows/build-msrv.yml index c0e4808c7cf4..db88aa874c64 100644 --- a/.github/workflows/build-msrv.yml +++ b/.github/workflows/build-msrv.yml @@ -11,7 +11,7 @@ env: RUST_LOG: "trace" jobs: - buid-test-check: + shadowsocks-rust: strategy: matrix: platform: @@ -28,12 +28,58 @@ jobs: - name: Install Rust run: | rustup set profile minimal - rustup toolchain install 1.75 - rustup default 1.75 - rustup override set 1.75 + rustup toolchain install 1.80 + rustup default 1.80 + rustup override set 1.80 - name: Build with All Features Enabled (Unix) if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }} run: cargo build --verbose --features "full-extra local-flow-stat utility-url-outline" - name: Build with All Features Enabled (Windows) if: ${{ runner.os == 'Windows' }} run: cargo build --verbose --features "full-extra local-flow-stat utility-url-outline winservice" + + shadowsocks-service: + strategy: + matrix: + platform: + - ubuntu-latest + - windows-latest + - macos-latest + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - if: ${{ runner.os == 'Windows' }} + uses: ilammy/setup-nasm@v1 + - name: Install Rust + run: | + rustup set profile minimal + rustup toolchain install 1.80 + rustup default 1.80 + rustup override set 1.80 + - name: Build with All Features Enabled + run: cargo build --manifest-path crates/shadowsocks-service/Cargo.toml --verbose --features "full dns-over-tls dns-over-https dns-over-h3 local-dns local-flow-stat local-http-rustls local-tun local-fake-dns local-online-config stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect" + + shadowsocks: + strategy: + matrix: + platform: + - ubuntu-latest + - windows-latest + - macos-latest + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - if: ${{ runner.os == 'Windows' }} + uses: ilammy/setup-nasm@v1 + - name: Install Rust + run: | + rustup set profile minimal + rustup toolchain install 1.75 + rustup default 1.75 + rustup override set 1.75 + - name: Build with All Features Enabled + run: cargo build --manifest-path crates/shadowsocks/Cargo.toml --verbose --features "stream-cipher aead-cipher-extra aead-cipher-2022 aead-cipher-2022-extra security-replay-attack-detect" diff --git a/Cargo.lock b/Cargo.lock index a791a10945c0..19323f51600d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3370,9 +3370,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smoltcp" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a1a996951e50b5971a2c8c0fa05a381480d70a933064245c4a223ddc87ccc97" +checksum = "dad095989c1533c1c266d9b1e8d70a1329dd3723c3edac6d03bbd67e7bf6f4bb" dependencies = [ "bitflags 1.3.2", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index d353f2ade57b..6877369354bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/shadowsocks-rust" keywords = ["shadowsocks", "proxy", "socks", "socks5", "firewall"] license = "MIT" edition = "2021" -rust-version = "1.75" +rust-version = "1.80" [badges] maintenance = { status = "passively-maintained" } diff --git a/crates/shadowsocks-service/Cargo.toml b/crates/shadowsocks-service/Cargo.toml index 9c08924e5a00..714521441e05 100644 --- a/crates/shadowsocks-service/Cargo.toml +++ b/crates/shadowsocks-service/Cargo.toml @@ -9,7 +9,7 @@ documentation = "https://docs.rs/shadowsocks-service" keywords = ["shadowsocks", "proxy", "socks", "socks5", "firewall"] license = "MIT" edition = "2021" -rust-version = "1.75" +rust-version = "1.80" [badges] maintenance = { status = "passively-maintained" } @@ -199,7 +199,7 @@ tun2 = { version = "4.0", optional = true, default-features = false, features = "async", ] } etherparse = { version = "0.16", optional = true } -smoltcp = { version = "0.11", optional = true, default-features = false, features = [ +smoltcp = { version = "0.12", optional = true, default-features = false, features = [ "std", "log", "medium-ip", diff --git a/crates/shadowsocks-service/src/local/tun/ip_packet.rs b/crates/shadowsocks-service/src/local/tun/ip_packet.rs index 3f9fabfd0a12..1ec076f1265e 100644 --- a/crates/shadowsocks-service/src/local/tun/ip_packet.rs +++ b/crates/shadowsocks-service/src/local/tun/ip_packet.rs @@ -1,6 +1,6 @@ //! IP packet encapsulation -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; +use std::net::IpAddr; use smoltcp::wire::{IpProtocol, IpVersion, Ipv4Packet, Ipv6Packet}; @@ -21,15 +21,15 @@ impl + Copy> IpPacket { pub fn src_addr(&self) -> IpAddr { match *self { - IpPacket::Ipv4(ref packet) => IpAddr::from(Ipv4Addr::from(packet.src_addr())), - IpPacket::Ipv6(ref packet) => IpAddr::from(Ipv6Addr::from(packet.src_addr())), + IpPacket::Ipv4(ref packet) => IpAddr::from(packet.src_addr()), + IpPacket::Ipv6(ref packet) => IpAddr::from(packet.src_addr()), } } pub fn dst_addr(&self) -> IpAddr { match *self { - IpPacket::Ipv4(ref packet) => IpAddr::from(Ipv4Addr::from(packet.dst_addr())), - IpPacket::Ipv6(ref packet) => IpAddr::from(Ipv6Addr::from(packet.dst_addr())), + IpPacket::Ipv4(ref packet) => IpAddr::from(packet.dst_addr()), + IpPacket::Ipv6(ref packet) => IpAddr::from(packet.dst_addr()), } } diff --git a/crates/shadowsocks-service/src/local/tun/tcp.rs b/crates/shadowsocks-service/src/local/tun/tcp.rs index b5b22d9f3ba1..4042a3d2184d 100644 --- a/crates/shadowsocks-service/src/local/tun/tcp.rs +++ b/crates/shadowsocks-service/src/local/tun/tcp.rs @@ -17,7 +17,7 @@ use std::{ use log::{debug, error, trace}; use shadowsocks::{net::TcpSocketOpts, relay::socks5::Address}; use smoltcp::{ - iface::{Config as InterfaceConfig, Interface, SocketHandle, SocketSet}, + iface::{Config as InterfaceConfig, Interface, PollResult, SocketHandle, SocketSet}, phy::{DeviceCapabilities, Medium}, socket::tcp::{Socket as TcpSocket, SocketBuffer as TcpSocketBuffer, State as TcpState}, storage::RingBuffer, @@ -324,9 +324,7 @@ impl TcpTun { } let before_poll = SmolInstant::now(); - let updated_sockets = iface.poll(before_poll, device, &mut socket_set); - - if updated_sockets { + if let PollResult::SocketStateChanged = iface.poll(before_poll, device, &mut socket_set) { trace!("VirtDevice::poll costed {}", SmolInstant::now() - before_poll); } @@ -357,7 +355,10 @@ impl TcpTun { } // SHUT_WR - if matches!(control.send_state, TcpSocketState::Close) && socket.send_queue() == 0 && control.send_buffer.is_empty() { + if matches!(control.send_state, TcpSocketState::Close) + && socket.send_queue() == 0 + && control.send_buffer.is_empty() + { trace!("closing TCP Write Half, {:?}", socket.state()); // Close the socket. Set to FIN state diff --git a/crates/shadowsocks-service/src/local/tun/virt_device.rs b/crates/shadowsocks-service/src/local/tun/virt_device.rs index f8e97e73409e..5bcb46d6c440 100644 --- a/crates/shadowsocks-service/src/local/tun/virt_device.rs +++ b/crates/shadowsocks-service/src/local/tun/virt_device.rs @@ -72,7 +72,7 @@ impl Device for VirtTunDevice { } fn transmit(&mut self, _timestamp: Instant) -> Option> { - return Some(VirtTxToken(self)); + Some(VirtTxToken(self)) } fn capabilities(&self) -> DeviceCapabilities { @@ -86,17 +86,17 @@ pub struct VirtRxToken<'a> { } impl phy::RxToken for VirtRxToken<'_> { - fn consume(mut self, f: F) -> R + fn consume(self, f: F) -> R where - F: FnOnce(&mut [u8]) -> R, + F: FnOnce(&[u8]) -> R, { - f(&mut self.buffer[..]) + f(&self.buffer) } } pub struct VirtTxToken<'a>(&'a mut VirtTunDevice); -impl<'a> phy::TxToken for VirtTxToken<'a> { +impl phy::TxToken for VirtTxToken<'_> { fn consume(self, len: usize, f: F) -> R where F: FnOnce(&mut [u8]) -> R,