mock

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFreePort

func GetFreePort() (int, error)

GetFreePort 获取空闲端口

Types

type MockStats

type MockStats struct {
	Upload   int64 `json:"upload"`
	Download int64 `json:"download"`
}

MockStats 模拟流量统计

type MockUser

type MockUser struct {
	ID             uint32 `json:"id"`
	UUID           string `json:"uuid"`
	Email          string `json:"email"`
	SpeedLimit     int64  `json:"speed_limit"`
	DeviceLimit    int    `json:"device_limit"`
	TransferEnable int64  `json:"transfer_enable"`
	UsedUpload     int64  `json:"used_upload"`
	UsedDownload   int64  `json:"used_download"`
}

MockUser 模拟用户

type NodeConfig

type NodeConfig struct {
	Host       string `json:"host"`
	ServerPort int    `json:"server_port"`
	Type       string `json:"type"`
	Network    string `json:"network"`
	TLS        int    `json:"tls"`
}

NodeConfig 节点配置响应

type Server

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

Server Mock 服务器

func NewServer

func NewServer(port int) *Server

NewServer 创建 Mock 服务器

func (*Server) AddUser

func (s *Server) AddUser(user *MockUser)

AddUser 添加用户

func (*Server) GetStats

func (s *Server) GetStats(uuid string) *MockStats

GetStats 获取流量统计

func (*Server) RemoveUser

func (s *Server) RemoveUser(uuid string)

RemoveUser 移除用户

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start 启动服务器

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop 停止服务器

func (*Server) URL

func (s *Server) URL() string

URL 返回服务器 URL

Jump to

Keyboard shortcuts

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