Expand description
§VCL Keepalive
Automatic keepalive for maintaining connections through NAT and firewalls.
§Why keepalive matters for VPN
Client ──── NAT ──── Internet ──── Server
NAT table entry:
client:4500 → server:4500 TTL: 30s (mobile), 120s (home), 300s (corporate)
Without keepalive:
30s of silence → NAT drops entry → connection dead
With keepalive:
Every 25s → tiny ping → NAT entry refreshed → connection alive§Example
use vcl_protocol::keepalive::{KeepaliveConfig, KeepaliveManager};
use std::time::Duration;
let config = KeepaliveConfig::aggressive(); // 25s interval, for mobile NAT
let mut manager = KeepaliveManager::new(config);
// Call this in your main loop
if manager.should_send_keepalive() {
// send ping here
manager.record_keepalive_sent();
}
// When pong arrives
manager.record_pong_received();Structs§
- Keepalive
Config - Configuration for the keepalive mechanism.
- Keepalive
Manager - Manages keepalive timing, miss counting, and adaptive interval adjustment.
Enums§
- Keepalive
Action - The result of a keepalive check — what action to take.
- Keepalive
Preset - Preset keepalive strategies for different network environments.