mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-21 00:20:53 +00:00
Ffi (#89)
This commit is contained in:
parent
e9c378099e
commit
a26621bbcd
11 changed files with 224 additions and 26 deletions
12
src/api.rs
12
src/api.rs
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue