diff --git a/fake-tcp/Cargo.toml b/fake-tcp/Cargo.toml index 43c4196..3c8e651 100644 --- a/fake-tcp/Cargo.toml +++ b/fake-tcp/Cargo.toml @@ -15,11 +15,11 @@ packet oriented tunneling with minimum overhead. benchmark = [] [dependencies] -bytes = "1" -pnet = "0.33" -tokio = { version = "1.14", features = ["full"] } -rand = { version = "0.8", features = ["small_rng"] } -log = "0.4" -internet-checksum = "0.2" +bytes = "1.4.0" +pnet = "0.33.0" +tokio = { version = "1.28.0", features = ["full"] } +rand = { version = "0.8.5", features = ["small_rng"] } +log = "0.4.17" +internet-checksum = "0.2.1" tokio-tun = "0.7" -flume = "0.10" +flume = "0.10.14" diff --git a/phantun/Cargo.toml b/phantun/Cargo.toml index 94ea726..0b5e487 100644 --- a/phantun/Cargo.toml +++ b/phantun/Cargo.toml @@ -11,14 +11,15 @@ Transforms UDP stream into (fake) TCP streams that can go through Layer 3 & Layer 4 (NAPT) firewalls/NATs. """ [dependencies] -clap = { version = "4.0", features = ["cargo"] } -socket2 = { version = "0.5", features = ["all"] } +clap = { version = "4.2.5", features = ["cargo"] } +socket2 = { version = "0.5.2", features = ["all"] } fake-tcp = { path = "../fake-tcp", version = "0.5" } -tokio = { version = "1.14", features = ["full"] } -tokio-util = "0.7" -log = "0.4" -pretty_env_logger = "0.4" +tokio = { version = "1.28.0", features = ["full"] } +tokio-util = "0.7.8" +log = "0.4.17" +env_logger = "0.10.0" +chrono = "0.4.24" tokio-tun = "0.7" -num_cpus = "1.13" -neli = "0.6" -nix = "0.26" +num_cpus = "1.15.0" +neli = "0.6.4" +nix = "0.26.2" diff --git a/phantun/src/bin/client.rs b/phantun/src/bin/client.rs index 360101e..33e8394 100644 --- a/phantun/src/bin/client.rs +++ b/phantun/src/bin/client.rs @@ -2,6 +2,12 @@ use clap::{crate_version, Arg, ArgAction, Command}; use fake_tcp::packet::MAX_PACKET_LEN; use fake_tcp::{Socket, Stack}; 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 std::collections::HashMap; use std::fs; @@ -17,7 +23,27 @@ use phantun::UDP_TTL; #[tokio::main] 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.level(), + record.target(), + record.args() + ) + }) + .filter(None, LevelFilter::Info) + .init(); let matches = Command::new("Phantun Client") .version(crate_version!()) diff --git a/phantun/src/bin/server.rs b/phantun/src/bin/server.rs index c5dfeea..5eac967 100644 --- a/phantun/src/bin/server.rs +++ b/phantun/src/bin/server.rs @@ -2,6 +2,12 @@ use clap::{crate_version, Arg, ArgAction, Command}; use fake_tcp::packet::MAX_PACKET_LEN; use fake_tcp::Stack; 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 std::fs; use std::io; @@ -17,7 +23,27 @@ use phantun::UDP_TTL; #[tokio::main] 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.level(), + record.target(), + record.args() + ) + }) + .filter(None, LevelFilter::Info) + .init(); let matches = Command::new("Phantun Server") .version(crate_version!())