package aerotun import "time" const ( ProtocolName = "AeroTUN" ProtocolVersion = 2 DefaultMTU = 1420 DefaultPort = 51830 MagicHeader = 0xAE70 // "AE" FlagCompressedLZ4 = 0x01 FlagKeepalive = 0x02 StoragePath = "/etc/debtik/vpn/aerotun_instances.json" ) // TunnelInstance represents a configured AeroTUN interface and its live status type TunnelInstance struct { Backend string `json:"backend,omitempty"` ConfiguredMTU int `json:"configured_mtu,omitempty"` DropBreakdown *DropBreakdown `json:"drop_breakdown,omitempty"` Handshakes uint64 `json:"handshakes,omitempty"` Protocol int `json:"protocol_version,omitempty"` PrivateKey string `json:"private_key,omitempty"` PublicKey string `json:"public_key,omitempty"` PeerPublicKey string `json:"peer_public_key,omitempty"` AllowedIPs []string `json:"allowed_ips,omitempty"` HasPSK bool `json:"has_psk,omitempty"` HasPrivateKey bool `json:"has_private_key,omitempty"` ID string `json:"id"` Name string `json:"name"` // e.g. "aerotun0" Mode string `json:"mode"` // "server" (listen) or "client" (dial) ListenPort int `json:"listen_port"` // UDP port to bind RemoteEndpoint string `json:"remote_endpoint"` // "host:port" (used if client or static peer) LocalAddress string `json:"local_address"` // CIDR e.g. "10.99.0.1/24" PeerAddress string `json:"peer_address"` // Peer CIDR e.g. "10.99.0.2/24" PSK string `json:"psk,omitempty"` // 32-byte hex/base64 pre-shared key Compression bool `json:"compression"` // Enable adaptive LZ4 MTU int `json:"mtu"` // e.g. 1420 DefaultRoute bool `json:"default_route"` // Route 0.0.0.0/0 via this tunnel Disabled bool `json:"disabled"` // MikroTik 'X' flag Comment string `json:"comment,omitempty"` CreatedAt time.Time `json:"created_at"` // Runtime state & telemetry Connected bool `json:"connected"` LastError string `json:"last_error,omitempty"` DroppedPackets uint64 `json:"dropped_packets"` AuthFailures uint64 `json:"auth_failures"` ReplayDrops uint64 `json:"replay_drops"` Running bool `json:"running"` ActivePeerEndpoint string `json:"active_peer_endpoint,omitempty"` LastHandshake string `json:"last_handshake,omitempty"` RxBytes uint64 `json:"rx_bytes"` TxBytes uint64 `json:"tx_bytes"` RawBytesIn uint64 `json:"raw_bytes_in"` // uncompressed RX payload RawBytesOut uint64 `json:"raw_bytes_out"` // uncompressed TX payload WireBytesIn uint64 `json:"wire_bytes_in"` // actual wire RX WireBytesOut uint64 `json:"wire_bytes_out"` // actual wire TX SavedBytes uint64 `json:"saved_bytes"` // Bandwidth saved through compression CompressionRatio string `json:"compression_ratio,omitempty"` PacketsRx uint64 `json:"packets_rx"` PacketsTx uint64 `json:"packets_tx"` CompressedPackets uint64 `json:"compressed_packets"` RawPackets uint64 `json:"raw_packets"` } // SummaryStats aggregates performance across all AeroTUN tunnels type DropBreakdown struct { InvalidOutgoing uint64 `json:"invalid_outgoing"` MissingSession uint64 `json:"missing_session"` SendFailure uint64 `json:"send_failure"` InvalidIncoming uint64 `json:"invalid_incoming"` SourcePolicy uint64 `json:"source_policy"` InterfaceWrite uint64 `json:"interface_write"` } type SummaryStats struct { TotalTunnels int `json:"total_tunnels"` ActiveTunnels int `json:"active_tunnels"` TotalRxBytes uint64 `json:"total_rx_bytes"` TotalTxBytes uint64 `json:"total_tx_bytes"` TotalSavedBytes uint64 `json:"total_saved_bytes"` AverageRatio string `json:"average_ratio"` AlgorithmCrypto string `json:"algorithm_crypto"` AlgorithmCompress string `json:"algorithm_compress"` }