pkg

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorUserNotModified = errors.New("users not modified")
)

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 UnmarshalUsers

func UnmarshalUsers(data []byte) (*[]User, error)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client APIClient create a api client to the panel.

func New

func New(apiConfig *Config) *Client

New creat a api instance

func (*Client) Config

func (c *Client) Config(nodeId NodeId, nodeType NodeType) (config NodeConfig, err error)

func (*Client) Debug

func (c *Client) Debug(enable bool)

Debug set the client debug for client

func (*Client) Heartbeat

func (c *Client) Heartbeat(nodeId NodeId, nodeType NodeType, nodeIp string) error

func (*Client) RawConfig

func (c *Client) RawConfig(nodeId NodeId, nodeType NodeType) (rawData []byte, err error)

func (*Client) RawUsers

func (c *Client) RawUsers(nodeId NodeId, nodeType NodeType) (rawData []byte, hash string, err error)

func (*Client) Submit

func (c *Client) Submit(nodeId NodeId, nodeType NodeType, userTraffic []*UserTraffic) error

Submit reports the user traffic

func (*Client) SubmitStatsWithAgent

func (c *Client) SubmitStatsWithAgent(nodeId NodeId, nodeType NodeType, nodeIp string, stats *TrafficStats) error

func (*Client) SubmitWithAgent

func (c *Client) SubmitWithAgent(nodeId NodeId, nodeType NodeType, userTraffic []*UserTraffic) error

func (*Client) Users

func (c *Client) Users(nodeId NodeId, nodeType NodeType) (UserList *[]User, hash string, err error)

Users will pull users form server

type Config

type Config struct {
	APIHost string
	Token   string
	Timeout time.Duration
	Debug   bool
}

Config api config

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)

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 NodeConfig interface {
	String() string
	TypeName() string
}

type NodeId

type NodeId int

type NodeType

type NodeType string
const (
	Trojan      NodeType = "trojan"
	ShadowSocks NodeType = "shadowsocks"
	Hysteria    NodeType = "hysteria"
	Hysteria2   NodeType = "hysteria2"
	VMess       NodeType = "vmess"
)

func (NodeType) String

func (n NodeType) String() string

type RespConfig

type RespConfig struct {
	Data    NodeConfig `json:"data"`
	Message string     `json:"message"`
}

type RespHeartBeat

type RespHeartBeat RespSubmit

type RespSubmit

type RespSubmit struct {
	Data    bool   `json:"data"`
	Message string `json:"message"`
}

type RespSubmitStatsWithAgent

type RespSubmitStatsWithAgent RespSubmit

type RespSubmitWithAgent

type RespSubmitWithAgent RespSubmit

type RespUsers

type RespUsers struct {
	Data    *[]User `json:"data"`
	Message string  `json:"message"`
}

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 TrafficStats struct {
	Count        int         `json:"count"`
	Requests     int         `json:"requests"`
	UserIds      []int       `json:"user_ids"`
	UserRequests map[int]int `json:"user_requests"`
}

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 User

type User struct {
	ID   int    `json:"id"`
	UUID string `json:"uuid"`
}

type UserTraffic

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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