Documentation
¶
Overview ¶
Package config contains the functionality for reading in and loosely validating config files. The configuration is exposed via package level public variables. These must never be changed on the fly and instead configured via the config file or env vars
Env variables will override the config values. They can all be set using the same format as shown to map to the correct config keys:
export discord.token=TOKEN_TOKEN_TOKEN_TOKEN_TOKEN export general.steam_key=STEAM_KEY_STEAM_KEY_STEAM_KEY ./gbans serve
Index ¶
Constants ¶
const ( // Release is production mode, minimal logging Release runMode = "release" // Debug has much more logging and uses non-embedded assets Debug runMode = "debug" // Test is for unit tests Test runMode = "test" )
Variables ¶
var ( General generalConfig HTTP httpConfig Filter filterConfig Relay relayConfig DB dbConfig Discord discordConfig Log logConfig Net netBans RPC rpcConfig )
Default config values. Anything defined in the config or env will override them
Functions ¶
func DefaultExpiration ¶
DefaultExpiration returns the default expiration time delta from Now()
func FmtDuration ¶ added in v0.1.3
FmtDuration calculates and returns a string for duration differences. This handles values larger than a day unlike the stdlib in functionalities
func FmtTimeShort ¶ added in v0.1.3
FmtTimeShort returns a common format for time display
func Now ¶
Now returns the current time in the configured format of the application runtime
All calls to time.Now() should use this instead to ensure consistency
func ParseDuration ¶
ParseDuration works exactly like time.ParseDuration except that it supports durations longer than hours Formats: s, m, h, d, w, M, y
Types ¶
type BanList ¶
type BanList struct { URL string `mapstructure:"url"` Name string `mapstructure:"name"` Type BanListType `mapstructure:"type"` }
BanList holds details to load a ban lost
type BanListType ¶
type BanListType string
BanListType is the type or source of a ban list
const ( // CIDR formatted list CIDR BanListType = "cidr" // ValveNet is the srcds network ban list format ValveNet BanListType = "valve_net" // ValveSID is the srcds steamid ban list format ValveSID BanListType = "valve_steamid" // TF2BD sources ban list TF2BD BanListType = "tf2bd" )