Documentation
¶
Index ¶
- Constants
- type AliveMap
- type AnyTlsNode
- type BaseConfig
- type Client
- func (c *Client) Debug()
- func (c *Client) GetNodeInfo() (node *NodeInfo, err error)
- func (c *Client) GetUserAlive() (map[int]int, error)
- func (c *Client) GetUserList() ([]UserInfo, error)
- func (c *Client) ReportNodeMetrics(metrics *NodeMetrics) error
- func (c *Client) ReportNodeOnlineUsers(data *map[int][]string) error
- func (c *Client) ReportNodeStatus(status *NodeStatus) error
- func (c *Client) ReportUserTraffic(userTraffic []UserTraffic) error
- func (c *Client) StartWebSocket()
- func (c *Client) StopWebSocket()
- type CommonNode
- type EncSettings
- type NodeInfo
- type NodeMetrics
- type NodeStatus
- type NodeStatusMem
- type OnlineUser
- type RawDNS
- type RealityConfig
- type Route
- type Rules
- type ShadowsocksNode
- type TlsSettings
- type TrojanNode
- type UserInfo
- type UserListBody
- type UserTraffic
- type VAllssNode
Constants ¶
const ( None = 0 Tls = 1 Reality = 2 )
Security type
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyTlsNode ¶
type AnyTlsNode struct {
CommonNode
PaddingScheme []string `json:"padding_scheme,omitempty"`
}
type BaseConfig ¶
type Client ¶
type Client struct {
APIHost string
APISendIP string
Token string
NodeType string
NodeId int
UserList *UserListBody
AliveMap *AliveMap
// contains filtered or unexported fields
}
func (*Client) GetNodeInfo ¶
func (*Client) GetUserAlive ¶
GetUserAlive will fetch the alive_ip count for users
func (*Client) GetUserList ¶
GetUserList will pull user from v2board
func (*Client) ReportNodeMetrics ¶ added in v0.8.2
func (c *Client) ReportNodeMetrics(metrics *NodeMetrics) error
ReportNodeMetrics pushes the rich runtime metrics to the panel. Preferred transport is the WebSocket `node.status` event because X-Board handles it inline (NodeEventHandlers::handleNodeStatus → updateMetrics) — that's the same path the official Xboard-Node uses to populate the admin popup.
HTTP fallback is the V2 unified `/api/v2/server/node/report` endpoint with only the `metrics` field set; the controller treats each section as independent so we don't disturb traffic/alive/online/status reporting which continues to flow through the existing V1 paths.
func (*Client) ReportNodeOnlineUsers ¶
func (*Client) ReportNodeStatus ¶ added in v0.7.0
func (c *Client) ReportNodeStatus(status *NodeStatus) error
ReportNodeStatus pushes the cpu/mem/swap/disk load snapshot to the panel over HTTP. Matches the schema validated by UniProxyController::status in X-Board — the only legacy V1 path that accepts it.
func (*Client) ReportUserTraffic ¶
func (c *Client) ReportUserTraffic(userTraffic []UserTraffic) error
ReportUserTraffic reports the user traffic
func (*Client) StartWebSocket ¶ added in v0.8.0
func (c *Client) StartWebSocket()
StartWebSocket spawns the optional WebSocket driver if WebSocket.Enabled is set in config. When disabled the function is a no-op. Safe to call at most once per Client; invoked by the node bootstrap after the HTTP client is confirmed working.
func (*Client) StopWebSocket ¶ added in v0.8.0
func (c *Client) StopWebSocket()
StopWebSocket tears down the driver if present. Idempotent.
type CommonNode ¶
type CommonNode struct {
Host string `json:"host"`
ServerPort int `json:"server_port"`
ServerName string `json:"server_name"`
Routes []Route `json:"routes"`
BaseConfig *BaseConfig `json:"base_config"`
}
type EncSettings ¶
type NodeInfo ¶
type NodeInfo struct {
Id int
Type string
Security int
PushInterval time.Duration
PullInterval time.Duration
RawDNS RawDNS
Rules Rules
// origin
VAllss *VAllssNode
AnyTls *AnyTlsNode
Shadowsocks *ShadowsocksNode
Trojan *TrojanNode
Common *CommonNode
}
type NodeMetrics ¶ added in v0.8.2
type NodeMetrics struct {
Uptime int64 `json:"uptime"`
Goroutines int `json:"goroutines"`
ActiveConnections int `json:"active_connections"`
TotalConnections int `json:"total_connections"`
TotalUsers int `json:"total_users"`
ActiveUsers int `json:"active_users"`
InboundSpeed int64 `json:"inbound_speed"`
OutboundSpeed int64 `json:"outbound_speed"`
CPUPerCore []float64 `json:"cpu_per_core"`
Load []float64 `json:"load"`
SpeedLimiter map[string]interface{} `json:"speed_limiter"`
GC map[string]interface{} `json:"gc"`
API map[string]interface{} `json:"api"`
WS map[string]interface{} `json:"ws"`
Limits map[string]interface{} `json:"limits"`
KernelStatus bool `json:"kernel_status"`
}
NodeMetrics mirrors the shape consumed by X-Board's ServerService::updateMetrics. Every field is optional from the panel's point of view (zeroes are accepted), so the agent can fill what it knows and leave the rest empty without breaking validation.
The panel surfaces these fields in the admin "节点状态" popup via the `metrics` accessor on the Server model. Without this payload the popup shows uptime/goroutines/users/speeds as empty placeholders even though cpu/mem/disk render correctly from the LOAD_STATUS cache.
type NodeStatus ¶ added in v0.7.0
type NodeStatus struct {
Cpu float64 `json:"cpu"`
Mem NodeStatusMem `json:"mem"`
Swap NodeStatusMem `json:"swap"`
Disk NodeStatusMem `json:"disk"`
}
NodeStatus is the payload reported to X-Board's /UniProxy/status endpoint. All totals/used values are in bytes; Cpu is a percentage in [0, 100].
IMPORTANT: This payload is *only* delivered over HTTP. The WebSocket event `node.status` is reserved for NodeMetrics — feeding the cpu/mem/swap/disk shape into it would cause X-Board's NodeEventHandlers::handleNodeStatus to call ServerService::updateMetrics with mismatched fields, polluting the METRICS cache with zeros for uptime/goroutines/etc.
type NodeStatusMem ¶ added in v0.7.0
type OnlineUser ¶
type RealityConfig ¶
type ShadowsocksNode ¶
type ShadowsocksNode struct {
CommonNode
Cipher string `json:"cipher"`
ServerKey string `json:"server_key"`
}
type TlsSettings ¶
type TrojanNode ¶
type TrojanNode struct {
CommonNode
Network string `json:"network"`
NetworkSettings json.RawMessage `json:"networkSettings"`
}
type UserListBody ¶
type UserListBody struct {
Users []UserInfo `json:"users" msgpack:"users"`
}
type UserTraffic ¶
type VAllssNode ¶
type VAllssNode struct {
CommonNode
Tls int `json:"tls"`
TlsSettings TlsSettings `json:"tls_settings"`
TlsSettingsBack *TlsSettings `json:"tlsSettings"`
Network string `json:"network"`
NetworkSettings json.RawMessage `json:"network_settings"`
NetworkSettingsBack json.RawMessage `json:"networkSettings"`
Encryption string `json:"encryption"`
EncryptionSettings EncSettings `json:"encryption_settings"`
ServerName string `json:"server_name"`
// vless only
Flow string `json:"flow"`
RealityConfig RealityConfig `json:"-"`
}
VAllssNode is vmess and vless node info