controller

package
v0.0.0-...-48af030 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MPL-2.0 Imports: 49 Imported by: 0

Documentation

Overview

Package controller Package generate the InboundConfig used by add inbound

Index

Constants

This section is empty.

Variables

Functions

func BuildWSEndpoint

func BuildWSEndpoint(wsConfig *api.WSConfig, runtimeConfig *WebSocketConfig) (string, error)

func InboundBuilder

func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.InboundHandlerConfig, error)

InboundBuilder is the compatibility adapter for callers that still provide api.NodeInfo. Internal controller paths call buildInbound with a focused view.

func InboundBuilderWithUsers

func InboundBuilderWithUsers(config *Config, nodeInfo *api.NodeInfo, tag string, userInfo *[]api.UserInfo) (*core.InboundHandlerConfig, error)

InboundBuilderWithUsers is the compatibility adapter for callers that still provide api.NodeInfo. Internal controller paths call buildInboundWithUsers with the focused listener view.

func OutboundBuilder

func OutboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.OutboundHandlerConfig, error)

OutboundBuilder is the compatibility adapter for callers that still provide api.NodeInfo. Internal controller paths call buildOutbound with a focused view.

Types

type AutoSpeedLimitConfig

type AutoSpeedLimitConfig struct {
	Limit         int `mapstructure:"Limit"` // mbps
	WarnTimes     int `mapstructure:"WarnTimes"`
	LimitSpeed    int `mapstructure:"LimitSpeed"`    // mbps
	LimitDuration int `mapstructure:"LimitDuration"` // minute
}

type Config

type Config struct {
	ListenIP                  string                           `mapstructure:"ListenIP"`
	SendIP                    string                           `mapstructure:"SendIP"`
	UpdatePeriodic            int                              `mapstructure:"UpdatePeriodic"`
	CertConfig                *mylego.CertConfig               `mapstructure:"CertConfig"`
	EnableDNS                 bool                             `mapstructure:"EnableDNS"`
	DNSType                   string                           `mapstructure:"DNSType"`
	DisableUploadTraffic      bool                             `mapstructure:"DisableUploadTraffic"`
	DisableGetRule            bool                             `mapstructure:"DisableGetRule"`
	EnableProxyProtocol       bool                             `mapstructure:"EnableProxyProtocol"`
	EnableFallback            bool                             `mapstructure:"EnableFallback"`
	DisableIVCheck            bool                             `mapstructure:"DisableIVCheck"`
	DisableSniffing           bool                             `mapstructure:"DisableSniffing"`
	AutoSpeedLimitConfig      *AutoSpeedLimitConfig            `mapstructure:"AutoSpeedLimitConfig"`
	GlobalDeviceLimitConfig   *limiter.GlobalDeviceLimitConfig `mapstructure:"GlobalDeviceLimitConfig"`
	FallBackConfigs           []*FallBackConfig                `mapstructure:"FallBackConfigs"`
	DisableLocalREALITYConfig bool                             `mapstructure:"DisableLocalREALITYConfig"`
	EnableREALITY             bool                             `mapstructure:"EnableREALITY"`
	REALITYConfigs            *REALITYConfig                   `mapstructure:"REALITYConfigs"`
	WebSocketConfig           *WebSocketConfig                 `mapstructure:"WebSocketConfig"`
	ShowErrorDetails          bool                             `mapstructure:"-"`
}

func (*Config) Clone

func (config *Config) Clone() *Config

Clone returns an independently owned copy of the controller configuration. The copy keeps nil versus non-nil collection semantics and detaches every pointer, slice, and map reachable from Config.

type Controller

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

func New

func New(server *core.Instance, apiClient PanelClient, config *Config, panelType string) *Controller

New return a Controller service with default parameters.

func (*Controller) AddInboundLimiter

func (c *Controller) AddInboundLimiter(tag string, nodeSpeedLimit uint64, userList *[]api.UserInfo, globalDeviceLimitConfig *limiter.GlobalDeviceLimitConfig) error

func (*Controller) Close

func (c *Controller) Close() error

Close implement the Close() function of the service interface.

func (*Controller) CloseContext

func (c *Controller) CloseContext(parent context.Context) error

func (*Controller) DeleteInboundLimiter

func (c *Controller) DeleteInboundLimiter(tag string) error

func (*Controller) ExecuteSyncAction

func (c *Controller) ExecuteSyncAction(ctx context.Context, action syncAction) error

func (*Controller) GetDetectResult

