1
0
mirror of https://github.com/dndx/phantun.git synced 2025-04-09 05:29:28 +08:00

Merge 81d25b5dd3376718eaeb0cefa439a10387524761 into 8a0ec729e21877e6535edb6ab42d90b4d40a9410

This commit is contained in:
Luca Ferrarotti 2024-01-07 11:20:13 +00:00 committed by GitHub
commit 71d1a95483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 23 deletions

@ -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"
@ -15,11 +15,11 @@ packet oriented tunneling with minimum overhead.
benchmark = [] benchmark = []
[dependencies] [dependencies]
bytes = "1" bytes = "1.4.0"
pnet = "0.34" pnet = "0.34.0"
tokio = { version = "1.14", features = ["full"] } tokio = { version = "1.28.0", features = ["full"] }
rand = { version = "0.8", features = ["small_rng"] } rand = { version = "0.8.5", features = ["small_rng"] }
log = "0.4" log = "0.4.17"
internet-checksum = "0.2" internet-checksum = "0.2.1"
tokio-tun = "0.11" tokio-tun = "0.11.2"
flume = "0.11" flume ="0.11.0"

@ -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"
@ -11,14 +11,15 @@ 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 = { version = "4.0", features = ["cargo"] } clap = { version = "4.2.5", features = ["cargo"] }
socket2 = { version = "0.5", 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.14", features = ["full"] } tokio = { version = "1.28.0", features = ["full"] }
tokio-util = "0.7" tokio-util = "0.7.8"
log = "0.4" log = "0.4.17"
pretty_env_logger = "0.5" env_logger = "0.10.0"
tokio-tun = "0.11" chrono = "0.4.24"
num_cpus = "1.13" tokio-tun = "0.11.2"
neli = "0.6" num_cpus = "1.15.0"
nix = { version = "0.27", features = ["net"] } neli = "0.6.4"
nix = { version = "0.27.1", features = ["net"] }

@ -2,6 +2,12 @@ use clap::{crate_version, Arg, ArgAction, Command};
use fake_tcp::packet::MAX_PACKET_LEN; use fake_tcp::packet::MAX_PACKET_LEN;
use fake_tcp::{Socket, Stack}; use fake_tcp::{Socket, Stack};
use log::{debug, error, info}; use log::{debug, error, info};
use chrono::Local;
use log::LevelFilter;
use std::io::Write;
use env_logger::fmt::Color;
use Color::{Blue, Cyan, Green, Red, Yellow};
use log::Level;
use phantun::utils::{assign_ipv6_address, new_udp_reuseport}; use phantun::utils::{assign_ipv6_address, new_udp_reuseport};
use std::collections::HashMap; use std::collections::HashMap;
use std::fs; use std::fs;
@ -17,7 +23,26 @@ use phantun::UDP_TTL;
#[tokio::main] #[tokio::main]
async fn main() -> io::Result<()> { async fn main() -> io::Result<()> {
pretty_env_logger::init(); env_logger::Builder::new()
.format(|buf, record| {
let mut level_style = buf.style();
match record.level() {
Level::Trace => level_style.set_color(Cyan),
Level::Debug => level_style.set_color(Blue),
Level::Info => level_style.set_color(Green),
Level::Warn => level_style.set_color(Yellow),
Level::Error => level_style.set_color(Red).set_bold(true),
};
writeln!(buf,
"[{} {} {}] {}",
Local::now().format("%d-%m-%Y %H:%M:%S"),
level_style.value(record.level()),
record.target(),
record.args()
)
})
.filter(None, LevelFilter::Info)
.init();
let matches = Command::new("Phantun Client") let matches = Command::new("Phantun Client")
.version(crate_version!()) .version(crate_version!())

@ -2,6 +2,12 @@ use clap::{crate_version, Arg, ArgAction, Command};
use fake_tcp::packet::MAX_PACKET_LEN; use fake_tcp::packet::MAX_PACKET_LEN;
use fake_tcp::Stack; use fake_tcp::Stack;
use log::{debug, error, info}; use log::{debug, error, info};
use chrono::Local;
use log::LevelFilter;
use std::io::Write;
use env_logger::fmt::Color;
use Color::{Blue, Cyan, Green, Red, Yellow};
use log::Level;
use phantun::utils::{assign_ipv6_address, new_udp_reuseport}; use phantun::utils::{assign_ipv6_address, new_udp_reuseport};
use std::fs; use std::fs;
use std::io; use std::io;
@ -17,7 +23,26 @@ use phantun::UDP_TTL;
#[tokio::main] #[tokio::main]
async fn main() -> io::Result<()> { async fn main() -> io::Result<()> {
pretty_env_logger::init(); env_logger::Builder::new()
.format(|buf, record| {
let mut level_style = buf.style();
match record.level() {
Level::Trace => level_style.set_color(Cyan),
Level::Debug => level_style.set_color(Blue),
Level::Info => level_style.set_color(Green),
Level::Warn => level_style.set_color(Yellow),
Level::Error => level_style.set_color(Red).set_bold(true),
};
writeln!(buf,
"[{} {} {}] {}",
Local::now().format("%d-%m-%Y %H:%M:%S"),
level_style.value(record.level()),
record.target(),
record.args()
)
})
.filter(None, LevelFilter::Info)
.init();
let matches = Command::new("Phantun Server") let matches = Command::new("Phantun Server")
.version(crate_version!()) .version(crate_version!())