conf

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingEnvVar = errors.New("missing required env var")

Functions

This section is empty.

Types

type ApiConfig

type ApiConfig struct {
	APIHost      string          `json:"ApiHost"`
	APISendIP    string          `json:"ApiSendIP"`
	NodeID       int             `json:"NodeID"`
	Key          string          `json:"ApiKey"`
	NodeType     string          `json:"NodeType"`
	Timeout      int             `json:"Timeout"`
	RuleListPath string          `json:"RuleListPath"`
	WebSocket    WebSocketConfig `json:"WebSocket"`
}

type CertConfig

type CertConfig struct {
	CertMode         string            `json:"CertMode"` // none, file, http, dns
	RejectUnknownSni bool              `json:"RejectUnknownSni"`
	CertDomain       string            `json:"CertDomain"`
	CertFile         string            `json:"CertFile"`
	KeyFile          string            `json:"KeyFile"`
	Provider         string            `json:"Provider"` // alidns, cloudflare, gandi, godaddy....
	Email            string            `json:"Email"`
	DNSEnv           map[string]string `json:"DNSEnv"`
}

func NewCertConfig

func NewCertConfig() *CertConfig

func (*CertConfig) UnmarshalJSON added in v0.10.0

func (c *CertConfig) UnmarshalJSON(data []byte) error

type Conf

type Conf struct {
	LogConfig   LogConfig    `json:"Log"`
	CoresConfig []CoreConfig `json:"Cores"`
	NodeConfig  []NodeConfig `json:"Nodes"`
}

func New

func New() *Conf

func (*Conf) LoadFromPath

func (p *Conf) LoadFromPath(filePath string) error

func (*Conf) Watch

func (p *Conf) Watch(filePath, xDnsPath string, reload func()) error

type CoreConfig

type CoreConfig struct {
	Type       string      `json:"Type"`
	Name       string      `json:"Name"`
	XrayConfig *XrayConfig `json:"-"`
}

func (*CoreConfig) UnmarshalJSON

func (c *CoreConfig) UnmarshalJSON(b []byte) error

type DynamicSpeedLimitConfig

type DynamicSpeedLimitConfig struct {
	Periodic   int   `json:"Periodic"`
	Traffic    int64 `json:"Traffic"`
	SpeedLimit int   `json:"SpeedLimit"`
	ExpireTime int   `json:"ExpireTime"`
}

type FallBackConfigForXray

type FallBackConfigForXray struct {
	SNI              string `json:"SNI"`
	Alpn             string `json:"Alpn"`
	Path             string `json:"Path"`
	Dest             string `json:"Dest"`
	ProxyProtocolVer uint64 `json:"ProxyProtocolVer"`
}

type IpReportConfig

type IpReportConfig struct {
	Periodic       int             `json:"Periodic"`
	Type           string          `json:"Type"`
	RecorderConfig *RecorderConfig `json:"RecorderConfig"`
	RedisConfig    *RedisConfig    `json:"RedisConfig"`
	EnableIpSync   bool            `json:"EnableIpSync"`
}

type LimitConfig

type LimitConfig struct {
	EnableRealtime          bool                     `json:"EnableRealtime"`
	SpeedLimit              int                      `json:"SpeedLimit"`
	IPLimit                 int                      `json:"DeviceLimit"`
	ConnLimit               int                      `json:"ConnLimit"`
	EnableIpRecorder        bool                     `json:"EnableIpRecorder"`
	IpRecorderConfig        *IpReportConfig          `json:"IpRecorderConfig"`
	EnableDynamicSpeedLimit bool                     `json:"EnableDynamicSpeedLimit"`
	DynamicSpeedLimitConfig *DynamicSpeedLimitConfig `json:"DynamicSpeedLimitConfig"`
}

type LogConfig

type LogConfig struct {
	Level  string `json:"Level"`
	Output string `json:"Output"`
}

type NodeConfig

type NodeConfig struct {
	ApiConfig ApiConfig `json:"-"`
	Options   Options   `json:"-"`
}

func (*NodeConfig) UnmarshalJSON

func (n *NodeConfig) UnmarshalJSON(data []byte) (err error)

type Options

type Options struct {
	Name                   string          `json:"Name"`
	Core                   string          `json:"Core"`
	CoreName               string          `json:"CoreName"`
	ListenIP               string          `json:"ListenIP"`
	SendIP                 string          `json:"SendIP"`
	DeviceOnlineMinTraffic int64           `json:"DeviceOnlineMinTraffic"`
	ReportMinTraffic       int64           `json:"ReportMinTraffic"`
	LimitConfig            LimitConfig     `json:"LimitConfig"`
	RawOptions             json.RawMessage `json:"RawOptions"`
	XrayOptions            *XrayOptions    `json:"XrayOptions"`
	CertConfig             *CertConfig     `json:"CertConfig"`
}

func (*Options) UnmarshalJSON

func (o *Options) UnmarshalJSON(data []byte) error

type RecorderConfig

type RecorderConfig struct {
	Url     string `json:"Url"`
	Token   string `json:"Token"`
	Timeout int    `json:"Timeout"`
}

type RedisConfig

type RedisConfig struct {
	Address  string `json:"Address"`
	Password string `json:"Password"`
	Db       int    `json:"Db"`
	Expiry   int    `json:"Expiry"`
}

type WebSocketConfig added in v0.8.0

type WebSocketConfig struct {
	// Enabled opts in to the WS driver. Leave false to stay on pure HTTP.
	Enabled bool `json:"Enabled"`
	// URL is the full ws:// or wss:// endpoint, e.g. wss://api.example.com/ws/.
	// When empty the driver derives it from ApiHost (http -> ws, https -> wss)
	// and appends /ws/.
	URL string `json:"URL"`
	// Debug enables verbose per-message logs; use while commissioning.
	Debug bool `json:"Debug"`
}

WebSocketConfig controls the optional WebSocket driver that talks to the X-Board /ws/ endpoint. Default zero value keeps the driver disabled so an N2X upgrade is a no-op for existing deployments; flip Enabled to true only after verifying panel support.

type XrayConfig

type XrayConfig struct {
	LogConfig          *XrayLogConfig        `json:"Log"`
	AssetPath          string                `json:"AssetPath"`
	DnsConfigPath      string                `json:"DnsConfigPath"`
	RouteConfigPath    string                `json:"RouteConfigPath"`
	ConnectionConfig   *XrayConnectionConfig `json:"ConnectionConfig"`
	LegacyConnConfig   *XrayConnectionConfig `json:"XrayConnectionConfig"`
	InboundConfigPath  string                `json:"InboundConfigPath"`
	OutboundConfigPath string                `json:"OutboundConfigPath"`
}

func NewXrayConfig

func NewXrayConfig() *XrayConfig

func (*XrayConfig) UnmarshalJSON added in v0.5.2

func (x *XrayConfig) UnmarshalJSON(b []byte) error

type XrayConnectionConfig

type XrayConnectionConfig struct {
	StatsUserUplink   bool   `json:"statsUserUplink"`
	StatsUserDownlink bool   `json:"statsUserDownlink"`
	Handshake         uint32 `json:"handshake"`
	ConnIdle          uint32 `json:"connIdle"`
	UplinkOnly        uint32 `json:"uplinkOnly"`
	DownlinkOnly      uint32 `json:"downlinkOnly"`
	BufferSize        int32  `json:"bufferSize"`
}

type XrayLogConfig

type XrayLogConfig struct {
	Level      string `json:"Level"`
	AccessPath string `json:"AccessPath"`
	ErrorPath  string `json:"ErrorPath"`
}

type XrayOptions

type XrayOptions struct {
	EnableProxyProtocol bool                    `json:"EnableProxyProtocol"`
	EnableDNS           bool                    `json:"EnableDNS"`
	DNSType             string                  `json:"DNSType"`
	EnableUot           bool                    `json:"EnableUot"`
	EnableTFO           bool                    `json:"EnableTFO"`
	DisableIVCheck      bool                    `json:"DisableIVCheck"`
	DisableSniffing     bool                    `json:"DisableSniffing"`
	EnableFallback      bool                    `json:"EnableFallback"`
	FallBackConfigs     []FallBackConfigForXray `json:"FallBackConfigs"`
}

func NewXrayOptions

func NewXrayOptions() *XrayOptions