zlayer-overlay
Encrypted overlay networking for ZLayer using boringtun (userspace WireGuard) with built-in DNS service discovery.
Features
- Encrypted Mesh - Peer-to-peer networking via boringtun (no kernel WireGuard module required)
- IP Allocation - Automatic CIDR-based IP management for overlay nodes
- DNS Service Discovery - Auto-register peers with DNS names for easy discovery
- Health Checking - Monitor peer connectivity via handshake times and ping
- Bootstrap Protocol - Leader/worker initialization with persistent state
Installation
Add to your Cargo.toml:
[]
= "0.8"
Quick Start
Initialize a Leader Node
use OverlayBootstrap;
use Path;
// Initialize as cluster leader
let mut bootstrap = init_leader.await?;
// Start the overlay network
bootstrap.start.await?;
println!; // 10.200.0.1
println!; // Overlay pubkey
Join an Existing Overlay
let mut bootstrap = join.await?;
bootstrap.start.await?;
DNS Service Discovery
Enable automatic DNS registration for overlay peers:
let mut bootstrap = init_leader
.await?
.with_dns?; // Zone and port
bootstrap.start.await?;
Auto-Generated DNS Names
When DNS is enabled, peers are automatically registered:
| IP Address | DNS Name | Description |
|---|---|---|
10.200.0.1 |
node-0-1.overlay.local |
IP-based hostname |
10.200.0.1 |
leader.overlay.local |
Leader alias (leader only) |
10.200.0.5 |
node-0-5.overlay.local |
Worker node |
Custom Hostnames
Peers can have custom DNS names in addition to the auto-generated ones:
let peer = new.with_hostname; // Registers as web.overlay.local
bootstrap.add_peer.await?;
Querying DNS
# Query from any node in the overlay
Default Port
DNS uses port 15353 by default to avoid conflicts with system DNS resolvers (systemd-resolved typically binds to 53).
Health Checking
Monitor peer connectivity:
use OverlayHealthChecker;
use Duration;
let checker = new;
// Single check
let health = checker.check_all.await?;
println!;
// Continuous monitoring with callbacks
checker.run.await;
API Reference
Core Types
| Type | Description |
|---|---|
OverlayBootstrap |
Main bootstrap manager for overlay lifecycle |
PeerConfig |
Configuration for a peer node |
DnsServer |
DNS server for service discovery |
DnsHandle |
Handle for managing DNS records after server starts |
DnsConfig |
DNS configuration (zone, port, bind address) |
OverlayHealthChecker |
Peer health monitoring |
IpAllocator |
CIDR-based IP address allocation |
Constants
| Constant | Value | Description |
|---|---|---|
DEFAULT_WG_PORT |
51820 | Default overlay listen port |
DEFAULT_DNS_PORT |
15353 | Default DNS server port |
DEFAULT_OVERLAY_CIDR |
10.200.0.0/16 | Default overlay network |
DEFAULT_INTERFACE_NAME |
zl-overlay0 | Default overlay interface |
License
MIT - See LICENSE for details.