-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
3,655 additions
and
1,630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[registries.crates-io] | ||
protocol = "sparse" | ||
|
||
[build] | ||
# target = ["x86_64-unknown-linux-musl"] | ||
# target = ["x86_64-unknown-linux-gnu"] | ||
# target = ["aarch64-linux-android"] | ||
# target = ["aarch64-apple-ios"] | ||
# target = ["x86_64-pc-windows-msvc"] | ||
# target = ["x86_64-apple-darwin"] | ||
# target = ["x86_64-unknown-freebsd"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
- package-ecosystem: "cargo" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Push or PR | ||
|
||
on: | ||
[push, pull_request] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build_n_test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: rustfmt | ||
if: ${{ !cancelled() }} | ||
run: cargo fmt --all -- --check | ||
- name: check | ||
if: ${{ !cancelled() }} | ||
run: cargo check --verbose | ||
- name: clippy | ||
if: ${{ !cancelled() }} | ||
run: cargo clippy --all-targets --all-features -- -D warnings | ||
- name: Build | ||
if: ${{ !cancelled() }} | ||
run: | | ||
cargo build --verbose --examples --tests --all-features --features="async tokio/rt-multi-thread" | ||
cargo clean | ||
cargo build --verbose --examples --tests --no-default-features | ||
- name: Abort on error | ||
if: ${{ failure() }} | ||
run: echo "Some of jobs failed" && false | ||
|
||
build_n_test_android: | ||
strategy: | ||
fail-fast: false | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install cargo ndk and rust compiler for android target | ||
if: ${{ !cancelled() }} | ||
run: | | ||
cargo install --locked cargo-ndk | ||
rustup target add x86_64-linux-android | ||
- name: clippy | ||
if: ${{ !cancelled() }} | ||
run: cargo ndk -t x86_64 clippy --all-features --features="async tokio/rt-multi-thread" -- -D warnings | ||
- name: Build | ||
if: ${{ !cancelled() }} | ||
run: | | ||
cargo ndk -t x86_64 rustc --verbose --all-features --features="async tokio/rt-multi-thread" --lib --crate-type=cdylib | ||
- name: Abort on error | ||
if: ${{ failure() }} | ||
run: echo "Android build job failed" && false | ||
|
||
build_n_test_ios: | ||
strategy: | ||
fail-fast: false | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install cargo lipo and rust compiler for ios target | ||
if: ${{ !cancelled() }} | ||
run: | | ||
cargo install --locked cargo-lipo | ||
rustup target add x86_64-apple-ios aarch64-apple-ios | ||
- name: clippy | ||
if: ${{ !cancelled() }} | ||
run: cargo clippy --target x86_64-apple-ios --all-features --features="async tokio/rt-multi-thread" -- -D warnings | ||
- name: Build | ||
if: ${{ !cancelled() }} | ||
run: | | ||
cargo lipo --verbose --all-features --features="async tokio/rt-multi-thread" | ||
- name: Abort on error | ||
if: ${{ failure() }} | ||
run: echo "iOs build job failed" && false | ||
|
||
semver: | ||
name: Check semver | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@stable | ||
- name: Check semver | ||
if: ${{ !cancelled() }} | ||
uses: obi1kenobi/cargo-semver-checks-action@v2 | ||
- name: Abort on error | ||
if: ${{ failure() }} | ||
run: echo "Semver check failed" && false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
.vscode/ | ||
.VSCodeCounter/ | ||
build/ | ||
tmp/ | ||
target/ | ||
**/*.rs.bk | ||
Cargo.lock | ||
wintun.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,83 @@ | ||
[package] | ||
name = "tun" | ||
version = "0.5.5" | ||
edition = "2018" | ||
|
||
authors = ["meh. <[email protected]>"] | ||
version = "0.8.0" | ||
edition = "2021" | ||
authors = ["meh. <[email protected]>", "@ssrlive"] | ||
license = "WTFPL" | ||
|
||
description = "TUN device creation and handling." | ||
repository = "https://github.com/meh/rust-tun" | ||
keywords = ["tun", "network", "tunnel", "bindings"] | ||
|
||
[lib] | ||
crate-type = ["staticlib", "cdylib", "lib"] | ||
|
||
[dependencies] | ||
libc = "0.2" | ||
bytes = { version = "1" } | ||
cfg-if = "1" | ||
futures-core = { version = "0.3", optional = true } | ||
libc = { version = "0.2", features = ["extra_traits"] } | ||
log = "0.4" | ||
thiserror = "1" | ||
tokio = { version = "1", features = [ | ||
"net", | ||
"macros", | ||
"io-util", | ||
], optional = true } | ||
tokio-util = { version = "0.7", features = ["codec"], optional = true } | ||
|
||
[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "ios", target_os = "android"))'.dependencies] | ||
tokio = { version = "1", features = ["net", "macros"], optional = true } | ||
tokio-util = { version = "0.6", features = ["codec"], optional = true } | ||
bytes = { version = "1", optional = true } | ||
byteorder = { version = "1", optional = true } | ||
# This is only for the `ready` macro. | ||
futures-core = { version = "0.3", optional = true } | ||
[target.'cfg(unix)'.dependencies] | ||
nix = { version = "0.29", features = ["ioctl"] } | ||
|
||
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies] | ||
ioctl = { version = "0.6", package = "ioctl-sys" } | ||
[target.'cfg(target_os = "windows")'.dependencies] | ||
futures = { version = "0.3", optional = true } | ||
windows-sys = { version = "0.59", features = [ | ||
"Win32_Foundation", | ||
"Win32_Security", | ||
"Win32_Security_WinTrust", | ||
"Win32_Security_Cryptography", | ||
"Win32_System_Threading", | ||
"Win32_UI_WindowsAndMessaging", | ||
"Win32_System_LibraryLoader", | ||
] } | ||
wintun-bindings = { version = "^0.7.7", features = [ | ||
"panic_on_unsent_packets", | ||
"verify_binary_signature", | ||
"async", | ||
] } | ||
|
||
[target.'cfg(any(target_os = "macos", target_os = "freebsd"))'.dependencies] | ||
ipnet = "2" | ||
|
||
[dev-dependencies] | ||
packet = "0.1" | ||
ctrlc2 = { version = "3", features = ["tokio", "termination"] } | ||
env_logger = "0.11" | ||
futures = "0.3" | ||
packet = "0.1" | ||
serde_json = "1" | ||
tokio = { version = "1", features = ["rt-multi-thread"] } | ||
|
||
[features] | ||
async = ["tokio", "tokio-util", "bytes", "byteorder", "futures-core"] | ||
default = [] | ||
# default = ["async"] | ||
async = [ | ||
"tokio", | ||
"futures-core", | ||
"futures", | ||
"tokio-util", | ||
"wintun-bindings/async", | ||
] | ||
|
||
[package.metadata.docs.rs] | ||
features = ["async"] | ||
|
||
[[example]] | ||
name = "read-async" | ||
required-features = [ "async", "tokio/rt-multi-thread" ] | ||
required-features = ["async"] | ||
|
||
[[example]] | ||
name = "read-async-codec" | ||
required-features = [ "async", "tokio/rt-multi-thread" ] | ||
required-features = ["async"] | ||
|
||
[[example]] | ||
name = "ping-tun" | ||
required-features = [ "async", "tokio/rt-multi-thread" ] | ||
required-features = ["async"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.