service

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TLS  = "tls"
	TCP  = "tcp"
	WS   = "ws"
	GRPC = "grpc"
)

Variables

This section is empty.

Functions

func InboundBuilder

func InboundBuilder(config *Config, nodeInfo *api.TrojanConfig) (*core.InboundHandlerConfig, error)

InboundBuilder build Inbound config for different protocol

func OutboundBuilder

func OutboundBuilder(ctx context.Context, nodeInfo *api.TrojanConfig, extConfigBytes []byte) (*core.OutboundHandlerConfig, error)

OutboundBuilder build monster outbund config for addoutbound

Types

type APIClient added in v0.3.0

type APIClient interface {
	Users(string, api.NodeType) (*[]api.User, error)
	Submit(string, api.NodeType, []*api.UserTraffic) error
	Heartbeat(string, api.NodeType, string) error
}

APIClient 定义了与API服务器交互所需的方法接口

type Builder

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

func New

func New(inboundTag string, instance *core.Instance, config *Config, nodeInfo *api.TrojanConfig, registerId string,
	apiClient APIClient,
) *Builder

New return a builder service with default parameters.

func (*Builder) Close

func (b *Builder) Close() error

Close implement the Close() function of the service interface

func (*Builder) Start

func (b *Builder) Start() error

Start implement the Start() function of the service interface

type CertConfig

type CertConfig struct {
	CertFile string
	KeyFile  string
}

type Config

type Config struct {
	NodeID                 int
	FetchUsersInterval     time.Duration
	ReportTrafficsInterval time.Duration
	HeartbeatInterval      time.Duration
	Cert                   *CertConfig
	ExtConfPath            string
	ServerHost             string
	ServerPort             int
	ListenAddr             string
}

type FallBackConfig

type FallBackConfig struct {
	Host string
	Port int
}

type Service

type Service interface {
	Start() error
	Close() error
}

Service is the interface of all the services running in the panel

Jump to

Keyboard shortcuts

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