项目
在 GitHub 查看
suquant/wgrest
关于
WireGuard REST API
系统与基础设施可以做什么
- Full wg-quick compatibility - Uses standard /etc/wireguard/*.conf files
- Device management - Create, update, delete WireGuard interfaces
- Peer management - Full CRUD operations with search and sorting
- Interface lifecycle - Bring interfaces up/down via API (wg-quick up/down)
实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文WGRest
WGRest is a WireGuard REST API server. It operates WireGuard through IPC and doesn't require any dependencies. It uses wg-quick style configuration files for persistent storage, providing full compatibility with standard WireGuard tooling.
Designed to be simple, fast, and lightweight — making it ideal for embedded devices such as routers or any other low-power, low-memory devices.
WireGuard is a simple and modern VPN. It is cross-platform (Windows, macOS, BSD, iOS, Android).
Features
- Full wg-quick compatibility - Uses standard
/etc/wireguard/*.conffiles - Device management - Create, update, delete WireGuard interfaces
- Peer management - Full CRUD operations with search and sorting
- Interface lifecycle - Bring interfaces up/down via API (
wg-quick up/down) - wg-quick config export - Download peer configurations as
quick.conf - ACME TLS support - Automatic Let's Encrypt certificates
- Bearer token auth - Simple token-based authorization
- Swagger UI - Interactive API documentation at
/docs/
Requirements
- Linux with WireGuard kernel module
wireguard-toolspackage (provideswgandwg-quick)
Install
On Debian / Ubuntu
# amd64
curl -L https://github.com/suquant/wgrest/releases/latest/download/wgrest_amd64.deb -o wgrest_amd64.deb
dpkg -i wgrest_amd64.deb
# arm64
curl -L https://github.com/suquant/wgrest/releases/latest/download/wgrest_arm64.deb -o wgrest_arm64.deb
dpkg -i wgrest_arm64.deb
Manual
curl -L https://github.com/suquant/wgrest/releases/latest/download/wgrest-linux-amd64 -o wgrest
chmod +x wgrest
sudo mv wgrest /usr/local/bin/
Configuration
wgrest --help
NAME:
wgrest - REST API for WireGuard
GLOBAL OPTIONS:
--conf value wgrest config file path (default: "/etc/wgrest/wgrest.conf")
--version Print version and exit
--listen value Listen address (default: "127.0.0.1:8000")
--config-dir value WireGuard config directory (default: "/etc/wireguard")
--certs-dir value ACME TLS certificates cache directory (default: "/var/lib/wgrest/certs")
--dump-interval value Config dump interval (default: 10m)
--static-auth-token value Bearer token for authorization
--tls-domain value TLS Domains for ACME (Let's Encrypt)
--help, -h show help
Environment Variables
| Variable | Description | Default |
|---|---|---|
WGREST_CONF |
Config file path | /etc/wgrest/wgrest.conf |
WGREST_LISTEN |
Listen address | 127.0.0.1:8000 |
WGREST_CONFIG_DIR |
WireGuard config dir | /etc/wireguard |
WGREST_CERTS_DIR |
TLS certificates dir | /var/lib/wgrest/certs |
WGREST_DUMP_INTERVAL |
Config dump interval | 10m |
WGREST_STATIC_AUTH_TOKEN |
Bearer token | - |
WGREST_TLS_DOMAIN |
ACME domains | - |
Quick Start
# Start server with auth token
wgrest --static-auth-token "secret" --listen "127.0.0.1:8000"
# Open Swagger UI
open http://127.0.0.1:8000/docs/
API Examples
Create a device
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer secret" \
-d '{
"name": "wg0",
"listen_port": 51820,
"address": ["10.0.0.1/24"]
}' \
http://127.0.0.1:8000/v1/devices/
Get devices
curl -H "Authorization: Bearer secret" \
http://127.0.0.1:8000/v1/devices/
Update device
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer secret" \
-d '{"listen_port": 51821}' \
http://127.0.0.1:8000/v1/devices/wg0/
Add peer
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer secret" \
-d '{"allowed_ips": ["10.0.0.2/32"]}' \
http://127.0.0.1:8000/v1/devices/wg0/peers/
Get peers
curl -H "Authorization: Bearer secret" \
http://127.0.0.1:8000/v1/devices/wg0/peers/
Bring interface up/down
# Bring up
curl -X POST \
-H "Authorization: Bearer secret" \
http://127.0.0.1:8000/v1/devices/wg0/up/
# Bring down
curl -X POST \
-H "Authorization: Bearer secret" \
http://127.0.0.1:8000/v1/devices/wg0/down/
Delete peer
curl -X DELETE \
-H "Authorization: Bearer secret" \
http://127.0.0.1:8000/v1/devices/wg0/peers/{urlSafePubKey}/
URL-Safe Public Keys
Peer public keys in URLs use URL-safe base64 encoding. Convert standard base64:
import base64
pub_key = "hQ1yeyFy+bZn/5jpQNNrZ8MTIGaimZxT6LbWAkvmKjA="
url_safe = base64.urlsafe_b64encode(base64.b64decode(pub_key)).decode()
print(url_safe) # hQ1yeyFy-bZn_5jpQNNrZ8MTIGaimZxT6LbWAkvmKjA=
Development
# Build
make build
# Run tests
make test
# Generate swagger docs
make swagger
# Run linter
make lint
Credits
- ForestVPN.com - Free VPN for all
- SpaceV.net - VPN for teams
探索相关项目
加载中…