Browse Source
Merge pull request #2 from kujeger/logging
Use log for logging
pull/4/head
B. Blechschmidt
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
8 additions and
8 deletions
-
Cargo.toml
-
src/main.rs
-
src/tun2proxy.rs
|
|
|
@ -5,7 +5,8 @@ name = "tun2proxy" |
|
|
|
version = "0.1.1" |
|
|
|
|
|
|
|
[dependencies] |
|
|
|
chrono = "0.4" |
|
|
|
clap = "3.2" |
|
|
|
mio = { version = "0.8", features = ["os-poll", "net", "os-ext"] } |
|
|
|
smoltcp = { version = "0.8", features = ["std"] } |
|
|
|
log = "0.4" |
|
|
|
env_logger = "0.9" |
|
|
|
|
|
|
|
@ -5,10 +5,12 @@ mod virtdevice; |
|
|
|
|
|
|
|
use crate::http::HttpManager; |
|
|
|
use crate::tun2proxy::TunToProxy; |
|
|
|
use env_logger::Env; |
|
|
|
use socks5::*; |
|
|
|
use std::net::ToSocketAddrs; |
|
|
|
|
|
|
|
fn main() { |
|
|
|
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init(); |
|
|
|
let matches = clap::App::new(env!("CARGO_PKG_NAME")) |
|
|
|
.version(env!("CARGO_PKG_VERSION")) |
|
|
|
.about("Tunnel interface to proxy.") |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
use crate::virtdevice::VirtualTunDevice; |
|
|
|
use log::{error, info}; |
|
|
|
use mio::event::Event; |
|
|
|
use mio::net::TcpStream; |
|
|
|
use mio::unix::SourceFd; |
|
|
|
@ -255,7 +256,7 @@ impl<'a> TunToProxy<'a> { |
|
|
|
.registry() |
|
|
|
.deregister(&mut connection_state.mio_stream) |
|
|
|
.unwrap(); |
|
|
|
println!("[{:?}] CLOSE {}", chrono::offset::Local::now(), connection); |
|
|
|
info!("CLOSE {}", connection); |
|
|
|
} |
|
|
|
|
|
|
|
fn get_connection_manager(&self, connection: &Connection) -> Option<&dyn ConnectionManager> { |
|
|
|
@ -268,7 +269,7 @@ impl<'a> TunToProxy<'a> { |
|
|
|
} |
|
|
|
|
|
|
|
fn print_error(error: ProxyError) { |
|
|
|
println!("Error: {}", error.message()); |
|
|
|
error!("{}", error.message()); |
|
|
|
} |
|
|
|
|
|
|
|
fn tunsocket_read_and_forward(&mut self, connection: &Connection) { |
|
|
|
@ -355,11 +356,7 @@ impl<'a> TunToProxy<'a> { |
|
|
|
|
|
|
|
self.connections.insert(connection, state); |
|
|
|
|
|
|
|
println!( |
|
|
|
"[{:?}] CONNECT {}", |
|
|
|
chrono::offset::Local::now(), |
|
|
|
connection |
|
|
|
); |
|
|
|
info!("CONNECT {}", connection,); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|