Expand description
§VCL TUN Interface
Provides VCLTun — a TUN virtual network interface that captures
IP packets from the OS network stack and injects them back after
decryption/routing through a VCL tunnel.
§How it works
Application
↓ (writes to TCP/UDP socket)
OS Network Stack
↓ (routes via routing table)
TUN interface (vcl0)
↓ (VCLTun::read_packet)
VCL Protocol (encrypt + send)
↓ (network)
Remote VCL (recv + decrypt)
↓ (VCLTun::write_packet)
TUN interface (remote vcl0)
↓ (inject into OS network stack)
Remote application§Requirements
- Linux only (TUN/TAP is a Linux kernel feature)
- Requires root or
CAP_NET_ADMINcapability - Does NOT work in WSL2 without custom kernel
§Example
use vcl_protocol::tun_device::{VCLTun, TunConfig};
#[tokio::main]
async fn main() {
let config = TunConfig {
name: "vcl0".to_string(),
address: "10.0.0.1".parse().unwrap(),
destination: "10.0.0.2".parse().unwrap(),
netmask: "255.255.255.0".parse().unwrap(),
mtu: 1420,
};
let mut tun = VCLTun::create(config).unwrap();
loop {
let packet = tun.read_packet().await.unwrap();
println!("Captured {} bytes", packet.len());
// encrypt and send via VCL connection
}
}Structs§
- IpPacket
- A parsed IP packet read from the TUN interface.
- TunConfig
- Configuration for a TUN virtual network interface.
- VCLTun
- A TUN virtual network interface for capturing and injecting IP packets.
Enums§
- IpVersion
- IP protocol version detected in a packet.
Functions§
- ip_
version - Returns the IP version of a raw packet, or
Noneif empty. - is_ipv4
- Check if a raw packet is IPv4.
- is_ipv6
- Check if a raw packet is IPv6.
- parse_
ip_ packet - Parse raw bytes from a TUN read into an
IpPacket.