chore(cargo): bump to Rust edition 2024 (#223)
Some checks are pending
Docker image build / build (push) Waiting to run
Rust / build (push) Waiting to run

* chore(cargo): bump to Rust edition 2024 and move shared dependency into
workspace `Cargo.toml`

* style(phantun): use Rust 2024 `&&` combination for `if let`
This commit is contained in:
Datong Sun 2025-08-23 00:20:07 +08:00 committed by GitHub
parent 2a37a2fc92
commit 66de44e32f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 14 deletions

View File

@ -1,8 +1,11 @@
[workspace] [workspace]
resolver = "3"
resolver = "2"
members = [ members = [
"fake-tcp", "fake-tcp",
"phantun", "phantun",
] ]
[workspace.dependencies]
tokio = { version = "1", features = ["full"] }
log = "0"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "fake-tcp" name = "fake-tcp"
version = "0.6.0" version = "0.6.0"
edition = "2021" edition = "2024"
authors = ["Datong Sun <dndx@idndx.com>"] authors = ["Datong Sun <dndx@idndx.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
repository = "https://github.com/dndx/phantun" repository = "https://github.com/dndx/phantun"
@ -17,9 +17,9 @@ benchmark = []
[dependencies] [dependencies]
bytes = "1" bytes = "1"
pnet = "0" pnet = "0"
tokio = { version = "1", features = ["full"] }
rand = { version = "0", features = ["small_rng"] } rand = { version = "0", features = ["small_rng"] }
log = "0"
internet-checksum = "0" internet-checksum = "0"
tokio-tun = "0" tokio-tun = "0"
flume = "0" flume = "0"
tokio = { workspace = true }
log = { workspace = true }

View File

@ -1,7 +1,7 @@
[package] [package]
name = "phantun" name = "phantun"
version = "0.7.0" version = "0.7.0"
edition = "2021" edition = "2024"
authors = ["Datong Sun <dndx@idndx.com>"] authors = ["Datong Sun <dndx@idndx.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
repository = "https://github.com/dndx/phantun" repository = "https://github.com/dndx/phantun"
@ -14,11 +14,11 @@ Layer 3 & Layer 4 (NAPT) firewalls/NATs.
clap = { version = "4", features = ["cargo"] } clap = { version = "4", features = ["cargo"] }
socket2 = { version = "0", features = ["all"] } socket2 = { version = "0", features = ["all"] }
fake-tcp = { path = "../fake-tcp", version = "0" } fake-tcp = { path = "../fake-tcp", version = "0" }
tokio = { version = "1", features = ["full"] }
tokio-util = "0" tokio-util = "0"
log = "0"
pretty_env_logger = "0" pretty_env_logger = "0"
tokio-tun = "0" tokio-tun = "0"
num_cpus = "1" num_cpus = "1"
neli = "0" neli = "0"
nix = { version = "0", features = ["net"] } nix = { version = "0", features = ["net"] }
tokio = { workspace = true }
log = { workspace = true }

View File

@ -245,13 +245,12 @@ async fn main() -> io::Result<()> {
res = sock.recv(&mut buf_tcp) => { res = sock.recv(&mut buf_tcp) => {
match res { match res {
Some(size) => { Some(size) => {
if size > 0 { if size > 0
if let Err(e) = udp_sock.send(&buf_tcp[..size]).await { && let Err(e) = udp_sock.send(&buf_tcp[..size]).await {
error!("Unable to send UDP packet to {}: {}, closing connection", e, addr); error!("Unable to send UDP packet to {}: {}, closing connection", e, addr);
quit.cancel(); quit.cancel();
return; return;
} }
}
}, },
None => { None => {
debug!("removed fake TCP socket from connections table"); debug!("removed fake TCP socket from connections table");

View File

@ -219,13 +219,12 @@ async fn main() -> io::Result<()> {
res = sock.recv(&mut buf_tcp) => { res = sock.recv(&mut buf_tcp) => {
match res { match res {
Some(size) => { Some(size) => {
if size > 0 { if size > 0
if let Err(e) = udp_sock.send(&buf_tcp[..size]).await { && let Err(e) = udp_sock.send(&buf_tcp[..size]).await {
error!("Unable to send UDP packet to {}: {}, closing connection", e, remote_addr); error!("Unable to send UDP packet to {}: {}, closing connection", e, remote_addr);
quit.cancel(); quit.cancel();
return; return;
} }
}
}, },
None => { None => {
quit.cancel(); quit.cancel();