config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: ISC Imports: 10 Imported by: 0

Documentation

Overview

Package config provides configuration management for the MaxMindDB MCP server.

Index

Constants

View Source
const (
	ModeMaxMind     = "maxmind"
	ModeDirectory   = "directory"
	ModeGeoIPCompat = "geoip_compat"
)

Mode constants for configuration.

Variables

This section is empty.

Functions

func DefaultGeoIPPaths

func DefaultGeoIPPaths() []string

DefaultGeoIPPaths returns the default paths where GeoIP.conf might be located.

func GenerateDefaultTOMLConfig

func GenerateDefaultTOMLConfig(path string) error

GenerateDefaultTOMLConfig creates a default TOML config file.

func Paths

func Paths() []string

Paths returns the list of configuration file paths to search.

func SaveTOMLConfig

func SaveTOMLConfig(path string, config *Config) error

SaveTOMLConfig saves configuration to a TOML file.

Types

type Config

type Config struct {
	GeoIPCompat                     GeoIPCompatConfig `toml:"geoip_compat"`
	Mode                            string            `toml:"mode"`
	UpdateInterval                  string            `toml:"update_interval"`
	IteratorTTL                     string            `toml:"iterator_ttl"`
	IteratorCleanupInterval         string            `toml:"iterator_cleanup_interval"`
	Directory                       DirectoryConfig   `toml:"directory"`
	MaxMind                         MaxMindConfig     `toml:"maxmind"`
	UpdateIntervalDuration          time.Duration     `toml:"-"`
	IteratorTTLDuration             time.Duration     `toml:"-"`
	IteratorCleanupIntervalDuration time.Duration     `toml:"-"`
	AutoUpdate                      bool              `toml:"auto_update"`
}

Config represents the application configuration.

func ConvertGeoIPToTOML

func ConvertGeoIPToTOML(geoipPath string) (*Config, error)

ConvertGeoIPToTOML converts a GeoIP.conf file to TOML format.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a configuration with default values.

func Load

func Load() (*Config, error)

Load loads configuration from the first available config file.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads configuration from a TOML file.

func (*Config) ExpandPaths

func (c *Config) ExpandPaths() error

ExpandPaths expands ~ in file paths to the user's home directory.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration and parses durations.

type DirectoryConfig

type DirectoryConfig struct {
	Paths []string `toml:"paths"`
}

DirectoryConfig holds configuration for directory mode.

type GeoIPCompatConfig

type GeoIPCompatConfig struct {
	ConfigPath  string `toml:"config_path"`
	DatabaseDir string `toml:"database_dir"`
}

GeoIPCompatConfig holds configuration for GeoIP.conf compatibility.

type GeoIPConfig

type GeoIPConfig struct {
	LicenseKey        string
	DatabaseDirectory string
	Host              string
	Proxy             string
	ProxyUserPassword string
	LockFile          string
	RetryFor          string
	EditionIDs        []string
	AccountID         int
	PreserveFileTimes int
	Parallelism       int
}

GeoIPConfig represents a parsed GeoIP.conf file.

func ParseGeoIPConfig

func ParseGeoIPConfig(path string) (*GeoIPConfig, error)

ParseGeoIPConfig parses a GeoIP.conf file.

type MaxMindConfig

type MaxMindConfig struct {
	LicenseKey  string   `toml:"license_key"`
	DatabaseDir string   `toml:"database_dir"`
	Endpoint    string   `toml:"endpoint"`
	Editions    []string `toml:"editions"`
	AccountID   int      `toml:"account_id"`
}

MaxMindConfig holds configuration for MaxMind database updates.

Jump to

Keyboard shortcuts

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