0d84b07f68
CI / docker (push) Successful in 1m58s
Go + Vue 管理台:Agent 隧道、域名反代、IP 安全、访客验证与监控大盘。 Gitea Actions CI 多架构镜像;纯 Go SQLite、无 CGO Docker 构建。 Co-authored-by: Cursor <cursoragent@cursor.com>
98 lines
4.9 KiB
Go
98 lines
4.9 KiB
Go
package api
|
|
|
|
// OpenAPI 3.0 spec for Wormhole external API (authenticate with X-API-Key header).
|
|
const openAPISpec = `{
|
|
"openapi": "3.0.3",
|
|
"info": {
|
|
"title": "Wormhole API",
|
|
"version": "1.0.0",
|
|
"description": "使用 X-API-Key 请求头或 Bearer JWT 访问。Base URL: http://host:8529/api。"
|
|
},
|
|
"servers": [{ "url": "/api" }],
|
|
"components": {
|
|
"securitySchemes": {
|
|
"ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "X-API-Key" },
|
|
"BearerAuth": { "type": "http", "scheme": "bearer", "bearerFormat": "JWT" }
|
|
},
|
|
"schemas": {
|
|
"Error": {
|
|
"type": "object",
|
|
"properties": {
|
|
"error": { "type": "string", "description": "错误信息" }
|
|
}
|
|
},
|
|
"Ok": {
|
|
"type": "object",
|
|
"properties": {
|
|
"ok": { "type": "boolean", "example": true }
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"BadRequest": {
|
|
"description": "请求参数无效",
|
|
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
|
|
},
|
|
"Forbidden": {
|
|
"description": "权限不足",
|
|
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
|
|
},
|
|
"NotFound": {
|
|
"description": "资源不存在",
|
|
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
|
|
},
|
|
"Conflict": {
|
|
"description": "路由冲突",
|
|
"content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
|
|
}
|
|
}
|
|
},
|
|
"security": [{ "ApiKeyAuth": [] }, { "BearerAuth": [] }],
|
|
"paths": {
|
|
"/clients": {
|
|
"get": {
|
|
"summary": "列出客户端及在线状态",
|
|
"responses": { "200": { "description": "OK" } }
|
|
}
|
|
},
|
|
"/tunnels": {
|
|
"get": {
|
|
"summary": "分页查询隧道",
|
|
"parameters": [
|
|
{ "name": "page", "in": "query", "schema": { "type": "integer" } },
|
|
{ "name": "page_size", "in": "query", "schema": { "type": "integer" } },
|
|
{ "name": "q", "in": "query", "schema": { "type": "string" } }
|
|
],
|
|
"responses": { "200": { "description": "OK" } }
|
|
},
|
|
"post": { "summary": "创建隧道", "responses": { "200": { "description": "OK" } } }
|
|
},
|
|
"/tunnels/{id}": {
|
|
"put": { "summary": "更新隧道", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } },
|
|
"delete": { "summary": "删除隧道", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } }
|
|
},
|
|
"/tunnels/{id}/start": { "post": { "summary": "启动隧道", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } } },
|
|
"/tunnels/{id}/stop": { "post": { "summary": "停止隧道", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } } },
|
|
"/tunnels/{id}/pause": { "post": { "summary": "暂停隧道", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } } },
|
|
"/tunnels/{id}/resume": { "post": { "summary": "恢复隧道", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } } },
|
|
"/hosts": {
|
|
"get": {
|
|
"summary": "分页查询域名",
|
|
"parameters": [
|
|
{ "name": "page", "in": "query", "schema": { "type": "integer" } },
|
|
{ "name": "page_size", "in": "query", "schema": { "type": "integer" } },
|
|
{ "name": "q", "in": "query", "schema": { "type": "string" } }
|
|
],
|
|
"responses": { "200": { "description": "OK" } }
|
|
},
|
|
"post": { "summary": "创建域名", "responses": { "200": { "description": "OK" } } }
|
|
},
|
|
"/hosts/{id}": {
|
|
"put": { "summary": "更新域名", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } },
|
|
"delete": { "summary": "删除域名", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } }
|
|
},
|
|
"/hosts/{id}/pause": { "post": { "summary": "暂停域名", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } } },
|
|
"/hosts/{id}/resume": { "post": { "summary": "恢复域名", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }], "responses": { "200": { "description": "OK" } } } }
|
|
}
|
|
}`
|