Compare commits

...

2 commits

Author SHA1 Message Date
Joe Ardent
bcc485f2c0 release 1.618 2025-08-15 15:59:40 -07:00
Joe Ardent
5e40f29294 don't loop multicast back 2025-08-15 15:54:03 -07:00
5 changed files with 11 additions and 40 deletions

2
Cargo.lock generated
View file

@ -1324,7 +1324,7 @@ dependencies = [
[[package]]
name = "jocalsend"
version = "1.6.1"
version = "1.6.18"
dependencies = [
"axum",
"axum-server",

View file

@ -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"]

View file

@ -1 +1 @@
1.61
1.618

View file

@ -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!()
}
*/

View file

@ -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
});