server

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelDebug = "debug"
	LogLevelError = "error"
	LogLevelInfo  = "info"
)
View Source
const (
	DefaultDataDir = "/var/lib/trojan-node"
	StateFileName  = "state.json"
)

Variables

This section is empty.

Functions

func ClearState added in v0.3.1

func ClearState(dataDir string) error

ClearState 清空状态文件

func GetStateFilePath added in v0.3.1

func GetStateFilePath(dataDir string) string

GetStateFilePath 获取状态文件的完整路径

func SaveState added in v0.3.1

func SaveState(dataDir string, state *State) error

SaveState 保存状态到文件

Types

type Config

type Config struct {
	LogLevel string
}

type ConnectionConfig

type ConnectionConfig struct {
	Handshake    uint32 `mapstructure:"handshake"`
	ConnIdle     uint32 `mapstructure:"connIdle"`
	UplinkOnly   uint32 `mapstructure:"uplinkOnly"`
	DownlinkOnly uint32 `mapstructure:"downlinkOnly"`
	BufferSize   int32  `mapstructure:"bufferSize"`
}

type Server

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

func New

func New(config *Config, apiConfig *api.Config, serviceConfig *service.Config, extFileBytes []byte, dataDir string) (*Server, error)

func (*Server) Close

func (s *Server) Close()

func (*Server) Start

func (s *Server) Start() error

type State added in v0.3.1

type State struct {
	RegisterId string `json:"register_id"`
	NodeID     int    `json:"node_id"`
	Hostname   string `json:"hostname"`
}

State 节点状态信息

func LoadState added in v0.3.1

func LoadState(dataDir string) (*State, error)

LoadState 加载状态文件

Jump to

Keyboard shortcuts

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