servercfg

package
v0.34.10 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: GPL-3.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(key string) (bool, error)

func DefaultPaths

func DefaultPaths() []string

DefaultPaths returns the candidate nps server config paths in load order.

func DefaultString

func DefaultString(key, defaultValue string) string

func Int

func Int(key string) (int, error)

func Int64

func Int64(key string) (int64, error)

func IsSupportedConfigPath

func IsSupportedConfigPath(path string) bool

IsSupportedConfigPath reports whether the file extension maps to a registered parser.

func Load

func Load(path string) error

Load loads the server config from the provided file.

func LoadCandidates

func LoadCandidates(paths ...string) error

LoadCandidates loads the first readable config file from the provided paths.

func LoadDefault

func LoadDefault() error

LoadDefault loads the server config from the default candidate paths.

func Path

func Path() string

Path returns the path of the currently loaded server config file.

func RegisterFormat

func RegisterFormat(format string, parser parserFunc, extensions ...string) error

RegisterFormat registers a parser for one or more file extensions.

func RegisterViperFormat

func RegisterViperFormat(format string, extensions ...string) error

RegisterViperFormat registers a new config format backed by Viper.

func Reload

func Reload() error

Reload reloads the currently loaded config file. If no config has been loaded yet, it falls back to the default candidate paths.

func SetPreferredPath

func SetPreferredPath(path string)

SetPreferredPath configures an explicit config file path to try before defaults.

func String

func String(key string) string

func SupportedExtensions

func SupportedExtensions() []string

SupportedExtensions returns all registered config file extensions.

Types

type AppConfig

type AppConfig struct {
	Name        string
	Timezone    string
	DNSServer   string
	PprofIP     string
	PprofPort   string
	NTPServer   string
	NTPInterval int
	// GeoIPPath and GeoSitePath are the geodata files of the access lists,
	// relative to the run path unless absolute.
	GeoIPPath   string
	GeoSitePath string
	// AclMaxRules limits the rules of each access list users may write;
	// 0 means no limit.
	AclMaxRules int
	// IPRegisterMaxHours bounds registrations made on the registration page
	// with the public key, and with the key of a client that sets no limit.
	IPRegisterMaxHours int
	// IPRegisterIP and IPRegisterPort, when the port is set, serve the
	// registration page on a listener of its own.
	IPRegisterIP   string
	IPRegisterPort int
	// IPRegisterCertFile and IPRegisterKeyFile, when both are set, serve
	// the listener of the registration page over TLS.
	IPRegisterCertFile string
	IPRegisterKeyFile  string
}

type AuthConfig

type AuthConfig struct {
	Key             string
	CryptKey        string
	HTTPOnlyPass    string
	AllowXRealIP    bool
	TrustedProxyIPs string
}

type BridgeConfig

type BridgeConfig struct {
	Addr              string
	Type              string
	PrimaryType       string
	SelectMode        string
	CertFile          string
	KeyFile           string
	TCPEnable         bool
	KCPEnable         bool
	QUICEnable        bool
	TLSEnable         bool
	WSEnable          bool
	WSSEnable         bool
	ServerTCPEnabled  bool
	ServerKCPEnabled  bool
	ServerQUICEnabled bool
	ServerTLSEnabled  bool
	ServerWSEnabled   bool
	ServerWSSEnabled  bool
	Display           BridgeDisplayConfig
}

type BridgeDisplayEndpoint

type BridgeDisplayEndpoint struct {
	Show bool
	IP   string
	Port string
	ALPN string
}

type FeatureConfig

type FeatureConfig struct {
	AllowUserLogin          bool
	AllowUserRegister       bool
	AllowUserVkeyLogin      bool
	AllowUserChangeUsername bool
	OpenCaptcha             bool
	AllowFlowLimit          bool
	// FlowLimitActual makes flow limits count the actual usage, twice the
	// inbound and outbound traffic, rather than the traffic itself.
	FlowLimitActual         bool
	AllowRateLimit          bool
	AllowTimeLimit          bool
	AllowConnectionNumLimit bool
	AllowMultiIP            bool
	AllowTunnelNumLimit     bool
	AllowLocalProxy         bool
	AllowUserLocal          bool
	AllowSecretLink         bool
	AllowSecretLocal        bool
	SystemInfoDisplay       bool
	AllowPorts              string
}

type LogConfig

type LogConfig struct {
	Type     string
	Level    string
	Path     string
	MaxFiles int
	MaxDays  int
	MaxSize  int
	Compress bool
	Color    bool
}

type NetworkConfig

type NetworkConfig struct {
	BridgeIP           string
	BridgeHost         string
	BridgeTCPIP        string
	BridgeKCPIP        string
	BridgeQUICIP       string
	BridgeTLSIP        string
	BridgeWSIP         string
	BridgeWSSIP        string
	BridgePort         int
	BridgeTCPPort      int
	BridgeKCPPort      int
	BridgeQUICPort     int
	BridgeTLSPort      int
	BridgeWSPort       int
	BridgeWSSPort      int
	BridgePath         string
	BridgeTrustedIPs   string
	BridgeRealIPHeader string
	HTTPProxyIP        string
	HTTPProxyPort      int
	HTTPSProxyPort     int
	// HTTPProxyAccessPort and HTTPSProxyAccessPort are the ports visitors
	// reach the host proxy on from outside, behind a reverse proxy or port
	// mapping; they default to the listen ports and only build links.
	HTTPProxyAccessPort    int
	HTTPSProxyAccessPort   int
	HTTP3ProxyPort         int
	WebIP                  string
	WebPort                int
	P2PIP                  string
	P2PPort                int
	QUICALPN               string
	QUICALPNList           []string
	QUICKeepAlivePeriod    int
	QUICMaxIdleTimeout     int
	QUICMaxIncomingStreams int64
	MuxPingInterval        int
}

type P2PConfig

type P2PConfig struct {
	STUNServers         string
	EnableUPNPPortmap   bool
	EnablePCPPortmap    bool
	EnableNATPMPPortmap bool
	PortmapLeaseSeconds int
	ProbeTimeoutMs      int
	HandshakeTimeoutMs  int
	TransportTimeoutMs  int
}

type ProxyConfig

type ProxyConfig struct {
	AddOriginHeader    bool
	ResponseTimeout    int
	ErrorPage          string
	ErrorPageTimeLimit string
	ErrorPageFlowLimit string
	ErrorAlways        bool
	BridgeHTTP3        bool
	ForceAutoSSL       bool
	SSL                SSLConfig
}

type RuntimeConfig

type RuntimeConfig struct {
	ClientHistoryLimit int
	PublicVKey         string
	DisconnectTimeout  int
	FlowStoreInterval  int
}

type SSLConfig

type SSLConfig struct {
	Email           string
	CA              string
	Path            string
	ZeroSSLAPI      string
	DefaultCertFile string
	DefaultKeyFile  string
	CacheMax        int
	CacheReload     int
	CacheIdle       int
}

type SecurityConfig

type SecurityConfig struct {
	SecureMode        bool
	ForcePoW          bool
	AuthTimeWindow    int64
	PoWBits           int
	LoginBanTime      int64
	LoginIPBanTime    int64
	LoginUserBanTime  int64
	LoginMaxFailTimes int
	LoginMaxBody      int64
	LoginMaxSkew      int64
}

type Snapshot

type Snapshot struct {
	App      AppConfig
	Log      LogConfig
	Web      WebConfig
	Auth     AuthConfig
	Feature  FeatureConfig
	Security SecurityConfig
	Runtime  RuntimeConfig
	Network  NetworkConfig
	Bridge   BridgeConfig
	Proxy    ProxyConfig
	P2P      P2PConfig
}

func Current

func Current() *Snapshot

type WebConfig

type WebConfig struct {
	InstanceKeyFile string
	BaseURL         string
	HeadCustomCode  string
	Host            string
	IP              string
	Port            int
	OpenSSL         bool
	CloseOnNotFound bool
	KeyFile         string
	CertFile        string
	Username        string
	Password        string
	TOTPSecret      string
}

Jump to

Keyboard shortcuts

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