Documentation
¶
Index ¶
- Variables
- func AsConfig[T NodeConfig](nc NodeConfig) (T, error)
- func MarshalTrafficStats(stats *TrafficStats) ([]byte, error)
- func MarshalTraffics(traffics []*UserTraffic) ([]byte, error)
- func UnmarshalConfig[T any](data []byte) (*T, error)
- func UnmarshalUsers(data []byte) (*[]User, error)
- type APIError
- func NewAPIError(statusCode int, errorType ErrorType, message string, url string, err error) *APIError
- func NewAPIErrorFromStatusCode(statusCode int, message string, url string, err error) *APIError
- func NewBusinessLogicError(message string, url string) *APIError
- func NewNetworkError(message string, url string, err error) *APIError
- func NewNotModifiedError() *APIError
- func NewParseError(message string, err error) *APIError
- type AnyTLSConfig
- type Client
- func (c *Client) Config(nodeId NodeId, nodeType NodeType) (config NodeConfig, err error)
- func (c *Client) Debug(enable bool)
- func (c *Client) Heartbeat(registerId string, nodeType NodeType, nodeIp string) error
- func (c *Client) RawConfig(nodeId NodeId, nodeType NodeType) (rawData []byte, err error)
- func (c *Client) RawUsers(registerId string, nodeType NodeType) (rawData []byte, err error)
- func (c *Client) Register(nodeId NodeId, nodeType NodeType, hostname string, port int, nodeIp string) (registerId string, err error)
- func (c *Client) Submit(registerId string, nodeType NodeType, userTraffic []*UserTraffic) error
- func (c *Client) SubmitStatsWithAgent(registerId string, nodeType NodeType, stats *TrafficStats) error
- func (c *Client) SubmitWithAgent(registerId string, nodeType NodeType, userTraffic []*UserTraffic) error
- func (c *Client) Unregister(nodeType NodeType, registerId string) error
- func (c *Client) Users(registerId string, nodeType NodeType) (UserList *[]User, err error)
- func (c *Client) Verify(registerId string, nodeType NodeType) (bool, error)
- type Config
- type ErrorType
- type Hysteria2Config
- type HysteriaConfig
- type NodeConfig
- type NodeId
- type NodeType
- type RespConfig
- type RespHeartBeat
- type RespRegister
- type RespSubmit
- type RespSubmitStatsWithAgent
- type RespSubmitWithAgent
- type RespUnregister
- type RespUsers
- type RespVerify
- type ShadowsocksConfig
- type TrafficStats
- type TrojanConfig
- type User
- type UserTraffic
- type VMessConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorUserNotModified = NewNotModifiedError()
ErrorUserNotModified 用户数据未修改错误 (304)
Functions ¶
func AsConfig ¶
func AsConfig[T NodeConfig](nc NodeConfig) (T, error)
func MarshalTrafficStats ¶ added in v0.0.7
func MarshalTrafficStats(stats *TrafficStats) ([]byte, error)
func MarshalTraffics ¶ added in v0.0.7
func MarshalTraffics(traffics []*UserTraffic) ([]byte, error)
func UnmarshalConfig ¶ added in v0.0.12
UnmarshalConfig 是一个通用的泛型反序列化函数
func UnmarshalUsers ¶
Types ¶
type APIError ¶ added in v0.1.0
type APIError struct {
StatusCode int // HTTP状态码
Type ErrorType // 错误类型
Message string // 错误消息
URL string // 请求的URL
Err error // 原始错误
}
APIError 自定义API错误类型
func NewAPIError ¶ added in v0.1.0
func NewAPIError(statusCode int, errorType ErrorType, message string, url string, err error) *APIError
NewAPIError 创建一个新的API错误
func NewAPIErrorFromStatusCode ¶ added in v0.1.0
NewAPIErrorFromStatusCode 根据状态码自动推断错误类型
func NewBusinessLogicError ¶ added in v0.1.0
NewBusinessLogicError 创建业务逻辑错误 业务逻辑错误通常来自API响应中的Message字段,默认视为服务端错误(500)
func NewNetworkError ¶ added in v0.1.0
NewNetworkError 创建网络错误
func NewNotModifiedError ¶ added in v0.1.0
func NewNotModifiedError() *APIError
NewNotModifiedError 创建304未修改错误
func NewParseError ¶ added in v0.1.0
NewParseError 创建解析错误
func (*APIError) IsNetworkError ¶ added in v0.1.0
IsNetworkError 判断是否为网络错误
func (*APIError) IsNotModified ¶ added in v0.1.0
IsNotModified 判断是否为304未修改
func (*APIError) IsParseError ¶ added in v0.1.0
IsParseError 判断是否为解析错误
func (*APIError) IsServerError ¶ added in v0.1.0
IsServerError 判断是否为服务端错误 (4xx/5xx)
type AnyTLSConfig ¶ added in v0.0.12
type AnyTLSConfig struct {
ID int `json:"id"`
ServerPort int `json:"server_port"`
AllowInsecure int `json:"allow_insecure"`
ServerName string `json:"server_name"`
PaddingRules string `json:"padding_rules"`
}
func AsAnyTLSConfig ¶ added in v0.0.12
func AsAnyTLSConfig(nc NodeConfig) (*AnyTLSConfig, error)
func UnmarshalAnyTLSConfig ¶ added in v0.0.12
func UnmarshalAnyTLSConfig(data []byte) (*AnyTLSConfig, error)
func (*AnyTLSConfig) String ¶ added in v0.0.12
func (n *AnyTLSConfig) String() string
func (*AnyTLSConfig) TypeName ¶ added in v0.0.12
func (n *AnyTLSConfig) TypeName() string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client APIClient create a api client to the panel.
func (*Client) Config ¶
func (c *Client) Config(nodeId NodeId, nodeType NodeType) (config NodeConfig, err error)
Config get node config by nodeId
func (*Client) Register ¶ added in v0.1.0
func (c *Client) Register(nodeId NodeId, nodeType NodeType, hostname string, port int, nodeIp string) (registerId string, err error)
Register register node and return register_id
func (*Client) Submit ¶
func (c *Client) Submit(registerId string, nodeType NodeType, userTraffic []*UserTraffic) error
Submit reports the user traffic
func (*Client) SubmitStatsWithAgent ¶
func (c *Client) SubmitStatsWithAgent(registerId string, nodeType NodeType, stats *TrafficStats) error
func (*Client) SubmitWithAgent ¶
func (c *Client) SubmitWithAgent(registerId string, nodeType NodeType, userTraffic []*UserTraffic) error
func (*Client) Unregister ¶ added in v0.1.0
type ErrorType ¶ added in v0.1.0
type ErrorType string
ErrorType 定义错误类型
const ( // HTTP错误 ErrorTypeServerError ErrorType = "ServerError" // 5xx 服务端错误 // 特殊错误类型 ErrorTypeNetworkError ErrorType = "NetworkError" // 网络连接错误 ErrorTypeParseError ErrorType = "ParseError" // 响应解析错误 ErrorTypeNotModified ErrorType = "NotModified" // 304 Not Modified ErrorTypeUnknown ErrorType = "Unknown" // 未知错误 )
type Hysteria2Config ¶
type Hysteria2Config struct {
ID int `json:"id"`
ServerPort int `json:"server_port"`
Obfs string `json:"obfs"`
UpMbps int `json:"up_mbps"`
DownMbps int `json:"down_mbps"`
IgnoreCliBandWidth bool `json:"ignore_cli_band_width"`
DisableUDP bool `json:"disable_udp"`
}
func AsHysteria2Config ¶
func AsHysteria2Config(nc NodeConfig) (*Hysteria2Config, error)
func UnmarshalHysteria2Config ¶
func UnmarshalHysteria2Config(data []byte) (*Hysteria2Config, error)
使用泛型函数重写原有的 Unmarshal 函数
func (*Hysteria2Config) String ¶
func (n *Hysteria2Config) String() string
func (*Hysteria2Config) TypeName ¶
func (n *Hysteria2Config) TypeName() string
type HysteriaConfig ¶
type HysteriaConfig struct {
ID int `json:"id"`
ServerPort int `json:"server_port"`
Protocol string `json:"protocol"`
Obfs string `json:"obfs"`
UpMbps int `json:"up_mbps"`
DownMbps int `json:"down_mbps"`
DisableMTUDiscovery bool `json:"disable_mtu_discovery"`
DisableUdp bool `json:"disable_udp"`
}
func AsHysteriaConfig ¶
func AsHysteriaConfig(nc NodeConfig) (*HysteriaConfig, error)
func UnmarshalHysteriaConfig ¶
func UnmarshalHysteriaConfig(data []byte) (*HysteriaConfig, error)
func (*HysteriaConfig) String ¶
func (n *HysteriaConfig) String() string
func (*HysteriaConfig) TypeName ¶
func (n *HysteriaConfig) TypeName() string
type NodeConfig ¶
type RespConfig ¶
type RespConfig struct {
Data NodeConfig `json:"data"`
Message string `json:"message"`
}
type RespHeartBeat ¶
type RespHeartBeat RespSubmit
type RespRegister ¶ added in v0.1.0
type RespSubmit ¶
type RespSubmitStatsWithAgent ¶
type RespSubmitStatsWithAgent RespSubmit
type RespSubmitWithAgent ¶
type RespSubmitWithAgent RespSubmit
type RespUnregister ¶ added in v0.1.0
type RespUnregister RespSubmit
type RespVerify ¶ added in v0.1.1
type RespVerify RespSubmit
type ShadowsocksConfig ¶
type ShadowsocksConfig struct {
ID int `json:"id"`
ServerPort int `json:"server_port"`
Method string `json:"method"`
Network string `json:"network"`
}
func AsShadowsocksConfig ¶
func AsShadowsocksConfig(nc NodeConfig) (*ShadowsocksConfig, error)
func UnmarshalShadowsocksConfig ¶
func UnmarshalShadowsocksConfig(data []byte) (*ShadowsocksConfig, error)
func (*ShadowsocksConfig) String ¶
func (n *ShadowsocksConfig) String() string
func (*ShadowsocksConfig) TypeName ¶
func (n *ShadowsocksConfig) TypeName() string
type TrafficStats ¶
type TrojanConfig ¶
type TrojanConfig struct {
ID int `json:"id"`
ServerPort int `json:"server_port"`
AllowInsecure int `json:"allow_insecure"`
ServerName string `json:"server_name"`
Network string `json:"network"`
WebSocketConfig *xray.WebSocketConfig `json:"ws_settings,omitempty"`
GrpcConfig *xray.GRPCConfig `json:"grpc_settings,omitempty"`
}
func AsTrojanConfig ¶
func AsTrojanConfig(nc NodeConfig) (*TrojanConfig, error)
func UnmarshalTrojanConfig ¶
func UnmarshalTrojanConfig(data []byte) (*TrojanConfig, error)
func (*TrojanConfig) String ¶
func (n *TrojanConfig) String() string
func (*TrojanConfig) TypeName ¶
func (n *TrojanConfig) TypeName() string
type UserTraffic ¶
type VMessConfig ¶
type VMessConfig struct {
ID int `json:"id"`
ServerPort int `json:"server_port"`
TLS int `json:"tls"`
Network string `json:"network"`
TlsConfig *xray.TLSConfig `json:"tls_settings"`
WebSocketConfig *xray.WebSocketConfig `json:"ws_settings,omitempty"`
H2Config *xray.HTTPConfig `json:"h2_config"`
TcpConfig *xray.TCPConfig `json:"tcp_settings,omitempty"`
GrpcConfig *xray.GRPCConfig `json:"grpc_settings,omitempty"`
RouterSettings *xray.RouterConfig `json:"router_settings,omitempty"`
DnsSettings *xray.DNSConfig `json:"dns_settings,omitempty"`
}
func AsVMessConfig ¶
func AsVMessConfig(nc NodeConfig) (*VMessConfig, error)
func UnmarshalVMessConfig ¶
func UnmarshalVMessConfig(data []byte) (*VMessConfig, error)
func (*VMessConfig) String ¶
func (n *VMessConfig) String() string
func (*VMessConfig) TypeName ¶
func (n *VMessConfig) TypeName() string
Click to show internal directories.
Click to hide internal directories.