9 Commits

Author SHA1 Message Date
Datong Sun
b3c781cdc5 chore(phantun) bump phantun to v0.2.4 2021-12-05 07:10:42 -08:00
Datong Sun
d5e30c113f chore(phantun) bump clap and tokio dependencies to latest 2021-12-05 07:01:58 -08:00
Datong Sun
e2a9194f6f chore(fake-tcp) bump to v0.2.2 2021-12-05 06:57:23 -08:00
Datong Sun
d0eaefe5d0 chore(phantun) specify exact version for fake-tcp dependency 2021-12-05 06:49:35 -08:00
Datong Sun
299646a54f chore(fake-tcp) bump to v0.2.1 2021-12-05 06:43:18 -08:00
Datong Sun
8b28cdc6c2 chore(crates) do not include bugfix version in dependency as it prevents
auto update from Dependabot
2021-12-05 22:41:05 +08:00
Datong Sun
a8ad203754 docs(readme) fixed some typos 2021-12-01 15:10:52 +08:00
Datong Sun
33e510e7ba fix(fake-tcp) remove unneeded State::Closed as it is not in a
reachable code path
2021-11-19 10:45:13 -08:00
Datong Sun
521a3f1a01 docs(readme) bump release version and add host name support info for
`--remote`
2021-11-18 20:48:53 -08:00
4 changed files with 32 additions and 26 deletions

View File

@@ -31,16 +31,16 @@ Table of Contents
# Latest release # 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 # 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. 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. 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 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. 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 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. 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 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) [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 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) [Back to TOC](#table-of-contents)
### Client ### 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 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) [Back to TOC](#table-of-contents)
# MTU overhead # MTU overhead
@@ -264,7 +276,7 @@ for tunneling TCP/UDP traffic between two test instances and MTU has been tuned
# Compariation to udp2raw # Compariation to udp2raw
[udp2raw](https://github.com/wangyu-/udp2raw-tunnel) is another popular project by [@wangyu-](https://github.com/wangyu-) [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 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 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 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. performance overall and less MTU overhead because lack of additional headers inside the TCP payload.

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "fake-tcp" name = "fake-tcp"
version = "0.2.0" version = "0.2.2"
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,9 +16,9 @@ benchmark = []
[dependencies] [dependencies]
bytes = "1" bytes = "1"
pnet = "0.28.0" pnet = "0.28"
tokio = { version = "1.12.0", features = ["full"] } tokio = { version = "1.14", features = ["full"] }
rand = { version = "0.8.4", features = ["small_rng"] } rand = { version = "0.8", features = ["small_rng"] }
log = "0.4" log = "0.4"
internet-checksum = "0.2.0" internet-checksum = "0.2"
dndx-fork-tokio-tun = "0.4.0" dndx-fork-tokio-tun = "0.4"

View File

@@ -57,7 +57,6 @@ pub enum State {
SynSent, SynSent,
SynReceived, SynReceived,
Established, Established,
Closed,
} }
pub struct Socket { pub struct Socket {
@@ -116,12 +115,10 @@ impl Socket {
tokio::select! { tokio::select! {
res = self.tun.send(&buf) => { res = self.tun.send(&buf) => {
res.unwrap(); res.ok().and(Some(()))
Some(())
}, },
} }
} }
State::Closed => None,
_ => unreachable!(), _ => unreachable!(),
} }
} }
@@ -148,7 +145,6 @@ impl Socket {
Some(payload.len()) Some(payload.len())
}) })
} }
State::Closed => None,
_ => unreachable!(), _ => unreachable!(),
} }
} }
@@ -252,8 +248,6 @@ impl Socket {
impl Drop for Socket { impl Drop for Socket {
fn drop(&mut self) { fn drop(&mut self) {
self.state = State::Closed;
let tuple = AddrTuple::new(self.local_addr, self.remote_addr); let tuple = AddrTuple::new(self.local_addr, self.remote_addr);
// dissociates ourself from the dispatch map // dissociates ourself from the dispatch map
assert!(self.shared.tuples.write().unwrap().remove(&tuple).is_some()); assert!(self.shared.tuples.write().unwrap().remove(&tuple).is_some());

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "phantun" name = "phantun"
version = "0.2.3" version = "0.2.4"
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"
@@ -11,11 +11,11 @@ Transforms UDP stream into (fake) TCP streams that can go through
Layer 3 & Layer 4 (NAPT) firewalls/NATs. Layer 3 & Layer 4 (NAPT) firewalls/NATs.
""" """
[dependencies] [dependencies]
clap = "2.33.3" clap = "2.34"
socket2 = { version = "0.4.2", features = ["all"] } socket2 = { version = "0.4", features = ["all"] }
fake-tcp = "0.2.0" fake-tcp = "0.2.2"
tokio = { version = "1.12.0", features = ["full"] } tokio = { version = "1.14", features = ["full"] }
log = "0.4" log = "0.4"
pretty_env_logger = "0.4.0" pretty_env_logger = "0.4"
dndx-fork-tokio-tun = "0.4.0" dndx-fork-tokio-tun = "0.4"
num_cpus = "1.13.0" num_cpus = "1.13"