Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to Veil. Dates are dd/mm/yyyy.

## Unreleased

### Fixed

- **Guests who reach the host over IPv6 can see each other.** Guests link to each other
through the host's own rendezvous, which listened on IPv4 only. A guest who reached the
host over IPv6 could reach the host but not the rendezvous, so other guests showed as
"Guest" and a key prefix, with no sound or video. The rendezvous now listens on the host's
public IPv6 address too, is named there in invites, and gets its own IPv6 pinhole when
port opening is on.
- The log says when each media link to another member comes up and how (direct, punched,
relayed), and once if it has not come up after 20 seconds, on both sides of the link.

## 0.1.18, 05/12/2026

### Changed
Expand Down
78 changes: 59 additions & 19 deletions crates/veil-app/src/engine/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
//! The call's socket is dual-stack where the system allows it. A public IPv6 address goes in
//! every invite and to the rendezvous, guests dial it first, and, with port opening on, the
//! router is asked for an IPv6 pinhole (`pinhole.rs`). If the public node has an IPv6 address
//! too, the IPv6 address is checked from outside as well.
//! too, the IPv6 address is checked from outside as well. The host's own rendezvous listens on
//! IPv6 too, at the same address, with a pinhole of its own: guests link to each other through
//! it, so a guest who reached the host over IPv6 must reach it the same way.
//!
//! The forwarder for calls above 4 people is `VEIL_FORWARDER` if set. Otherwise, when the
//! host also runs its own rendezvous, it runs its own forwarder on a third port, reachable
Expand Down Expand Up @@ -43,7 +45,7 @@
//! `MediaSession::apply` to its own task when calls grow.

use std::collections::HashSet;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use std::sync::Arc;
use std::time::Duration;

