This commit is contained in:
ssrlive 2024-02-12 21:36:18 +08:00 committed by GitHub
parent e9c378099e
commit a26621bbcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 224 additions and 26 deletions

View file

@ -18,10 +18,18 @@ pub(crate) fn tun2proxy_internal_run(args: Args, tun_mtu: u16) -> c_int {
}
let block = async move {
log::info!("Proxying {}", args.proxy);
log::info!("Proxy {} server: {}", args.proxy.proxy_type, args.proxy.addr);
let mut config = tun2::Configuration::default();
config.raw_fd(args.tun_fd.ok_or(crate::Error::from("tun_fd"))?);
#[cfg(unix)]
if let Some(fd) = args.tun_fd {
config.raw_fd(fd);
} else {
config.name(&args.tun);
}
#[cfg(windows)]
config.name(&args.tun);
let device = tun2::create_as_async(&config).map_err(std::io::Error::from)?;
let join_handle = tokio::spawn(crate::run(device, tun_mtu, args, shutdown_token));