controller

package
v0.0.0-...-7333294 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 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"`
	TrustedXForwardedFor      []string                         `mapstructure:"TrustedXForwardedFor"`
	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:"-"`
	GlobalPanelType           string                           `mapstructure:"-"`
	// contains filtered or unexported fields
}

func (*Config) CaptureLocalCertConfig

func (config *Config) CaptureLocalCertConfig()

CaptureLocalCertConfig records the certificate configuration as declared locally, before any panel snapshot is merged into it. Panel snapshots are always merged over this basis rather than over the applied certificate configuration, so a value supplied by an earlier snapshot does not persist after a later snapshot stops supplying it. It is idempotent and nil-safe: once captured, later calls keep the recorded basis instead of recapturing merged values, so both the panel materialize step and New may call it.

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.

func (*Config) MergePanelCertConfig

func (config *Config) MergePanelCertConfig(panel *api.XrayRCertConfig) *mylego.CertConfig

MergePanelCertConfig returns the effective certificate configuration produced by one panel snapshot over the local basis. Supplied panel values take precedence; omitted values fall back to the local basis; DNS credentials are merged per key. Content material is taken from the panel only in content mode, so private keys from earlier snapshots never leak into other modes. The basis is captured on first use if the caller has not captured it yet. The result shares no maps or pointers with the config or the snapshot.

func (*Config) ValidateGlobalDeviceLimit

func (config *Config) ValidateGlobalDeviceLimit() error

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) SyncAliveSnapshot

func (c *Controller) SyncAliveSnapshot(tag string, snapshot *api.AliveSnapshot, reportedIPs 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 = api.PanelClient

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