Compare commits
2 commits
9b1734f8c0
...
bcc485f2c0
Author | SHA1 | Date | |
---|---|---|---|
|
bcc485f2c0 | ||
|
5e40f29294 |
5 changed files with 11 additions and 40 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1324,7 +1324,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "jocalsend"
|
||||
version = "1.6.1"
|
||||
version = "1.6.18"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-server",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[package]
|
||||
name = "jocalsend"
|
||||
# 1.61803398874989484
|
||||
#----^
|
||||
version = "1.6.1"
|
||||
#-----^
|
||||
version = "1.6.18"
|
||||
edition = "2024"
|
||||
authors = ["Joe Ardent <code@ardent.nebcorp.com>"]
|
||||
keywords = ["p2p", "localsend", "tui", "linux"]
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.61
|
||||
1.618
|
||||
|
|
|
@ -138,33 +138,3 @@ async fn announce_multicast(
|
|||
socket.send_to(msg.as_bytes(), addr).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/*
|
||||
async fn announce_unicast(
|
||||
device: &Device,
|
||||
ip: Option<SocketAddr>,
|
||||
client: reqwest::Client,
|
||||
) -> crate::error::Result<()> {
|
||||
// for enumerating subnet peers when multicast fails (https://github.com/localsend/protocol?tab=readme-ov-file#32-http-legacy-mode)
|
||||
let std::net::IpAddr::V4(ip) = local_ip_address::local_ip()? else {
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
let mut _network_ip = ip;
|
||||
let nifs = NetworkInterface::show()?;
|
||||
for addr in nifs.into_iter().flat_map(|i| i.addr) {
|
||||
if let Addr::V4(V4IfAddr {
|
||||
ip: ifip,
|
||||
netmask: Some(netmask),
|
||||
..
|
||||
}) = addr
|
||||
&& ip == ifip
|
||||
{
|
||||
_network_ip = ip & netmask;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
todo!()
|
||||
}
|
||||
*/
|
||||
|
|
13
src/lib.rs
13
src/lib.rs
|
@ -32,7 +32,7 @@ pub const DEFAULT_PORT: u16 = 53317;
|
|||
pub const MULTICAST_IP: Ipv4Addr = Ipv4Addr::new(224, 0, 0, 167);
|
||||
pub const LISTENING_SOCKET_ADDR: SocketAddrV4 =
|
||||
SocketAddrV4::new(Ipv4Addr::from_bits(0), DEFAULT_PORT);
|
||||
pub const DEFAULT_INTERVAL: Duration = Duration::from_millis(200);
|
||||
pub const DEFAULT_INTERVAL: Duration = Duration::from_micros(33333);
|
||||
|
||||
pub type Peers = Arc<Mutex<BTreeMap<String, (SocketAddr, Device)>>>;
|
||||
pub type Sessions = Arc<Mutex<BTreeMap<String, Session>>>; // Session ID to Session
|
||||
|
@ -114,7 +114,7 @@ impl JocalService {
|
|||
) -> crate::error::Result<(Self, UnboundedReceiver<JocalEvent>)> {
|
||||
let (tx, rx) = mpsc::unbounded_channel();
|
||||
let socket = UdpSocket::bind(LISTENING_SOCKET_ADDR).await?;
|
||||
socket.set_multicast_loop_v4(true)?;
|
||||
socket.set_multicast_loop_v4(false)?;
|
||||
socket.set_multicast_ttl_v4(8)?; // 8 hops out from localnet
|
||||
socket.join_multicast_v4(MULTICAST_IP, Ipv4Addr::from_bits(0))?;
|
||||
|
||||
|
@ -162,15 +162,16 @@ impl JocalService {
|
|||
let mut tick = tokio::time::interval(DEFAULT_INTERVAL);
|
||||
|
||||
loop {
|
||||
let rstate = service.running_state.lock().await;
|
||||
if *rstate == RunningState::Stopping {
|
||||
break;
|
||||
}
|
||||
tick.tick().await;
|
||||
service
|
||||
.transfer_event_tx
|
||||
.send(JocalEvent::Tick)
|
||||
.unwrap_or_else(|e| log::warn!("could not send tick event: {e:?}"));
|
||||
|
||||
let rstate = service.running_state.lock().await;
|
||||
if *rstate == RunningState::Stopping {
|
||||
break;
|
||||
}
|
||||
}
|
||||
JocalTasks::Tick
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue