### Start Triglav VPN Server Source: https://context7.com/19h/triglav/llms.txt Starts the Triglav server to accept client connections. Use --generate-key for ephemeral keys or --key for persistent key files. Multiple listen addresses and TCP fallback are supported. ```bash # Start server with auto-generated ephemeral key triglav server --generate-key --listen 0.0.0.0:7443 ``` ```bash # Start server with persistent key file triglav server --key /etc/triglav/server.key --generate-key --listen 0.0.0.0:7443 ``` ```bash # Print connection key and exit (useful for scripts) triglav server --key /etc/triglav/server.key --print-key ``` ```bash # Server with multiple listen addresses and TCP fallback triglav server --key server.key --listen 0.0.0.0:7443 --listen [::]:7443 --tcp-fallback true ``` ```text # Output: # ╔══════════════════════════════════════════╗ # ║ TRIGLAV SERVER ║ # ╚══════════════════════════════════════════╝ # Client Connection Key: # ────────────────────────────────────────────────── # tg1_Base64EncodedKeyWithServerAddresses... # ────────────────────────────────────────────────── ``` -------------------------------- ### Triglav Server: Start Server Source: https://github.com/19h/triglav/blob/master/README.md Launches the Triglav server, listening on the specified address and port, and using the provided key file for authentication. ```bash triglav server --listen 0.0.0.0:7443 --key /path/to/key ``` -------------------------------- ### Start Docker Test Environment Source: https://github.com/19h/triglav/blob/master/README.md Launch the Triglav Docker test environment using docker-compose. This spins up the Triglav server, clients, routers, a chaos agent, and monitoring tools. ```bash cd docker/testnet docker-compose up ``` -------------------------------- ### Connect to Server and Start Maintenance Source: https://context7.com/19h/triglav/llms.txt Connects the MultipathManager to a server using its public key and starts a background maintenance loop for health checks and retries. The server's public key must be provided in Base64 format. ```rust // Connect to server (server's public key from connection string) let server_pubkey = PublicKey::from_base64("server_public_key_base64")?; manager.connect(server_pubkey).await?; // Start background maintenance (health checks, retries, pings) manager.start_maintenance_loop(); ``` -------------------------------- ### Build Xcode App from Command Line Source: https://github.com/19h/triglav/blob/master/apps/macos/README.md Builds the Triglav macOS application using the provided script, assuming a full Xcode installation. ```bash ./apps/macos/scripts/build-xcode-app.sh ``` -------------------------------- ### Manage Triglav Configurations Source: https://context7.com/19h/triglav/llms.txt Illustrates loading configurations from TOML files, using default paths, creating example configurations, initializing logging, and programmatically setting up server and client configurations. ```rust use triglav::config::{Config, ServerConfig, ClientConfig, LoggingConfig, init_logging}; use triglav::multipath::UplinkConfig; use std::path::Path; fn main() -> triglav::Result<()> { // Load configuration from file let config = Config::load("/etc/triglav/config.toml")?; // Or use default path let default_path = Config::default_path(); if default_path.exists() { let config = Config::load(&default_path)?; } // Create example configuration let example = Config::example(); example.save("/tmp/triglav-example.toml")?; // Initialize logging from config let log_config = LoggingConfig { level: "info".to_string(), format: "text".to_string(), color: true, file: None, }; init_logging(&log_config)?; // Programmatic configuration let config = Config { server: ServerConfig { enabled: true, listen_addrs: vec!["0.0.0.0:7443".parse()?], max_connections: 10000, tcp_fallback: true, ..Default::default() }, client: ClientConfig { enabled: false, auto_discover: true, uplinks: vec![ UplinkConfig { id: "primary".into(), interface: Some("en0".into()), remote_addr: "server.example.com:7443".parse()?, weight: 100, ..Default::default() }, ], socks_port: Some(1080), http_proxy_port: Some(8080), ..Default::default() }, ..Default::default() }; config.validate()?; Ok(()) } ``` -------------------------------- ### Create SOCKS5 and HTTP Proxy Servers with Triglav Source: https://context7.com/19h/triglav/llms.txt Set up SOCKS5 and HTTP proxy servers to route traffic through a multi-path connection managed by Triglav. This example shows configuration and running the servers. ```rust use triglav::proxy::{Socks5Config, Socks5Server, HttpProxyConfig, HttpProxyServer}; use triglav::multipath::{MultipathManager, MultipathConfig}; use triglav::crypto::KeyPair; use std::sync::Arc; #[tokio::main] async fn main() -> triglav::Result<()> { let keypair = KeyPair::generate(); let manager = Arc::new(MultipathManager::new(MultipathConfig::default(), keypair)); // Connect manager to server first... // manager.add_uplink(...)?; // manager.connect(server_pubkey).await?; // Create SOCKS5 proxy let socks_config = Socks5Config { listen_addr: "127.0.0.1:1080".parse()?, allow_no_auth: true, username: None, // Or Some("user".to_string()) for auth password: None, // Or Some("pass".to_string()) for auth connect_timeout_secs: 30, max_connections: 1000, }; let socks_server = Socks5Server::new(socks_config, Arc::clone(&manager)); // Run SOCKS5 in background tokio::spawn(async move { if let Err(e) = socks_server.run().await { eprintln!("SOCKS5 error: {}", e); } }); // Create HTTP proxy let http_config = HttpProxyConfig { listen_addr: "127.0.0.1:8080".parse()?, connect_timeout_secs: 30, max_connections: 1000, }; let http_server = HttpProxyServer::new(http_config, Arc::clone(&manager)); // Run HTTP proxy (blocks) http_server.run().await?; Ok(()) } ``` -------------------------------- ### Start E2E Validation Server Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Initiate the end-to-end validation server in server-only mode for testing across machines. Note the authentication key printed to stdout. ```bash # On server machine (e.g., VPS) ./e2e_validation.sh --server-only ``` -------------------------------- ### Triglav Server: Run as Daemon Source: https://github.com/19h/triglav/blob/master/README.md Starts the Triglav server in the background as a daemon process, logging its PID to a specified file. ```bash triglav server --daemon --pid-file /var/run/triglav.pid ``` -------------------------------- ### Run End-to-End Validation as Server Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Start the `e2e_validation.sh` script in server-only mode, typically on Machine A. ```bash # Machine A (server) ./e2e_validation.sh --server-only ``` -------------------------------- ### Run End-to-End Validation as Client Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Start the `e2e_validation.sh` script in client-only mode on Machine B, connecting to a specified server URI. ```bash # Machine B (client) ./e2e_validation.sh --client-only "triglav://..." ``` -------------------------------- ### Build Triglav Binary with Cargo Source: https://github.com/19h/triglav/blob/master/apps/macos/README.md Builds the core Triglav Rust binary using Cargo. This is necessary if the CLI is not installed globally. ```bash cargo build ``` -------------------------------- ### Run Multiple Test Suites Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute multiple test suites concurrently, for example, using the `--quick` and `--stress` flags. ```bash # Multiple test suites ./run_physical_tests.sh --quick --stress ``` -------------------------------- ### Triglav Proxy Mode: HTTP Proxy Source: https://github.com/19h/triglav/blob/master/README.md Starts Triglav as an HTTP proxy on the specified port. ```bash triglav connect --http-proxy 8080 ``` -------------------------------- ### Setup Network Impairment Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Configure network impairments such as latency and packet loss on a specified interface using `network_impairment.sh`. ```bash # Add 100ms latency to WiFi sudo ./network_impairment.sh setup en0 100 0 ``` ```bash # Add 100ms latency + 5% packet loss sudo ./network_impairment.sh setup en0 100 5 ``` ```bash # Add bandwidth limit (1 Mbps) sudo ./network_impairment.sh setup en0 0 0 1000 ``` ```bash # Simulate poor mobile connection (200ms, 10% loss) sudo ./network_impairment.sh setup en0 200 10 ``` -------------------------------- ### Triglav Proxy Mode: SOCKS5 Proxy Source: https://github.com/19h/triglav/blob/master/README.md Starts Triglav as a SOCKS5 proxy on the specified port. Does not require root privileges. ```bash triglav connect --socks 1080 --auto-discover ``` -------------------------------- ### Monitor Uplink Quality with Triglav Source: https://context7.com/19h/triglav/llms.txt Use QualityMetrics to monitor uplink quality and connection health. This snippet demonstrates how to get quality summaries and individual uplink metrics. ```rust use triglav::metrics::QualityMetrics; use triglav::multipath::{MultipathManager, MultipathConfig, UplinkConfig}; use triglav::crypto::KeyPair; use std::sync::Arc; #[tokio::main] async fn main() -> triglav::Result<()> { let keypair = KeyPair::generate(); let manager = Arc::new(MultipathManager::new(MultipathConfig::default(), keypair)); // Add uplinks... // manager.add_uplink(...)?; // Get quality summary for all uplinks let summary = manager.quality_summary(); println!("Usable uplinks: {}/{}", summary.usable_uplinks, summary.total_uplinks); println!("Average RTT: {:?}", summary.avg_rtt); println!("Average loss: {:.2}%", summary.avg_loss * 100.0); println!("Total bandwidth: {} bytes/sec", summary.total_bandwidth.bytes_per_sec); // Get individual uplink metrics for uplink in manager.uplinks() { let metrics = uplink.quality_metrics(); println!("\nUplink {}:", uplink.id()); println!(" RTT: {:?}", metrics.rtt); println!(" Jitter: {:?}", metrics.jitter); println!(" Packet loss: {:.2}%", metrics.packet_loss * 100.0); println!(" Health: {:?}", metrics.health); println!(" Score: {}/100", metrics.score()); println!(" Status: {}", metrics.status()); if metrics.has_issues() { println!(" WARNING: Uplink has quality issues!"); } } // Get throughput metrics let throughput = manager.throughput_summary(); println!("\nThroughput Summary:"); println!(" Total: {:.2} Mbps", throughput.total_bandwidth_mbps); // Get effective throughput for specific uplink if let Some(eff) = manager.effective_throughput(0) { println!(" Uplink 0 effective: {:.2} Mbps", eff.effective_bps / 1_000_000.0); println!(" Transfer time for 1MB: {:?}", eff.transfer_time(1_000_000)); } // Find best uplink for a transfer if let Some(best) = manager.best_uplink_for_size(10_000_000) { // 10MB println!("Best uplink for 10MB transfer: {}", best); } Ok(()) } ``` -------------------------------- ### Get Throughput Summary Source: https://context7.com/19h/triglav/llms.txt Obtains a summary of the network throughput, specifically the total bandwidth in Megabits per second (Mbps). This metric is useful for assessing the data transfer rate. ```rust // Get throughput metrics let throughput = manager.throughput_summary(); println!("Throughput: {:.2} Mbps", throughput.total_bandwidth_mbps); ``` -------------------------------- ### Get Connection Quality Summary Source: https://context7.com/19h/triglav/llms.txt Retrieves a summary of the current connection quality, including the number of usable and total uplinks, average Round-Trip Time (RTT), and average packet loss percentage. This provides insights into the network's performance. ```rust // Check connection quality let quality = manager.quality_summary(); println!("Quality: {}/{} uplinks, RTT: {:?}, Loss: {:.1}%", quality.usable_uplinks, quality.total_uplinks, quality.avg_rtt, quality.avg_loss * 100.0 ); ``` -------------------------------- ### Initialize and Configure MultipathManager Source: https://context7.com/19h/triglav/llms.txt Demonstrates how to set up the MultipathManager with custom configurations for scheduling, aggregation, and deduplication. Ensure all necessary imports are present. ```rust use triglav::prelude::*; use triglav::multipath::{MultipathConfig, MultipathManager, UplinkConfig, SchedulingStrategy}; use triglav::transport::TransportProtocol; use std::sync::Arc; #[tokio::main] async fn main() -> triglav::Result<()> { // Generate keypair for this client let keypair = KeyPair::generate(); // Configure multipath manager let mut config = MultipathConfig::default(); config.scheduler.strategy = SchedulingStrategy::Adaptive; config.aggregation_mode = triglav::multipath::AggregationMode::Full; // Enable bandwidth aggregation config.deduplication = true; config.max_uplinks = 8; // Create manager let manager = Arc::new(MultipathManager::new(config, keypair)); ``` -------------------------------- ### Triglav Operations: Generate Shell Completions Source: https://github.com/19h/triglav/blob/master/README.md Generates shell completion scripts for Triglav, for example, for Bash. ```bash triglav completions bash > /etc/bash_completion.d/triglav ``` -------------------------------- ### Run Basic and All Physical Tests Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute quick connectivity tests or run the full suite of physical network tests. ```bash # Run basic connectivity tests ./run_physical_tests.sh --quick ``` ```bash # Run all tests ./run_physical_tests.sh --all ``` -------------------------------- ### Parse and Create AuthKey Connection Keys Source: https://context7.com/19h/triglav/llms.txt Shows how to parse a connection key string to extract server public key and addresses, and how to create a new AuthKey from a keypair and a list of server addresses. ```rust use triglav::types::AuthKey; use std::net::SocketAddr; fn main() -> triglav::Result<()> { // Parse connection key from server let key_string = "tg1_Base64EncodedConnectionKey..."; let auth_key = AuthKey::parse(key_string)?; // Extract server information let server_pubkey: [u8; 32] = auth_key.server_pubkey(); let server_addrs: Vec = auth_key.server_addrs(); println!("Server addresses: {:?}", server_addrs); // Create new connection key let keypair = triglav::crypto::KeyPair::generate(); let addresses: Vec = vec![ "203.0.113.1:7443".parse()?, "203.0.113.2:7443".parse()?, ]; let new_auth_key = AuthKey::new(*keypair.public.as_bytes(), addresses); let key_string = new_auth_key.to_string(); println!("Connection key: {}", key_string); // Share this key with clients Ok(()) } ``` -------------------------------- ### Configure Triglav TUN Mode (Full VPN) Source: https://context7.com/19h/triglav/llms.txt Creates a virtual TUN interface for full VPN tunneling, routing all traffic through the VPN. Use --auto-discover for automatic configuration. Supports split tunneling, excluding local networks, custom TUN settings, and DNS forwarding. ```bash # Full tunnel mode - route ALL traffic through VPN sudo triglav tun tg1_ --full-tunnel --auto-discover ``` ```bash # Split tunnel - only route specific networks sudo triglav tun tg1_ --route 10.0.0.0/8 --route 172.16.0.0/12 --route 192.168.0.0/16 ``` ```bash # Exclude local network from tunnel sudo triglav tun tg1_ --full-tunnel --exclude 192.168.1.0/24 ``` ```bash # Specify interfaces and custom TUN settings sudo triglav tun tg1_ \ -i en0 -i en1 -i pdp_ip0 \ --tun-name tg0 \ --ipv4 10.0.85.1 \ --full-tunnel \ --strategy adaptive ``` ```bash # Enable DNS through tunnel sudo triglav tun tg1_ --full-tunnel --dns --dns-server 1.1.1.1:53 ``` ```text # Output: # → Server: ● 203.0.113.1:7443 # → Interfaces: ● en0 ● en1 # → TUN device: tg0 # IPv4: 10.0.85.1 # Mode: Full Tunnel (all traffic) # ✓ Connected! # ● Tunnel running. Press Ctrl+C to stop. ``` -------------------------------- ### Run All Unit and Integration Tests Source: https://github.com/19h/triglav/blob/master/README.md Executes all available unit and integration tests for the project. This command is useful for a comprehensive check of the codebase. ```bash cargo test ``` -------------------------------- ### Open Xcode Project Source: https://github.com/19h/triglav/blob/master/apps/macos/README.md Opens the main Xcode project file for the Triglav macOS app and its privileged helper. ```bash open apps/macos/Triglav.xcodeproj ``` -------------------------------- ### List Dummynet Pipes Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Display the current dummynet pipes configuration using `dnctl list`, useful for network impairment troubleshooting. ```bash # Check dummynet pipes sudo dnctl list ``` -------------------------------- ### Execute TUN Device Test Binary Source: https://github.com/19h/triglav/blob/master/README.md Directly executes the compiled TUN device test binary. This also requires root privileges. ```bash sudo ./target/debug/tun_test ``` -------------------------------- ### Build Triglav from Source Source: https://github.com/19h/triglav/blob/master/README.md Compile the Triglav project from its source code using Cargo. This is the standard method for building the application. ```bash git clone https://github.com/triglav/triglav cd triglav cargo build --release ``` -------------------------------- ### List Available Network Interfaces Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Use the `network_impairment.sh` script to list all available network interfaces on the system. ```bash sudo ./network_impairment.sh list-interfaces ``` -------------------------------- ### Configure Adaptive Scheduling Strategy Source: https://context7.com/19h/triglav/llms.txt Sets up the adaptive scheduling strategy, which balances RTT, loss, bandwidth, and NAT. Use `Default::default()` for other parameters. ```rust use triglav::multipath::{SchedulerConfig, SchedulingStrategy, MultipathConfig, MultipathManager}; use triglav::crypto::KeyPair; fn main() { // Adaptive scheduling (default) - balances RTT, loss, bandwidth, NAT let adaptive_config = SchedulerConfig { strategy: SchedulingStrategy::Adaptive, rtt_weight: 0.35, loss_weight: 0.35, bandwidth_weight: 0.20, nat_penalty_weight: 0.10, ..Default::default() }; // Apply to multipath manager let keypair = KeyPair::generate(); let mut mp_config = MultipathConfig::default(); mp_config.scheduler = adaptive_config; let manager = MultipathManager::new(mp_config, keypair); } ``` -------------------------------- ### Run SwiftPM Project Directly Source: https://github.com/19h/triglav/blob/master/apps/macos/README.md Navigates to the macOS app directory and runs the project directly using Swift Package Manager. ```bash cd apps/macos swift run ``` -------------------------------- ### Send Data with Flow Affinity Source: https://context7.com/19h/triglav/llms.txt Sends data over a specific flow using the MultipathManager, ensuring consistency for protocols like TCP. The `allocate_flow` method is used to get a flow ID. ```rust // Send data with flow affinity (for TCP consistency) let flow_id = manager.allocate_flow(); let data = b"Hello through multi-path tunnel"; let seq = manager.send_on_flow(Some(flow_id), data).await?; println!("Sent packet with sequence: {}", seq); ``` -------------------------------- ### Run Multi-Interface Connectivity Test Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the multi-interface connectivity test to verify path diversity by sending traffic from multiple local IPs. ```bash cargo test --test physical_multipath test_multi_interface_connectivity -- --ignored --nocapture ``` -------------------------------- ### Run Interface Discovery Test Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the interface discovery test to verify the availability and independent usability of network interfaces. ```bash cargo test --test physical_multipath test_interface_discovery -- --ignored --nocapture ``` -------------------------------- ### Run All Physical Interface Tests Source: https://github.com/19h/triglav/blob/master/README.md Executes all tests that use real network interfaces. Requires multiple NICs and uses flags to ignore tests by default. ```bash cargo test --test physical_multipath -- --ignored --nocapture ``` -------------------------------- ### Build Triglav with Specific Feature Flags Source: https://github.com/19h/triglav/blob/master/README.md Build Triglav with different feature flags to customize the build. Use `--no-default-features --features cli` for a client-only build, or `--features full` for all features. ```bash cargo build --release # Default: CLI + metrics + server cargo build --release --no-default-features --features cli # Client only cargo build --release --features full # Everything ``` -------------------------------- ### Configure Lowest Latency Scheduling Strategy Source: https://context7.com/19h/triglav/llms.txt Sets up the lowest latency scheduling strategy, which always picks the fastest path. Use `Default::default()` for other parameters. ```rust use triglav::multipath::{SchedulerConfig, SchedulingStrategy, MultipathConfig, MultipathManager}; use triglav::crypto::KeyPair; fn main() { // Lowest latency - always pick fastest path let latency_config = SchedulerConfig { strategy: SchedulingStrategy::LowestLatency, ..Default::default() }; // Apply to multipath manager let keypair = KeyPair::generate(); let mut mp_config = MultipathConfig::default(); mp_config.scheduler = latency_config; let manager = MultipathManager::new(mp_config, keypair); } ``` -------------------------------- ### Run Specific Test Suite Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute a single test suite, such as 'bandwidth', using the `run_physical_tests.sh` script. ```bash # Run single test ./run_physical_tests.sh bandwidth ``` -------------------------------- ### Open Swift Package in Xcode Source: https://github.com/19h/triglav/blob/master/apps/macos/README.md Opens the Swift Package Manager definition file in Xcode, useful for the lightweight developer shell. ```bash open apps/macos/Package.swift ``` -------------------------------- ### Generate and Use X25519 KeyPairs Source: https://context7.com/19h/triglav/llms.txt Demonstrates generating X25519 keypairs for Diffie-Hellman key exchange, serializing/deserializing keys, and performing cryptographic operations like signing and verification with Ed25519. Also shows BLAKE3 hashing and secure random byte generation. ```rust use triglav::crypto::{KeyPair, PublicKey, SecretKey, SigningKeyPair, hash, random_bytes}; fn main() -> triglav::Result<()> { // Generate X25519 keypair for key exchange let keypair = KeyPair::generate(); println!("Public key: {}", keypair.public.to_base64()); // Serialize/deserialize keys let secret_b64 = keypair.secret.to_base64(); let restored_secret = SecretKey::from_base64(&secret_b64)?; let restored_keypair = KeyPair::from_secret(restored_secret); // Public key from bytes let pubkey_bytes: [u8; 32] = *keypair.public.as_bytes(); let restored_pubkey = PublicKey::from_bytes(pubkey_bytes); // Diffie-Hellman key exchange let alice = KeyPair::generate(); let bob = KeyPair::generate(); let alice_shared = alice.secret.diffie_hellman(&bob.public); let bob_shared = bob.secret.diffie_hellman(&alice.public); assert_eq!(alice_shared, bob_shared); // Same shared secret // Generate Ed25519 signing keypair let signing_key = SigningKeyPair::generate(); let message = b"Important message"; let signature = signing_key.sign(message); signing_key.verify(message, &signature)?; // Verify with only public key let public_bytes = signing_key.public_bytes(); SigningKeyPair::verify_with_public(&public_bytes, message, &signature)?; // BLAKE3 hashing let hash_result = hash(b"data to hash"); println!("Hash: {}", hex::encode(hash_result)); // Secure random bytes let nonce: [u8; 24] = random_bytes(); Ok(()) } ``` -------------------------------- ### Package App Bundle with Custom Binary Source: https://github.com/19h/triglav/blob/master/apps/macos/README.md Packages the Triglav macOS application into a .app bundle, allowing specification of a custom triglav CLI binary to embed. ```bash TRIGLAV_BIN=/path/to/triglav ./apps/macos/scripts/package-app.sh ``` -------------------------------- ### Configure Size-Based Scheduling Strategy Source: https://context7.com/19h/triglav/llms.txt Sets up the size-based scheduling strategy, where small transfers prefer latency and large transfers prefer bandwidth. Use `Default::default()` for other parameters. ```rust use triglav::multipath::{SchedulerConfig, SchedulingStrategy, MultipathConfig, MultipathManager}; use triglav::crypto::KeyPair; fn main() { // Size-based - small transfers prefer latency, large prefer bandwidth let size_config = SchedulerConfig { strategy: SchedulingStrategy::SizeBased, size_threshold_bytes: 64 * 1024, // 64KB threshold ..Default::default() }; // Apply to multipath manager let keypair = KeyPair::generate(); let mut mp_config = MultipathConfig::default(); mp_config.scheduler = size_config; let manager = MultipathManager::new(mp_config, keypair); } ``` -------------------------------- ### Run Bandwidth Measurement Test Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the bandwidth measurement test to determine the raw throughput capabilities of each network interface. ```bash cargo test --test physical_multipath test_bandwidth_measurement -- --ignored --nocapture ``` -------------------------------- ### Benchmark Connection Throughput Source: https://context7.com/19h/triglav/llms.txt Measure the network throughput for a specific connection using the 'benchmark' command. Customize duration, number of streams, and direction for detailed performance analysis. ```bash triglav benchmark tg1_ --duration 30 --streams 8 --direction both ``` -------------------------------- ### Configure ECMP-Aware Scheduling Strategy Source: https://context7.com/19h/triglav/llms.txt Sets up the ECMP-aware scheduling strategy with flow-sticky hashing for TCP consistency. Use `Default::default()` for other parameters. ```rust use triglav::multipath::{SchedulerConfig, SchedulingStrategy, MultipathConfig, MultipathManager}; use triglav::crypto::KeyPair; fn main() { // ECMP-aware - flow-sticky hashing for TCP consistency let ecmp_config = SchedulerConfig { strategy: SchedulingStrategy::EcmpAware, sticky_paths: true, sticky_timeout: std::time::Duration::from_secs(5), ..Default::default() }; // Apply to multipath manager let keypair = KeyPair::generate(); let mut mp_config = MultipathConfig::default(); mp_config.scheduler = ecmp_config; let manager = MultipathManager::new(mp_config, keypair); } ``` -------------------------------- ### Run TUN Device Tests with Root Privileges Source: https://github.com/19h/triglav/blob/master/README.md Executes tests that require root privileges for interacting with TUN devices. Use 'sudo' to run these tests. ```bash sudo cargo test --test tun_test -- --nocapture ``` -------------------------------- ### Triglav Server Configuration Source: https://context7.com/19h/triglav/llms.txt TOML format for server configuration, including network settings, security, and logging. ```toml [server] enabled = true listen_addrs = ["0.0.0.0:7443", "[::]:7443"] key_file = "/etc/triglav/server.key" max_connections = 10000 idle_timeout = "5m" tcp_fallback = true rate_limit = 0 # 0 = unlimited [transport] send_buffer_size = 2097152 # 2 MB recv_buffer_size = 2097152 connect_timeout = "10s" tcp_nodelay = true tcp_keepalive = "30s" [metrics] enabled = true listen = "127.0.0.1:9090" [logging] level = "info" format = "text" color = true ``` -------------------------------- ### Re-discover Network Interfaces Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the `run_physical_tests.sh` script with the `--list` option to re-discover network interfaces, useful when IP addresses change. ```bash ./run_physical_tests.sh --list ``` -------------------------------- ### Run Network Impairment Simulation Source: https://github.com/19h/triglav/blob/master/README.md Execute the Monte Carlo simulation framework to test network scenarios. Navigate to the simulation directory and run the cargo command. ```bash cd simulation cargo run --release ``` -------------------------------- ### Connect Client in Full VPN Mode Source: https://github.com/19h/triglav/blob/master/README.md Configure the Triglav client to route all traffic through the tunnel. This mode is recommended for comprehensive VPN usage. Requires elevated privileges. ```bash sudo triglav tun tg1_ --full-tunnel --auto-discover ``` -------------------------------- ### Run Test Suite with Verbose Output Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute a test suite, like 'latency', with verbose output enabled using the `--verbose` flag. ```bash # With verbose output ./run_physical_tests.sh --verbose latency ``` -------------------------------- ### Run End-to-End Validation Locally Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Perform end-to-end validation with real traffic, testing SOCKS5 proxy, data integrity, and performance metrics. ```bash # Run end-to-end validation with real traffic ./e2e_validation.sh --local ``` -------------------------------- ### Run Impairment Test Suite Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the impairment test suite, which requires root privileges. ```bash # Run impairment test suite (requires sudo) sudo ./run_physical_tests.sh --impairment ``` -------------------------------- ### Triglav TUN Mode: Enable DNS Source: https://github.com/19h/triglav/blob/master/README.md Configures Triglav to route DNS queries through the tunnel. ```bash sudo triglav tun --full-tunnel --dns ``` -------------------------------- ### Triglav Server: Generate Key Source: https://github.com/19h/triglav/blob/master/README.md Generates a new server key and prints it to the console. This key is essential for server authentication. ```bash triglav server --generate-key --print-key ``` -------------------------------- ### Configure Effective Throughput Scheduling Strategy Source: https://context7.com/19h/triglav/llms.txt Sets up the effective throughput scheduling strategy, optimizing for actual data transfer speed. Use `Default::default()` for other parameters. ```rust use triglav::multipath::{SchedulerConfig, SchedulingStrategy, MultipathConfig, MultipathManager}; use triglav::crypto::KeyPair; fn main() { // Effective throughput - optimizes for actual data transfer speed let throughput_config = SchedulerConfig { strategy: SchedulingStrategy::EffectiveThroughput, throughput_aware: true, prevent_latency_blocking: true, latency_blocking_ratio: 10.0, ..Default::default() }; // Apply to multipath manager let keypair = KeyPair::generate(); let mut mp_config = MultipathConfig::default(); mp_config.scheduler = throughput_config; let manager = MultipathManager::new(mp_config, keypair); } ``` -------------------------------- ### Run External Connectivity Test Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the external connectivity test to verify triglav's ability to connect to real external endpoints. ```bash cargo test --test physical_multipath test_external_connectivity -- --ignored --nocapture ``` -------------------------------- ### Connect E2E Validation Client Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Connect the end-to-end validation client to a remote server using the provided triglav URI. ```bash # On client machine ./e2e_validation.sh --client-only "triglav://..." ``` -------------------------------- ### Connect Client in Legacy Proxy Mode Source: https://github.com/19h/triglav/blob/master/README.md Use Triglav in a legacy proxy mode (SOCKS) without requiring root privileges. This is an alternative for scenarios where root access is not available. ```bash triglav connect tg1_ --socks 1080 --auto-discover ``` -------------------------------- ### Triglav Operations: Generate Server Key Source: https://github.com/19h/triglav/blob/master/README.md Generates a server key file and specifies the address and port for the server to listen on. ```bash triglav keygen --output server.key --address 1.2.3.4:7443 ``` -------------------------------- ### Package macOS App Bundle Source: https://github.com/19h/triglav/blob/master/apps/macos/README.md Packages the Triglav macOS application into a .app bundle, embedding the triglav CLI binary. ```bash ./apps/macos/scripts/package-app.sh ``` -------------------------------- ### Configure TunnelRunner for Full VPN Mode Source: https://context7.com/19h/triglav/llms.txt Sets up a TUN device for transparent IP traffic tunneling in full VPN mode. Requires root or CAP_NET_ADMIN privileges. Configures TUN interface, NAT, and routing rules. ```rust use triglav::tun::{TunnelConfig, TunnelRunner, TunConfig, NatConfig, RouteConfig}; use triglav::multipath::UplinkConfig; use triglav::crypto::PublicKey; use triglav::transport::TransportProtocol; #[tokio::main] async fn main() -> triglav::Result<()> { // Check for required privileges if !triglav::tun::check_privileges()? { eprintln!("TUN devices require root or CAP_NET_ADMIN capability"); return Ok(()) } // Configure TUN device let mut tun_config = TunConfig::default(); tun_config.name = "tg0".to_string(); tun_config.ipv4_addr = Some("10.0.85.1".parse()?); tun_config.mtu = Some(1420); // Configure NAT translation let mut nat_config = NatConfig::default(); nat_config.tunnel_ipv4 = "10.0.85.1".parse()?; nat_config.port_range_start = 32768; nat_config.port_range_end = 61000; // Configure routing (full tunnel or split tunnel) let mut route_config = RouteConfig::default(); route_config.full_tunnel = true; route_config.exclude_routes = vec![ "192.168.1.0/24".to_string(), // Local network "203.0.113.1/32".to_string(), // Server IP (must be excluded) ]; // Build tunnel configuration let tunnel_config = TunnelConfig { tun: tun_config, nat: nat_config, routing: route_config, ..Default::default() }; // Create tunnel runner let mut runner = TunnelRunner::new(tunnel_config)?; // Add uplinks runner.add_uplink(UplinkConfig { id: "primary".into(), interface: Some("en0".into()), remote_addr: "203.0.113.1:7443".parse()?, protocol: TransportProtocol::Udp, weight: 100, enabled: true, ..Default::default() })?; // Connect to server let server_pubkey = PublicKey::from_base64("server_public_key")?; runner.connect(server_pubkey).await?; println!("Tunnel {} running with {} uplinks", runner.tun_name(), runner.manager().uplink_count() ); // Subscribe to tunnel events let mut events = runner.subscribe(); tokio::spawn(async move { while let Ok(event) = events.recv().await { match event { triglav::tun::TunnelEvent::StatsUpdated(stats) => { println!("TUN: {} pkts read, {} pkts written", stats.tun_packets_read, stats.tun_packets_written ); } triglav::tun::TunnelEvent::Error(e) => { eprintln!("Tunnel error: {}", e); } _ => {} } } }); // Run tunnel (blocks until stopped) runner.run().await?; Ok(()) } ``` -------------------------------- ### Configure Redundant Scheduling Strategy Source: https://context7.com/19h/triglav/llms.txt Sets up the redundant scheduling strategy, which sends data on ALL uplinks for critical traffic. Use `Default::default()` for other parameters. ```rust use triglav::multipath::{SchedulerConfig, SchedulingStrategy, MultipathConfig, MultipathManager}; use triglav::crypto::KeyPair; fn main() { // Redundant - send on ALL uplinks (for critical traffic) let redundant_config = SchedulerConfig { strategy: SchedulingStrategy::Redundant, ..Default::default() }; // Apply to multipath manager let keypair = KeyPair::generate(); let mut mp_config = MultipathConfig::default(); mp_config.scheduler = redundant_config; let manager = MultipathManager::new(mp_config, keypair); } ``` -------------------------------- ### Run Only Unit Tests Source: https://github.com/19h/triglav/blob/master/README.md Executes only the unit tests, excluding integration and end-to-end tests. This is faster for verifying individual components. ```bash cargo test --lib ``` -------------------------------- ### Run End-to-End Validation with Custom Server Port Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the `e2e_validation.sh` script for local testing, specifying a custom server port using the `SERVER_PORT` environment variable. ```bash SERVER_PORT=8443 ./e2e_validation.sh --local ``` -------------------------------- ### Check Port Usage with lsof Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Use `lsof` to identify processes that are currently using specific network ports, helpful for resolving 'Bind failed' errors. ```bash # Check what's using ports lsof -i :17443 lsof -i :11080 ``` -------------------------------- ### View Triglav Server Log Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Display the contents of the Triglav server log file located at `/tmp/triglav_server.log` to check for authentication keys or other server-side information. ```bash cat /tmp/triglav_server.log ``` -------------------------------- ### Run Scheduler Strategies Tests Source: https://github.com/19h/triglav/blob/master/README.md Executes tests specifically for the scheduler strategies. This helps in verifying different scheduling algorithms. ```bash cargo test --test scheduler_strategies ``` -------------------------------- ### Run Manual Failover Test Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the manual failover test, which requires interactive interface disconnection to test failover mechanisms. ```bash cargo test --test physical_multipath test_manual_failover -- --ignored --nocapture ``` -------------------------------- ### Triglav Proxy Mode: Both Proxies Source: https://github.com/19h/triglav/blob/master/README.md Enables both SOCKS5 and HTTP proxy functionalities simultaneously. ```bash triglav connect --socks 1080 --http-proxy 8080 ``` -------------------------------- ### Run Latency Distribution Test Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Execute the latency distribution test to measure the latency characteristics of each network interface. ```bash cargo test --test physical_multipath test_latency_distribution -- --ignored --nocapture ``` -------------------------------- ### Configure Full Bandwidth Aggregation Source: https://context7.com/19h/triglav/llms.txt Enables full bandwidth aggregation, which stripes all packets across all uplinks. Configures the reorder buffer for handling out-of-order packets. ```rust use triglav::multipath::{MultipathConfig, MultipathManager, AggregationMode, AggregatorConfig}; use triglav::crypto::KeyPair; use std::time::Duration; fn main() { let keypair = KeyPair::generate(); // Configure bandwidth aggregation let mut config = MultipathConfig::default(); // Full aggregation - stripe ALL packets across ALL uplinks config.aggregation_mode = AggregationMode::Full; // Configure reorder buffer for handling out-of-order packets config.aggregator = AggregatorConfig { reorder_buffer_size: 1024, reorder_timeout: Duration::from_millis(500), enable_striping: true, ..Default::default() }; let manager = MultipathManager::new(config, keypair); // Get aggregation statistics let stats = manager.aggregator_stats(); println!("Packets striped: {}", stats.packets_striped); println!("Reorder buffer size: {}", stats.reorder_buffer_size); let reorder_stats = manager.reorder_stats(); println!("Packets reordered: {}", reorder_stats.packets_reordered); println!("Packets delivered: {}", reorder_stats.packets_delivered); } ``` -------------------------------- ### Triglav Operations: List Uplinks Source: https://github.com/19h/triglav/blob/master/README.md Lists all available network interfaces that Triglav can use as uplinks. ```bash triglav uplink list ``` -------------------------------- ### Triglav Operations: Generate Config Source: https://github.com/19h/triglav/blob/master/README.md Generates a TOML configuration file for the Triglav server. ```bash triglav config --server --output server.toml ``` -------------------------------- ### Generate Triglav Cryptographic Keys Source: https://context7.com/19h/triglav/llms.txt Generates cryptographic keypairs for server authentication. Keys can be output in base64 format, embedded with server addresses to create connection keys, or saved to a file. ```bash # Generate keypair and output to console triglav keygen --key-format base64 ``` ```bash # Generate keypair with server addresses embedded (creates connection key) triglav keygen --address 203.0.113.1:7443 --address 203.0.113.2:7443 ``` ```bash # Save keypair to file triglav keygen --output /etc/triglav/server.key --address 203.0.113.1:7443 ``` ```text # Output: # Generated new keypair: # Public Key: aW5jb3JyZWN0X2tleV9mb3JtYXRfZXhhbXBsZQ # Secret Key: c2VjcmV0X2tleV9yZWRhY3RlZF9mb3Jfc2FmZXR5 # Client Connection Key: # tg1_Base64EncodedKeyWithEmbeddedAddresses... ``` -------------------------------- ### Add Uplinks to MultipathManager Source: https://context7.com/19h/triglav/llms.txt Shows how to add multiple network interfaces (uplinks) to the MultipathManager, specifying their IDs, network interfaces, remote addresses, protocols, and weights. Ensure the remote address is correctly parsed. ```rust // Add uplinks (network interfaces) let wifi_config = UplinkConfig { id: "wifi".into(), interface: Some("en0".into()), remote_addr: "203.0.113.1:7443".parse()?, protocol: TransportProtocol::Udp, weight: 100, enabled: true, ..Default::default() }; let cellular_config = UplinkConfig { id: "cellular".into(), interface: Some("pdp_ip0".into()), remote_addr: "203.0.113.1:7443".parse()?, protocol: TransportProtocol::Udp, weight: 50, // Lower weight for metered connection enabled: true, ..Default::default() }; manager.add_uplink(wifi_config)?; manager.add_uplink(cellular_config)?; ``` -------------------------------- ### Test Through Proxy with Curl Source: https://github.com/19h/triglav/blob/master/physical_tests/README.md Use `curl` with SOCKS5 proxy support to test connectivity through a proxy server, specifying the proxy address and port. ```bash # Machine B - test through proxy curl --socks5 localhost:11080 http://example.com ``` -------------------------------- ### Configure Tunnel with TunnelBuilder Fluent API Source: https://context7.com/19h/triglav/llms.txt Uses the TunnelBuilder for a more concise and fluent configuration of tunnels. Allows setting TUN name, IP, routing, DNS, and uplinks using method chaining. ```rust use triglav::tun::runner::TunnelBuilder; use triglav::multipath::{UplinkConfig, SchedulingStrategy}; use triglav::transport::TransportProtocol; use triglav::crypto::PublicKey; #[tokio::main] async fn main() -> triglav::Result<()> { let server_pubkey = PublicKey::from_base64("server_public_key")?; let mut runner = TunnelBuilder::new() .tun_name("tg0") .ipv4("10.0.85.1".parse()?) .full_tunnel(true) .exclude("192.168.1.0/24") // Local network bypass .exclude("203.0.113.1/32") // Server IP bypass .route("10.0.0.0/8") // Additional route .dns_server("1.1.1.1:53".parse()?) .local_dns("127.0.0.1:5353".parse()?) .strategy(SchedulingStrategy::Adaptive) .uplink(UplinkConfig { id: "wifi".into(), interface: Some("en0".into()), remote_addr: "203.0.113.1:7443".parse()?, protocol: TransportProtocol::Udp, weight: 100, enabled: true, ..Default::default() }) .build()?; runner.connect(server_pubkey).await?; runner.run().await?; Ok(()) } ``` -------------------------------- ### Run Stress Tests Source: https://github.com/19h/triglav/blob/master/README.md Executes stress tests to evaluate the system's performance and stability under heavy load. ```bash cargo test --test stress_tests ``` -------------------------------- ### Triglav Client Configuration: TUN Mode Source: https://github.com/19h/triglav/blob/master/README.md TOML configuration for Triglav client in TUN mode, covering authentication, TUN interface settings, routing, NAT, and multipath options. ```toml [client] auth_key = "tg1_..." auto_discover = true [tun] name = "tg0" ipv4_addr = "10.0.85.1" ipv4_netmask = 24 mtu = 1420 [routing] full_tunnel = true exclude_routes = ["192.168.1.0/24"] # Local network bypass dns_servers = ["1.1.1.1", "8.8.8.8"] [nat] tunnel_ipv4 = "10.0.85.1" udp_timeout = "3m" tcp_timeout = "2h" port_range_start = 32768 port_range_end = 61000 [multipath] max_uplinks = 16 retry_delay = "100ms" max_retries = 3 aggregation_mode = "full" # none, full, or adaptive [multipath.aggregator] enabled = true reorder_buffer_size = 1024 reorder_timeout = "500ms" [multipath.scheduler] strategy = "adaptive" rtt_weight = 0.35 loss_weight = 0.35 bandwidth_weight = 0.2 nat_penalty_weight = 0.1 ```