func (c *Controller) GetDetectResult(tag string) (*[]api.DetectResult, error)

func (*Controller) GetOnlineDevice

func (c *Controller) GetOnlineDevice(tag string) (*[]api.OnlineUser, error)

func (*Controller) ObservabilitySnapshot

func (c *Controller) ObservabilitySnapshot() service.RuntimeSnapshot

func (*Controller) SetWSEventRuntimeFactory

func (c *Controller) SetWSEventRuntimeFactory(factory WSEventRuntimeFactory)

func (*Controller) Start

func (c *Controller) Start() error

Start implement the Start() function of the service interface.

func (*Controller) StartContext

func (c *Controller) StartContext(parent context.Context) error

func (*Controller) SyncAliveList

func (c *Controller) SyncAliveList(tag string, aliveList map[int][]string) error

func (*Controller) UpdateInboundLimiter

func (c *Controller) UpdateInboundLimiter(tag string, updatedUserList *[]api.UserInfo) error

func (*Controller) UpdateRule

func (c *Controller) UpdateRule(tag string, newRuleList []api.DetectRule) error

type FallBackConfig

type FallBackConfig struct {
	SNI              string `mapstructure:"SNI"`
	Alpn             string `mapstructure:"Alpn"`
	Path             string `mapstructure:"Path"`
	Dest             string `mapstructure:"Dest"`
	ProxyProtocolVer uint64 `mapstructure:"ProxyProtocolVer"`
}

type LimitInfo

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

type NodeHandlerBuilder

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

NodeHandlerBuilder owns normalized node and configuration inputs for constructing Xray inbound and outbound handlers. Its fields are deliberately opaque because the owned inputs may contain credentials or private keys.

func NewNodeHandlerBuilder

func NewNodeHandlerBuilder(config *Config, nodeInfo *api.NodeInfo) (*NodeHandlerBuilder, error)

NewNodeHandlerBuilder prepares an owned handler-construction interface. Mutating config or nodeInfo after this call does not affect later builds.

func (*NodeHandlerBuilder) BuildInbound

func (b *NodeHandlerBuilder) BuildInbound(tag string) (*core.InboundHandlerConfig, error)

BuildInbound constructs an inbound handler from the owned inputs.

func (*NodeHandlerBuilder) BuildInboundWithUsers

func (b *NodeHandlerBuilder) BuildInboundWithUsers(tag string, users []api.UserInfo) (*core.InboundHandlerConfig, error)

BuildInboundWithUsers constructs a Socks or HTTP inbound with embedded users.

func (*NodeHandlerBuilder) BuildOutbound

func (b *NodeHandlerBuilder) BuildOutbound(tag string) (*core.OutboundHandlerConfig, error)

BuildOutbound constructs an outbound handler from the owned inputs.

type PanelClient

type PanelClient interface {
	// contains filtered or unexported methods
}

type REALITYConfig

type REALITYConfig struct {
	Show             bool     `mapstructure:"Show"`
	Dest             string   `mapstructure:"Dest"`
	ProxyProtocolVer uint64   `mapstructure:"ProxyProtocolVer"`
	ServerNames      []string `mapstructure:"ServerNames"`
	PrivateKey       string   `mapstructure:"PrivateKey"`
	MinClientVer     string   `mapstructure:"MinClientVer"`
	MaxClientVer     string   `mapstructure:"MaxClientVer"`
	MaxTimeDiff      uint64   `mapstructure:"MaxTimeDiff"`
	ShortIds         []string `mapstructure:"ShortIds"`
}

type WSEventRuntimeFactory

type WSEventRuntimeFactory func(WSEventSubmitter) (WSRuntimeLifecycle, error)

type WSEventSubmitter

type WSEventSubmitter interface {
	SubmitWSEvent(*newV2board.WSEvent)
	SubmitWSParseError()
	SubmitWSDisconnect()
	SubmitWSReconnect()
}

type WSRuntimeLifecycle

type WSRuntimeLifecycle interface {
	Start()
	Stop()
}

type WebSocketConfig

type WebSocketConfig struct {
	Enable            bool   `mapstructure:"Enable"`
	Endpoint          string `mapstructure:"Endpoint"`
	HeartbeatInterval int    `mapstructure:"HeartbeatInterval"`
	ReconnectBackoff  int    `mapstructure:"ReconnectBackoff"`
	ResyncOnReconnect bool   `mapstructure:"ResyncOnReconnect"`
}

Jump to

Keyboard shortcuts

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