mirror of
https://github.com/dndx/phantun.git
synced 2025-09-16 04:04:29 +08:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b3c781cdc5 | ||
|
d5e30c113f | ||
|
e2a9194f6f | ||
|
d0eaefe5d0 | ||
|
299646a54f | ||
|
8b28cdc6c2 | ||
|
a8ad203754 | ||
|
33e510e7ba | ||
|
521a3f1a01 |
22
README.md
22
README.md
@@ -31,16 +31,16 @@ Table of Contents
|
||||
|
||||
# Latest release
|
||||
|
||||
[v0.2.2](https://github.com/dndx/phantun/releases/tag/v0.2.2)
|
||||
[v0.2.3](https://github.com/dndx/phantun/releases/tag/v0.2.3)
|
||||
|
||||
# Overview
|
||||
|
||||
Phanton is a project that obfuscated UDP packets into TCP connections. It aims to
|
||||
Phantun is a project that obfuscated UDP packets into TCP connections. It aims to
|
||||
achieve maximum performance with minimum processing and encapsulation overhead.
|
||||
|
||||
It is commonly used in environments where UDP is blocked/throttled but TCP is allowed through.
|
||||
|
||||
Phanton simply converts a stream of UDP packets into obfuscated TCP stream packets. The TCP stack
|
||||
Phantun simply converts a stream of UDP packets into obfuscated TCP stream packets. The TCP stack
|
||||
used by Phantun is designed to pass through most L3/L4 stateful/stateless firewalls/NAT
|
||||
devices. It will **not** be able to pass through L7 proxies.
|
||||
However, the advantage of this approach is that none of the common UDP over TCP performance killer
|
||||
@@ -134,7 +134,7 @@ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||
Server needs to DNAT the TCP listening port to Phantun's TUN interface address.
|
||||
|
||||
Note: change `eth0` to whatever actual physical interface name is and `4567` to
|
||||
actual TCP port number used by Phanton server
|
||||
actual TCP port number used by Phantun server
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
@@ -185,6 +185,12 @@ rule specified above. `127.0.0.1:1234` is the UDP Server to connect to for new c
|
||||
RUST_LOG=info /usr/local/bin/phantun_server --local 4567 --remote 127.0.0.1:1234
|
||||
```
|
||||
|
||||
Or use host name with `--remote`:
|
||||
|
||||
```
|
||||
RUST_LOG=info /usr/local/bin/phantun_server --local 4567 --remote example.com:1234
|
||||
```
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
### Client
|
||||
@@ -196,6 +202,12 @@ the Phantun Server to connect.
|
||||
RUST_LOG=info /usr/local/bin/phantun_client --local 127.0.0.1:1234 --remote 10.0.0.1:4567
|
||||
```
|
||||
|
||||
Or use host name with `--remote`:
|
||||
|
||||
```
|
||||
RUST_LOG=info /usr/local/bin/phantun_client --local 127.0.0.1:1234 --remote example.com:4567
|
||||
```
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
# MTU overhead
|
||||
@@ -264,7 +276,7 @@ for tunneling TCP/UDP traffic between two test instances and MTU has been tuned
|
||||
# Compariation to udp2raw
|
||||
[udp2raw](https://github.com/wangyu-/udp2raw-tunnel) is another popular project by [@wangyu-](https://github.com/wangyu-)
|
||||
that is very similar to what Phantun can do. In fact I took inspirations of Phantun from udp2raw. The biggest reason for
|
||||
developing Phanton is because of lack of performance when running udp2raw (especially on multi-core systems such as Raspberry Pi).
|
||||
developing Phantun is because of lack of performance when running udp2raw (especially on multi-core systems such as Raspberry Pi).
|
||||
However, the goal is never to be as feature complete as udp2raw and only support the most common use cases. Most notably, UDP over ICMP
|
||||
and UDP over UDP mode are not supported and there is no anti-replay nor encryption support. The benefit of this is much better
|
||||
performance overall and less MTU overhead because lack of additional headers inside the TCP payload.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fake-tcp"
|
||||
version = "0.2.0"
|
||||
version = "0.2.2"
|
||||
edition = "2021"
|
||||
authors = ["Datong Sun <dndx@idndx.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
@@ -16,9 +16,9 @@ benchmark = []
|
||||
|
||||
[dependencies]
|
||||
bytes = "1"
|
||||
pnet = "0.28.0"
|
||||
tokio = { version = "1.12.0", features = ["full"] }
|
||||
rand = { version = "0.8.4", features = ["small_rng"] }
|
||||
pnet = "0.28"
|
||||
tokio = { version = "1.14", features = ["full"] }
|
||||
rand = { version = "0.8", features = ["small_rng"] }
|
||||
log = "0.4"
|
||||
internet-checksum = "0.2.0"
|
||||
dndx-fork-tokio-tun = "0.4.0"
|
||||
internet-checksum = "0.2"
|
||||
dndx-fork-tokio-tun = "0.4"
|
||||
|
@@ -57,7 +57,6 @@ pub enum State {
|
||||
SynSent,
|
||||
SynReceived,
|
||||
Established,
|
||||
Closed,
|
||||
}
|
||||
|
||||
pub struct Socket {
|
||||
@@ -116,12 +115,10 @@ impl Socket {
|
||||
|
||||
tokio::select! {
|
||||
res = self.tun.send(&buf) => {
|
||||
res.unwrap();
|
||||
Some(())
|
||||
res.ok().and(Some(()))
|
||||
},
|
||||
}
|
||||
}
|
||||
State::Closed => None,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -148,7 +145,6 @@ impl Socket {
|
||||
Some(payload.len())
|
||||
})
|
||||
}
|
||||
State::Closed => None,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@@ -252,8 +248,6 @@ impl Socket {
|
||||
|
||||
impl Drop for Socket {
|
||||
fn drop(&mut self) {
|
||||
self.state = State::Closed;
|
||||
|
||||
let tuple = AddrTuple::new(self.local_addr, self.remote_addr);
|
||||
// dissociates ourself from the dispatch map
|
||||
assert!(self.shared.tuples.write().unwrap().remove(&tuple).is_some());
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "phantun"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
edition = "2021"
|
||||
authors = ["Datong Sun <dndx@idndx.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
@@ -11,11 +11,11 @@ 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.2.0"
|
||||
tokio = { version = "1.12.0", features = ["full"] }
|
||||
clap = "2.34"
|
||||
socket2 = { version = "0.4", features = ["all"] }
|
||||
fake-tcp = "0.2.2"
|
||||
tokio = { version = "1.14", features = ["full"] }
|
||||
log = "0.4"
|
||||
pretty_env_logger = "0.4.0"
|
||||
dndx-fork-tokio-tun = "0.4.0"
|
||||
num_cpus = "1.13.0"
|
||||
pretty_env_logger = "0.4"
|
||||
dndx-fork-tokio-tun = "0.4"
|
||||
num_cpus = "1.13"
|
||||
|
Reference in New Issue
Block a user