config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServerPort string `env:"SERVER_PORT" env-default:"8080" env-description:"HTTP server port"`

	OwnerPrivateKey   string `env:"OWNER_PRIVATE_KEY" env-required:"true" env-description:"Private key for faucet owner wallet (without 0x prefix)"`
	NitronodeURL      string `env:"NITRONODE_URL" env-required:"true" env-description:"Nitronode WebSocket URL"`
	TokenSymbol       string `env:"TOKEN_SYMBOL" env-required:"true" env-description:"Token symbol to distribute (e.g., usdc, weth)"`
	StandardTipAmount string `env:"STANDARD_TIP_AMOUNT" env-required:"true" env-description:"Default amount to send per request"`
	MinTransferCount  int    `` /* 128-byte string literal not displayed */
	CooldownPeriod    string `env:"COOLDOWN_PERIOD" env-default:"24h" env-description:"Cooldown between requests per wallet/IP (e.g. 24h, 1h30m)"`
	// IPRateLimitEnabled toggles the per-IP bucket. With ingress-level
	// limits (limit-rps, limit-connections) handling flood protection, the
	// per-IP app cooldown becomes redundant — and worse, collapses to a
	// single bucket whenever TRUSTED_PROXIES is unset, since gin's
	// ClientIP() then returns the ingress pod's address for every request.
	IPRateLimitEnabled bool   `` /* 165-byte string literal not displayed */
	TrustedProxies     string `env:"TRUSTED_PROXIES" env-default:"" env-description:"Comma-separated trusted proxy IPs; empty means direct exposure only"`

	// Log carries LOG_LEVEL / LOG_FORMAT / LOG_OUTPUT (see pkg/log).
	Log log.Config

	// Parsed values (set after loading)
	StandardTipAmountDecimal decimal.Decimal
	CooldownPeriodDuration   time.Duration
	TrustedProxyList         []string
}

Config holds all runtime configuration for the faucet server.

func Load

func Load() (*Config, error)

Load reads configuration from a .env file (if present) or environment variables. A missing .env file is not an error; any other read or validation failure is.

func (*Config) Validate

func (c *Config) Validate() error

Validate parses and range-checks all fields that require post-load processing.

Jump to

Keyboard shortcuts

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