mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 16:41:01 +00:00
separate to lib and exe
This commit is contained in:
parent
95820d6e31
commit
4ce2bdf0ba
2 changed files with 29 additions and 12 deletions
26
src/lib.rs
Normal file
26
src/lib.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use crate::{http::HttpManager, socks5::Socks5Manager, tun2proxy::TunToProxy};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub mod http;
|
||||
pub mod socks5;
|
||||
pub mod tun2proxy;
|
||||
pub mod virtdevice;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum ProxyType {
|
||||
Socks5,
|
||||
Http,
|
||||
}
|
||||
|
||||
pub fn main_entry(tun: &str, addr: SocketAddr, proxy_type: ProxyType) {
|
||||
let mut ttp = TunToProxy::new(tun);
|
||||
match proxy_type {
|
||||
ProxyType::Socks5 => {
|
||||
ttp.add_connection_manager(Box::new(Socks5Manager::new(addr)));
|
||||
}
|
||||
ProxyType::Http => {
|
||||
ttp.add_connection_manager(Box::new(HttpManager::new(addr)));
|
||||
}
|
||||
}
|
||||
ttp.run();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue