Documentation
¶
Index ¶
- Constants
- Variables
- type AckPayload
- type AlertPayload
- type AliveMap
- type AnyTlsNode
- type BaseConfig
- type CertUpdatePayload
- type Client
- func (c *Client) AutoRegister(authKey, name, host string, port int, credStore *CredentialStore) (*Credential, error)
- func (c *Client) AutoRegisterEncrypted(authKey, name, host string, port int, credStore *EncryptedCredentialStore) (*Credential, error)
- func (c *Client) Close() error
- func (c *Client) Debug()
- func (c *Client) GetAPIHost() string
- func (c *Client) GetAPIKey() string
- func (c *Client) GetNodeID() int
- func (c *Client) GetNodeInfo() (node *NodeInfo, err error)
- func (c *Client) GetSecret() string
- func (c *Client) GetUserAlive() (map[int]int, error)
- func (c *Client) GetUserList() ([]UserInfo, error)
- func (c *Client) Heartbeat(req *HeartbeatRequest) error
- func (c *Client) IsSignEnabled() bool
- func (c *Client) Register(req *RegisterRequest) (*RegisterResponse, error)
- func (c *Client) ReportNodeLogs(_ []NodeLogEntry) error
- func (c *Client) ReportNodeOnlineUsers(data *map[int][]string) error
- func (c *Client) ReportNodeRuntimeHealth(healthy bool, message string) error
- func (c *Client) ReportNodeStatus(_ *monitor.SystemInfo, _ int, _ int64, _ int64) error
- func (c *Client) ReportUserTraffic(userTraffic []UserTraffic) error
- func (c *Client) SendHeartbeatWithSystemInfo(onlineUsers int, upload, download int64) error
- func (c *Client) SetNodeType(nodeType string)
- func (c *Client) SupportsSync() bool
- type CommonNode
- type ConfigChange
- type ConfigUpdatePayload
- type Credential
- type CredentialStore
- type DebugConfig
- type DebugDumper
- func (d *DebugDumper) DumpGeneratedConfig(configType string, config interface{}, nodeID int) error
- func (d *DebugDumper) DumpNodeConfig(rawJSON []byte, nodeID int) error
- func (d *DebugDumper) DumpParsedNodeInfo(nodeInfo *NodeInfo, nodeID int) error
- func (d *DebugDumper) DumpSummary(nodeID int, info map[string]interface{}) error
- func (d *DebugDumper) DumpUserAlive(rawJSON []byte, nodeID int) error
- func (d *DebugDumper) DumpUserList(rawJSON []byte, nodeID int) error
- func (d *DebugDumper) GetSessionDir() string
- func (d *DebugDumper) IsEnabled() bool
- type EncSettings
- type EncryptedCredentialStore
- type ForceReloadPayload
- type HeartbeatPayload
- type HeartbeatRequest
- type HeartbeatResponse
- type Hysteria2Node
- type HysteriaNode
- type NodeInfo
- type NodeLogEntry
- type OnlineUser
- type PingPayload
- type PongPayload
- type RawDNS
- type RealityConfig
- type RegisterRequest
- type RegisterResponse
- type RegisterResponseData
- type Route
- type RuleUpdatePayload
- type Rules
- type RuntimeHealthRequest
- type ShadowsocksNode
- type SyncMessage
- type SyncMessageType
- type TlsSettings
- type TrafficReportPayload
- type TrojanNode
- type TuicNode
- type UserBanPayload
- type UserInfo
- type UserListBody
- type UserTraffic
- type UserUpdatePayload
- type VAllssNode
- type WireGuardHealthCheck
- type WireGuardNetworkPath
- type WireGuardNetworkPolicy
- type WireGuardNode
- type WireGuardRelay
Constants ¶
const ( None = 0 Tls = 1 Reality = 2 )
Security type
Variables ¶
var Version = "3.1.0-alpha.1"
Functions ¶
This section is empty.
Types ¶
type AckPayload ¶
type AckPayload struct {
MessageID string `json:"msg_id"` // 原消息ID
Success bool `json:"success"` // 是否成功
Error string `json:"error,omitempty"` // 错误信息
Timestamp int64 `json:"timestamp"` // 处理时间
}
AckPayload 确认消息负载
type AlertPayload ¶
type AlertPayload struct {
Level string `json:"level"` // info | warning | error | critical
Type string `json:"type"` // 告警类型
Message string `json:"message"` // 告警消息
Details map[string]string `json:"details,omitempty"` // 详细信息
Timestamp int64 `json:"timestamp"` // 发生时间
}
AlertPayload 告警负载
type AnyTlsNode ¶
type AnyTlsNode struct {
CommonNode
PaddingScheme []string `json:"padding_scheme,omitempty"`
}
type BaseConfig ¶
type CertUpdatePayload ¶
type CertUpdatePayload struct {
Domain string `json:"domain"` // 域名
CertPEM string `json:"cert_pem"` // 证书内容 (PEM)
KeyPEM string `json:"key_pem"` // 私钥内容 (PEM)
ExpireAt int64 `json:"expire_at"` // 过期时间
AutoReload bool `json:"auto_reload"` // 是否自动重载
}
CertUpdatePayload 证书更新负载
type Client ¶
type Client struct {
APIHost string
APISendIP string
Token string
APIKey string // 用于自动发现模式
Secret string // 用于请求签名
NodeType string
ProtocolType string
NodeId int
UserList *UserListBody
AliveMap *AliveMap
CredStore *CredentialStore // 凭证存储 (明文)
EncCredStore *EncryptedCredentialStore // 凭证存储 (加密)
EnableSign bool // 是否启用签名
EncryptCred bool // 是否加密凭证
Debugger *DebugDumper // 调试工具
// contains filtered or unexported fields
}
func (*Client) AutoRegister ¶
func (c *Client) AutoRegister(authKey, name, host string, port int, credStore *CredentialStore) (*Credential, error)
AutoRegister 自动注册节点 (明文凭证存储)
func (*Client) AutoRegisterEncrypted ¶
func (c *Client) AutoRegisterEncrypted(authKey, name, host string, port int, credStore *EncryptedCredentialStore) (*Credential, error)
AutoRegisterEncrypted 自动注册节点 (加密凭证存储)
func (*Client) Close ¶
Close implements api/client.NodeAPI. REST transport has no persistent connection to close.
func (*Client) GetAPIHost ¶
GetAPIHost implements api/client.NodeAPI.
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) IsSignEnabled ¶
IsSignEnabled implements api/client.NodeAPI.
func (*Client) Register ¶
func (c *Client) Register(req *RegisterRequest) (*RegisterResponse, error)
Register 节点注册
func (*Client) ReportNodeLogs ¶
func (c *Client) ReportNodeLogs(_ []NodeLogEntry) error
ReportNodeLogs implements api/client.NodeAPI. REST transport does not expose a dedicated node log ingestion endpoint, so this is a no-op.
func (*Client) ReportNodeOnlineUsers ¶
func (*Client) ReportNodeRuntimeHealth ¶
ReportNodeRuntimeHealth sends the supervised runtime state through the node-scoped REST channel.
func (*Client) ReportNodeStatus ¶
ReportNodeStatus implements api/client.NodeAPI. REST transport does not expose a dedicated node status RPC, so this is a no-op.
func (*Client) ReportUserTraffic ¶
func (c *Client) ReportUserTraffic(userTraffic []UserTraffic) error
ReportUserTraffic reports the user traffic
func (*Client) SendHeartbeatWithSystemInfo ¶
SendHeartbeatWithSystemInfo 发送包含系统信息的心跳
func (*Client) SetNodeType ¶
SetNodeType implements api/client.NodeAPI.
func (*Client) SupportsSync ¶
SupportsSync implements api/client.NodeAPI.
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 ConfigChange ¶
type ConfigChange struct {
Field string `json:"field"` // 变更字段路径 (如 "server_port", "tls_settings.server_name")
OldValue interface{} `json:"old_value,omitempty"` // 旧值
NewValue interface{} `json:"new_value"` // 新值
Action string `json:"action,omitempty"` // set | delete
}
ConfigChange 配置变更项
type ConfigUpdatePayload ¶
type ConfigUpdatePayload struct {
Version int64 `json:"version"` // 配置版本号
ChangeType string `json:"change_type"` // full | partial
NodeInfo *NodeInfo `json:"node_info,omitempty"` // 完整配置 (full 时使用)
Changes []ConfigChange `json:"changes,omitempty"` // 变更列表 (partial 时使用)
}
ConfigUpdatePayload 配置更新负载
type Credential ¶
type Credential struct {
NodeID int `json:"node_id"`
APIKey string `json:"api_key"`
Secret string `json:"secret"`
}
Credential 节点凭证
type CredentialStore ¶
type CredentialStore struct {
// contains filtered or unexported fields
}
CredentialStore 凭证存储
func NewCredentialStore ¶
func NewCredentialStore(filePath string) *CredentialStore
NewCredentialStore 创建凭证存储
type DebugConfig ¶
DebugConfig 调试配置
type DebugDumper ¶
type DebugDumper struct {
// contains filtered or unexported fields
}
DebugDumper API 响应调试工具
func (*DebugDumper) DumpGeneratedConfig ¶
func (d *DebugDumper) DumpGeneratedConfig(configType string, config interface{}, nodeID int) error
DumpGeneratedConfig 保存生成的核心配置
func (*DebugDumper) DumpNodeConfig ¶
func (d *DebugDumper) DumpNodeConfig(rawJSON []byte, nodeID int) error
DumpNodeConfig 保存节点配置响应
func (*DebugDumper) DumpParsedNodeInfo ¶
func (d *DebugDumper) DumpParsedNodeInfo(nodeInfo *NodeInfo, nodeID int) error
DumpParsedNodeInfo 保存解析后的节点信息
func (*DebugDumper) DumpSummary ¶
func (d *DebugDumper) DumpSummary(nodeID int, info map[string]interface{}) error
DumpSummary 保存汇总信息
func (*DebugDumper) DumpUserAlive ¶
func (d *DebugDumper) DumpUserAlive(rawJSON []byte, nodeID int) error
DumpUserAlive 保存用户在线状态响应
func (*DebugDumper) DumpUserList ¶
func (d *DebugDumper) DumpUserList(rawJSON []byte, nodeID int) error
DumpUserList 保存用户列表响应
func (*DebugDumper) GetSessionDir ¶
func (d *DebugDumper) GetSessionDir() string
GetSessionDir 获取当前会话的目录
type EncSettings ¶
type EncryptedCredentialStore ¶
type EncryptedCredentialStore struct {
// contains filtered or unexported fields
}
EncryptedCredentialStore 加密凭证存储
func NewEncryptedCredentialStore ¶
func NewEncryptedCredentialStore(filePath string) (*EncryptedCredentialStore, error)
NewEncryptedCredentialStore 创建加密凭证存储
func (*EncryptedCredentialStore) Clear ¶
func (s *EncryptedCredentialStore) Clear() error
Clear 清除凭证
func (*EncryptedCredentialStore) Exists ¶
func (s *EncryptedCredentialStore) Exists() bool
Exists 检查凭证是否存在
func (*EncryptedCredentialStore) Get ¶
func (s *EncryptedCredentialStore) Get() *Credential
Get 获取当前凭证
func (*EncryptedCredentialStore) Load ¶
func (s *EncryptedCredentialStore) Load() (*Credential, error)
Load 解密加载凭证
func (*EncryptedCredentialStore) Save ¶
func (s *EncryptedCredentialStore) Save(cred *Credential) error
Save 加密保存凭证
type ForceReloadPayload ¶
type ForceReloadPayload struct {
Reason string `json:"reason,omitempty"` // 重载原因
ClearCache bool `json:"clear_cache,omitempty"` // 是否清除缓存
}
ForceReloadPayload 强制重载负载
type HeartbeatPayload ¶
type HeartbeatPayload struct {
CPUUsage float64 `json:"cpu_usage"`
MemoryUsage float64 `json:"memory_usage"`
DiskUsage float64 `json:"disk_usage"`
Uptime int64 `json:"uptime"`
OnlineUsers int `json:"online_users"`
Connections int `json:"connections"`
Upload int64 `json:"upload"`
Download int64 `json:"download"`
Version string `json:"version"`
ConfigVersion int64 `json:"config_version,omitempty"`
}
HeartbeatPayload 心跳负载
type HeartbeatRequest ¶
type HeartbeatRequest struct {
CPUUsage float64 `json:"cpu_usage"`
MemoryUsage float64 `json:"memory_usage"`
DiskUsage float64 `json:"disk_usage"`
Uptime int64 `json:"uptime"`
OnlineUsers int `json:"online_users"`
Upload int64 `json:"upload"`
Download int64 `json:"download"`
}
HeartbeatRequest 心跳请求
type HeartbeatResponse ¶
type HeartbeatResponse struct {
Message string `json:"message"`
}
HeartbeatResponse 心跳响应
type Hysteria2Node ¶
type HysteriaNode ¶
type HysteriaNode struct {
CommonNode
UpMbps int `json:"up_mbps"`
DownMbps int `json:"down_mbps"`
Obfs string `json:"obfs"`
}
type NodeInfo ¶
type NodeInfo struct {
Id int
Type string
Security int
PushInterval time.Duration
PullInterval time.Duration
RawDNS RawDNS
Rules Rules
// origin
VAllss *VAllssNode
Shadowsocks *ShadowsocksNode
Trojan *TrojanNode
Tuic *TuicNode
AnyTls *AnyTlsNode
Hysteria *HysteriaNode
Hysteria2 *Hysteria2Node
WireGuard *WireGuardNode
Common *CommonNode
}
type NodeLogEntry ¶
type OnlineUser ¶
type PingPayload ¶
type PingPayload struct {
ServerTime int64 `json:"server_time"` // 服务端时间
}
PingPayload Ping 负载
type PongPayload ¶
type PongPayload struct {
ServerTime int64 `json:"server_time"` // 回显服务端时间
ClientTime int64 `json:"client_time"` // 客户端时间
Latency int64 `json:"latency"` // 延迟 (ms)
}
PongPayload Pong 负载
type RealityConfig ¶
type RegisterRequest ¶
type RegisterRequest struct {
AuthKey string `json:"auth_key"`
Name string `json:"name,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
ServerVersion string `json:"server_version,omitempty"`
ServerOS string `json:"server_os,omitempty"`
}
RegisterRequest 注册请求
type RegisterResponse ¶
type RegisterResponse struct {
Message string `json:"message"`
Data RegisterResponseData `json:"data"`
}
RegisterResponse 注册响应
type RegisterResponseData ¶
type RegisterResponseData struct {
NodeID int `json:"node_id"`
APIKey string `json:"api_key"`
Secret string `json:"secret"`
Message string `json:"message"`
}
RegisterResponseData 注册响应数据
type RuleUpdatePayload ¶
type RuleUpdatePayload struct {
Action string `json:"action"` // replace | append | remove
Rules Rules `json:"rules"` // 规则内容
}
RuleUpdatePayload 规则更新负载
type RuntimeHealthRequest ¶
type ShadowsocksNode ¶
type ShadowsocksNode struct {
CommonNode
Cipher string `json:"cipher"`
ServerKey string `json:"server_key"`
}
type SyncMessage ¶
type SyncMessage struct {
ID string `json:"id"` // 消息唯一ID
Type SyncMessageType `json:"type"` // 消息类型
Timestamp int64 `json:"timestamp"` // 时间戳 (Unix)
NodeID int `json:"node_id"` // 节点ID
Payload json.RawMessage `json:"payload"` // 消息负载
Priority int `json:"priority,omitempty"` // 优先级 (0=普通, 1=高, 2=紧急)
RequireAck bool `json:"require_ack,omitempty"` // 是否需要确认
}
SyncMessage 同步消息
func NewSyncMessage ¶
func NewSyncMessage(msgType SyncMessageType, nodeID int, payload interface{}) (*SyncMessage, error)
NewSyncMessage 创建新的同步消息
func (*SyncMessage) IsHighPriority ¶
func (m *SyncMessage) IsHighPriority() bool
IsHighPriority 是否高优先级消息
func (*SyncMessage) ParsePayload ¶
func (m *SyncMessage) ParsePayload(v interface{}) error
ParsePayload 解析消息负载
type SyncMessageType ¶
type SyncMessageType string
SyncMessageType 同步消息类型
const ( // 服务端 -> 节点 MsgTypeConfigUpdate SyncMessageType = "config_update" // 配置更新 MsgTypeUserUpdate SyncMessageType = "user_update" // 用户变更 MsgTypeUserBan SyncMessageType = "user_ban" // 用户封禁 (紧急) MsgTypeRuleUpdate SyncMessageType = "rule_update" // 规则更新 MsgTypeCertUpdate SyncMessageType = "cert_update" // 证书更新 MsgTypePing SyncMessageType = "ping" // 心跳检测 MsgTypeForceReload SyncMessageType = "force_reload" // 强制重载 // 节点 -> 服务端 MsgTypeHeartbeat SyncMessageType = "heartbeat" // 心跳响应 MsgTypeAck SyncMessageType = "ack" // 消息确认 MsgTypeTrafficReport SyncMessageType = "traffic_report" // 流量上报 MsgTypeAlertReport SyncMessageType = "alert" // 告警上报 MsgTypePong SyncMessageType = "pong" // Pong 响应 )
type TlsSettings ¶
type TrafficReportPayload ¶
type TrafficReportPayload struct {
Period int64 `json:"period"` // 统计周期 (秒)
Traffic []UserTraffic `json:"traffic"` // 用户流量
TotalUp int64 `json:"total_up"` // 总上传
TotalDown int64 `json:"total_down"` // 总下载
}
TrafficReportPayload 流量上报负载
type TrojanNode ¶
type TrojanNode struct {
CommonNode
Network string `json:"network"`
NetworkSettings json.RawMessage `json:"networkSettings"`
}
type TuicNode ¶
type TuicNode struct {
CommonNode
CongestionControl string `json:"congestion_control"`
ZeroRTTHandshake bool `json:"zero_rtt_handshake"`
}
type UserBanPayload ¶
type UserBanPayload struct {
UserIDs []int `json:"user_ids"` // 用户ID列表
UUIDs []string `json:"uuids"` // UUID列表
Reason string `json:"reason,omitempty"` // 封禁原因
ExpireAt int64 `json:"expire_at,omitempty"` // 过期时间 (0=永久)
Immediate bool `json:"immediate"` // 是否立即生效
}
UserBanPayload 用户封禁负载 (紧急消息专用)
type UserInfo ¶
type UserInfo struct {
Id int `json:"id" msgpack:"id"`
Uuid string `json:"uuid" msgpack:"uuid"`
SpeedLimit int `json:"speed_limit" msgpack:"speed_limit"`
DeviceLimit int `json:"device_limit" msgpack:"device_limit"`
WireGuardPeerIP string `json:"wireguard_peer_ip" msgpack:"wireguard_peer_ip"`
WireGuardPublicKey string `json:"wireguard_public_key" msgpack:"wireguard_public_key"`
Extra map[string]string `json:"extra" msgpack:"extra"`
}
type UserListBody ¶
type UserListBody struct {
Users []UserInfo `json:"users" msgpack:"users"`
}
type UserTraffic ¶
type UserUpdatePayload ¶
type UserUpdatePayload struct {
Action string `json:"action"` // add | remove | update | ban
Users []UserInfo `json:"users"` // 涉及的用户
Reason string `json:"reason,omitempty"` // 原因 (封禁时使用)
}
UserUpdatePayload 用户更新负载
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
type WireGuardHealthCheck ¶
type WireGuardNetworkPath ¶
type WireGuardNetworkPolicy ¶
type WireGuardNetworkPolicy struct {
Version int `json:"version"`
Strategy string `json:"strategy"`
Paths []WireGuardNetworkPath `json:"paths"`
HealthCheck WireGuardHealthCheck `json:"health_check"`
ActiveTable int `json:"active_table"`
ActivePriority int `json:"active_priority"`
}
type WireGuardNode ¶
type WireGuardNode struct {
CommonNode
CIDR string `json:"cidr"`
ServerAddress string `json:"server_address"`
ServerPrivateKey string `json:"server_private_key"`
ServerPublicKey string `json:"server_public_key"`
MTU int `json:"mtu"`
DNS []string `json:"dns"`
AllowedIPs []string `json:"allowed_ips"`
TunnelType string `json:"tunnel_type"`
Relay WireGuardRelay `json:"relay"`
}
type WireGuardRelay ¶
type WireGuardRelay struct {
Backend string `json:"backend"`
Mode string `json:"mode"`
Role string `json:"role"`
WSSCompat bool `json:"wss_compat"`
ExitNAT bool `json:"exit_nat"`
EntryStats bool `json:"entry_stats"`
Server string `json:"server"`
ServerPort int `json:"server_port"`
TunName string `json:"tun_name"`
TunPort int `json:"tun_port"`
TunAddress string `json:"tun_address"`
EntryTunAddress string `json:"entry_tun_address"`
ExitTunAddress string `json:"exit_tun_address"`
OutboundIface string `json:"outbound_iface"`
RoutingTable int `json:"routing_table"`
RoutingPriority int `json:"routing_priority"`
WSSPath string `json:"wss_path"`
WSSSecure bool `json:"wss_secure"`
WSSServerName string `json:"wss_server_name"`
WSSCAFile string `json:"wss_ca_file"`
WSSCertFile string `json:"wss_cert_file"`
WSSKeyFile string `json:"wss_key_file"`
NetworkPolicy WireGuardNetworkPolicy `json:"network_policy"`
}