Initialize Tun Interface based on platform

This commit is contained in:
Jett Chen 2023-12-12 15:48:38 +08:00
parent c346ec5b39
commit 54ec260fe3
6 changed files with 24 additions and 14 deletions

View file

@ -54,12 +54,7 @@ impl DaemonInstance {
warn!("Got start, but tun interface already up.");
}
RunState::Idle => {
let raw = tun::TunInterface::retrieve().unwrap();
debug!("TunInterface retrieved: {:?}", raw.name()?);
let retrieved = TunInterface::new(raw)?;
let tun_if = Arc::new(RwLock::new(retrieved));
// let tun_if = Arc::new(RwLock::new(TunInterface::new(st.tun.open()?)?));
let tun_if = Arc::new(RwLock::new(st.tun.open()?));
debug!("Setting tun_interface");
self.tun_interface = Some(tun_if.clone());

View file

@ -53,9 +53,14 @@ pub async fn daemon_main() -> Result<()> {
let private_key = parse_secret_key("GNqIAOCRxjl/cicZyvkvpTklgQuUmGUIEkH7IXF/sEE=")?;
let public_key = parse_public_key("uy75leriJay0+oHLhRMpV+A5xAQ0hCJ+q7Ww81AOvT4=")?;
let preshared_key = Some(parse_key("s7lx/mg+reVEMnGnqeyYOQkzD86n2+gYnx1M9ygi08k=")?);
let endpoint = "wg.burrow.rs:51820".to_socket_addrs()?.next()
tracing::debug!("beginning to find endpoint location");
let endpoint = "wg.burrow.rs:51820".to_socket_addrs()?
.filter(|sock| {sock.is_ipv4()})
.next()
.ok_or(anyhow!("DNS Lookup Fails!"))?; // DNS lookup under macos fails, somehow
tracing::debug!("endpoint initialized: {:?}", endpoint.to_string());
let iface = Interface::new(vec![Peer {
endpoint,
private_key,