parent
60feaff4be
commit
07c74649d1
@ -1,2 +1,12 @@ |
||||
mod shared; |
||||
pub use self::shared::*; |
||||
|
||||
#[cfg(target_os = "windows")] |
||||
pub mod windows; |
||||
mod windows; |
||||
#[cfg(target_os = "windows")] |
||||
pub use self::windows::*; |
||||
|
||||
#[cfg(not(target_os="windows"))] |
||||
mod unix; |
||||
#[cfg(not(target_os="windows"))] |
||||
use self::unix::*; |
||||
|
@ -0,0 +1,18 @@ |
||||
use std::net::{IpAddr, UdpSocket}; |
||||
|
||||
pub fn get_local_ipaddr() -> Option<IpAddr> { |
||||
let socket = match UdpSocket::bind("0.0.0.0:0") { |
||||
Ok(s) => s, |
||||
Err(_) => return None, |
||||
}; |
||||
|
||||
match socket.connect("1.1.1.1:80") { |
||||
Ok(()) => (), |
||||
Err(_) => return None, |
||||
}; |
||||
|
||||
match socket.local_addr() { |
||||
Ok(addr) => return Some(addr.ip()), |
||||
Err(_) => return None, |
||||
}; |
||||
} |
@ -0,0 +1,6 @@ |
||||
use crate::interface::{Interface, MacAddr}; |
||||
|
||||
pub fn get_interfaces() -> Vec<Interface> { |
||||
let interfaces: Vec<Interface> = vec![]; |
||||
return interfaces; |
||||
} |
Loading…
Reference in new issue