Skip to content

Commit 0550eb0

Browse files
committed
Merge branch 'master' into master
2 parents 299520b + 8a6b0d3 commit 0550eb0

File tree

30 files changed

+308
-250
lines changed

30 files changed

+308
-250
lines changed

.cargo/config.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
protocol = "sparse"
33

44
[build]
5+
# target = ["aarch64-apple-tvos"]
56
# target = ["x86_64-unknown-linux-musl"]
67
# target = ["x86_64-unknown-linux-gnu"]
7-
# target = ["aarch64-linux-android"]
8+
# target = ["aarch64-linux-android"] # arm64-v8a
9+
# target = ["armv7-linux-androideabi"] # armeabi-v7a
10+
# target = ["i686-linux-android"] # x86
11+
# target = ["x86_64-linux-android"] # x86_64
812
# target = ["aarch64-apple-ios"]
913
# target = ["x86_64-pc-windows-msvc"]
1014
# target = ["x86_64-apple-darwin"]

.github/workflows/freebsd.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ jobs:
3636
ARGS="$ARGS --features nightly"
3737
fi
3838
39+
rustup show
40+
3941
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} fmt --all -- --check
4042
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} clippy --all-features -- -D warnings
4143
RUST_BACKTRACE=1 cargo +${{ matrix.toolchain }} build --all-features

.github/workflows/rust.yml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Push or PR
22

33
on:
4-
[push, pull_request]
4+
[push, pull_request, workflow_dispatch]
55

66
env:
77
CARGO_TERM_COLOR: always
@@ -17,6 +17,7 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v4
20+
- uses: dtolnay/rust-toolchain@stable
2021
- name: rustfmt
2122
if: ${{ !cancelled() }}
2223
run: cargo fmt --all -- --check
@@ -43,6 +44,7 @@ jobs:
4344

4445
steps:
4546
- uses: actions/checkout@v4
47+
- uses: dtolnay/rust-toolchain@stable
4648
- name: Install cargo ndk and rust compiler for android target
4749
if: ${{ !cancelled() }}
4850
run: |
@@ -66,6 +68,7 @@ jobs:
6668

6769
steps:
6870
- uses: actions/checkout@v4
71+
- uses: dtolnay/rust-toolchain@stable
6972
- name: Install cargo lipo and rust compiler for ios target
7073
if: ${{ !cancelled() }}
7174
run: |
@@ -82,6 +85,29 @@ jobs:
8285
if: ${{ failure() }}
8386
run: echo "iOS build job failed" && false
8487

88+
build_n_test_tvos:
89+
strategy:
90+
matrix:
91+
target: [aarch64-apple-tvos, aarch64-apple-tvos-sim, x86_64-apple-tvos]
92+
fail-fast: false
93+
runs-on: macos-latest
94+
95+
steps:
96+
- uses: actions/checkout@v4
97+
- uses: dtolnay/rust-toolchain@nightly
98+
with:
99+
components: clippy, rust-src
100+
- name: clippy
101+
if: ${{ !cancelled() }}
102+
run: cargo +nightly clippy -Zbuild-std --target ${{matrix.target}} --all-features --features="async tokio/rt-multi-thread" -- -D warnings
103+
- name: Build
104+
if: ${{ !cancelled() }}
105+
run: |
106+
cargo +nightly build -Zbuild-std --verbose --target ${{matrix.target}} --all-features --features="async tokio/rt-multi-thread"
107+
- name: Abort on error
108+
if: ${{ failure() }}
109+
run: echo "tvOS build job failed" && false
110+
85111
build_n_test_openharmony:
86112
strategy:
87113
matrix:
@@ -91,10 +117,10 @@ jobs:
91117

92118
steps:
93119
- uses: actions/checkout@v4
94-
- uses: openharmony-rs/setup-ohos-sdk@v0.2
120+
- uses: openharmony-rs/setup-ohos-sdk@v0.2.1
95121
id: setup-ohos
96122
with:
97-
version: "5.0"
123+
version: "5.0.1"
98124
- name: Install ohrs and rust compiler for ohos target
99125
if: ${{ !cancelled() }}
100126
run: |

Cargo.toml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
[package]
22
name = "tun"
3-
version = "0.8.0"
4-
edition = "2021"
3+
version = "0.7.20"
4+
edition = "2024"
55
authors = ["meh. <meh@schizofreni.co>", "@ssrlive"]
66
license = "WTFPL"
77
description = "TUN device creation and handling."
88
repository = "https://github.com/meh/rust-tun"
99
keywords = ["tun", "network", "tunnel", "bindings"]
10-
rust-version = "1.77"
10+
# rust-version = "1.85"
1111

1212
[package.metadata.docs.rs]
1313
all-features = true
1414

1515
[lib]
16-
crate-type = ["staticlib", "cdylib", "lib"]
16+
crate-type = ["staticlib", "lib"]
1717

