geoipupdate

package
v7.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Overview

Package geoipupdate provides a library for using MaxMind's GeoIP Update service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithOutput

func WithOutput(c *Config) error

WithOutput enables JSON output for the config.

func WithVerbose

func WithVerbose(c *Config) error

WithVerbose enable verbose output for the config.

Types

type Config

type Config struct {
	// AccountID is the account ID.
	AccountID int

	// DatabaseDirectory is where database files are going to be
	// stored.
	DatabaseDirectory string
	// EditionIDs are the database editions to be updated.
	EditionIDs []string
	// LicenseKey is the license attached to the account.
	LicenseKey string
	// LockFile is the path of a lock file that ensures that only one
	// geoipupdate process can run at a time.
	LockFile string
	// PreserveFileTimes sets whether database modification times
	// are preserved across downloads.
	PreserveFileTimes bool
	// Parallelism defines the number of concurrent downloads that
	// can be triggered at the same time. It defaults to 1, which
	// wouldn't change the existing behavior of downloading files
	// sequentially.
	Parallelism int
	// Proxy is host name or IP address of a proxy server.
	Proxy *url.URL

	// RetryFor is the retry timeout for HTTP requests. It defaults
	// to 5 minutes.
	RetryFor time.Duration
	// URL points to maxmind servers.
	URL string
	// Verbose turns on debug statements.
	Verbose bool
	// Output turns on sending the download/update result to stdout as JSON.
	Output bool
	// contains filtered or unexported fields
}

Config is a parsed configuration file.

func NewConfig

func NewConfig(
	flagOptions ...Option,
) (*Config, error)

NewConfig creates a new configuration and populates it based on an optional config file pointed to by an option set with WithConfigFile, then by various environment variables, and then finally by flag overrides provided by flagOptions. Values from the later override the former.

type Option

type Option func(f *Config) error

Option is a function type that modifies a configuration object. It is used to define functions that override a config with values set as command line arguments.

func WithConfigFile

func WithConfigFile(file string) Option

WithConfigFile returns an Option that sets the configuration file to be used.

func WithDatabaseDirectory

func WithDatabaseDirectory(dir string) Option

WithDatabaseDirectory returns an Option that sets the DatabaseDirectory value of a config.

func WithParallelism

func WithParallelism(i int) Option

WithParallelism returns an Option that sets the Parallelism value of a config.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater uses config data to initiate a download or update process for GeoIP databases.

func NewUpdater

func NewUpdater(config *Config) (*Updater, error)

NewUpdater initialized a new Updater struct.

func (*Updater) Run

func (u *Updater) Run(ctx context.Context) error

Run starts the download or update process.

Directories

Path Synopsis
Package database writes MMDBs to disk.
Package database writes MMDBs to disk.

Jump to

Keyboard shortcuts

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