mirror of
https://github.com/dndx/phantun.git
synced 2025-04-04 11:09:29 +08:00
Some adaption and alligned to the source code from dndx
This commit is contained in:
parent
422a465d6e
commit
1fea277103
8
.github/workflows/docker.yml
vendored
8
.github/workflows/docker.yml
vendored
@ -11,18 +11,18 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup QEMU
|
- name: Setup QEMU
|
||||||
uses: docker/setup-qemu-action@v2
|
uses: docker/setup-qemu-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
|
||||||
- name: Setup Docker Buildx
|
- name: Setup Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build Docker Image
|
- name: Build Docker Image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: docker/Dockerfile
|
file: docker/Dockerfile
|
||||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -31,7 +31,7 @@ jobs:
|
|||||||
- mipsel-unknown-linux-musl
|
- mipsel-unknown-linux-musl
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
|
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
members = [
|
members = [
|
||||||
"fake-tcp",
|
"fake-tcp",
|
||||||
"phantun",
|
"phantun",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fake-tcp"
|
name = "fake-tcp"
|
||||||
version = "0.5.0"
|
version = "0.5.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Datong Sun <dndx@idndx.com>"]
|
authors = ["Datong Sun <dndx@idndx.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
@ -16,10 +16,10 @@ benchmark = []
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytes = "1.4.0"
|
bytes = "1.4.0"
|
||||||
pnet = "0.33.0"
|
pnet = "0.34.0"
|
||||||
tokio = { version = "1.28.0", features = ["full"] }
|
tokio = { version = "1.28.0", features = ["full"] }
|
||||||
rand = { version = "0.8.5", features = ["small_rng"] }
|
rand = { version = "0.8.5", features = ["small_rng"] }
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
internet-checksum = "0.2.1"
|
internet-checksum = "0.2.1"
|
||||||
tokio-tun = "0.7"
|
tokio-tun = "0.9.1"
|
||||||
flume = "0.10.14"
|
flume ="0.11.0"
|
||||||
|
@ -146,7 +146,7 @@ impl Socket {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_tcp_packet(&self, flags: u16, payload: Option<&[u8]>) -> Bytes {
|
fn build_tcp_packet(&self, flags: u8, payload: Option<&[u8]>) -> Bytes {
|
||||||
let ack = self.ack.load(Ordering::Relaxed);
|
let ack = self.ack.load(Ordering::Relaxed);
|
||||||
self.last_ack.store(ack, Ordering::Relaxed);
|
self.last_ack.store(ack, Ordering::Relaxed);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ pub fn build_tcp_packet(
|
|||||||
remote_addr: SocketAddr,
|
remote_addr: SocketAddr,
|
||||||
seq: u32,
|
seq: u32,
|
||||||
ack: u32,
|
ack: u32,
|
||||||
flags: u16,
|
flags: u8,
|
||||||
payload: Option<&[u8]>,
|
payload: Option<&[u8]>,
|
||||||
) -> Bytes {
|
) -> Bytes {
|
||||||
let ip_header_len = match local_addr {
|
let ip_header_len = match local_addr {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "phantun"
|
name = "phantun"
|
||||||
version = "0.6.0"
|
version = "0.6.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Datong Sun <dndx@idndx.com>"]
|
authors = ["Datong Sun <dndx@idndx.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
@ -13,13 +13,13 @@ Layer 3 & Layer 4 (NAPT) firewalls/NATs.
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.2.5", features = ["cargo"] }
|
clap = { version = "4.2.5", features = ["cargo"] }
|
||||||
socket2 = { version = "0.5.2", features = ["all"] }
|
socket2 = { version = "0.5.2", features = ["all"] }
|
||||||
fake-tcp = { path = "../fake-tcp", version = "0.5" }
|
fake-tcp = { path = "../fake-tcp", version = "0.5.5" }
|
||||||
tokio = { version = "1.28.0", features = ["full"] }
|
tokio = { version = "1.28.0", features = ["full"] }
|
||||||
tokio-util = "0.7.8"
|
tokio-util = "0.7.8"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
chrono = "0.4.24"
|
chrono = "0.4.24"
|
||||||
tokio-tun = "0.7"
|
tokio-tun = "0.9.1"
|
||||||
num_cpus = "1.15.0"
|
num_cpus = "1.15.0"
|
||||||
neli = "0.6.4"
|
neli = "0.6.4"
|
||||||
nix = "0.26.2"
|
nix = { version = "0.27.1", features = ["net"] }
|
||||||
|
@ -96,7 +96,7 @@ async fn main() -> io::Result<()> {
|
|||||||
.required(false)
|
.required(false)
|
||||||
.help("Only use IPv4 address when connecting to remote")
|
.help("Only use IPv4 address when connecting to remote")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.conflicts_with_all(&["tun_local6", "tun_peer6"]),
|
.conflicts_with_all(["tun_local6", "tun_peer6"]),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("tun_local6")
|
Arg::new("tun_local6")
|
||||||
|
@ -96,7 +96,7 @@ async fn main() -> io::Result<()> {
|
|||||||
.required(false)
|
.required(false)
|
||||||
.help("Do not assign IPv6 addresses to Tun interface")
|
.help("Do not assign IPv6 addresses to Tun interface")
|
||||||
.action(ArgAction::SetTrue)
|
.action(ArgAction::SetTrue)
|
||||||
.conflicts_with_all(&["tun_local6", "tun_peer6"]),
|
.conflicts_with_all(["tun_local6", "tun_peer6"]),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new("tun_local6")
|
Arg::new("tun_local6")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user