Documentation ¶
Overview ¶
Package utils [general utility functions for the db1000n app]
Index ¶
- func BindToInterface(name string) func(network, address string, conn syscall.RawConn) error
- func CheckCountryOrFail(ctx context.Context, logger *zap.Logger, cfg *CountryCheckerConfig, ...) string
- func Decode(input any, output any) 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 InfiniteRange[T any](ctx context.Context, input []T) chan T
- func IsEncrypted(cfg []byte) bool
- func NonNilOrDefault[T any](v *T, dflt T) T
- func PanicHandler(logger *zap.Logger)
- func Sleep(ctx context.Context, t time.Duration) bool
- func Unmarshal(input []byte, output any, format string) error
- func UpdateRLimit() error
- type BackoffConfig
- type BackoffController
- type Counter
- type CountryCheckerConfig
- type ProxyFunc
- type ProxyParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindToInterface ¶ added in v0.9.0
func CheckCountryOrFail ¶ added in v0.8.3
func CheckCountryOrFail(ctx context.Context, logger *zap.Logger, cfg *CountryCheckerConfig, proxyParams ProxyParams) string
CheckCountryOrFail checks the country of client origin by IP and exits the program if it is in the blacklist.
func Decode ¶
Decode is an alias to a mapstructure.NewDecoder({Squash: true}).Decode() with WeaklyTypedInput set to true and MatchFunc that only compares aplhanumeric sequence in field names
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 InfiniteRange ¶ added in v0.8.23
It could've been more effective if go had yield but this should be close enough
func IsEncrypted ¶
IsEncrypted returns true if cfg encrypted with age tool (https://github.com/FiloSottile/age)
func NonNilOrDefault ¶ added in v0.8.16
func NonNilOrDefault[T any](v *T, dflt T) T
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 UpdateRLimit ¶ added in v0.8.23
func UpdateRLimit() error
Types ¶
type BackoffConfig ¶ added in v0.8.11
func DefaultBackoffConfig ¶ added in v0.8.11
func DefaultBackoffConfig() BackoffConfig
type BackoffController ¶ added in v0.8.11
type BackoffController struct { BackoffConfig // contains filtered or unexported fields }
func (BackoffController) GetTimeout ¶ added in v0.8.11
func (c BackoffController) GetTimeout() time.Duration
func (*BackoffController) Increment ¶ added in v0.8.11
func (c *BackoffController) Increment() *BackoffController
func (*BackoffController) Reset ¶ added in v0.8.11
func (c *BackoffController) Reset()
type Counter ¶ added in v0.8.11
type Counter struct { Count int // contains filtered or unexported fields }
type CountryCheckerConfig ¶ added in v0.8.3
type CountryCheckerConfig struct {
// contains filtered or unexported fields
}
func NewCountryCheckerConfigWithFlags ¶ added in v0.8.3
func NewCountryCheckerConfigWithFlags() *CountryCheckerConfig
NewGlobalConfigWithFlags returns a GlobalConfig initialized with command line flags.
type ProxyFunc ¶ added in v0.8.0
func GetProxyFunc ¶ added in v0.8.0
func GetProxyFunc(params ProxyParams, protocol string) ProxyFunc
this won't work for udp payloads but if people use proxies they might not want to have their ip exposed so it's probably better to fail instead of routing the traffic directly
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package metrics collects and reports job metrics.
|
Package metrics collects and reports job metrics. |
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] |