-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
51 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub mod datagram; | ||
pub mod inbound; | ||
|
||
pub use netstack_lwip as netstack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub mod inbound; | ||
pub use netstack_lwip as netstack; | ||
mod datagram; | ||
pub use inbound::get_runner as get_tun_runner; | ||
mod lwip; | ||
mod smoltcp; | ||
|
||
pub use lwip::inbound::get_runner as get_tun_runner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::sync::Arc; | ||
|
||
use url::Url; | ||
|
||
use crate::{ | ||
app::{dispatcher::Dispatcher, dns::ThreadSafeDNSResolver}, | ||
config::internal::config::TunConfig, | ||
Error, Runner, | ||
}; | ||
|
||
pub fn get_runner( | ||
cfg: TunConfig, | ||
dispatcher: Arc<Dispatcher>, | ||
resolver: ThreadSafeDNSResolver, | ||
) -> Result<Option<Runner>, Error> { | ||
let device_id = cfg.device_id; | ||
|
||
let u = | ||
Url::parse(&device_id).map_err(|x| Error::InvalidConfig(format!("tun device {}", x)))?; | ||
|
||
let device = match u.scheme() { | ||
"fd" => { | ||
let fd = u | ||
.host() | ||
.expect("tun fd must be provided") | ||
.to_string() | ||
.parse() | ||
.map_err(|x| Error::InvalidConfig(format!("tun fd {}", x)))?; | ||
TunTapInterface::from_fd(fd)? | ||
} | ||
"dev" => { | ||
let dev = u.host().expect("tun dev must be provided").to_string(); | ||
tun_cfg.name(dev); | ||
} | ||
_ => { | ||
return Err(Error::InvalidConfig(format!( | ||
"invalid device id: {}", | ||
device_id | ||
))); | ||
} | ||
}; | ||
} |