Enable date and time via logging

This commit is contained in:
Luca Ferrarotti 2023-05-14 15:29:00 +02:00
parent 6c42f02b28
commit 7220b72b39
4 changed files with 71 additions and 18 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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!())

View File

@ -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!())