Expand Down Expand Up @@ -127,9 +129,9 @@ pub async fn run(
(Some(node), Some(_)) => node.resolve_ipv6().await,
_ => None,
};
let rendezvous = match configured {
Some(addr) => addr,
None => own_server(lan, Own::Rendezvous, &identity, room_id, config.local_only)?,
let (rendezvous, rendezvous6) = match configured {
Some(addr) => (addr, None),
None => own_server(lan, Own::Rendezvous, &identity, room_id, config.local_only, v6)?,
};
let forwarder = match (
resolve(config.forwarder.as_ref(), "forwarder")
Expand All @@ -142,13 +144,9 @@ pub async fn run(
configured,
) {
(Some(addr), _) => Some(addr),
(None, None) => Some(own_server(
lan,
Own::Forwarder,
&identity,
room_id,
config.local_only,
)?),
(None, None) => Some(
own_server(lan, Own::Forwarder, &identity, room_id, config.local_only, None)?.0,
),
(None, Some(_)) => None,
};
let started = if config.persistent {
Expand Down Expand Up @@ -183,7 +181,7 @@ pub async fn run(
let until_end = false;
let mut relay = RelayAddrs::from(rendezvous);
if configured.is_none() {
relay.addrs = hosted_addresses(rendezvous, None, config.local_only);
relay.addrs = hosted_addresses(rendezvous, None, rendezvous6, config.local_only);
}
let expires = new_invite(
&host,
Expand Down Expand Up @@ -225,6 +223,7 @@ pub async fn run(
};
let ports = PortStatus::new(router.as_ref(), relay_router.as_ref());
let v6_port = V6Port::start(config.open_port, v6, port);
let relay_v6_port = V6Port::start(config.open_port, rendezvous6, rendezvous.addr.port());
// Only a public node can dial in from outside; the host's own rendezvous cannot.
let mut reach = Reachability::default();
let mut checking = config
Expand Down Expand Up @@ -270,6 +269,8 @@ pub async fn run(
relay_router,
ports,
v6_port,
rendezvous6,
relay_v6_port,
at6,
reach,
persistent,
Expand All @@ -285,18 +286,26 @@ async fn publish_addresses(host: &HostHandle, addrs: &[SocketAddr]) {

/// Where guests reach the host's own helper. In a Local only call it listens on every
/// interface, so its local scope addresses are listed too (IPv6-only LANs need them).
/// Otherwise only the router's public mapping and the LAN address are given, as before.
/// Otherwise the router's public mapping, the public IPv6 address `v6` when the helper
/// listens there (at its own port), and the LAN address.
fn hosted_addresses(
node: NodeAddr,
public: Option<SocketAddr>,
v6: Option<Ipv6Addr>,
local_only: bool,
) -> Vec<SocketAddr> {
let extra = if local_only {
veil_net::local::local_candidates(node.addr.port())
} else {
Vec::new()
};
let mut addrs: Vec<_> = public.into_iter().chain([node.addr]).chain(extra).collect();
let v6 = v6.map(|ip| SocketAddr::new(ip.into(), node.addr.port()));
let mut addrs: Vec<_> = public
.into_iter()
.chain(v6)
.chain([node.addr])
.chain(extra)
.collect();
let mut seen = HashSet::new();
addrs.retain(|at| seen.insert(*at));
addrs.truncate(veil_call::relay_field::MAX_RELAY_ADDRS);
Expand Down Expand Up @@ -352,22 +361,30 @@ enum Own {
/// long as the call's runtime.
/// Starts a rendezvous or forwarder for this call only: it serves `host`'s room `room_id` and
/// refuses everyone else's, so strangers who find its port cannot use this upload.
/// Returns its node and, for a rendezvous given the host's public IPv6 address `v6`, that
/// address when it listens there too.
fn own_server(
lan: Option<IpAddr>,
kind: Own,
host: &Identity,
room_id: [u8; 16],
local_only: bool,
) -> Result<NodeAddr, String> {
v6: Option<Ipv6Addr>,
) -> Result<(NodeAddr, Option<Ipv6Addr>), String> {
let what = match kind {
Own::Rendezvous => "rendezvous",
Own::Forwarder => "forwarder",
};
let identity = Identity::generate();
// Outside Local only the helper stays IPv4, as before: dual stack would put it on the
// host's global IPv6 address, reachable from the whole internet.
// A rendezvous goes on the host's public IPv6 address too, where the call already is:
// guests who reached the host over IPv6 link to each other through it. It serves this
// room only, so being on the internet lends nothing to strangers. The forwarder stays
// IPv4: members reach it on the LAN, or not at all (`forwarder_check.rs`).
let dual = matches!(kind, Own::Rendezvous) && v6.is_some();
let node = if local_only {
Node::bind_local(&identity, 0)
} else if dual {
Node::bind_any(&identity, 0)
} else {
Node::bind(&identity, SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), 0))
}
Expand All @@ -385,6 +402,8 @@ fn own_server(
key: node.id(),
addr: local_addr,
};
// `bind_any` falls back to IPv4 where the system has no dual-stack socket.
let v6 = v6.filter(|_| dual && !local_only && node.ipv6());
match kind {
Own::Rendezvous => drop(tokio::spawn(
RendezvousServer::new(node)
Expand All @@ -397,7 +416,7 @@ fn own_server(
.run(),
)),
}
Ok(addr)
Ok((addr, v6))
}

/// The link to show for `full`: a short one when that works as well, otherwise `full` itself.
Expand Down Expand Up @@ -461,3 +480,24 @@ async fn until(at: u64) {
tokio::time::sleep(Duration::from_secs(at - now)).await;
}
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
mod tests {
use super::*;

#[test]
fn the_rendezvous_is_listed_at_its_ipv6_address_too() {
let node = NodeAddr {
key: Identity::generate().public(),
addr: "192.168.1.20:7001".parse().unwrap(),
};
let public: SocketAddr = "81.2.69.160:7001".parse().unwrap();
let v6: Ipv6Addr = "2001:db8::20".parse().unwrap();
let addrs = hosted_addresses(node, Some(public), Some(v6), false);
let at6: SocketAddr = "[2001:db8::20]:7001".parse().unwrap();
assert_eq!(addrs, vec![public, at6, node.addr]);
// Without IPv6, as before.
assert_eq!(hosted_addresses(node, None, None, false), vec![node.addr]);
}
}
18 changes: 15 additions & 3 deletions crates/veil-app/src/engine/host/hosting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! the leave dialog that fails leaves this device host and says so.

use std::collections::HashMap;
use std::net::SocketAddr;
use std::net::{Ipv6Addr, SocketAddr};
use std::sync::Arc;
use std::time::{Duration, Instant};

Expand Down Expand Up @@ -61,6 +61,10 @@ pub(in crate::engine) struct Hosting {
pub relay_router: Option<Router>,
pub ports: PortStatus,
pub v6_port: Option<V6Port>,
/// The public IPv6 address the host's own rendezvous listens on, if it does.
pub rendezvous6: Option<Ipv6Addr>,
/// That rendezvous port's IPv6 pinhole, asked for with the call's.
pub relay_v6_port: Option<V6Port>,
pub at6: Option<SocketAddr>,
pub reach: Reachability,
pub persistent: bool,
Expand Down Expand Up @@ -333,7 +337,7 @@ impl Hosting {
if let Some(addr) = public {
crate::note!("rendezvous: guests on the internet reach it at {addr}");
}
self.relay.addrs = hosted_addresses(self.rendezvous, public, local_only);
self.relay.addrs = hosted_addresses(self.rendezvous, public, self.rendezvous6, local_only);
let ports = self.ports.view();
self.shared.update(|view| view.router = ports);
if self.ports.settled() {
Expand All @@ -351,12 +355,20 @@ impl Hosting {
self.shared.update(|view| view.reach = reach);
}
}
// Logged and renewed only: whether guests reach the call is checked above.
// shortcut: a refused rendezvous pinhole is logged, not shown in People as
// `RouterPort::GuestsApart` is for IPv4. Show it there if it proves common.
opened = next_v6(&mut self.relay_v6_port) => {
if !opened {
crate::note!("rendezvous: no IPv6 pinhole, so guests on IPv6 may not reach each other");
}
}
verdict = self.reach.next() => self.shared.update(|view| view.reach = verdict),
}
moderated::carry_out(&self.host, &mut self.session, &mut knocks).await;
};
let close_v6 = async {
if let Some(v6_port) = self.v6_port {
for v6_port in [self.v6_port, self.relay_v6_port].into_iter().flatten() {
v6_port.close().await;
}
};
Expand Down
27 changes: 15 additions & 12 deletions crates/veil-app/src/engine/host/successor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! until the call ends. They serve only this device's own room, and a later offer reuses them
//! ([`Prepared::reseal`]). Stop them on a lost offer if people hand over often.

use std::net::SocketAddr;
use std::net::{Ipv6Addr, SocketAddr};
use std::sync::Arc;

use tokio::sync::mpsc::Receiver;
Expand All @@ -37,6 +37,7 @@ use crate::engine::view::Shared;
pub(in crate::engine) struct Prepared {
pub contact: Vec<u8>,
rendezvous: NodeAddr,
rendezvous6: Option<Ipv6Addr>,
configured: Option<NodeAddr>,
forwarder: Option<NodeAddr>,
relay: RelayAddrs,
Expand All @@ -61,30 +62,27 @@ pub(in crate::engine) async fn prepare(
veil_net::family::global_ipv6()
};
let configured = resolve(config.rendezvous.as_ref(), "rendezvous").await?;
let rendezvous = match configured {
Some(addr) => addr,
None => own_server(lan, Own::Rendezvous, identity, room_id, config.local_only)?,
let (rendezvous, rendezvous6) = match configured {
Some(addr) => (addr, None),
None => own_server(lan, Own::Rendezvous, identity, room_id, config.local_only, v6)?,
};
let forwarder = match (resolve(config.forwarder.as_ref(), "forwarder").await?, configured) {
(Some(addr), _) => Some(addr),
(None, None) => Some(own_server(
lan,
Own::Forwarder,
identity,
room_id,
config.local_only,
)?),
(None, None) => Some(
own_server(lan, Own::Forwarder, identity, room_id, config.local_only, None)?.0,
),
(None, Some(_)) => None,
};
let mut relay = RelayAddrs::from(rendezvous);
if configured.is_none() {
relay.addrs = hosted_addresses(rendezvous, None, config.local_only);
relay.addrs = hosted_addresses(rendezvous, None, rendezvous6, config.local_only);
}
let addrs = advertised(config, v6, lan, port);
let contact = seal(identity, room_id, epoch, &addrs, &relay)?;
Ok(Prepared {
contact,
rendezvous,
rendezvous6,
configured,
forwarder,
relay,
Expand Down Expand Up @@ -145,6 +143,7 @@ pub(in crate::engine) async fn take_over(
session.set_host(me);
let Prepared {
rendezvous,
rendezvous6,
configured,
forwarder,
relay,
Expand All @@ -166,6 +165,7 @@ pub(in crate::engine) async fn take_over(
veil_net::family::global_ipv6()
};
let v6_port = V6Port::start(config.open_port, v6, port);
let relay_v6_port = V6Port::start(config.open_port, rendezvous6, rendezvous.addr.port());
let mut reach = Reachability::default();
if let Some(at) = config.advertise.first() {
check(&mut reach, &call, configured, *at);
Expand Down Expand Up @@ -209,6 +209,8 @@ pub(in crate::engine) async fn take_over(
relay_router,
ports,
v6_port,
rendezvous6,
relay_v6_port,
at6: None,
reach,
persistent: true,
Expand All @@ -234,6 +236,7 @@ mod tests {
let mut prepared = Prepared {
contact: seal(&me, room, 3, &addrs, &relay).unwrap(),
rendezvous: node,
rendezvous6: None,
configured: None,
forwarder: None,
relay: relay.clone(),
Expand Down
Loading