Files
wireguard-vpn/app/docs/swagger.json
T
datadunia 6d8899a078 feat(app): add WGRplane web UI and backend features
- Add Vue 3 frontend with glassmorphism design (Tailwind CSS)
- Add Go backend handlers: auth, webhooks, stats, scheduler, validation
- Add i18n support (EN, ID, ZH)
- Add Swagger docs and API handlers
- Add nftables integration and plugins support
- Remove deprecated go.mod (migrated to wgrplane)
2026-05-03 23:20:34 +07:00

1220 lines
40 KiB
JSON

{
"swagger": "2.0",
"info": {
"description": "WireGuard Control Plane with Dynamic Policy Firewall. REST API for managing WireGuard servers, peers, webhooks, SMTP settings, and real-time stats.",
"title": "WGRplane API",
"contact": {
"name": "API Support"
},
"version": "1.0"
},
"host": "localhost:10087",
"basePath": "/",
"paths": {
"/api/peers/{id}": {
"put": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Updates a peer and computes diffs to apply incremental nftables changes.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"peers"
],
"summary": "Update a peer",
"parameters": [
{
"type": "string",
"description": "Peer ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Updated peer fields",
"name": "peer",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.Peer"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/main.Peer"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Deletes a peer, cleans up nftables rules, and triggers webhooks.",
"produces": [
"application/json"
],
"tags": [
"peers"
],
"summary": "Delete a peer",
"parameters": [
{
"type": "string",
"description": "Peer ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No content"
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/peers/{id}/config": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Downloads the WireGuard .conf file for a specific peer.",
"produces": [
"text/plain"
],
"tags": [
"peers"
],
"summary": "Get peer config",
"parameters": [
{
"type": "string",
"description": "Peer ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "WireGuard configuration file",
"schema": {
"type": "string"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/peers/{id}/qrcode": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Returns a QR code PNG image of the peer config for mobile import.",
"produces": [
"image/png"
],
"tags": [
"peers"
],
"summary": "Get peer QR code",
"parameters": [
{
"type": "string",
"description": "Peer ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "QR code PNG image",
"schema": {
"type": "file"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/servers": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Returns a list of all registered WireGuard servers.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "List all servers",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/main.Server"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Creates a new WireGuard server with the provided configuration.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "Create a server",
"parameters": [
{
"description": "Server configuration",
"name": "server",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.Server"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/main.Server"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/servers/{id}": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Returns a single WireGuard server by its ID.",
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "Get a server",
"parameters": [
{
"type": "string",
"description": "Server ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/main.Server"
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"put": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Updates fields of an existing WireGuard server.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "Update a server",
"parameters": [
{
"type": "string",
"description": "Server ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Updated server fields",
"name": "server",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.Server"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/main.Server"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Deletes a WireGuard server and cascade-removes its peers and webhooks.",
"produces": [
"application/json"
],
"tags": [
"servers"
],
"summary": "Delete a server",
"parameters": [
{
"type": "string",
"description": "Server ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No content"
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/servers/{id}/peers": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Returns all peers belonging to a specific WireGuard server.",
"produces": [
"application/json"
],
"tags": [
"peers"
],
"summary": "List server peers",
"parameters": [
{
"type": "string",
"description": "Server ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/main.Peer"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Creates a new WireGuard peer. Applies nftables rules in forward mode or triggers webhooks in standalone mode.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"peers"
],
"summary": "Create a peer",
"parameters": [
{
"type": "string",
"description": "Server ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Peer configuration",
"name": "peer",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.Peer"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/main.Peer"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/servers/{id}/stats": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Returns per-server statistics including peer count and webhook count.",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Get server stats",
"parameters": [
{
"type": "string",
"description": "Server ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": true
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/servers/{id}/webhooks": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Returns all webhooks configured for a specific WireGuard server.",
"produces": [
"application/json"
],
"tags": [
"webhooks"
],
"summary": "List server webhooks",
"parameters": [
{
"type": "string",
"description": "Server ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/main.Webhook"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Creates a new webhook configuration for a WireGuard server.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"webhooks"
],
"summary": "Create a webhook",
"parameters": [
{
"type": "string",
"description": "Server ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Webhook configuration",
"name": "webhook",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.Webhook"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/main.Webhook"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/settings/smtp": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Returns the current SMTP configuration for email notifications.",
"produces": [
"application/json"
],
"tags": [
"settings"
],
"summary": "Get SMTP settings",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/main.SMTPSettings"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Saves or updates SMTP configuration for email notifications.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"settings"
],
"summary": "Save SMTP settings",
"parameters": [
{
"description": "SMTP configuration",
"name": "settings",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/main.SMTPSettings"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/main.SMTPSettings"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/api/stats": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Returns global statistics including total servers, peers, and webhooks.",
"produces": [
"application/json"
],
"tags": [
"stats"
],
"summary": "Get global stats",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": {
"type": "integer",
"format": "int64"
}
}
}
}
}
},
"/api/webhooks/{id}": {
"delete": {
"security": [
{
"ApiKeyAuth": []
},
{
"BearerAuth": []
}
],
"description": "Deletes a webhook by its ID.",
"produces": [
"application/json"
],
"tags": [
"webhooks"
],
"summary": "Delete a webhook",
"parameters": [
{
"type": "string",
"description": "Webhook ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No content"
},
"404": {
"description": "Not Found",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
"main.Peer": {
"type": "object",
"properties": {
"allowAccess": {
"type": "array",
"items": {
"type": "integer"
}
},
"allowInternet": {
"type": "boolean"
},
"createdAt": {
"type": "string"
},
"currentDataUsageBytes": {
"description": "CurrentDataUsageBytes tracks the amount of data used by this peer (in bytes)",
"type": "integer",
"format": "int64"
},
"dataLimitGB": {
"description": "DataLimitGB defines the monthly data limit per peer (in GB). 0 means unlimited.",
"type": "integer",
"format": "int64"
},
"enabled": {
"description": "Enabled indicates whether the peer is active. Auto-restrict disables the peer if over the limit.",
"type": "boolean"
},
"expiresAt": {
"description": "ExpiresAt defines when this peer should be considered expired and eligible for auto-deletion",
"type": "string"
},
"id": {
"type": "integer"
},
"ip": {
"type": "string"
},
"publicKey": {
"type": "string"
},
"serverID": {
"type": "integer"
},
"updatedAt": {
"type": "string"
}
}
},
"main.SMTPSettings": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"fromEmail": {
"type": "string"
},
"fromName": {
"type": "string"
},
"id": {
"type": "integer"
},
"password": {
"type": "string"
},
"port": {
"type": "integer"
},
"server": {
"type": "string"
},
"useAuth": {
"type": "boolean"
},
"useTLS": {
"type": "boolean"
},
"username": {
"type": "string"
}
}
},
"main.Server": {
"type": "object",
"properties": {
"createdAt": {
"type": "string"
},
"endpoint": {
"type": "string"
},
"id": {
"type": "integer"
},
"mode": {
"type": "string"
},
"name": {
"type": "string"
},
"peers": {
"type": "array",
"items": {
"$ref": "#/definitions/main.Peer"
}
},
"publicKey": {
"type": "string"
},
"updatedAt": {
"type": "string"
},
"webhooks": {
"type": "array",
"items": {
"$ref": "#/definitions/main.Webhook"
}
}
}
},
"main.Webhook": {
"type": "object",
"properties": {
"createdAt": {
"type": "string"
},
"customBody": {
"type": "string"
},
"customHeaders": {
"type": "array",
"items": {
"type": "integer"
}
},
"defaultPayload": {
"type": "string"
},
"id": {
"type": "integer"
},
"isEnabled": {
"type": "boolean"
},
"isGlobal": {
"type": "boolean"
},
"name": {
"type": "string"
},
"serverID": {
"type": "integer"
},
"subscribedActions": {
"type": "array",
"items": {
"type": "integer"
}
},
"template": {
"type": "string"
},
"updatedAt": {
"type": "string"
},
"url": {
"type": "string"
},
"verifySSL": {
"type": "boolean"
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "wg-rplane-datadunia",
"in": "header"
},
"BearerAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}