feat(1d): wire oapi-codegen, generate types/server/client, add 501 stubs — tsk_Kp80nvHV2yLc
- Fix openapi.yaml: quote bearerAuth description that contained unquoted `: ` plain-scalar YAML
- Add server/api/cfg-{types,server,client}.yaml — oapi-codegen v2 config for three split outputs
- Add server/api/gen/gen.go — three //go:generate directives; run `make generate`
- Generate server/api/gen/{types,server,client}.gen.go from the contract (all 15 operations)
- Add github.com/oapi-codegen/runtime v1.4.1 to go.mod (runtime types needed by generated code)
- Add server/internal/httpapi/unimplemented.go — UnimplementedServer satisfies gen.ServerInterface;
every method writes HTTP 501 + {code,message_zh,message_en} JSON body (no dep on task-1f apierr)
- Update server/cmd/server/main.go — mount /v1 API via gen.HandlerFromMuxWithBaseURL; keep /healthz
- Update server/Makefile — `generate` target now runs `go generate ./...`;
add `check-generate` CI guard (regenerate + git diff --exit-code)
- Add server/internal/httpapi/unimplemented_test.go — 19 httptest cases covering all 15 API routes
(501+body), undefined routes (404), and /healthz isolation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package: gen
|
||||
generate:
|
||||
client: true
|
||||
embedded-spec: false
|
||||
output: client.gen.go
|
||||
@@ -0,0 +1,5 @@
|
||||
package: gen
|
||||
generate:
|
||||
chi-server: true
|
||||
embedded-spec: true
|
||||
output: server.gen.go
|
||||
@@ -0,0 +1,5 @@
|
||||
package: gen
|
||||
generate:
|
||||
models: true
|
||||
embedded-spec: false
|
||||
output: types.gen.go
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
// Package gen contains oapi-codegen generated files for the Pangolin API.
|
||||
// Run `go generate ./...` (or `make generate`) to regenerate.
|
||||
package gen
|
||||
|
||||
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=../cfg-types.yaml ../openapi.yaml
|
||||
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=../cfg-server.yaml ../openapi.yaml
|
||||
//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=../cfg-client.yaml ../openapi.yaml
|
||||
@@ -0,0 +1,903 @@
|
||||
// Package gen provides primitives to interact with the openapi HTTP API.
|
||||
//
|
||||
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.7.1 DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/flate"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/oapi-codegen/runtime"
|
||||
openapi_types "github.com/oapi-codegen/runtime/types"
|
||||
)
|
||||
|
||||
// ServerInterface represents all server handlers.
|
||||
type ServerInterface interface {
|
||||
// 激励视频广告解锁当日时长
|
||||
// (POST /ads/unlock)
|
||||
AdsUnlock(w http.ResponseWriter, r *http.Request)
|
||||
// 发送邮箱验证码
|
||||
// (POST /auth/code)
|
||||
SendVerificationCode(w http.ResponseWriter, r *http.Request)
|
||||
// 登录
|
||||
// (POST /auth/login)
|
||||
Login(w http.ResponseWriter, r *http.Request)
|
||||
// 刷新 Access Token
|
||||
// (POST /auth/refresh)
|
||||
RefreshToken(w http.ResponseWriter, r *http.Request)
|
||||
// 注册账户
|
||||
// (POST /auth/register)
|
||||
Register(w http.ResponseWriter, r *http.Request)
|
||||
// 获取当前账户信息
|
||||
// (GET /me)
|
||||
GetMe(w http.ResponseWriter, r *http.Request)
|
||||
// 获取设备列表
|
||||
// (GET /me/devices)
|
||||
ListDevices(w http.ResponseWriter, r *http.Request)
|
||||
// 移除设备
|
||||
// (DELETE /me/devices/{id})
|
||||
DeleteDevice(w http.ResponseWriter, r *http.Request, id openapi_types.UUID)
|
||||
// 获取节点目录
|
||||
// (GET /nodes)
|
||||
ListNodes(w http.ResponseWriter, r *http.Request, params ListNodesParams)
|
||||
// 连接节点 — 下发连接凭证
|
||||
// (POST /nodes/{id}/connect)
|
||||
ConnectNode(w http.ResponseWriter, r *http.Request, id openapi_types.UUID)
|
||||
// 断开节点连接
|
||||
// (POST /nodes/{id}/disconnect)
|
||||
DisconnectNode(w http.ResponseWriter, r *http.Request, id openapi_types.UUID)
|
||||
// 获取公告列表
|
||||
// (GET /notices)
|
||||
ListNotices(w http.ResponseWriter, r *http.Request)
|
||||
// 获取套餐目录
|
||||
// (GET /plans)
|
||||
ListPlans(w http.ResponseWriter, r *http.Request)
|
||||
// 兑换激活码
|
||||
// (POST /redeem)
|
||||
RedeemCode(w http.ResponseWriter, r *http.Request)
|
||||
// 获取用量曲线
|
||||
// (GET /usage)
|
||||
GetUsage(w http.ResponseWriter, r *http.Request, params GetUsageParams)
|
||||
}
|
||||
|
||||
// Unimplemented server implementation that returns http.StatusNotImplemented for each endpoint.
|
||||
|
||||
type Unimplemented struct{}
|
||||
|
||||
// 激励视频广告解锁当日时长
|
||||
// (POST /ads/unlock)
|
||||
func (_ Unimplemented) AdsUnlock(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 发送邮箱验证码
|
||||
// (POST /auth/code)
|
||||
func (_ Unimplemented) SendVerificationCode(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 登录
|
||||
// (POST /auth/login)
|
||||
func (_ Unimplemented) Login(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 刷新 Access Token
|
||||
// (POST /auth/refresh)
|
||||
func (_ Unimplemented) RefreshToken(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 注册账户
|
||||
// (POST /auth/register)
|
||||
func (_ Unimplemented) Register(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 获取当前账户信息
|
||||
// (GET /me)
|
||||
func (_ Unimplemented) GetMe(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 获取设备列表
|
||||
// (GET /me/devices)
|
||||
func (_ Unimplemented) ListDevices(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 移除设备
|
||||
// (DELETE /me/devices/{id})
|
||||
func (_ Unimplemented) DeleteDevice(w http.ResponseWriter, r *http.Request, id openapi_types.UUID) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 获取节点目录
|
||||
// (GET /nodes)
|
||||
func (_ Unimplemented) ListNodes(w http.ResponseWriter, r *http.Request, params ListNodesParams) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 连接节点 — 下发连接凭证
|
||||
// (POST /nodes/{id}/connect)
|
||||
func (_ Unimplemented) ConnectNode(w http.ResponseWriter, r *http.Request, id openapi_types.UUID) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 断开节点连接
|
||||
// (POST /nodes/{id}/disconnect)
|
||||
func (_ Unimplemented) DisconnectNode(w http.ResponseWriter, r *http.Request, id openapi_types.UUID) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 获取公告列表
|
||||
// (GET /notices)
|
||||
func (_ Unimplemented) ListNotices(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 获取套餐目录
|
||||
// (GET /plans)
|
||||
func (_ Unimplemented) ListPlans(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 兑换激活码
|
||||
// (POST /redeem)
|
||||
func (_ Unimplemented) RedeemCode(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// 获取用量曲线
|
||||
// (GET /usage)
|
||||
func (_ Unimplemented) GetUsage(w http.ResponseWriter, r *http.Request, params GetUsageParams) {
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
// ServerInterfaceWrapper converts contexts to parameters.
|
||||
type ServerInterfaceWrapper struct {
|
||||
Handler ServerInterface
|
||||
HandlerMiddlewares []MiddlewareFunc
|
||||
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
|
||||
}
|
||||
|
||||
type MiddlewareFunc func(http.Handler) http.Handler
|
||||
|
||||
// AdsUnlock operation middleware
|
||||
func (siw *ServerInterfaceWrapper) AdsUnlock(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.AdsUnlock(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// SendVerificationCode operation middleware
|
||||
func (siw *ServerInterfaceWrapper) SendVerificationCode(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.SendVerificationCode(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// Login operation middleware
|
||||
func (siw *ServerInterfaceWrapper) Login(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.Login(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// RefreshToken operation middleware
|
||||
func (siw *ServerInterfaceWrapper) RefreshToken(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.RefreshToken(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// Register operation middleware
|
||||
func (siw *ServerInterfaceWrapper) Register(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.Register(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// GetMe operation middleware
|
||||
func (siw *ServerInterfaceWrapper) GetMe(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.GetMe(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// ListDevices operation middleware
|
||||
func (siw *ServerInterfaceWrapper) ListDevices(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.ListDevices(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// DeleteDevice operation middleware
|
||||
func (siw *ServerInterfaceWrapper) DeleteDevice(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var err error
|
||||
_ = err
|
||||
|
||||
// ------------- Path parameter "id" -------------
|
||||
var id openapi_types.UUID
|
||||
|
||||
err = runtime.BindStyledParameterWithOptions("simple", "id", chi.URLParam(r, "id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true, Type: "string", Format: "uuid"})
|
||||
if err != nil {
|
||||
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "id", Err: err})
|
||||
return
|
||||
}
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.DeleteDevice(w, r, id)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// ListNodes operation middleware
|
||||
func (siw *ServerInterfaceWrapper) ListNodes(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var err error
|
||||
_ = err
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
// Parameter object where we will unmarshal all parameters from the context
|
||||
var params ListNodesParams
|
||||
|
||||
// ------------- Optional query parameter "if_version" -------------
|
||||
|
||||
err = runtime.BindQueryParameterWithOptions("form", true, false, "if_version", r.URL.Query(), ¶ms.IfVersion, runtime.BindQueryParameterOptions{Type: "integer", Format: "int64"})
|
||||
if err != nil {
|
||||
var requiredError *runtime.RequiredParameterError
|
||||
if errors.As(err, &requiredError) {
|
||||
siw.ErrorHandlerFunc(w, r, &RequiredParamError{ParamName: "if_version"})
|
||||
} else {
|
||||
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "if_version", Err: err})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.ListNodes(w, r, params)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// ConnectNode operation middleware
|
||||
func (siw *ServerInterfaceWrapper) ConnectNode(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var err error
|
||||
_ = err
|
||||
|
||||
// ------------- Path parameter "id" -------------
|
||||
var id openapi_types.UUID
|
||||
|
||||
err = runtime.BindStyledParameterWithOptions("simple", "id", chi.URLParam(r, "id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true, Type: "string", Format: "uuid"})
|
||||
if err != nil {
|
||||
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "id", Err: err})
|
||||
return
|
||||
}
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.ConnectNode(w, r, id)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// DisconnectNode operation middleware
|
||||
func (siw *ServerInterfaceWrapper) DisconnectNode(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var err error
|
||||
_ = err
|
||||
|
||||
// ------------- Path parameter "id" -------------
|
||||
var id openapi_types.UUID
|
||||
|
||||
err = runtime.BindStyledParameterWithOptions("simple", "id", chi.URLParam(r, "id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true, Type: "string", Format: "uuid"})
|
||||
if err != nil {
|
||||
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "id", Err: err})
|
||||
return
|
||||
}
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.DisconnectNode(w, r, id)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// ListNotices operation middleware
|
||||
func (siw *ServerInterfaceWrapper) ListNotices(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.ListNotices(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// ListPlans operation middleware
|
||||
func (siw *ServerInterfaceWrapper) ListPlans(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.ListPlans(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// RedeemCode operation middleware
|
||||
func (siw *ServerInterfaceWrapper) RedeemCode(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.RedeemCode(w, r)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// GetUsage operation middleware
|
||||
func (siw *ServerInterfaceWrapper) GetUsage(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var err error
|
||||
_ = err
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
|
||||
|
||||
r = r.WithContext(ctx)
|
||||
|
||||
// Parameter object where we will unmarshal all parameters from the context
|
||||
var params GetUsageParams
|
||||
|
||||
// ------------- Optional query parameter "days" -------------
|
||||
|
||||
err = runtime.BindQueryParameterWithOptions("form", true, false, "days", r.URL.Query(), ¶ms.Days, runtime.BindQueryParameterOptions{Type: "integer", Format: ""})
|
||||
if err != nil {
|
||||
var requiredError *runtime.RequiredParameterError
|
||||
if errors.As(err, &requiredError) {
|
||||
siw.ErrorHandlerFunc(w, r, &RequiredParamError{ParamName: "days"})
|
||||
} else {
|
||||
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "days", Err: err})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
siw.Handler.GetUsage(w, r, params)
|
||||
}))
|
||||
|
||||
for _, middleware := range siw.HandlerMiddlewares {
|
||||
handler = middleware(handler)
|
||||
}
|
||||
|
||||
handler.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
type UnescapedCookieParamError struct {
|
||||
ParamName string
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *UnescapedCookieParamError) Error() string {
|
||||
return fmt.Sprintf("error unescaping cookie parameter '%s'", e.ParamName)
|
||||
}
|
||||
|
||||
func (e *UnescapedCookieParamError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
type UnmarshalingParamError struct {
|
||||
ParamName string
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *UnmarshalingParamError) Error() string {
|
||||
return fmt.Sprintf("Error unmarshaling parameter %s as JSON: %s", e.ParamName, e.Err.Error())
|
||||
}
|
||||
|
||||
func (e *UnmarshalingParamError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
type RequiredParamError struct {
|
||||
ParamName string
|
||||
}
|
||||
|
||||
func (e *RequiredParamError) Error() string {
|
||||
return fmt.Sprintf("Query argument %s is required, but not found", e.ParamName)
|
||||
}
|
||||
|
||||
type RequiredHeaderError struct {
|
||||
ParamName string
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *RequiredHeaderError) Error() string {
|
||||
return fmt.Sprintf("Header parameter %s is required, but not found", e.ParamName)
|
||||
}
|
||||
|
||||
func (e *RequiredHeaderError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
type InvalidParamFormatError struct {
|
||||
ParamName string
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *InvalidParamFormatError) Error() string {
|
||||
return fmt.Sprintf("Invalid format for parameter %s: %s", e.ParamName, e.Err.Error())
|
||||
}
|
||||
|
||||
func (e *InvalidParamFormatError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
type TooManyValuesForParamError struct {
|
||||
ParamName string
|
||||
Count int
|
||||
}
|
||||
|
||||
func (e *TooManyValuesForParamError) Error() string {
|
||||
return fmt.Sprintf("Expected one value for %s, got %d", e.ParamName, e.Count)
|
||||
}
|
||||
|
||||
// Handler creates http.Handler with routing matching OpenAPI spec.
|
||||
func Handler(si ServerInterface) http.Handler {
|
||||
return HandlerWithOptions(si, ChiServerOptions{})
|
||||
}
|
||||
|
||||
type ChiServerOptions struct {
|
||||
BaseURL string
|
||||
BaseRouter chi.Router
|
||||
Middlewares []MiddlewareFunc
|
||||
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
|
||||
}
|
||||
|
||||
// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
|
||||
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler {
|
||||
return HandlerWithOptions(si, ChiServerOptions{
|
||||
BaseRouter: r,
|
||||
})
|
||||
}
|
||||
|
||||
func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler {
|
||||
return HandlerWithOptions(si, ChiServerOptions{
|
||||
BaseURL: baseURL,
|
||||
BaseRouter: r,
|
||||
})
|
||||
}
|
||||
|
||||
// HandlerWithOptions creates http.Handler with additional options
|
||||
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler {
|
||||
r := options.BaseRouter
|
||||
|
||||
if r == nil {
|
||||
r = chi.NewRouter()
|
||||
}
|
||||
if options.ErrorHandlerFunc == nil {
|
||||
options.ErrorHandlerFunc = func(w http.ResponseWriter, r *http.Request, err error) {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
}
|
||||
wrapper := ServerInterfaceWrapper{
|
||||
Handler: si,
|
||||
HandlerMiddlewares: options.Middlewares,
|
||||
ErrorHandlerFunc: options.ErrorHandlerFunc,
|
||||
}
|
||||
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Post(options.BaseURL+"/ads/unlock", wrapper.AdsUnlock)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Post(options.BaseURL+"/auth/code", wrapper.SendVerificationCode)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Post(options.BaseURL+"/auth/login", wrapper.Login)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Post(options.BaseURL+"/auth/refresh", wrapper.RefreshToken)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Post(options.BaseURL+"/auth/register", wrapper.Register)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Get(options.BaseURL+"/me", wrapper.GetMe)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Get(options.BaseURL+"/me/devices", wrapper.ListDevices)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Delete(options.BaseURL+"/me/devices/{id}", wrapper.DeleteDevice)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Get(options.BaseURL+"/nodes", wrapper.ListNodes)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Post(options.BaseURL+"/nodes/{id}/connect", wrapper.ConnectNode)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Post(options.BaseURL+"/nodes/{id}/disconnect", wrapper.DisconnectNode)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Get(options.BaseURL+"/notices", wrapper.ListNotices)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Get(options.BaseURL+"/plans", wrapper.ListPlans)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Post(options.BaseURL+"/redeem", wrapper.RedeemCode)
|
||||
})
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Get(options.BaseURL+"/usage", wrapper.GetUsage)
|
||||
})
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// Base64 encoded, compressed with deflate, json marshaled OpenAPI spec.
|
||||
// Stored as a slice of fixed-width chunks rather than one concatenated
|
||||
// const string: with thousands of chunks the chained `+` fold is several
|
||||
// times slower for the Go compiler than parsing a slice literal.
|
||||
var swaggerSpec = []string{
|
||||
"5HxrUxNZGvBfOZV9q3bXQRIEnBmqrFpHZ3acUYcS3a2p0YI2aSE7oTvb3VHZKbcCckkwIWEMtxDkIpeM",
|
||||
"QoKoEJMGPrz/ZOxzuvtT/sJb55xOp5N0CKOMzlv7hSJJ9znPee7X85PDzff7eY7lJNHR8ZNDYEU/z4ks",
|
||||
"+fAF47nG/jvAihL+5OY5ieXIv4zf7/O6GcnLc85/iTyHvxPdfWw/g//7PwJ7x9Hh+JOzvLST/io6vxQE",
|
||||
"XnA8ePCgyeFhRbfg9eNFHB0OLbuHXgzB2BCa2tYXnqCXUyg0reSScHwZLS3rzyJw9YX2as3xoMlxgefu",
|
||||
"+LzuDwHU62GUj8PRHfXZYFEOwfUhfSijZl7AvR30Mg1HI2+Dg+gwiF4V1KVBuLejrTyHI5MoulKUwxjS",
|
||||
"r3jhttfjYbnfH1SlsKqGIygVRlMhZX8ULTzU5+JKLqrtvqSQw5Go9uqNGg5pmUN9JqMUZrVXb7TxIXXo",
|
||||
"zdvgoJY5gKtjSi4KXzxR8hNw/zEMR9VEGoX2jLNc4iRW4Bjf738UlIrC8WX1eRaOjugP03piTstmMQhX",
|
||||
"eekrPsB5fn8Q1PkMWhqj5MdI2ZqFqTQG4TrPX2G4AUMsxA8lF/rKpDoxpu2OaIdj+lwchnaLckRNR2F8",
|
||||
"Qh+LatkpR5Ojj2U8rEBAusZKwsDp83ckVsAfK1eEmRUU2sPozSfUrTA8GFGTw+rGz2hqG8Yn4GjUXLEM",
|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EEmqbzB",
|
||||
"/rHJFGoireQn6Dg/fUZffq3kJpTCHlqSYfYNyiaoe2vkGmiTcNJU8VjMydQmMHt8inJEXy6oqUe0Dako",
|
||||
"R1oAjG2XsmRh0ufYee07euOQPhenzUlFOfKZ6xNA53GLcqS9+iU4v6LPLtI98Wa5LWU/Wjc3hnm0k+Dn",
|
||||
"RDnURPmx+JNM9jbiTrrksXiTEuGj8yYBoyY6rWopo5c5HdUwapmlIwU0GqDSaT5ziM86wYd9DtJxTEce",
|
||||
"323YkbIzUXn60wk0sYGXiU6VGuTJICP5FbTT5rPtGFaN8Qk9MQhaAP2IIaFpfnoKChUt2zIBj1fq9vG9",
|
||||
"9QqnGC8n2oJmXzq9IPDuH+/wggd8wYhs6xlgxXULKazC+HMa3yv70epp3Yunv/zq71+f/ubby1dOX+10",
|
||||
"uY53l9THDlgqRmht1TuhF6lO/qEdkj9ysbPcKVEpw/WVgXln0xGWCqWC2uEkuArg6i9qcpiaFev8Frmg",
|
||||
"BtsrtbCoZZb15ddofFbNH8L5A+AEaPGFOr4L5w+oNatT+iQTY43CBNqeT+GBY0tw9Rds0wqzWmYVfEqm",
|
||||
"3IJwdQN87qqTejUGd8sc62HvMGSm+1PL7TifuxpcunXrZC0X7zXuWD+W6bKM1jU0YHTl41iwqnE8qyn7",
|
||||
"MHL4/tbPOML8jpq3NlRTxrr1oKoboHKQ6YdbmKj00k87xlMTi0p+Q53IwpWHjiZHQPAZA0hih9PJ+L0V",
|
||||
"97w677Y48HIGBLW1tlUtO6jO5+AIuYE9Nmk20LwNDprXx9Nuv7fBQaPr6TrteDOKNvTWU0DnrQzuJkd5",
|
||||
"0GQ/tWZmlenstOUto9RV+yKcGlVySX1mS53IYney8poDDJmlnR1/tLgftBHP2MLUOTbAWRLqGERLyoQm",
|
||||
"UazlVziyRi7QsyxNo7jadSkzUH1Ufprygs1JiVNvXZV68w9uPfh/AQAA//8=",
|
||||
}
|
||||
|
||||
// decodeSpec returns the embedded OpenAPI spec as raw JSON bytes,
|
||||
// after base64-decoding and flate-decompressing the embedded blob.
|
||||
func decodeSpec() ([]byte, error) {
|
||||
encoded := strings.Join(swaggerSpec, "")
|
||||
compressed, err := base64.StdEncoding.DecodeString(encoded)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error base64 decoding spec: %w", err)
|
||||
}
|
||||
zr := flate.NewReader(bytes.NewReader(compressed))
|
||||
var buf bytes.Buffer
|
||||
if _, err := buf.ReadFrom(zr); err != nil {
|
||||
return nil, fmt.Errorf("read flate: %w", err)
|
||||
}
|
||||
if err := zr.Close(); err != nil {
|
||||
return nil, fmt.Errorf("close flate reader: %w", err)
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
var rawSpec = decodeSpecCached()
|
||||
|
||||
// a naive cache of the decoded OpenAPI spec
|
||||
func decodeSpecCached() func() ([]byte, error) {
|
||||
data, err := decodeSpec()
|
||||
return func() ([]byte, error) {
|
||||
return data, err
|
||||
}
|
||||
}
|
||||
|
||||
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
|
||||
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
|
||||
res := make(map[string]func() ([]byte, error))
|
||||
if len(pathToFile) > 0 {
|
||||
res[pathToFile] = rawSpec
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// GetSpec returns the OpenAPI specification corresponding to the generated
|
||||
// code in this file. External references in the spec are resolved through
|
||||
// PathToRawSpec; externally-referenced files must be embedded in their
|
||||
// corresponding Go packages (via the import-mapping feature). URL-based
|
||||
// external refs are not supported.
|
||||
func GetSpec() (swagger *openapi3.T, err error) {
|
||||
resolvePath := PathToRawSpec("")
|
||||
|
||||
loader := openapi3.NewLoader()
|
||||
loader.IsExternalRefsAllowed = true
|
||||
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
|
||||
pathToFile := url.String()
|
||||
pathToFile = path.Clean(pathToFile)
|
||||
getSpec, ok := resolvePath[pathToFile]
|
||||
if !ok {
|
||||
err1 := fmt.Errorf("path not found: %s", pathToFile)
|
||||
return nil, err1
|
||||
}
|
||||
return getSpec()
|
||||
}
|
||||
var specData []byte
|
||||
specData, err = rawSpec()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
swagger, err = loader.LoadFromData(specData)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetSpecJSON returns the raw JSON bytes of the embedded OpenAPI
|
||||
// specification: decompressed but not unmarshaled. External references
|
||||
// are not resolved here; the bytes are the spec exactly as embedded by
|
||||
// codegen. The result is cached at package init time, so repeated calls
|
||||
// are cheap.
|
||||
func GetSpecJSON() ([]byte, error) {
|
||||
return rawSpec()
|
||||
}
|
||||
|
||||
// GetSwagger returns the OpenAPI specification corresponding to the
|
||||
// generated code in this file.
|
||||
//
|
||||
// Deprecated: GetSwagger predates kin-openapi renaming openapi3.Swagger
|
||||
// to openapi3.T. Use [GetSpec] instead. This wrapper is retained for
|
||||
// backwards compatibility.
|
||||
func GetSwagger() (*openapi3.T, error) {
|
||||
return GetSpec()
|
||||
}
|
||||
@@ -0,0 +1,551 @@
|
||||
// Package gen provides primitives to interact with the openapi HTTP API.
|
||||
//
|
||||
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.7.1 DO NOT EDIT.
|
||||
package gen
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
openapi_types "github.com/oapi-codegen/runtime/types"
|
||||
)
|
||||
|
||||
const (
|
||||
BearerAuthScopes bearerAuthContextKey = "bearerAuth.Scopes"
|
||||
)
|
||||
|
||||
// Defines values for ConnectCredentialProtocol.
|
||||
const (
|
||||
Hysteria2 ConnectCredentialProtocol = "hysteria2"
|
||||
Reality ConnectCredentialProtocol = "reality"
|
||||
)
|
||||
|
||||
// Valid indicates whether the value is a known member of the ConnectCredentialProtocol enum.
|
||||
func (e ConnectCredentialProtocol) Valid() bool {
|
||||
switch e {
|
||||
case Hysteria2:
|
||||
return true
|
||||
case Reality:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Defines values for DevicePlatform.
|
||||
const (
|
||||
Android DevicePlatform = "android"
|
||||
Ios DevicePlatform = "ios"
|
||||
Linux DevicePlatform = "linux"
|
||||
Macos DevicePlatform = "macos"
|
||||
Windows DevicePlatform = "windows"
|
||||
)
|
||||
|
||||
// Valid indicates whether the value is a known member of the DevicePlatform enum.
|
||||
func (e DevicePlatform) Valid() bool {
|
||||
switch e {
|
||||
case Android:
|
||||
return true
|
||||
case Ios:
|
||||
return true
|
||||
case Linux:
|
||||
return true
|
||||
case Macos:
|
||||
return true
|
||||
case Windows:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Defines values for NodeTier.
|
||||
const (
|
||||
NodeTierFree NodeTier = "free"
|
||||
NodeTierPro NodeTier = "pro"
|
||||
)
|
||||
|
||||
// Valid indicates whether the value is a known member of the NodeTier enum.
|
||||
func (e NodeTier) Valid() bool {
|
||||
switch e {
|
||||
case NodeTierFree:
|
||||
return true
|
||||
case NodeTierPro:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Defines values for PlanCode.
|
||||
const (
|
||||
PlanCodeFree PlanCode = "free"
|
||||
PlanCodePro PlanCode = "pro"
|
||||
PlanCodeTeam PlanCode = "team"
|
||||
)
|
||||
|
||||
// Valid indicates whether the value is a known member of the PlanCode enum.
|
||||
func (e PlanCode) Valid() bool {
|
||||
switch e {
|
||||
case PlanCodeFree:
|
||||
return true
|
||||
case PlanCodePro:
|
||||
return true
|
||||
case PlanCodeTeam:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Defines values for RedeemResultPlanCode.
|
||||
const (
|
||||
RedeemResultPlanCodeFree RedeemResultPlanCode = "free"
|
||||
RedeemResultPlanCodePro RedeemResultPlanCode = "pro"
|
||||
RedeemResultPlanCodeTeam RedeemResultPlanCode = "team"
|
||||
)
|
||||
|
||||
// Valid indicates whether the value is a known member of the RedeemResultPlanCode enum.
|
||||
func (e RedeemResultPlanCode) Valid() bool {
|
||||
switch e {
|
||||
case RedeemResultPlanCodeFree:
|
||||
return true
|
||||
case RedeemResultPlanCodePro:
|
||||
return true
|
||||
case RedeemResultPlanCodeTeam:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Defines values for SubscriptionInfoPlanCode.
|
||||
const (
|
||||
SubscriptionInfoPlanCodeFree SubscriptionInfoPlanCode = "free"
|
||||
SubscriptionInfoPlanCodePro SubscriptionInfoPlanCode = "pro"
|
||||
SubscriptionInfoPlanCodeTeam SubscriptionInfoPlanCode = "team"
|
||||
)
|
||||
|
||||
// Valid indicates whether the value is a known member of the SubscriptionInfoPlanCode enum.
|
||||
func (e SubscriptionInfoPlanCode) Valid() bool {
|
||||
switch e {
|
||||
case SubscriptionInfoPlanCodeFree:
|
||||
return true
|
||||
case SubscriptionInfoPlanCodePro:
|
||||
return true
|
||||
case SubscriptionInfoPlanCodeTeam:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Defines values for SubscriptionInfoSource.
|
||||
const (
|
||||
Admin SubscriptionInfoSource = "admin"
|
||||
Code SubscriptionInfoSource = "code"
|
||||
Trial SubscriptionInfoSource = "trial"
|
||||
)
|
||||
|
||||
// Valid indicates whether the value is a known member of the SubscriptionInfoSource enum.
|
||||
func (e SubscriptionInfoSource) Valid() bool {
|
||||
switch e {
|
||||
case Admin:
|
||||
return true
|
||||
case Code:
|
||||
return true
|
||||
case Trial:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Defines values for UserInfoStatus.
|
||||
const (
|
||||
Active UserInfoStatus = "active"
|
||||
Suspended UserInfoStatus = "suspended"
|
||||
)
|
||||
|
||||
// Valid indicates whether the value is a known member of the UserInfoStatus enum.
|
||||
func (e UserInfoStatus) Valid() bool {
|
||||
switch e {
|
||||
case Active:
|
||||
return true
|
||||
case Suspended:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// ConnectCredential sing-box 连接凭证,支持 REALITY 主线 + Hysteria2 备线。
|
||||
// 每用户一个数据面 UUID(dp_uuid),与账号 UUID 解耦、可独立轮换;
|
||||
// 节点侧只见 dp_uuid,零账号信息,单节点被抄不泄露用户库。
|
||||
//
|
||||
// **字段稳定性**:本 schema 可能随数据面树(任务 #5)最终敲定后 bump,
|
||||
// 在正式实现前以该任务产出为权威依据。
|
||||
type ConnectCredential struct {
|
||||
// Flow VLESS flow 参数,REALITY 协议时使用(通常为 `xtls-rprx-vision`)
|
||||
Flow *string `json:"flow,omitempty"`
|
||||
|
||||
// Hysteria2 Hysteria2 备线参数(仅 protocol=hysteria2 或客户端协议降级时使用)
|
||||
Hysteria2 *Hysteria2Params `json:"hysteria2,omitempty"`
|
||||
|
||||
// Port 主协议端口(REALITY 用 TCP 443;Hysteria2 用 UDP 443)
|
||||
Port int `json:"port"`
|
||||
|
||||
// Protocol 优先协议(客户端按网络状况自动选;服务端返回当前最优)
|
||||
Protocol ConnectCredentialProtocol `json:"protocol"`
|
||||
|
||||
// Reality REALITY 协议参数(仅 protocol=reality 时有意义)
|
||||
Reality *RealityParams `json:"reality,omitempty"`
|
||||
|
||||
// Server 节点服务器地址(IP 或域名)
|
||||
Server string `json:"server"`
|
||||
|
||||
// TtlSeconds 凭证有效秒数。免费版 = 当日剩余分钟数 × 60;付费版 = 86400(24h,在线自动续期)。
|
||||
TtlSeconds int `json:"ttl_seconds"`
|
||||
|
||||
// Uuid 用户数据面 UUID(dp_uuid),即 VLESS uuid 字段。
|
||||
// Hysteria2 auth password 由同一 UUID 派生(客户端无需单独字段)。
|
||||
Uuid openapi_types.UUID `json:"uuid"`
|
||||
}
|
||||
|
||||
// ConnectCredentialProtocol 优先协议(客户端按网络状况自动选;服务端返回当前最优)
|
||||
type ConnectCredentialProtocol string
|
||||
|
||||
// Device defines model for Device.
|
||||
type Device struct {
|
||||
// LastSeen 最后活跃时间(UTC ISO-8601)
|
||||
LastSeen time.Time `json:"last_seen"`
|
||||
|
||||
// Name 设备名称(客户端上报,如「iPhone 15 Pro」)
|
||||
Name string `json:"name"`
|
||||
|
||||
// Platform 设备平台
|
||||
Platform DevicePlatform `json:"platform"`
|
||||
|
||||
// Uuid 设备 UUID
|
||||
Uuid openapi_types.UUID `json:"uuid"`
|
||||
}
|
||||
|
||||
// DevicePlatform 设备平台
|
||||
type DevicePlatform string
|
||||
|
||||
// Error 统一错误响应体,三字段均 required。文案遵守脱敏口径(不含红线词)。
|
||||
type Error struct {
|
||||
// Code 机器可读错误码,例如 `auth.code_expired` / `redeem.already_redeemed`
|
||||
Code string `json:"code"`
|
||||
|
||||
// MessageEn 英文错误文案(面向用户展示)
|
||||
MessageEn string `json:"message_en"`
|
||||
|
||||
// MessageZh 中文错误文案(面向用户展示)
|
||||
MessageZh string `json:"message_zh"`
|
||||
}
|
||||
|
||||
// Hysteria2Params Hysteria2 备线参数(仅 protocol=hysteria2 或客户端协议降级时使用)
|
||||
type Hysteria2Params struct {
|
||||
// Obfs 混淆模式(可选,如 `salamander`);null 表示不启用混淆
|
||||
Obfs *string `json:"obfs,omitempty"`
|
||||
|
||||
// Password Hysteria2 auth password(由 dp_uuid 派生,服务端同源生成)
|
||||
Password string `json:"password"`
|
||||
|
||||
// Port Hysteria2 UDP 端口(通常 443)
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
||||
// Me defines model for Me.
|
||||
type Me struct {
|
||||
Subscription SubscriptionInfo `json:"subscription"`
|
||||
TodayUsage TodayUsageSummary `json:"today_usage"`
|
||||
User UserInfo `json:"user"`
|
||||
}
|
||||
|
||||
// Node 节点目录条目。**不含任何密钥或连接参数**(reality_pbk/sni/password 等),
|
||||
// 这些信息仅在 POST /nodes/{id}/connect 成功后下发。
|
||||
type Node struct {
|
||||
// Load 节点当前负载百分比(0~100),由 agent 每 30s 上报到 Redis
|
||||
Load int `json:"load"`
|
||||
|
||||
// NameEn 节点英文名称
|
||||
NameEn string `json:"name_en"`
|
||||
|
||||
// NameZh 节点中文名称
|
||||
NameZh string `json:"name_zh"`
|
||||
|
||||
// Region 地区代码,2 字母大写(HK/JP/SG/US …)
|
||||
Region string `json:"region"`
|
||||
|
||||
// Signal 信号格数(0~4),由 agent 上报延迟换算,客户端展示信号条
|
||||
Signal int `json:"signal"`
|
||||
|
||||
// Tier 节点等级(free 节点免费版可用,pro 节点需付费订阅)
|
||||
Tier NodeTier `json:"tier"`
|
||||
|
||||
// Uuid 节点 UUID(connect 时作为 path 参数)
|
||||
Uuid openapi_types.UUID `json:"uuid"`
|
||||
}
|
||||
|
||||
// NodeTier 节点等级(free 节点免费版可用,pro 节点需付费订阅)
|
||||
type NodeTier string
|
||||
|
||||
// NodeDirectory defines model for NodeDirectory.
|
||||
type NodeDirectory struct {
|
||||
Nodes []Node `json:"nodes"`
|
||||
|
||||
// Version 目录全局版本号;任何节点变更 bump 此值,客户端据此决定是否刷新缓存
|
||||
Version int64 `json:"version"`
|
||||
}
|
||||
|
||||
// Notice defines model for Notice.
|
||||
type Notice struct {
|
||||
// BodyEn 公告英文正文(Markdown)
|
||||
BodyEn string `json:"body_en"`
|
||||
|
||||
// BodyZh 公告中文正文(Markdown)
|
||||
BodyZh string `json:"body_zh"`
|
||||
|
||||
// Id 公告 UUID
|
||||
Id openapi_types.UUID `json:"id"`
|
||||
|
||||
// PublishedAt 发布时间(UTC ISO-8601)
|
||||
PublishedAt time.Time `json:"published_at"`
|
||||
|
||||
// TitleEn 公告英文标题
|
||||
TitleEn string `json:"title_en"`
|
||||
|
||||
// TitleZh 公告中文标题
|
||||
TitleZh string `json:"title_zh"`
|
||||
}
|
||||
|
||||
// Plan defines model for Plan.
|
||||
type Plan struct {
|
||||
// AdGate 首次连接是否需要激励广告解锁(仅 free=true)
|
||||
AdGate bool `json:"ad_gate"`
|
||||
|
||||
// Code 套餐唯一代码
|
||||
Code PlanCode `json:"code"`
|
||||
|
||||
// DailyMinutes 每日可用分钟数上限;null 表示无限制(pro/team)
|
||||
DailyMinutes *int `json:"daily_minutes,omitempty"`
|
||||
|
||||
// MaxDevices 最大同时在线设备数(free=1, pro=5, team=10)
|
||||
MaxDevices int `json:"max_devices"`
|
||||
}
|
||||
|
||||
// PlanCode 套餐唯一代码
|
||||
type PlanCode string
|
||||
|
||||
// RealityParams REALITY 协议参数(仅 protocol=reality 时有意义)
|
||||
type RealityParams struct {
|
||||
// PublicKey REALITY 服务端公钥(x25519)
|
||||
PublicKey string `json:"public_key"`
|
||||
|
||||
// ShortId REALITY short ID(十六进制字符串)
|
||||
ShortId string `json:"short_id"`
|
||||
|
||||
// Sni TLS SNI 伪装域名
|
||||
Sni string `json:"sni"`
|
||||
}
|
||||
|
||||
// RedeemResult 激活码兑换结果。幂等设计:同一用户重复提交同一码返回首次结果(非报错)。
|
||||
type RedeemResult struct {
|
||||
// ExpiresAt 兑换后的订阅到期时间(UTC ISO-8601)
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
|
||||
// ExtendedDays 本次顺延的天数(叠加而非覆盖)
|
||||
ExtendedDays int `json:"extended_days"`
|
||||
|
||||
// PlanCode 本次兑换激活的套餐代码
|
||||
PlanCode RedeemResultPlanCode `json:"plan_code"`
|
||||
}
|
||||
|
||||
// RedeemResultPlanCode 本次兑换激活的套餐代码
|
||||
type RedeemResultPlanCode string
|
||||
|
||||
// SubscriptionInfo defines model for SubscriptionInfo.
|
||||
type SubscriptionInfo struct {
|
||||
// ExpiresAt 订阅到期时间(UTC ISO-8601),免费版无到期时间时为 null
|
||||
ExpiresAt *time.Time `json:"expires_at,omitempty"`
|
||||
|
||||
// PlanCode 当前套餐代码
|
||||
PlanCode SubscriptionInfoPlanCode `json:"plan_code"`
|
||||
|
||||
// Source 订阅来源(试用 / 激活码 / 管理员)
|
||||
Source SubscriptionInfoSource `json:"source"`
|
||||
}
|
||||
|
||||
// SubscriptionInfoPlanCode 当前套餐代码
|
||||
type SubscriptionInfoPlanCode string
|
||||
|
||||
// SubscriptionInfoSource 订阅来源(试用 / 激活码 / 管理员)
|
||||
type SubscriptionInfoSource string
|
||||
|
||||
// TodayUsageSummary defines model for TodayUsageSummary.
|
||||
type TodayUsageSummary struct {
|
||||
// AdUnlocked 免费版今日是否已完成激励广告解锁
|
||||
AdUnlocked *bool `json:"ad_unlocked,omitempty"`
|
||||
|
||||
// MinutesRemaining 今日剩余分钟数,付费无限制时为 null
|
||||
MinutesRemaining *int `json:"minutes_remaining"`
|
||||
|
||||
// MinutesUsed 今日已使用分钟数
|
||||
MinutesUsed int `json:"minutes_used"`
|
||||
}
|
||||
|
||||
// TokenPair defines model for TokenPair.
|
||||
type TokenPair struct {
|
||||
// AccessToken JWT access token,有效期 15 分钟
|
||||
AccessToken string `json:"access_token"`
|
||||
|
||||
// ExpiresIn access_token 有效秒数(固定 900)
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
|
||||
// RefreshToken Refresh token,有效期 30 天
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
|
||||
// UsagePoint 单日用量数据点(无目的地/DNS/流量内容,仅字节数与分钟数,符合无日志承诺)
|
||||
type UsagePoint struct {
|
||||
// BytesDown 当日下行字节数
|
||||
BytesDown int64 `json:"bytes_down"`
|
||||
|
||||
// BytesUp 当日上行字节数
|
||||
BytesUp int64 `json:"bytes_up"`
|
||||
|
||||
// Date 日期(UTC,YYYY-MM-DD)
|
||||
Date openapi_types.Date `json:"date"`
|
||||
|
||||
// MinutesUsed 当日已用分钟数
|
||||
MinutesUsed int `json:"minutes_used"`
|
||||
}
|
||||
|
||||
// UserInfo defines model for UserInfo.
|
||||
type UserInfo struct {
|
||||
Email openapi_types.Email `json:"email"`
|
||||
|
||||
// Status 账户状态
|
||||
Status UserInfoStatus `json:"status"`
|
||||
|
||||
// Uuid 用户全局唯一标识(对外口径,永不暴露自增 ID)
|
||||
Uuid openapi_types.UUID `json:"uuid"`
|
||||
}
|
||||
|
||||
// UserInfoStatus 账户状态
|
||||
type UserInfoStatus string
|
||||
|
||||
// BadRequest 统一错误响应体,三字段均 required。文案遵守脱敏口径(不含红线词)。
|
||||
type BadRequest = Error
|
||||
|
||||
// Conflict 统一错误响应体,三字段均 required。文案遵守脱敏口径(不含红线词)。
|
||||
type Conflict = Error
|
||||
|
||||
// Forbidden 统一错误响应体,三字段均 required。文案遵守脱敏口径(不含红线词)。
|
||||
type Forbidden = Error
|
||||
|
||||
// Internal 统一错误响应体,三字段均 required。文案遵守脱敏口径(不含红线词)。
|
||||
type Internal = Error
|
||||
|
||||
// NotFound 统一错误响应体,三字段均 required。文案遵守脱敏口径(不含红线词)。
|
||||
type NotFound = Error
|
||||
|
||||
// TooManyRequests 统一错误响应体,三字段均 required。文案遵守脱敏口径(不含红线词)。
|
||||
type TooManyRequests = Error
|
||||
|
||||
// Unauthorized 统一错误响应体,三字段均 required。文案遵守脱敏口径(不含红线词)。
|
||||
type Unauthorized = Error
|
||||
|
||||
// bearerAuthContextKey is the context key for bearerAuth security scheme
|
||||
type bearerAuthContextKey string
|
||||
|
||||
// AdsUnlockJSONBody defines parameters for AdsUnlock.
|
||||
type AdsUnlockJSONBody struct {
|
||||
// AdToken 广告 SDK 签发的服务端回执 token
|
||||
AdToken string `json:"ad_token"`
|
||||
|
||||
// DeviceId 发起广告的设备 UUID
|
||||
DeviceId openapi_types.UUID `json:"device_id"`
|
||||
}
|
||||
|
||||
// SendVerificationCodeJSONBody defines parameters for SendVerificationCode.
|
||||
type SendVerificationCodeJSONBody struct {
|
||||
Email openapi_types.Email `json:"email"`
|
||||
}
|
||||
|
||||
// LoginJSONBody defines parameters for Login.
|
||||
type LoginJSONBody struct {
|
||||
Email openapi_types.Email `json:"email"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
// RefreshTokenJSONBody defines parameters for RefreshToken.
|
||||
type RefreshTokenJSONBody struct {
|
||||
// RefreshToken 有效的 refresh token(30 天有效期)
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
|
||||
// RegisterJSONBody defines parameters for Register.
|
||||
type RegisterJSONBody struct {
|
||||
// Code 6 位数字验证码
|
||||
Code string `json:"code"`
|
||||
Email openapi_types.Email `json:"email"`
|
||||
|
||||
// Password 用户密码,argon2id 存储
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
// ListNodesParams defines parameters for ListNodes.
|
||||
type ListNodesParams struct {
|
||||
// IfVersion 客户端已缓存的目录版本号;命中则返回 304
|
||||
IfVersion *int64 `form:"if_version,omitempty" json:"if_version,omitempty"`
|
||||
}
|
||||
|
||||
// ConnectNodeJSONBody defines parameters for ConnectNode.
|
||||
type ConnectNodeJSONBody struct {
|
||||
// DeviceId 发起连接的设备 UUID
|
||||
DeviceId openapi_types.UUID `json:"device_id"`
|
||||
}
|
||||
|
||||
// DisconnectNodeJSONBody defines parameters for DisconnectNode.
|
||||
type DisconnectNodeJSONBody struct {
|
||||
// DeviceId 发起断开的设备 UUID
|
||||
DeviceId openapi_types.UUID `json:"device_id"`
|
||||
}
|
||||
|
||||
// RedeemCodeJSONBody defines parameters for RedeemCode.
|
||||
type RedeemCodeJSONBody struct {
|
||||
// Code Crockford Base32 激活码,16 位含校验位
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
// GetUsageParams defines parameters for GetUsage.
|
||||
type GetUsageParams struct {
|
||||
// Days 查询最近几天,默认 7,最大 90
|
||||
Days *int `form:"days,omitempty" json:"days,omitempty"`
|
||||
}
|
||||
|
||||
// AdsUnlockJSONRequestBody defines body for AdsUnlock for application/json ContentType.
|
||||
type AdsUnlockJSONRequestBody AdsUnlockJSONBody
|
||||
|
||||
// SendVerificationCodeJSONRequestBody defines body for SendVerificationCode for application/json ContentType.
|
||||
type SendVerificationCodeJSONRequestBody SendVerificationCodeJSONBody
|
||||
|
||||
// LoginJSONRequestBody defines body for Login for application/json ContentType.
|
||||
type LoginJSONRequestBody LoginJSONBody
|
||||
|
||||
// RefreshTokenJSONRequestBody defines body for RefreshToken for application/json ContentType.
|
||||
type RefreshTokenJSONRequestBody RefreshTokenJSONBody
|
||||
|
||||
// RegisterJSONRequestBody defines body for Register for application/json ContentType.
|
||||
type RegisterJSONRequestBody RegisterJSONBody
|
||||
|
||||
// ConnectNodeJSONRequestBody defines body for ConnectNode for application/json ContentType.
|
||||
type ConnectNodeJSONRequestBody ConnectNodeJSONBody
|
||||
|
||||
// DisconnectNodeJSONRequestBody defines body for DisconnectNode for application/json ContentType.
|
||||
type DisconnectNodeJSONRequestBody DisconnectNodeJSONBody
|
||||
|
||||
// RedeemCodeJSONRequestBody defines body for RedeemCode for application/json ContentType.
|
||||
type RedeemCodeJSONRequestBody RedeemCodeJSONBody
|
||||
@@ -557,7 +557,7 @@ components:
|
||||
type: http
|
||||
scheme: bearer
|
||||
bearerFormat: JWT
|
||||
description: JWT RS256,`Authorization: Bearer <access_token>`
|
||||
description: "JWT RS256,`Authorization: Bearer <access_token>`"
|
||||
|
||||
# ── 统一错误响应 ────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user