3d1a31a19f
- getServerUserListLogic.getExpiredUsers 之前完全忽略 user_subscribe.speed_limit, 现在带出用户级覆盖并与过期节点组 speed_limit 取更严(mergeSpeedLimit:0 视为无限制) - node_group.SpeedLimit 注释从 "KB/s" 修正为 "Mbps"(旧注释是笔误,实际下发节点的 ServerUser.SpeedLimit 字段语义就是 Mbps,节点端 ppanel-node 按 *1e6/8 换算为 Byte/s) - apis/node/node.api 给 ServerUser.SpeedLimit 加 Mbps 单位注释 - 新增 TestMergeSpeedLimit 表驱动测试覆盖 8 种边界 主链路(活跃用户、套餐 traffic_limit 阶梯)行为不变,已在生产 (server_id=52) 验证 147 个限速用户下发正确,与 DB 完全对应。
150 lines
3.8 KiB
Plaintext
150 lines
3.8 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 (
|
||
OnlineUser {
|
||
SID int64 `json:"uid"`
|
||
IP string `json:"ip"`
|
||
}
|
||
ShadowsocksProtocol {
|
||
Port int `json:"port"`
|
||
Method string `json:"method"`
|
||
}
|
||
VmessProtocol {
|
||
Host string `json:"host"`
|
||
Port int `json:"port"`
|
||
EnableTLS *bool `json:"enable_tls"`
|
||
TLSConfig string `json:"tls_config"`
|
||
Network string `json:"network"`
|
||
Transport string `json:"transport"`
|
||
}
|
||
VlessProtocol {
|
||
Host string `json:"host"`
|
||
Port int `json:"port"`
|
||
Network string `json:"network"`
|
||
Transport string `json:"transport"`
|
||
Security string `json:"security"`
|
||
SecurityConfig string `json:"security_config"`
|
||
XTLS string `json:"xtls"`
|
||
}
|
||
TrojanProtocol {
|
||
Host string `json:"host"`
|
||
Port int `json:"port"`
|
||
EnableTLS *bool `json:"enable_tls"`
|
||
TLSConfig string `json:"tls_config"`
|
||
Network string `json:"network"`
|
||
Transport string `json:"transport"`
|
||
}
|
||
GetServerConfigRequest {
|
||
ServerCommon
|
||
}
|
||
GetServerConfigResponse {
|
||
Basic ServerBasic `json:"basic"`
|
||
Protocol string `json:"protocol"`
|
||
Config interface{} `json:"config"`
|
||
}
|
||
ServerBasic {
|
||
PushInterval int64 `json:"push_interval"`
|
||
PullInterval int64 `json:"pull_interval"`
|
||
}
|
||
ServerCommon {
|
||
Protocol string `form:"protocol"`
|
||
ServerId int64 `form:"server_id"`
|
||
SecretKey string `form:"secret_key"`
|
||
}
|
||
ServerUser {
|
||
Id int64 `json:"id"`
|
||
UUID string `json:"uuid"`
|
||
// SpeedLimit 单位为 Mbps,0 表示不限速。
|
||
// 节点端 (V2bX/XrayR 等) 按 Mbps 解释该值,服务端透传不做单位换算。
|
||
SpeedLimit int64 `json:"speed_limit"`
|
||
DeviceLimit int64 `json:"device_limit"`
|
||
}
|
||
GetServerUserListRequest {
|
||
ServerCommon
|
||
}
|
||
GetServerUserListResponse {
|
||
Users []ServerUser `json:"users"`
|
||
}
|
||
UserTraffic {
|
||
SID int64 `json:"uid"`
|
||
Upload int64 `json:"upload"`
|
||
Download int64 `json:"download"`
|
||
}
|
||
ServerPushUserTrafficRequest {
|
||
ServerCommon
|
||
Traffic []UserTraffic `json:"traffic"`
|
||
}
|
||
ServerPushStatusRequest {
|
||
ServerCommon
|
||
Cpu float64 `json:"cpu"`
|
||
Mem float64 `json:"mem"`
|
||
Disk float64 `json:"disk"`
|
||
UpdatedAt int64 `json:"updated_at"`
|
||
}
|
||
OnlineUsersRequest {
|
||
ServerCommon
|
||
Users []OnlineUser `json:"users"`
|
||
}
|
||
QueryServerConfigRequest {
|
||
ServerID int64 `path:"server_id"`
|
||
SecretKey string `form:"secret_key"`
|
||
Protocols []string `form:"protocols,omitempty"`
|
||
}
|
||
QueryServerConfigResponse {
|
||
TrafficReportThreshold int64 `json:"traffic_report_threshold"`
|
||
IPStrategy string `json:"ip_strategy"`
|
||
DNS []NodeDNS `json:"dns"`
|
||
Block []string `json:"block"`
|
||
Outbound []NodeOutbound `json:"outbound"`
|
||
Protocols []Protocol `json:"protocols"`
|
||
Total int64 `json:"total"`
|
||
}
|
||
)
|
||
|
||
@server (
|
||
prefix: v1/server
|
||
group: node/server
|
||
middleware: ServerMiddleware
|
||
)
|
||
service ppanel {
|
||
@doc "Get user list"
|
||
@handler GetServerUserList
|
||
get /user (GetServerUserListRequest) returns (GetServerUserListResponse)
|
||
|
||
@doc "Push user Traffic"
|
||
@handler ServerPushUserTraffic
|
||
post /push (ServerPushUserTrafficRequest)
|
||
|
||
@doc "Push server status"
|
||
@handler ServerPushStatus
|
||
post /status (ServerPushStatusRequest)
|
||
|
||
@doc "Get server config"
|
||
@handler GetServerConfig
|
||
get /config (GetServerConfigRequest) returns (GetServerConfigResponse)
|
||
|
||
@doc "Push online users"
|
||
@handler PushOnlineUsers
|
||
post /online (OnlineUsersRequest)
|
||
}
|
||
|
||
@server (
|
||
prefix: v2/server
|
||
group: node/server
|
||
)
|
||
service ppanel {
|
||
@doc "Get Server Protocol Config"
|
||
@handler QueryServerProtocolConfig
|
||
get /:server_id (QueryServerConfigRequest) returns (QueryServerConfigResponse)
|
||
}
|