Let the elected opener invite its authenticated peer to dial back after a forward TCP attempt fails. Limit the reverse attempt, correlate failure replies with the active generation and cancel it on membership or policy changes. Only mutually enabled carriers with link-reverse v1 participate. Keep native TCP/TLS wire v2 and use the advertised TCP port with direct control-path or configured bootstrap IPs. Race candidate connects, bound handshakes, verify the Ed25519 SPKI and wake every link-close waiter. Add two separately versioned embedded Shoes profiles. VLESS runs over XHTTP stream-one with HTTP/2 and pinned TLS 1.3. Shadowsocks 2022 selects AES-128-GCM or AES-256-GCM per connection. Allocate a new credential and request path or salt for each attempt and admit it once through private mesh control. Both profiles terminate a local mesh service and retain the existing inner WireGuard tunnel. Attribute the adapted Shoes v0.3.8 wire code and keep its MIT license. Preferred ports are 9443 and 9444. Expose WireGuard, iroh, Native and Shoes as collapsible groups in the desktop and Android transport editor. A partial group's checkbox enables all its children. Keep the global protocol priority, save the concrete list per network and preserve explicitly saved choices including none. New networks enable all six carriers. Keep the existing CLI protocol names and unqualified port behavior. Advance local IPC to v30 for the catalog labels and groups. The existing network identity and encrypted data formats for the four original protocols stay compatible. Checked formatting, strict workspace Clippy and the full macOS workspace test suite (684 passed, 8 opted out by default). The initial sandbox denied loopback sockets. A full run also exposed an overly broad control dispatch check in the existing standalone AWG test; restoring the transport contract fixed it. Ran the opt-in upstream Shoes 0.3.8 reference test on loopback for HTTP/2 and both Shadowsocks methods. Checked Android arm64 and Windows GNU targets by cross-compilation. No live DPI or physical-device network measurements were performed.
79 lines
2.7 KiB
Rust
79 lines
2.7 KiB
Rust
#![allow(missing_docs)]
|
|
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
|
|
use rustls::client::danger::ServerCertVerifier;
|
|
use rustls::pki_types::{ServerName, UnixTime};
|
|
use tsunagi::identity::DeviceIdentity;
|
|
use tsunagi_tcp_tls::cert::{PinnedEndpointVerifier, generate_self_signed_cert};
|
|
|
|
#[test]
|
|
fn test_generate_and_pin_certificate() {
|
|
let identity = DeviceIdentity::generate();
|
|
let peer_id = identity.endpoint_id();
|
|
|
|
let (cert, _key) =
|
|
generate_self_signed_cert(&identity.secret_bytes(), tsunagi_tcp_tls::cert::DEFAULT_SNI)
|
|
.expect("cert generation should succeed");
|
|
|
|
let verifier = PinnedEndpointVerifier::new(peer_id);
|
|
let server_name = ServerName::try_from(tsunagi_tcp_tls::cert::DEFAULT_SNI).unwrap();
|
|
|
|
let verified = verifier.verify_server_cert(&cert, &[], &server_name, &[], UnixTime::now());
|
|
|
|
assert!(
|
|
verified.is_ok(),
|
|
"certificate matching peer endpoint id must verify"
|
|
);
|
|
|
|
let other_identity = DeviceIdentity::generate();
|
|
let wrong_verifier = PinnedEndpointVerifier::new(other_identity.endpoint_id());
|
|
|
|
let wrong_verified =
|
|
wrong_verifier.verify_server_cert(&cert, &[], &server_name, &[], UnixTime::now());
|
|
|
|
assert!(
|
|
wrong_verified.is_err(),
|
|
"certificate with wrong endpoint id must fail verification"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn test_make_client_and_server_config() {
|
|
let identity = DeviceIdentity::generate();
|
|
let peer_id = identity.endpoint_id();
|
|
|
|
let (cert, key) = generate_self_signed_cert(&identity.secret_bytes(), "custom.example.com")
|
|
.expect("cert generation should succeed");
|
|
|
|
let server_config = tsunagi_tcp_tls::cert::make_server_config(cert, key);
|
|
assert!(server_config.is_ok());
|
|
|
|
let client_config = tsunagi_tcp_tls::cert::make_client_config(peer_id);
|
|
assert!(client_config.is_ok());
|
|
}
|
|
|
|
#[test]
|
|
fn unrelated_certificate_fields_cannot_satisfy_the_identity_pin() {
|
|
let expected = DeviceIdentity::generate().endpoint_id();
|
|
let key = rcgen::KeyPair::generate_for(&rcgen::PKCS_ED25519).unwrap();
|
|
let mut params = rcgen::CertificateParams::new(vec!["peer.invalid".into()]).unwrap();
|
|
params
|
|
.custom_extensions
|
|
.push(rcgen::CustomExtension::from_oid_content(
|
|
&[1, 3, 6, 1, 4, 1, 55555, 1],
|
|
expected.as_bytes().to_vec(),
|
|
));
|
|
let cert = params.self_signed(&key).unwrap();
|
|
assert!(
|
|
PinnedEndpointVerifier::new(expected)
|
|
.verify_server_cert(
|
|
cert.der(),
|
|
&[],
|
|
&ServerName::try_from("peer.invalid").unwrap(),
|
|
&[],
|
|
UnixTime::now()
|
|
)
|
|
.is_err()
|
|
);
|
|
}
|