Documentation ¶
Overview ¶
Package utils [general utility functions for the db1000n app]
Index ¶
- Variables
- func CheckCountry(countriesToAvoid []string, strictCountryCheck bool) (bool, string)
- func CheckCountryOrFail(cfg *CountryCheckerConfig) string
- func Decode(input interface{}, output interface{}) error
- func Decrypt(cfg []byte) ([]byte, error)
- func GetEncryptionKeys() ([]string, error)
- func GetEnvBoolDefault(key string, defaultValue bool) bool
- func GetEnvDurationDefault(key string, defaultValue time.Duration) time.Duration
- func GetEnvIntDefault(key string, defaultValue int) int
- func GetEnvStringDefault(key, defaultValue string) string
- func IsEncrypted(cfg []byte) bool
- func NonNilDurationOrDefault(d *time.Duration, dflt time.Duration) time.Duration
- func NonNilIntOrDefault(i *int, dflt int) int
- func PanicHandler(logger *zap.Logger)
- func ReportStatistics(traffic int64, clientID string) error
- func Unmarshal(input []byte, output interface{}, format string) error
- type CountryCheckerConfig
- type ProxyFunc
Constants ¶
This section is empty.
Variables ¶
var EncryptionKeys = `/45pB920B6DFNwCB/n4rYUio3AVMawrdtrFnjTSIzL4=`
EncryptionKeys random 32 byte key encoded into base64 string. Used by default for configs
Functions ¶
func CheckCountry ¶
CheckCountry checks which country the app is running from and whether it is in the blacklist.
func CheckCountryOrFail ¶
func CheckCountryOrFail(cfg *CountryCheckerConfig) string
CheckCountryOrFail checks the country of client origin by IP and exits the program if it is in the blacklist.
func Decode ¶
func Decode(input interface{}, output interface{}) error
Decode is an alias to a mapstructure.NewDecoder({Squash: true}).Decode()
func GetEncryptionKeys ¶
GetEncryptionKeys returns list of encryption keys from ENCRYPTION_KEYS env variable name or default value
func GetEnvBoolDefault ¶
GetEnvBoolDefault returns environment variable or default value if no env varible is present
func GetEnvDurationDefault ¶
GetEnvDurationDefault returns environment variable or default value if no env varible is present
func GetEnvIntDefault ¶
GetEnvIntDefault returns environment variable or default value if no env varible is present
func GetEnvStringDefault ¶
GetEnvStringDefault returns environment variable or default value if no env varible is present
func IsEncrypted ¶
IsEncrypted returns true if cfg encrypted with age tool (https://github.com/FiloSottile/age)
func NonNilDurationOrDefault ¶
func NonNilIntOrDefault ¶
func PanicHandler ¶
PanicHandler just stub it in the beginning of every major module invocation to prevent single module failure from crashing the whole app
func ReportStatistics ¶
ReportStatistics sends basic usage events to google analytics
Types ¶
type CountryCheckerConfig ¶
type CountryCheckerConfig struct {
// contains filtered or unexported fields
}
func NewCountryCheckerConfigWithFlags ¶
func NewCountryCheckerConfigWithFlags() *CountryCheckerConfig
NewGlobalConfigWithFlags returns a GlobalConfig initialized with command line flags.
Directories ¶
Path | Synopsis |
---|---|
Package metrics [everything related to metrics goes here]
|
Package metrics [everything related to metrics goes here] |
Package ota [allows hot update and reload of the executable]
|
Package ota [allows hot update and reload of the executable] |
Package templates [provides utility functions to enable templating in app configuration]
|
Package templates [provides utility functions to enable templating in app configuration] |