Preserve mesh transport through an internet exit in 1.0.3-rc1
On macOS a connected socket using the physical source lost its route before PF could see the packet. Fresh sockets could leave via the physical uplink, but Darwin rejected reverse-NAT replies delivered to a utun address there. With two live meshes remote control and data sessions expired within a minute. Install matching interface-scoped uplink routes before capturing the two unscoped defaults. Keep PF state on the physical interface, preserve transport ports and return tagged replies via loopback. Reconcile uplink changes and recover only owned routes using a private journal and kernel markers. On Windows keep existing LAN routes, retain recent verified reconnect paths and refresh the gateway and relay DNS without replacing the split defaults. Exercise two memberships of the same peer, new and established native transport sockets, ordinary application traffic and scoped route cleanup. Run hosted macOS and Windows native regressions on affected changes. Bump the packages to 1.0.3-rc1 and encode Debian prereleases with a tilde so apt can upgrade to the final release. Mesh wire formats and identities are unchanged. Checked workspace formatting, strict Clippy and the full workspace suite on macOS (586 passed, four opt-in tests skipped by default). The privileged macOS kernel test passed separately. A launchd trial of the RC kept master and ch reachable over both meshes and used the external exit past the original timeout. Disabling the exit restored the physical IP and cleared the routes. Linux ARM64 passed four real-agent exit tests and the privileged netns regression. The RC APK passed the dual-subnet UDP/ICMP test on an Android 37 ARM64 emulator. Verified Debian and pacman version ordering. Native Windows execution is covered by the hosted workflow and was not run on this Mac.
This commit is contained in:
1 parent
32aa73721a
commit
a189d0ad3e
28 files changed
+1698
-185
No files matched your search
@@ -19,10 +19,10 @@
|
||||
|
||||
use crate::BoxFuture;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::exit::{ExitHostPlan, ExitHostReport, ExitHostRules};
|
||||
use super::macos_exit::{apply_plan, clear_all, run_tool};
|
||||
use super::macos_exit::{HostState, apply_plan, clear_all, refresh_client, run_tool};
|
||||
use super::{BroadcastHostRules, BroadcastRulesPlan, BroadcastRulesReport, RuleOutcome};
|
||||
|
||||
/// The limited-broadcast destination routed through the overlay interface.
|
||||
@@ -68,17 +68,25 @@ fn firewall_todo(plan: &BroadcastRulesPlan) -> String {
|
||||
/// `pf` plus `route` for exit nodes (see [`super::macos_exit`]).
|
||||
#[derive(Debug, Default)]
|
||||
pub struct MacosHostRules {
|
||||
/// The reference `pfctl -E` handed out, held while exit-node rules need
|
||||
/// `pf` on and released when they are removed.
|
||||
pub(super) pf_token: Arc<Mutex<Option<String>>>,
|
||||
/// The PF reference and the physical routes owned by this agent.
|
||||
state: Arc<HostState>,
|
||||
}
|
||||
|
||||
impl MacosHostRules {
|
||||
/// Creates the host rules.
|
||||
/// Creates host rules with process-lifetime ownership. System services
|
||||
/// use [`Self::with_state_dir`] for recovery after abrupt termination.
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Tie crash recovery to this agent's state directory, even when macOS
|
||||
/// assigns its utun a different number on the next run.
|
||||
pub fn with_state_dir(dir: &std::path::Path) -> Self {
|
||||
Self {
|
||||
state: Arc::new(HostState::with_state_dir(dir)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Installs the route, replacing one this agent added earlier so the call
|
||||
/// can be repeated. The delete is best effort: a route that is not there
|
||||
/// is the state the add then reaches anyway.
|
||||
@@ -95,7 +103,7 @@ impl ExitHostRules for MacosHostRules {
|
||||
fn apply<'a>(&'a self, plan: &'a ExitHostPlan) -> BoxFuture<'a, ExitHostReport> {
|
||||
Box::pin(async move {
|
||||
let job_plan = plan.clone();
|
||||
let token = Arc::clone(&self.pf_token);
|
||||
let token = Arc::clone(&self.state);
|
||||
tokio::task::spawn_blocking(move || apply_plan(&run_tool, &token, &job_plan))
|
||||
.await
|
||||
.unwrap_or_else(|err| {
|
||||
@@ -113,10 +121,23 @@ impl ExitHostRules for MacosHostRules {
|
||||
})
|
||||
}
|
||||
|
||||
fn refresh<'a>(&'a self, plan: &'a ExitHostPlan) -> BoxFuture<'a, Option<RuleOutcome>> {
|
||||
Box::pin(async move {
|
||||
if !plan.client {
|
||||
return None;
|
||||
}
|
||||
let state = Arc::clone(&self.state);
|
||||
let plan = plan.clone();
|
||||
tokio::task::spawn_blocking(move || refresh_client(&run_tool, &state, &plan))
|
||||
.await
|
||||
.unwrap_or_else(|err| Some(RuleOutcome::Failed(err.to_string())))
|
||||
})
|
||||
}
|
||||
|
||||
fn clear<'a>(&'a self, interface: &'a str) -> BoxFuture<'a, ()> {
|
||||
Box::pin(async move {
|
||||
let name = interface.to_string();
|
||||
let token = Arc::clone(&self.pf_token);
|
||||
let token = Arc::clone(&self.state);
|
||||
let _ = tokio::task::spawn_blocking(move || clear_all(&run_tool, &token, &name)).await;
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user