config package - github.com/realDragonium/Ultraviolet/config - Go Packages

config

package
v1.0.3-beta Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPrivateKey            = errors.New("could not load private key")
	ErrCantCombineConfigs    = errors.New("failed to combine config structs")
	ErrFailedToConvertConfig = errors.New("failed to convert server config to a more usable config")

	MainConfigFileName = "ultraviolet.json"
)
View Source
var ErrNoConfigFiles = errors.New("no config files found")

Functions

func CheckExistingGeneratedKey

func CheckExistingGeneratedKey(cfg ServerConfig) (*ecdsa.PrivateKey, bool)

func GenerateKeys

func GenerateKeys(cfg ServerConfig) *ecdsa.PrivateKey

func NewBackendConfigFileReader

func NewBackendConfigFileReader(path string, verifier VerifyFunc) backendConfigFileReader

func NewVerifyError

func NewVerifyError() verifyError

func ReadPrivateKey

func ReadPrivateKey(path string) (*ecdsa.PrivateKey, error)

func VerifyConfigs

func VerifyConfigs(cfgs []ServerConfig) error

Types

type BackendWorkerConfig

type BackendWorkerConfig struct {
	Name                string
	StateOption         StateOptions
	StateUpdateCooldown time.Duration
	OldRealIp           bool
	NewRealIP           bool
	RealIPKey           *ecdsa.PrivateKey
	CacheStatus         bool
	CacheUpdateCooldown time.Duration
	ValidProtocol       int
	OfflineStatus       mc.Packet
	DisconnectPacket    mc.Packet
	ProxyTo             string
	ProxyBind           string
	DialTimeout         time.Duration
	SendProxyProtocol   bool
	RateLimit           int
	RateLimitStatus     bool
	RateLimitDuration   time.Duration
	RateBanListCooldown time.Duration
	RateDisconPk        mc.Packet
}

func ServerToBackendConfig

func ServerToBackendConfig(cfg ServerConfig) (BackendWorkerConfig, error)

type DuplicateDomain

type DuplicateDomain struct {
	Cfg1Path string
	Cfg2Path string
	Domain   string
}

func (*DuplicateDomain) Error

func (err *DuplicateDomain) Error() string

type ServerConfig

type ServerConfig struct {
	FilePath string
	Name     string   `json:"name"`
	Domains  []string `json:"domains"`

	ProxyTo           string `json:"proxyTo"`
	ProxyBind         string `json:"proxyBind"`
	DialTimeout       string `json:"dialTimeout"`
	OldRealIP         bool   `json:"useRealIPv2.4"`
	NewRealIP         bool   `json:"useRealIPv2.5"`
	RealIPKey         string `json:"realIPKeyPath"`
	SendProxyProtocol bool   `json:"sendProxyProtocol"`

	DisconnectMessage string `json:"disconnectMessage"`

	CacheStatus         bool            `json:"cacheStatus"`
	CacheUpdateCooldown string          `json:"cacheUpdateCooldown"`
	ValidProtocol       int             `json:"validProtocol"`
	OfflineStatus       mc.SimpleStatus `json:"offlineStatus"`

	RateLimit           int    `json:"rateLimit"`
	RateDuration        string `json:"rateCooldown"`
	RateBanListCooldown string `json:"banListCooldown"`
	RateDisconMsg       string `json:"reconnectMsg"`

	CheckStateOption    string
	StateUpdateCooldown string `json:"stateUpdateCooldown"`
}

func CombineServerConfigs

func CombineServerConfigs(old, new ServerConfig) (ServerConfig, error)

func DefaultServerConfig

func DefaultServerConfig() ServerConfig

func LoadServerCfgFromPath

func LoadServerCfgFromPath(path string) (ServerConfig, error)

func ReadServerConfigs

func ReadServerConfigs(path string) ([]ServerConfig, error)

func (ServerConfig) ID

func (cfg ServerConfig) ID() string

type ServerConfigReader

type ServerConfigReader interface {
	// Will only return the configs if they are deemed usable
	// If they contain conflicts of something goes wrong while reading
	//  it will return a error
	Read() ([]ServerConfig, error)
}

type StateOptions

type StateOptions int
const (
	CACHE StateOptions
	ALWAYS_ONLINE
	ALWAYS_OFFLINE
)

func NewStateOption

func NewStateOption(option string) StateOptions

type UVConfigReader

type UVConfigReader interface {
	Read() (UltravioletConfig, error)
}

func NewIVConfigFileReader

func NewIVConfigFileReader(path string) UVConfigReader

func NewUVConfigFileReader

func NewUVConfigFileReader(path string) UVConfigReader

type UltravioletConfig

type UltravioletConfig struct {
	ListenTo            string          `json:"listenTo"`
	DefaultStatus       mc.SimpleStatus `json:"defaultStatus"`
	NumberOfWorkers     int             `json:"numberOfWorkers"`
	NumberOfListeners   int             `json:"numberOfListeners"`
	AcceptProxyProtocol bool            `json:"acceptProxyProtocol"`
	UsePrometheus       bool            `json:"enablePrometheus"`
	PrometheusBind      string          `json:"prometheusBind"`
	APIBind             string          `json:"apiBind"`

	EnableHotSwap bool
	PidFile       string
	IODeadline    time.Duration
	LogOutput     io.Writer
}

func CombineUltravioletConfigs

func CombineUltravioletConfigs(old, new UltravioletConfig) (UltravioletConfig, error)

func DefaultUltravioletConfig

func DefaultUltravioletConfig() UltravioletConfig

func ReadUltravioletConfig

func ReadUltravioletConfig(path string) (UltravioletConfig, error)

type VerifyFunc

type VerifyFunc func(cfgs []ServerConfig) error

type WorkerConfig

type WorkerConfig struct {
	DefaultStatus mc.SimpleStatus
	IOTimeout     time.Duration
}

func DefaultWorkerConfig

func DefaultWorkerConfig() WorkerConfig

func NewWorkerConfig

func NewWorkerConfig(uvCfg UltravioletConfig) WorkerConfig

Jump to

Keyboard shortcuts

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