mirror of
https://github.com/dndx/phantun.git
synced 2025-09-15 19:54:29 +08:00
perf(fake-tcp) use cached tuples per dispatcher task to avoid RwLock
contentions. Use multi queue Tun. Upgraded tokio to 1.12.0. This makes the entire Phantun forward process completely lock contention free
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
[package]
|
||||
name = "phantun"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2018"
|
||||
authors = ["Datong Sun <dndx@idndx.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/dndx/phantun"
|
||||
readme = "README.md"
|
||||
description = """
|
||||
Turns transforms UDP stream into (fake) TCP streams that can go through
|
||||
Layer 4 firewalls.
|
||||
Transforms UDP stream into (fake) TCP streams that can go through
|
||||
Layer 3 & Layer 4 (NAPT) firewalls/NATs.
|
||||
"""
|
||||
[dependencies]
|
||||
clap = "2.33.3"
|
||||
socket2 = { version = "0.4.2", features = ["all"] }
|
||||
fake-tcp = "0.1.0"
|
||||
tokio-tun = "0.3.15"
|
||||
tokio = { version = "1.11.0", features = ["full"] }
|
||||
fake-tcp = { path = "../fake-tcp" }
|
||||
tokio = { version = "1.12.0", features = ["full"] }
|
||||
log = "0.4"
|
||||
pretty_env_logger = "0.4.0"
|
||||
dndx-fork-tokio-tun = "0.3.16"
|
||||
num_cpus = "1.13.0"
|
||||
|
@@ -1,3 +1,5 @@
|
||||
extern crate dndx_fork_tokio_tun as tokio_tun;
|
||||
|
||||
use clap::{App, Arg};
|
||||
use fake_tcp::packet::MAX_PACKET_LEN;
|
||||
use fake_tcp::{Socket, Stack};
|
||||
@@ -70,10 +72,10 @@ async fn main() {
|
||||
.up() // or set it up manually using `sudo ip link set <tun-name> up`.
|
||||
.address("192.168.200.1".parse().unwrap())
|
||||
.destination("192.168.200.2".parse().unwrap())
|
||||
.try_build()
|
||||
.try_build_mq(num_cpus::get())
|
||||
.unwrap();
|
||||
|
||||
info!("Created TUN device {}", tun.name());
|
||||
info!("Created TUN device {}", tun[0].name());
|
||||
|
||||
let udp_sock = Arc::new(new_udp_reuseport(local_addr));
|
||||
let connections = Arc::new(RwLock::new(HashMap::<SocketAddrV4, Arc<Socket>>::new()));
|
||||
|
@@ -1,3 +1,5 @@
|
||||
extern crate dndx_fork_tokio_tun as tokio_tun;
|
||||
|
||||
use clap::{App, Arg};
|
||||
use fake_tcp::packet::MAX_PACKET_LEN;
|
||||
use fake_tcp::Stack;
|
||||
@@ -53,9 +55,11 @@ async fn main() {
|
||||
.up() // or set it up manually using `sudo ip link set <tun-name> up`.
|
||||
.address("192.168.201.1".parse().unwrap())
|
||||
.destination("192.168.201.2".parse().unwrap())
|
||||
.try_build()
|
||||
.try_build_mq(num_cpus::get())
|
||||
.unwrap();
|
||||
|
||||
info!("Created TUN device {}", tun[0].name());
|
||||
|
||||
//thread::sleep(time::Duration::from_secs(5));
|
||||
let mut stack = Stack::new(tun);
|
||||
stack.listen(local_port);
|
||||
|
Reference in New Issue
Block a user