nps

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MulanPSL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddClientInfo

type AddClientInfo struct {
	Remark    string
	VerifyKey string
}

type AddTunnelInfo

type AddTunnelInfo struct {
	ClientId int64
	ModType  ModType
	Remark   string
	Port     int64
	Target   int64
}

type Client

type Client struct {
	Cnf             ClientCnf
	Id              int64
	VerifyKey       string
	Addr            string
	Remark          string
	Status          bool
	IsConnect       bool
	RateLimit       int64
	Flow            Flow
	Rate            ClientRate
	NoStore         bool
	NoDisplay       bool
	MaxConn         int64
	NowConn         int64
	WebUserName     string
	WebPassword     string
	ConfigConnAllow bool
	MaxTunnelNum    int64
	Version         string
}

type ClientCnf

type ClientCnf struct {
	U        string
	P        string
	Compress bool
	Crypt    bool
}

type ClientRate

type ClientRate struct {
	NowRate int64
}

type Flow

type Flow struct {
	ExportFlow int64
	InletFlow  int64
	FlowLimit  int64
}

type ListClientFilter

type ListClientFilter struct {
	Start  int64
	Limit  int64
	Search string
}

type ListClientResponse

type ListClientResponse struct {
	BridgePort int64    `json:"bridgePort"`
	BridgeType string   `json:"bridgeType"`
	Ip         string   `json:"ip"`
	Rows       []Client `json:"rows"`
	Total      int64    `json:"total"`
}

type ListTunnelFilter

type ListTunnelFilter struct {
	ModeType ModType
	Search   string
	ClientId int64
	Offset   int64
	Limit    int64
}

type ListTunnelResponse

type ListTunnelResponse struct {
	Rows  []Tunnel `json:"rows"`
	Total int64    `json:"total"`
}

type ModType

type ModType int8
const (
	ModTypeTcp ModType = iota + 1
	ModTypeUdp
	ModTypeHttpProx
	ModTypeSocks5
	ModTypeSecret
	ModTypeP2p
)

func (ModType) String

func (m ModType) String() string

type Sever

type Sever struct {
	Host      string
	ApiPort   int
	ProxyPort int
	AuthKey   string
}

func NewSever

func NewSever(host, authKey string, apiPort, proxyPort int) *Sever

func (*Sever) AddClient

func (s *Sever) AddClient(info AddClientInfo) error

AddClient 添加客户端 remark 不可为空,verifyKey 为空时,由 nps 服务器自动生成

func (*Sever) AddTunnel

func (s *Sever) AddTunnel(tunnel AddTunnelInfo) error

AddTunnel 添加隧道 modeType 为必传项,modeType 请从 nps包中获取已定义好的以"ModType"开头的常量,注意自行转化的不认,会返回错误 remark 不可为空, port 必须在 10000 ~ 11000 范围内 --去掉端口号限制 target 不可为 0

func (*Sever) DeleteClient

func (s *Sever) DeleteClient(clientId int64) error

DeleteClient 删除客户端

func (*Sever) DeleteTunnel

func (s *Sever) DeleteTunnel(tunnelId int64) error

DeleteTunnel 删除隧道

func (*Sever) GetClient

func (s *Sever) GetClient(clientId int64) (client Client, err error)

GetClient 获取单个客户端 clientId 不可为空

func (*Sever) GetClientList

func (s *Sever) GetClientList(filter ListClientFilter) (clients ListClientResponse, err error)

GetClientList 获取客户端列表 start, limit 不可小于 0, search 可为空

func (*Sever) GetClientTunnel

func (s *Sever) GetClientTunnel(filter ListTunnelFilter) (tunnels ListTunnelResponse, err error)

GetClientTunnel 获取隧道列表 modeType 为必传项,modeType 请从 nps包中获取已定义好的以"ModType"开头的常量,注意自行转化的不认,会返回错误 offset, limit 不可小于 0

type Tunnel

type Tunnel struct {
	Id                  int64
	Port                int64
	ServerIp            string
	Mode                string
	Status              bool
	RunStatus           bool
	Client              Client
	Ports               string
	Flow                Flow
	Password            string
	Remark              string
	TargetAddr          string
	NoStore             bool
	LocalPath           string
	StripPre            string
	Target              TunnelTarget
	MultiAccount        interface{} // todo 不确定结构,http 结果为 null 暂无法推测
	HealthCheckTimeout  int64
	HealthMaxFail       int64
	HealthCheckInterval int64
	HealthNextTime      string
	HealthMap           map[string]interface{} // todo 不确定结构,http 结果为 null 暂无法推测
	HttpHealthUrl       string
	HealthRemoveArr     interface{} // todo 不确定结构,http 结果为 null 暂无法推测
	HealthCheckType     string
	HealthCheckTarget   string
}

type TunnelTarget

type TunnelTarget struct {
	TargetStr  string
	TargetArr  interface{} // todo 不确定结构,http 结果为 null 暂无法推测
	LocalProxy bool
}

Jump to

Keyboard shortcuts

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