pub mod harness;
pub use harness::{
AtpPathEventKind, AtpPathExecutionResult, AtpPathLabError, AtpPathLabHarness,
AtpPathTestConfig, AtpPathTraceEvent, AtpPathValidation,
};
use crate::atp::path::PathKind;
use crate::lab::AtpLabRegime;
use crate::net::atp::path::NatProfile;
#[must_use]
pub fn regime_to_nat_profile(regime: AtpLabRegime) -> Option<NatProfile> {
match regime {
AtpLabRegime::EasyNat => Some(NatProfile::LikelyEasyNat),
AtpLabRegime::HardNat | AtpLabRegime::SymmetricNat => Some(NatProfile::HardSymmetricNat),
AtpLabRegime::UdpBlocked => Some(NatProfile::UdpBlocked),
AtpLabRegime::Ipv6Direct => Some(NatProfile::Ipv6Direct),
_ => None,
}
}
#[must_use]
pub fn regime_to_path_kind(regime: AtpLabRegime) -> Option<PathKind> {
match regime {
AtpLabRegime::LanMulticast => Some(PathKind::LanMulticast),
AtpLabRegime::EasyNat => Some(PathKind::NatPunchedUdp),
AtpLabRegime::ExplicitPublicUdp => Some(PathKind::ExplicitPublicUdp),
AtpLabRegime::Ipv6Direct => Some(PathKind::PublicIpv6),
AtpLabRegime::HardNat | AtpLabRegime::SymmetricNat => Some(PathKind::NatPunchedUdp),
AtpLabRegime::UdpBlocked => None, AtpLabRegime::RelayOnly => Some(PathKind::AtpRelayUdp),
AtpLabRegime::RelayTcpTls443 => Some(PathKind::AtpRelayTcpTls443),
AtpLabRegime::TailscalePrivateRoute => Some(PathKind::TailscaleIp),
AtpLabRegime::MasqueConnectUdpProxy => Some(PathKind::MasqueConnectUdp),
AtpLabRegime::OfflineMailbox => Some(PathKind::OfflineMailbox),
_ => None,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn regime_nat_profile_mapping_covers_network_regimes() {
assert_eq!(
regime_to_nat_profile(AtpLabRegime::EasyNat),
Some(NatProfile::LikelyEasyNat)
);
assert_eq!(
regime_to_nat_profile(AtpLabRegime::Ipv6Direct),
Some(NatProfile::Ipv6Direct)
);
assert_eq!(
regime_to_nat_profile(AtpLabRegime::HardNat),
Some(NatProfile::HardSymmetricNat)
);
assert_eq!(
regime_to_nat_profile(AtpLabRegime::UdpBlocked),
Some(NatProfile::UdpBlocked)
);
}
#[test]
fn regime_path_kind_mapping_covers_direct_paths() {
assert_eq!(
regime_to_path_kind(AtpLabRegime::LanMulticast),
Some(PathKind::LanMulticast)
);
assert_eq!(
regime_to_path_kind(AtpLabRegime::EasyNat),
Some(PathKind::NatPunchedUdp)
);
assert_eq!(
regime_to_path_kind(AtpLabRegime::ExplicitPublicUdp),
Some(PathKind::ExplicitPublicUdp)
);
assert_eq!(
regime_to_path_kind(AtpLabRegime::Ipv6Direct),
Some(PathKind::PublicIpv6)
);
assert_eq!(
regime_to_path_kind(AtpLabRegime::RelayOnly),
Some(PathKind::AtpRelayUdp)
);
assert_eq!(
regime_to_path_kind(AtpLabRegime::RelayTcpTls443),
Some(PathKind::AtpRelayTcpTls443)
);
assert_eq!(
regime_to_path_kind(AtpLabRegime::MasqueConnectUdpProxy),
Some(PathKind::MasqueConnectUdp)
);
assert_eq!(
regime_to_path_kind(AtpLabRegime::OfflineMailbox),
Some(PathKind::OfflineMailbox)
);
}
#[test]
fn udp_blocked_regime_forces_fallback_paths() {
assert_eq!(regime_to_path_kind(AtpLabRegime::UdpBlocked), None);
}
}