mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 16:41:01 +00:00
Use nix crate instead of interacting with libc directly, drop privileges
This commit is contained in:
parent
3dc7fde5e9
commit
15703a4823
6 changed files with 232 additions and 127 deletions
|
@ -111,25 +111,25 @@ impl Credentials {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main_entry(tun: &str, proxy: Proxy, options: Options) -> Result<(), Error> {
|
||||
pub fn main_entry(tun: &str, proxy: &Proxy, options: Options) -> Result<(), Error> {
|
||||
let mut ttp = TunToProxy::new(tun, options)?;
|
||||
match proxy.proxy_type {
|
||||
ProxyType::Socks4 => {
|
||||
ttp.add_connection_manager(SocksManager::new(
|
||||
proxy.addr,
|
||||
SocksVersion::V4,
|
||||
proxy.credentials,
|
||||
proxy.credentials.clone(),
|
||||
));
|
||||
}
|
||||
ProxyType::Socks5 => {
|
||||
ttp.add_connection_manager(SocksManager::new(
|
||||
proxy.addr,
|
||||
SocksVersion::V5,
|
||||
proxy.credentials,
|
||||
proxy.credentials.clone(),
|
||||
));
|
||||
}
|
||||
ProxyType::Http => {
|
||||
ttp.add_connection_manager(HttpManager::new(proxy.addr, proxy.credentials));
|
||||
ttp.add_connection_manager(HttpManager::new(proxy.addr, proxy.credentials.clone()));
|
||||
}
|
||||
}
|
||||
ttp.run()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue