144 lines
2.5 KiB
Markdown
144 lines
2.5 KiB
Markdown
# 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 (`ALIVE` or `DEAD`)
|
|
|
|
**Examples:**
|
|
- `GET /api/peers` - Returns all peers
|
|
- `GET /api/peers?status=ALIVE` - Returns only active peers
|
|
- `GET /api/peers?status=DEAD` - Returns only inactive peers
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"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:**
|
|
```json
|
|
{
|
|
"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:
|
|
```json
|
|
{
|
|
"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:**
|
|
```json
|
|
{
|
|
"bytesPerSecond": 1048576
|
|
}
|
|
```
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"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:**
|
|
```json
|
|
{
|
|
"quotaBytes": 1073741824
|
|
}
|
|
```
|
|
|
|
**Response:**
|
|
```json
|
|
{
|
|
"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 |