mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-04-26 16:56:05 +00:00
commit
b3ddf7462c
3 changed files with 8 additions and 8 deletions
|
@ -5,7 +5,8 @@ name = "tun2proxy"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4"
|
|
||||||
clap = "3.2"
|
clap = "3.2"
|
||||||
mio = { version = "0.8", features = ["os-poll", "net", "os-ext"] }
|
mio = { version = "0.8", features = ["os-poll", "net", "os-ext"] }
|
||||||
smoltcp = { version = "0.8", features = ["std"] }
|
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::http::HttpManager;
|
||||||
use crate::tun2proxy::TunToProxy;
|
use crate::tun2proxy::TunToProxy;
|
||||||
|
use env_logger::Env;
|
||||||
use socks5::*;
|
use socks5::*;
|
||||||
use std::net::ToSocketAddrs;
|
use std::net::ToSocketAddrs;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
|
||||||
let matches = clap::App::new(env!("CARGO_PKG_NAME"))
|
let matches = clap::App::new(env!("CARGO_PKG_NAME"))
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
.about("Tunnel interface to proxy.")
|
.about("Tunnel interface to proxy.")
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::virtdevice::VirtualTunDevice;
|
use crate::virtdevice::VirtualTunDevice;
|
||||||
|
use log::{error, info};
|
||||||
use mio::event::Event;
|
use mio::event::Event;
|
||||||
use mio::net::TcpStream;
|
use mio::net::TcpStream;
|
||||||
use mio::unix::SourceFd;
|
use mio::unix::SourceFd;
|
||||||
|
@ -255,7 +256,7 @@ impl<'a> TunToProxy<'a> {
|
||||||
.registry()
|
.registry()
|
||||||
.deregister(&mut connection_state.mio_stream)
|
.deregister(&mut connection_state.mio_stream)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("[{:?}] CLOSE {}", chrono::offset::Local::now(), connection);
|
info!("CLOSE {}", connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_connection_manager(&self, connection: &Connection) -> Option<&dyn ConnectionManager> {
|
fn get_connection_manager(&self, connection: &Connection) -> Option<&dyn ConnectionManager> {
|
||||||
|
@ -268,7 +269,7 @@ impl<'a> TunToProxy<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_error(error: ProxyError) {
|
fn print_error(error: ProxyError) {
|
||||||
println!("Error: {}", error.message());
|
error!("{}", error.message());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tunsocket_read_and_forward(&mut self, connection: &Connection) {
|
fn tunsocket_read_and_forward(&mut self, connection: &Connection) {
|
||||||
|
@ -355,11 +356,7 @@ impl<'a> TunToProxy<'a> {
|
||||||
|
|
||||||
self.connections.insert(connection, state);
|
self.connections.insert(connection, state);
|
||||||
|
|
||||||
println!(
|
info!("CONNECT {}", connection,);
|
||||||
"[{:?}] CONNECT {}",
|
|
||||||
chrono::offset::Local::now(),
|
|
||||||
connection
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue