panel

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package panel orchestrates multiple nodes, periodic panel tasks and hot reload. Placeholder — implemented in Phase 1 (doc/03 T11).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoSpeedLimitConfig

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

AutoSpeedLimitConfig is the T7 dynamic speed-limit policy (doc/09 §5.3). Consumed by the Controller when Limit > 0.

type CertConfig

type CertConfig struct {
	CertMode   string            `mapstructure:"CertMode"`
	CertDomain string            `mapstructure:"CertDomain"`
	CertFile   string            `mapstructure:"CertFile"`
	KeyFile    string            `mapstructure:"KeyFile"`
	Provider   string            `mapstructure:"Provider"`
	Email      string            `mapstructure:"Email"`
	DNSEnv     map[string]string `mapstructure:"DNSEnv"`
}

CertConfig — T10 cert automation policy (doc/09 §5.3). Mapped onto cert.CertConfig by the Controller before AddNode.

type Config

type Config struct {
	Log   LogConfig    `mapstructure:"Log"`
	Nodes []NodeConfig `mapstructure:"Nodes"`
	// AccessLog is the process-level access-log reporting policy (doc/09 §4.3,
	// doc/11 §13.1). It is the billing/accesslog.Config directly; the Manager's
	// normalize() fills defaults. Enable=false (the zero value) leaves access
	// logging off, so existing configs without an AccessLog block load cleanly.
	AccessLog accesslog.Config `mapstructure:"AccessLog"`
}

Config is the top-level config.yml shape (doc/09 §3).

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads a YAML config.yml from path (viper), unmarshals it into Config, and fills defaults. Key matching is case-insensitive (mapstructure), matching XrayR semantics.

type ConnLimitConfig

type ConnLimitConfig struct {
	Enable         bool `mapstructure:"Enable"`
	MaxConnPerUser int  `mapstructure:"MaxConnPerUser"`
}

ConnLimitConfig — net-new (doc/09 §5.3): per-user concurrent-connection cap, pushed to the shared ConnLimiter per node tag before AddNode.

type Controller

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

Controller drives one node. It satisfies Service.

func NewController

func NewController(server *singbox.Server, apiClient api.API, config *ControllerConfig) *Controller

NewController wires a node orchestrator over a shared Core and a panel client. A dynamic speed limiter is constructed when the node enables one (Limit > 0).

func (*Controller) Close

func (c *Controller) Close() error

Close stops the monitor and removes the node from the Core.

func (*Controller) Start

func (c *Controller) Start() error

Start performs the initial sync and launches the periodic monitor.

type ControllerConfig

type ControllerConfig struct {
	ListenIP            string `mapstructure:"ListenIP"`
	SendIP              string `mapstructure:"SendIP"`
	UpdatePeriodic      int    `mapstructure:"UpdatePeriodic"`
	EnableDNS           bool   `mapstructure:"EnableDNS"`
	DNSType             string `mapstructure:"DNSType"`
	EnableProxyProtocol bool   `mapstructure:"EnableProxyProtocol"`
	EnableFallback      bool   `mapstructure:"EnableFallback"`

	// Node-local REALITY: legacy panels keep the private key node-side and do not
	// deliver reality-opts, so the Controller injects REALITYConfigs into the
	// NodeInfo before AddNode when EnableREALITY is set (unless the operator forces
	// the panel copy via DisableLocalREALITYConfig). doc/09 §5.3.
	EnableREALITY             bool          `mapstructure:"EnableREALITY"`
	DisableLocalREALITYConfig bool          `mapstructure:"DisableLocalREALITYConfig"`
	REALITYConfigs            RealityConfig `mapstructure:"REALITYConfigs"`

	// Local control sub-blocks, all consumed by the Controller: AutoSpeedLimit
	// drives the T7 dynamic throttle; GlobalDeviceLimit / ConnLimit are pushed to
	// the shared limiter before AddNode; Cert feeds the T10 inbound TLS build.
	AutoSpeedLimitConfig    AutoSpeedLimitConfig            `mapstructure:"AutoSpeedLimitConfig"`    // T7 dynamic speed limit
	GlobalDeviceLimitConfig limiter.GlobalDeviceLimitConfig `mapstructure:"GlobalDeviceLimitConfig"` // cross-node device cap (Redis)
	ConnLimitConfig         ConnLimitConfig                 `mapstructure:"ConnLimitConfig"`         // per-user concurrent conns
	CertConfig              CertConfig                      `mapstructure:"CertConfig"`              // T10 cert automation
}

ControllerConfig is the node-level local control policy (doc/09 §5.3). Only ListenIP and UpdatePeriodic are load-bearing for increment D; the rest are parsed so configs round-trip and later increments can wire them.

type LogConfig

type LogConfig struct {
	Level      string `mapstructure:"Level"`
	AccessPath string `mapstructure:"AccessPath"`
	ErrorPath  string `mapstructure:"ErrorPath"`
}

LogConfig mirrors XrayR LogConfig (doc/09 §4.1).

type NodeConfig

type NodeConfig struct {
	PanelType        string           `mapstructure:"PanelType"`
	ApiConfig        api.Config       `mapstructure:"ApiConfig"`
	ControllerConfig ControllerConfig `mapstructure:"ControllerConfig"`
}

NodeConfig is one entry of Nodes[] (doc/09 §5): panel type + panel connection (api.Config) + local control policy.

type Panel

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

Panel owns the shared Core and the per-node services.

func New

func New(config *Config) *Panel

New constructs a Panel from a loaded Config. It does not start anything.

func (*Panel) Close

func (p *Panel) Close() error

Close stops every service in reverse order, then the Core.

func (*Panel) Start

func (p *Panel) Start() error

Start builds and starts the shared Core, then constructs and starts one Controller per node. On any failure it unwinds what it already started.

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"`
}

RealityConfig is the node-local REALITY server config (doc/09 §5.3), mirroring api.REALITYConfig. Fields map to the REALITYConfigs YAML block.

type Service

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

Service is the lifecycle contract every node orchestrator satisfies (ported from XrayR service.Service). The panel starts and closes them uniformly.

Jump to

Keyboard shortcuts

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