2.5 KiB
2.5 KiB
API Endpoints
Peer Management
GET /api/peers
Returns peers currently on the WireGuard interface with optional status filtering.
Query Parameters:
status(optional): Filter by peer status (ALIVEorDEAD)
Examples:
GET /api/peers- Returns all peersGET /api/peers?status=ALIVE- Returns only active peersGET /api/peers?status=DEAD- Returns only inactive peers
Response:
{
"success": true,
"peers": [
{
"public_key": "abc123...",
"ip_address": "10.0.0.5",
"last_handshake": "2024-01-01T12:00:00Z",
"minutes_since_handshake": 5,
"status": "ALIVE"
}
],
"total_count": 3,
"filter": "ALIVE"
}
POST /api/peer
Creates a new peer and returns peer configuration along with server details.
Response:
{
"peer": {
"ip": "10.0.0.5",
"privateKey": "...",
"publicKey": "..."
},
"server": {
"publicKey": "...",
"endpoint": "1.2.3.4:51820"
},
"success": true
}
DELETE /api/peer/<publicKey>
Removes a peer from the WireGuard interface.
URL Parameter:
publicKey- The peer's public key
Example: DELETE /api/peer/abc123def456...
**Response:
{
"success": true,
"message": "Peer deleted successfully"
}
GET /api/peer/<publicKey>/config
Status: Not implemented - returns 404.
URL Parameter:
publicKey- The peer's public key
Example: GET /api/peer/abc123def456.../config
Peer configuration retrieval is not available as peer info is not stored persistently.
PATCH /api/peer/<publicKey>/speed-limit
Sets traffic control speed limits for a peer.
URL Parameter:
publicKey- The peer's public key
Example: PATCH /api/peer/abc123def456.../speed-limit
Request Body:
{
"bytesPerSecond": 1048576
}
Response:
{
"success": true,
"message": "Speed limit set successfully"
}
PATCH /api/peer/<publicKey>/data-cap
Sets data usage quotas for a peer.
URL Parameter:
publicKey- The peer's public key
Example: PATCH /api/peer/abc123def456.../data-cap
Request Body:
{
"quotaBytes": 1073741824
}
Response:
{
"success": true,
"message": "Data cap set successfully"
}
Status Values
"ALIVE"- Last handshake within 150 seconds"DEAD"- Last handshake >150 seconds ago"No handshake yet"- Peer exists but never had a handshake"Peer not found in WireGuard"- Peer doesn't exist in WG interface