init NotificationSys

This commit is contained in:
weisd
2024-12-02 17:50:11 +08:00
18 changed files with 284 additions and 136 deletions
+6 -1
View File
@@ -2,8 +2,9 @@ use crate::error::{Error, Result};
use lazy_static::lazy_static;
use std::{
collections::HashSet,
net::{IpAddr, SocketAddr, ToSocketAddrs},
net::{IpAddr, SocketAddr, TcpListener, ToSocketAddrs},
};
use url::Host;
lazy_static! {
@@ -92,6 +93,10 @@ pub fn get_host_ip(host: Host<&str>) -> Result<HashSet<IpAddr>> {
}
}
pub fn get_available_port() -> u16 {
TcpListener::bind("0.0.0.0:0").unwrap().local_addr().unwrap().port()
}
/// returns IPs of local interface
pub(crate) fn must_get_local_ips() -> Result<Vec<IpAddr>> {
match netif::up() {