sspanel

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	APIHost             string
	NodeID              int
	Key                 string
	SpeedLimit          float64
	DeviceLimit         int
	DisableCustomConfig bool
	LocalRuleList       []api.DetectRule
	LastReportOnline    map[int]int
	// contains filtered or unexported fields
}

APIClient create a api client to the panel.

func New

func New(apiConfig *api.Config) *APIClient

New create api instance

func (*APIClient) Debug

func (c *APIClient) Debug()

Debug set the client debug for client

func (*APIClient) Describe

func (c *APIClient) Describe() api.ClientInfo

Describe return a description of the client

func (*APIClient) GetMediaCheckConfig added in v1.0.9

func (c *APIClient) GetMediaCheckConfig() (*api.MediaCheckConfig, error)

GetMediaCheckConfig fetches the streaming media check configuration from the panel. This includes whether media check is enabled and the check interval in hours.

func (*APIClient) GetNodeInfo

func (c *APIClient) GetNodeInfo() (nodeInfo *api.NodeInfo, err error)

GetNodeInfo will pull NodeInfo Config from ssPanel

func (*APIClient) GetNodeRule

func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error)

GetNodeRule will pull the audit rule form ssPanel

func (*APIClient) GetUserList

func (c *APIClient) GetUserList() (UserList *[]api.UserInfo, err error)

GetUserList will pull user form ssPanel

func (*APIClient) GetXrayRCertConfig added in v1.0.7

func (c *APIClient) GetXrayRCertConfig() (*api.XrayRCertConfig, error)

GetXrayRCertConfig fetches optional global XrayR certificate configuration from the panel via /mod_mu/nodes/config with type = xrayr_cert. This allows the panel to centrally control DNS provider, ACME email and DNS-01 environment variables (e.g. Cloudflare API credentials) for all nodes.

func (*APIClient) ParseSSNodeResponse

func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *NodeInfoResponse) (*api.NodeInfo, error)

ParseSSNodeResponse parse the response for the given node info format

func (*APIClient) ParseSSPanelNodeInfo

func (c *APIClient) ParseSSPanelNodeInfo(nodeInfoResponse *NodeInfoResponse) (*api.NodeInfo, error)

ParseSSPanelNodeInfo parse the response for the given node info format Only available for SSPanel version >= 2021.11

func (*APIClient) ParseSSPluginNodeResponse

func (c *APIClient) ParseSSPluginNodeResponse(nodeInfoResponse *NodeInfoResponse) (*api.NodeInfo, error)

ParseSSPluginNodeResponse parse the response for the given node info format

func (*APIClient) ParseTrojanNodeResponse

func (c *APIClient) ParseTrojanNodeResponse(nodeInfoResponse *NodeInfoResponse) (*api.NodeInfo, error)

ParseTrojanNodeResponse parse the response for the given node info format

func (*APIClient) ParseUserListResponse

func (c *APIClient) ParseUserListResponse(userInfoResponse *[]UserResponse) (*[]api.UserInfo, error)

ParseUserListResponse parse the response for the given node info format

func (*APIClient) ParseVmessNodeResponse added in v1.0.5

func (c *APIClient) ParseVmessNodeResponse(nodeInfoResponse *NodeInfoResponse) (*api.NodeInfo, error)

ParseVmessNodeResponse parses the legacy SSPanel node response format for VMess nodes.

func (*APIClient) ReportIllegal

func (c *APIClient) ReportIllegal(detectResultList *[]api.DetectResult) error

ReportIllegal reports the user illegal behaviors

func (*APIClient) ReportMediaCheckResult added in v1.0.9

func (c *APIClient) ReportMediaCheckResult(result string) error

ReportMediaCheckResult reports the streaming media unlock check results to the panel. The result parameter should be a JSON string containing all check results.

func (*APIClient) ReportMediaCheckResultForNode added in v1.1.0

func (c *APIClient) ReportMediaCheckResultForNode(nodeID int, result string) error

ReportMediaCheckResultForNode reports the streaming media unlock check results for a specific node. This allows one node to report results for multiple nodes (e.g., when using shared detection).

func (*APIClient) ReportNodeOnlineUsers

func (c *APIClient) ReportNodeOnlineUsers(onlineUserList *[]api.OnlineUser) error

ReportNodeOnlineUsers reports online user ip

func (*APIClient) ReportNodeStatus

func (c *APIClient) ReportNodeStatus(nodeStatus *api.NodeStatus) (err error)

ReportNodeStatus reports the node status to the ssPanel

func (*APIClient) ReportUserTraffic

func (c *APIClient) ReportUserTraffic(userTraffic *[]api.UserTraffic) error

ReportUserTraffic reports the user traffic

type CustomConfig

