237 lines
7.1 KiB
Plaintext
237 lines
7.1 KiB
Plaintext
syntax = "v1"
|
|
|
|
info (
|
|
title: "Node API"
|
|
desc: "API for ppanel"
|
|
author: "Tension"
|
|
email: "tension@ppanel.com"
|
|
version: "0.0.1"
|
|
)
|
|
|
|
import "../types.api"
|
|
|
|
type (
|
|
ServerOnlineIP {
|
|
IP string `json:"ip"`
|
|
Protocol string `json:"protocol"`
|
|
}
|
|
ServerOnlineUser {
|
|
IP []ServerOnlineIP `json:"ip"`
|
|
UserId int64 `json:"user_id"`
|
|
Subscribe string `json:"subscribe"`
|
|
SubscribeId int64 `json:"subscribe_id"`
|
|
Traffic int64 `json:"traffic"`
|
|
ExpiredAt int64 `json:"expired_at"`
|
|
}
|
|
ServerStatus {
|
|
Cpu float64 `json:"cpu"`
|
|
Mem float64 `json:"mem"`
|
|
Disk float64 `json:"disk"`
|
|
Protocol string `json:"protocol"`
|
|
Online []ServerOnlineUser `json:"online"`
|
|
}
|
|
Server {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Country string `json:"country"`
|
|
City string `json:"city"`
|
|
Ratio float32 `json:"ratio"`
|
|
Address string `json:"address"`
|
|
Sort int `json:"sort"`
|
|
Protocols []Protocol `json:"protocols"`
|
|
LastReportedAt int64 `json:"last_reported_at"`
|
|
Status ServerStatus `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
Protocol {
|
|
Type string `json:"type"`
|
|
Port uint16 `json:"port"`
|
|
Security string `json:"security,omitempty"`
|
|
SNI string `json:"sni,omitempty"`
|
|
AllowInsecure bool `json:"allow_insecure,omitempty"`
|
|
Fingerprint string `json:"fingerprint,omitempty"`
|
|
RealityServerAddr string `json:"reality_server_addr,omitempty"`
|
|
RealityServerPort int `json:"reality_server_port,omitempty"`
|
|
RealityPrivateKey string `json:"reality_private_key,omitempty"`
|
|
RealityPublicKey string `json:"reality_public_key,omitempty"`
|
|
RealityShortId string `json:"reality_short_id,omitempty"`
|
|
Transport string `json:"transport,omitempty"`
|
|
Host string `json:"host,omitempty"`
|
|
Path string `json:"path,omitempty"`
|
|
ServiceName string `json:"service_name,omitempty"`
|
|
Cipher string `json:"cipher,omitempty"`
|
|
ServerKey string `json:"server_key,omitempty"`
|
|
Flow string `json:"flow,omitempty"`
|
|
HopPorts string `json:"hop_ports,omitempty"`
|
|
HopInterval int `json:"hop_interval,omitempty"`
|
|
ObfsPassword string `json:"obfs_password,omitempty"`
|
|
DisableSNI bool `json:"disable_sni,omitempty"`
|
|
ReduceRtt bool `json:"reduce_rtt,omitempty"`
|
|
UDPRelayMode string `json:"udp_relay_mode,omitempty"`
|
|
CongestionController string `json:"congestion_controller,omitempty"`
|
|
}
|
|
CreateServerRequest {
|
|
Name string `json:"name"`
|
|
Country string `json:"country,omitempty"`
|
|
City string `json:"city,omitempty"`
|
|
Ratio float32 `json:"ratio"`
|
|
Address string `json:"address"`
|
|
Sort int `json:"sort,omitempty"`
|
|
Protocols []Protocol `json:"protocols"`
|
|
}
|
|
UpdateServerRequest {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Country string `json:"country,omitempty"`
|
|
City string `json:"city,omitempty"`
|
|
Ratio float32 `json:"ratio"`
|
|
Address string `json:"address"`
|
|
Sort int `json:"sort,omitempty"`
|
|
Protocols []Protocol `json:"protocols"`
|
|
}
|
|
DeleteServerRequest {
|
|
Id int64 `json:"id"`
|
|
}
|
|
FilterServerListRequest {
|
|
Page int `form:"page"`
|
|
Size int `form:"size"`
|
|
Search string `form:"search,omitempty"`
|
|
}
|
|
FilterServerListResponse {
|
|
Total int64 `json:"total"`
|
|
List []Server `json:"list"`
|
|
}
|
|
GetServerProtocolsRequest {
|
|
Id int64 `form:"id"`
|
|
}
|
|
GetServerProtocolsResponse {
|
|
Protocols []Protocol `json:"protocols"`
|
|
}
|
|
Node {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Tags []string `json:"tags"`
|
|
Port uint16 `json:"port"`
|
|
Address string `json:"address"`
|
|
ServerId int64 `json:"server_id"`
|
|
Protocol string `json:"protocol"`
|
|
Enabled *bool `json:"enabled"`
|
|
Sort int `json:"sort,omitempty"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
CreateNodeRequest {
|
|
Name string `json:"name"`
|
|
Tags []string `json:"tags,omitempty"`
|
|
Port uint16 `json:"port"`
|
|
Address string `json:"address"`
|
|
ServerId int64 `json:"server_id"`
|
|
Protocol string `json:"protocol"`
|
|
Enabled *bool `json:"enabled"`
|
|
}
|
|
UpdateNodeRequest {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Tags []string `json:"tags,omitempty"`
|
|
Port uint16 `json:"port"`
|
|
Address string `json:"address"`
|
|
ServerId int64 `json:"server_id"`
|
|
Protocol string `json:"protocol"`
|
|
Enabled *bool `json:"enabled"`
|
|
}
|
|
ToggleNodeStatusRequest {
|
|
Id int64 `json:"id"`
|
|
Enable *bool `json:"enable"`
|
|
}
|
|
DeleteNodeRequest {
|
|
Id int64 `json:"id"`
|
|
}
|
|
FilterNodeListRequest {
|
|
Page int `form:"page"`
|
|
Size int `form:"size"`
|
|
Search string `form:"search,omitempty"`
|
|
}
|
|
FilterNodeListResponse {
|
|
Total int64 `json:"total"`
|
|
List []Node `json:"list"`
|
|
}
|
|
HasMigrateSeverNodeResponse {
|
|
HasMigrate bool `json:"has_migrate"`
|
|
}
|
|
MigrateServerNodeResponse {
|
|
Succee uint64 `json:"succee"`
|
|
Fail uint64 `json:"fail"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
ResetSortRequest {
|
|
Page int `json:"page"`
|
|
Size int `json:"size"`
|
|
Sort []int64 `json:"sort"`
|
|
}
|
|
)
|
|
|
|
@server (
|
|
prefix: v1/admin/server
|
|
group: admin/server
|
|
middleware: AuthMiddleware
|
|
)
|
|
service ppanel {
|
|
@doc "Create Server"
|
|
@handler CreateServer
|
|
post /create (CreateServerRequest)
|
|
|
|
@doc "Update Server"
|
|
@handler UpdateServer
|
|
post /update (UpdateServerRequest)
|
|
|
|
@doc "Delete Server"
|
|
@handler DeleteServer
|
|
post /delete (DeleteServerRequest)
|
|
|
|
@doc "Filter Server List"
|
|
@handler FilterServerList
|
|
get /list (FilterServerListRequest) returns (FilterServerListResponse)
|
|
|
|
@doc "Get Server Protocols"
|
|
@handler GetServerProtocols
|
|
get /protocols (GetServerProtocolsRequest) returns (GetServerProtocolsResponse)
|
|
|
|
@doc "Create Node"
|
|
@handler CreateNode
|
|
post /node/create (CreateNodeRequest)
|
|
|
|
@doc "Update Node"
|
|
@handler UpdateNode
|
|
post /node/update (UpdateNodeRequest)
|
|
|
|
@doc "Delete Node"
|
|
@handler DeleteNode
|
|
post /node/delete (DeleteNodeRequest)
|
|
|
|
@doc "Filter Node List"
|
|
@handler FilterNodeList
|
|
get /node/list (FilterNodeListRequest) returns (FilterNodeListResponse)
|
|
|
|
@doc "Toggle Node Status"
|
|
@handler ToggleNodeStatus
|
|
post /node/status/toggle (ToggleNodeStatusRequest)
|
|
|
|
@doc "Check if there is any server or node to migrate"
|
|
@handler HasMigrateSeverNode
|
|
get /migrate/has returns (HasMigrateSeverNodeResponse)
|
|
|
|
@doc "Migrate server and node data to new database"
|
|
@handler MigrateServerNode
|
|
post /migrate/run returns (MigrateServerNodeResponse)
|
|
|
|
@doc "Reset server sort"
|
|
@handler ResetSortWithServer
|
|
post /server/sort (ResetSortRequest)
|
|
|
|
@doc "Reset node sort"
|
|
@handler ResetSortWithNode
|
|
post /node/sort (ResetSortRequest)
|
|
}
|
|
|