mirror of
https://github.com/dndx/phantun.git
synced 2025-04-04 11:09:29 +08:00
Enable date and time via logging
This commit is contained in:
parent
6c42f02b28
commit
7220b72b39
@ -15,11 +15,11 @@ packet oriented tunneling with minimum overhead.
|
|||||||
benchmark = []
|
benchmark = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytes = "1"
|
bytes = "1.4.0"
|
||||||
pnet = "0.33"
|
pnet = "0.33.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.7"
|
tokio-tun = "0.7"
|
||||||
flume = "0.10"
|
flume = "0.10.14"
|
||||||
|
@ -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" }
|
||||||
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.4"
|
env_logger = "0.10.0"
|
||||||
|
chrono = "0.4.24"
|
||||||
tokio-tun = "0.7"
|
tokio-tun = "0.7"
|
||||||
num_cpus = "1.13"
|
num_cpus = "1.15.0"
|
||||||
neli = "0.6"
|
neli = "0.6.4"
|
||||||
nix = "0.26"
|
nix = "0.26.2"
|
||||||
|
@ -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,27 @@ 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.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,27 @@ 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.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!())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user