type CustomConfig struct {
	OffsetPortNode        string          `json:"offset_port_node"`
	Host                  string          `json:"host"`
	Method                string          `json:"method"`
	ServerKey             string          `json:"server_key"`
	TLS                   string          `json:"tls"`
	Network               string          `json:"network"`
	Security              string          `json:"security"`
	Path                  string          `json:"path"`
	VerifyCert            bool            `json:"verify_cert"`
	Obfs                  string          `json:"obfs"`
	Header                json.RawMessage `json:"header"`
	AllowInsecure         string          `json:"allow_insecure"`
	Servicename           string          `json:"servicename"`
	EnableXtls            string          `json:"enable_xtls"`
	Flow                  string          `json:"flow"`
	EnableREALITY         bool            `json:"enable_reality"`
	RealityOpts           *REALITYConfig  `json:"reality-opts"`
	OffsetPortUser        string          `json:"offset_port_user"`
	ObfsPassword          string          `json:"obfs_password"`
	UpMbps                string          `json:"up_mbps"`
	DownMbps              string          `json:"down_mbps"`
	ServerName            string          `json:"server_name"`
	Sni                   string          `json:"sni"`
	Alpn                  []string        `json:"alpn"`
	Fingerprint           string          `json:"fingerprint"`
	IgnoreClientBandwidth bool            `json:"ignore_client_bandwidth"`
	PaddingScheme         []string        `json:"padding_scheme"`
	// Hysteria2 port hopping specific fields. We keep them as RawMessage so
	// that the panel can store booleans, numbers or strings without breaking
	// JSON decoding, mirroring the loose handling in the PHP panel
	// implementation.
	PortHopEnableRaw   json.RawMessage `json:"port_hop_enable"`
	PortHopPortsRaw    json.RawMessage `json:"port_hop_ports"`
	PortHopIntervalRaw json.RawMessage `json:"port_hop_interval"`
	// TUIC specific fields
	CongestionControl string `json:"congestion_control"`
	UDPRelayMode      string `json:"udp_relay_mode"`
	ZeroRTTHandshake  string `json:"zero_rtt_handshake"` // "0" or "1" from SSPanel
	Heartbeat         string `json:"heartbeat"`

	// EnableProxyProtocol / ProxyProtocolVer
	//
	// 这两个字段用于在面板中为每个节点单独控制 Proxy Protocol:
	// - enable_proxy_protocol: 是否在该节点上启用 PROXY protocol 支持;
	// - proxy_protocol_ver:    使用的 PROXY 协议版本,通常为 1 或 2;为 0 或未设置时
	//                          表示由后端选择默认行为或不启用版本特性。
	EnableProxyProtocol bool   `json:"enable_proxy_protocol"`
	ProxyProtocolVer    uint64 `json:"proxy_protocol_ver"`
}

type IllegalItem

type IllegalItem struct {
	ID  int    `json:"list_id"`
	UID int    `json:"user_id"`
	IP  string `json:"ip,omitempty"`
}

type MediaCheckConfigResponse added in v1.0.9

type MediaCheckConfigResponse struct {
	Enabled       bool `json:"enabled"`
	CheckInterval int  `json:"check_interval"`
}

MediaCheckConfigResponse is the response of media check config

type MediaCheckResultPost added in v1.0.9

type MediaCheckResultPost struct {
	NodeID int    `json:"node_id"`
	Result string `json:"result"`
}

MediaCheckResultPost is the data structure for posting media check result

type NodeInfoResponse

type NodeInfoResponse struct {
	Group           int             `json:"node_group"`
	Class           int             `json:"node_class"`
	SpeedLimit      float64         `json:"node_speedlimit"`
	TrafficRate     float64         `json:"traffic_rate"`
	Sort            int             `json:"sort"`
	RawServerString string          `json:"server"`
	Type            string          `json:"type"`
	CustomConfig    json.RawMessage `json:"custom_config"`
	Version         string          `json:"version"`
}

NodeInfoResponse is the response of node

type OnlineUser

type OnlineUser struct {
	UID int    `json:"user_id"`
	IP  string `json:"ip"`
}

OnlineUser is the data structure of online user

type PostData

type PostData struct {
	Data interface{} `json:"data"`
}

PostData is the data structure of post data

type REALITYConfig

type REALITYConfig struct {
	Dest             string   `json:"dest,omitempty"`
	ProxyProtocolVer uint64   `json:"proxy_protocol_ver,omitempty"`
	ServerNames      []string `json:"server_names,omitempty"`
	PrivateKey       string   `json:"private_key,omitempty"`
	MinClientVer     string   `json:"min_client_ver,omitempty"`
	MaxClientVer     string   `json:"max_client_ver,omitempty"`
	MaxTimeDiff      uint64   `json:"max_time_diff,omitempty"`
	ShortIds         []string `json:"short_ids,omitempty"`
}

type Response

type Response struct {
	Ret  uint            `json:"ret"`
	Data json.RawMessage `json:"data"`
}

Response is the common response

type RuleItem

type RuleItem struct {
	ID      int    `json:"id"`
	Content string `json:"regex"`
}

type SystemLoad

type SystemLoad struct {
	Uptime string `json:"uptime"`
	Load   string `json:"load"`
}

SystemLoad is the data structure of system load

type UserResponse

type UserResponse struct {
	ID          int     `json:"id"`
	Passwd      string  `json:"passwd"`
	Port        uint32  `json:"port"`
	Method      string  `json:"method"`
	SpeedLimit  float64 `json:"node_speedlimit"`
	DeviceLimit int     `json:"node_iplimit"`
	UUID        string  `json:"uuid"`
	AliveIP     int     `json:"alive_ip"`
}

UserResponse is the response of user

type UserTraffic

type UserTraffic struct {
	UID      int   `json:"user_id"`
	Upload   int64 `json:"u"`
	Download int64 `json:"d"`
}

UserTraffic is the data structure of traffic

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL