WireGold
Wire Golang Guard = WireGold
English | [中文](README_ZH.md)
## Overview
WireGold is a pure Go Layer 3 VPN inspired by WireGuard.
### Features
- **Encryption**: XChaCha20-Poly1305 (AEAD) + Curve25519 key exchange + BLAKE2B integrity check
- **Transport**: UDP / UDP-Lite / TCP / Raw IP / ICMP
- **Encoding**: Optional Base16384 encoding to traverse text-only filters
- **Anti-censorship**: XOR mask header obfuscation + randomized MTU scaling + optional double-send
- **Compression**: Optional Zstd payload compression
- **NAT traversal**: Built-in Hello/Query/Notify protocol for keepalive and hole punching
- **Routing**: Multi-hop forwarding with TTL decrement and routing table management
- **Key rotation**: 32 preshared key slots with random index selection per packet
## Usage
> On Windows, place the `wintun.dll` matching your architecture (from `lower/wintun/`) alongside the executable.
> For high-latency lossy links, consider pairing with [UDPspeeder](https://github.com/wangyu-/UDPspeeder).
```bash
wg [-c config.yaml] [-d|w] [-g] [-h] [-p] [-l log.txt]
```
#### Flags
```bash
-c string
specify conf file (default "config.yaml")
-d print debug logs
-g generate key pair
-h display this help
-l string
write log to file (default "-")
-p show my publickey
-pg
generate preshared key
-w only show logs above warn level
```
## Configuration
- **macOS Mojave**: max MTU (IPv4 endpoint) is `9159`
- **IPv6 endpoint**: recommended MTU `1280–1500` to avoid oversized segment drops
- **ICMP / Raw IP endpoint**: use bare IP address without port (e.g. `0.0.0.0`), requires root/admin privileges
```yaml
IP: 192.168.233.1
SubNet: 192.168.233.0/24
PrivateKey: 暲菉斂狧污爉窫擸紈卆帞蔩慈睠庮扝憚瞼縀
Network: udp # udp (default), udplite, tcp, ip, icmp
EndPoint: 0.0.0.0:56789
MTU: 1504
SpeedLoop: 4096
MaxTTL: 64
Mask: 0x1234567890abcdef
Base14: true
Peers:
-
IP: "192.168.233.2"
PublicKey: 徯萃嵾爻燸攗窍褃冔蒔犡緇袿屿組待族砇嘀
PresharedKey: 瀸敀爅崾嘊嵜紼樴稍毯攣矐訷蟷扛嬋庩崛昀
EndPoint: 1.2.3.4:56789
AllowedIPs: ["192.168.233.2/32", "x192.168.233.3/32"] # accept packets from 192.168.233.3, but don not create route
KeepAliveSeconds: 0
QueryList: ["192.168.233.3"]
MTU: 1400
MTURandomRange: 128
UseZstd: true
QuerySeconds: 10
AllowTrans: true
-
IP: "192.168.233.3"
PublicKey: 牢喨粷詸衭譛浾蘹櫠砙杹蟫瑳叩刋橋経挵蘀
PresharedKey: 竅琚喫従痸告烈兇厕趭萨假蔛瀇譄施烸蝫瘀
EndPoint: ""
AllowedIPs: ["192.168.233.3/32", "y192.168.66.1/32"] # add route to 192.168.66.1 into inner route table but do not add it to system one
MTU: 752
DoublePacket: true
KeepAliveSeconds: 0
AllowTrans: false
```
### Configuration Reference
| Field | Description |
|-------|-------------|
| `Network` | Transport protocol: `udp` (default), `udplite`, `tcp`, `ip`, `icmp` |
| `MaxTTL` | Initial TTL for outgoing packets; default `64` |
| `SpeedLoop` | Log receive throughput statistics every N packets; default `4096` |
| `AllowedIPs` | Prefix `x` to accept packets from the subnet without creating a system route; prefix `y` to add an internal route table entry only |
| `Mask` | XOR mask for header obfuscation |
| `Base14` | Enable Base16384 encoding |
| `MTURandomRange` | Randomly shrink MTU by up to this value (never grows), adding traffic fingerprint randomness |
| `DoublePacket` | Send every packet twice to counter heavy packet loss |
| `KeepAliveSeconds` | NAT keepalive interval in seconds; 0 disables keepalive |
| `QueryList` | Peer IPs to query for NAT traversal |
| `UseZstd` | Enable Zstd compression |
| `AllowTrans` | Allow this peer to relay traffic for other peers |
## Benchmark (localhost)
> MacBook Air M1, battery mode