Switching from pnet to if-addrs for Windows support
This commit is contained in:
parent
24231ba043
commit
79a3ad1790
@ -33,7 +33,7 @@ uuid = {version = "0.8", features = ["v4"]}
|
|||||||
webbrowser = "0.5.5"
|
webbrowser = "0.5.5"
|
||||||
libmdns = "0.6" #mDNS advertiser
|
libmdns = "0.6" #mDNS advertiser
|
||||||
multicast_dns = "0.5" #mDNS browser
|
multicast_dns = "0.5" #mDNS browser
|
||||||
pnet_datalink = "0.27.2"
|
if-addrs = "0.6"
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
scrypt = "0.7.0"
|
scrypt = "0.7.0"
|
||||||
zeroize = "1.2.0"
|
zeroize = "1.2.0"
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
use std::{net::IpAddr, io};
|
use std::{net::IpAddr, io};
|
||||||
|
use tokio::runtime::Handle;
|
||||||
use libmdns::{Responder, Service};
|
use libmdns::{Responder, Service};
|
||||||
use multicast_dns::discovery::{DiscoveryManager, DiscoveryListeners, ResolveListeners};
|
use multicast_dns::discovery::{DiscoveryManager, DiscoveryListeners, ResolveListeners};
|
||||||
use crate::{constants, print_error};
|
use crate::{constants, print_error};
|
||||||
|
|
||||||
const SERVICE_TYPE: &str = "_aira._tcp";
|
const SERVICE_TYPE: &str = "_aira._tcp";
|
||||||
|
|
||||||
pub fn advertise_me() -> io::Result<Service> {
|
pub async fn advertise_me() -> io::Result<Service> {
|
||||||
Ok(Responder::new()?.register(
|
Ok(Responder::spawn(&Handle::current())?.register(
|
||||||
SERVICE_TYPE.to_string(),
|
SERVICE_TYPE.to_string(),
|
||||||
"AIRA Node".to_string(),
|
"AIRA Node".to_string(),
|
||||||
constants::PORT,
|
constants::PORT,
|
||||||
|
@ -117,12 +117,13 @@ async fn websocket_worker(mut ui_connection: UiConnection, global_vars: Arc<RwLo
|
|||||||
ui_connection.load_msgs(&msgs.0, &msgs.1);
|
ui_connection.load_msgs(&msgs.0, &msgs.1);
|
||||||
});
|
});
|
||||||
let mut ips = Vec::new();
|
let mut ips = Vec::new();
|
||||||
for interface in pnet_datalink::interfaces() {
|
match if_addrs::get_if_addrs() {
|
||||||
if !interface.is_loopback() {
|
Ok(ifaces) => for iface in ifaces {
|
||||||
for ip in interface.ips {
|
if !iface.is_loopback() {
|
||||||
ips.push(ip.ip());
|
ips.push(iface.ip());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(e) => print_error!(e)
|
||||||
}
|
}
|
||||||
ui_connection.set_local_ips(ips);
|
ui_connection.set_local_ips(ips);
|
||||||
discover_peers(session_manager.clone());
|
discover_peers(session_manager.clone());
|
||||||
|
@ -528,7 +528,7 @@ impl SessionManager {
|
|||||||
let server_v4 = TcpListener::bind(SocketAddr::new("0.0.0.0".parse().unwrap(), constants::PORT)).await?;
|
let server_v4 = TcpListener::bind(SocketAddr::new("0.0.0.0".parse().unwrap(), constants::PORT)).await?;
|
||||||
let (sender, mut receiver) = mpsc::channel(1);
|
let (sender, mut receiver) = mpsc::channel(1);
|
||||||
*session_manager.listener_stop_signal.lock().unwrap() = Some(sender);
|
*session_manager.listener_stop_signal.lock().unwrap() = Some(sender);
|
||||||
match discovery::advertise_me() {
|
match discovery::advertise_me().await {
|
||||||
Ok(service) => *session_manager.mdns_service.lock().unwrap() = Some(service),
|
Ok(service) => *session_manager.mdns_service.lock().unwrap() = Some(service),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
print_error!("{}: you won't be discoverable by other peers.", e);
|
print_error!("{}: you won't be discoverable by other peers.", e);
|
||||||
|
Loading…
Reference in New Issue
Block a user