api

package
v0.0.0-...-a8e6978 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	GetNodeInfo() (nodeInfo *NodeInfo, err error)
	GetUserList() (userList []*UserInfo, err error)
	ReportUserTraffic(userTraffic []*UserTraffic) (err error)
	Describe() *ClientInfo
	Debug()
}

API is the interface for different panel's api.

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) Debug

func (c *Client) Debug()

Debug set the client debug for client

func (*Client) Describe

func (c *Client) Describe() *ClientInfo

Describe return a description of the client

func (*Client) GetNodeInfo

func (c *Client) GetNodeInfo() (nodeInfo *NodeInfo, err error)

GetNodeInfo will pull NodeInfo Config from sspanel

func (*Client) GetUserList

func (c *Client) GetUserList() (UserList *[]UserInfo, err error)

GetUserList will pull user form sspanel

func (*Client) ReportUserTraffic

func (c *Client) ReportUserTraffic(userTraffic []*UserTraffic) error

ReportUserTraffic reports the user traffic

type ClientInfo

type ClientInfo struct {
	APIHost string
	NodeID  int
	Token   string
}

type Config

type Config struct {
	APIHost string
	NodeID  int
	Token   string
	Timeout time.Duration
}

Config api config

type NodeInfo

type NodeInfo 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 int    `json:"disable_mtu_discovery"`
}

type RepNodeInfo

type RepNodeInfo struct {
	Data    *NodeInfo `json:"data"`
	Message string    `json:"message"`
}

type RepUserList

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

type RepUserTraffic

type RepUserTraffic struct {
	Message string `json:"message"`
}

type UserInfo

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

type UserTraffic

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

Jump to

Keyboard shortcuts

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