1818
[features]
19-
default = []
2019
# default = ["async"]
2120
async = [
2221
"tokio",
@@ -40,16 +39,8 @@ tokio = { version = "1", features = [
4039
], optional = true }
4140
tokio-util = { version = "0.7", features = ["codec"], optional = true }
4241

43-
[dev-dependencies]
44-
ctrlc2 = { version = "3", features = ["tokio", "termination"] }
45-
env_logger = "0.11"
46-
futures = "0.3"
47-
packet = "0.1"
48-
serde_json = "1"
49-
tokio = { version = "1", features = ["rt-multi-thread"] }
50-
51-
[target.'cfg(unix)'.dependencies]
52-
nix = { version = "0.29", features = ["ioctl"] }
42+
[target.'cfg(any(target_os = "macos", target_os = "freebsd"))'.dependencies]
43+
ipnet = "2"
5344

5445
[target.'cfg(target_os = "windows")'.dependencies]
5546
futures = { version = "0.3", optional = true }
@@ -66,10 +57,24 @@ wintun-bindings = { version = "^0.7.7", features = [
6657
"panic_on_unsent_packets",
6758
"verify_binary_signature",
6859
"async",
60+
"enable_inner_logging",
61+
"winreg",
6962
] }
7063

71-
[target.'cfg(any(target_os = "macos", target_os = "freebsd"))'.dependencies]
72-
ipnet = "2"
64+
[target.'cfg(unix)'.dependencies]
65+
nix = { version = "0.30", features = ["ioctl"] }
66+
67+
[dev-dependencies]
68+
ctrlc2 = { version = "3", features = ["tokio", "termination"] }
69+
env_logger = "0.11"
70+
futures = "0.3"
71+
packet = "0.1"
72+
serde_json = "1"
73+
tokio = { version = "1", features = ["rt-multi-thread"] }
74+
75+
[target.'cfg(unix)'.dev-dependencies]
76+
futures = "0.3"
77+
nix = { version = "0.30", features = ["ioctl"] }
7378

7479
[[example]]
7580
name = "read-async"

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Platforms
6464
- [x] FreeBSD
6565
- [x] Android
6666
- [x] iOS
67+
- [x] tvOS
6768
- [x] OpenHarmony
6869

6970

@@ -154,10 +155,6 @@ async fn setup(fd: i32) {
154155
rt.block_on(async {
155156
let mut cfg = tun::Configuration::default();
156157
cfg.raw_fd(fd);
157-
#[cfg(target_os = "ios")]
158-
cfg.platform_config(|p_cfg| {
159-
p_cfg.packet_information(true);
160-
});
161158
let mut tun = tun::create_as_async(&cfg).unwrap();
162159
let mut framed = tun.into_framed();
163160
while let Some(packet) = framed.next().await {

examples/dev-config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
// 0. You just DO WHAT THE FUCK YOU WANT TO.
1414

15-
use packet::{builder::Builder, icmp, ip, Packet};
15+
use packet::{Packet, builder::Builder, icmp, ip};
1616
use std::io::{Read, Write};
1717
use std::{net::Ipv4Addr, sync::mpsc::Receiver};
1818
use tun::{AbstractDevice, BoxError};

examples/ping-tun.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// 0. You just DO WHAT THE FUCK YOU WANT TO.
1414

1515
use futures::{SinkExt, StreamExt};
16-
use packet::{builder::Builder, icmp, ip, Packet};
16+
use packet::{Packet, builder::Builder, icmp, ip};
1717
use tokio::sync::mpsc::Receiver;
1818
use tun::{self, BoxError, Configuration};
1919

examples/read-async-codec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use bytes::BytesMut;
1616
use futures::StreamExt;
17-
use packet::{ip::Packet, Error};
17+
use packet::{Error, ip::Packet};
1818
use tokio::sync::mpsc::Receiver;
1919
use tokio_util::codec::{Decoder, FramedRead};
2020
use tun::BoxError;

examples/split.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
// 0. You just DO WHAT THE FUCK YOU WANT TO.
1414

15-
use packet::{builder::Builder, icmp, ip, Packet};
15+
use packet::{Packet, builder::Builder, icmp, ip};
1616
use std::io::{Read, Write};
1717
use std::sync::mpsc::Receiver;
1818
use tun::BoxError;
@@ -56,8 +56,7 @@ fn main_entry(quit: Receiver<()>) -> Result<(), BoxError> {
5656
loop {
5757
let size = reader.read(&mut buf)?;
5858
let pkt = &buf[..size];
59-
use std::io::{Error, ErrorKind::Other};
60-
tx.send(pkt.to_vec()).map_err(|e| Error::new(Other, e))?;
59+
tx.send(pkt.to_vec()).map_err(std::io::Error::other)?;
6160
}
6261
#[allow(unreachable_code)]
6362
Ok::<(), std::io::Error>(())

examples/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//
1313
// 0. You just DO WHAT THE FUCK YOU WANT TO.
1414

15-
use packet::{builder::Builder, icmp, ip, Packet};
15+
use packet::{Packet, builder::Builder, icmp, ip};
1616
use std::io::{Read, Write};
1717
use std::sync::mpsc::Receiver;
1818
use tun::BoxError;

0 commit comments

Comments
 (0)