dbip

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package dbip provides columns for the DBIP database.

Package dbip provides utilities to download DB-IP datasets from an OCI registry.

Index

Constants

View Source
const IntervalNever = time.Duration(0)

IntervalNever disables remote DBIP refreshes.

Variables

View Source
var ErrUnavailable = errors.New("dbip lookup unavailable")

ErrUnavailable means DBIP geolocation is not currently available.

Functions

func CityColumn

func CityColumn(t *GeoColumnFactory) schema.EventColumn

CityColumn creates a city column from a MMDB path.

func ContinentColumn

func ContinentColumn(t *GeoColumnFactory) schema.EventColumn

ContinentColumn creates a continent column from a MMDB path.

func CountryColumn

func CountryColumn(t *GeoColumnFactory) schema.EventColumn

CountryColumn creates a country column from a MMDB path.

func GeoColumns

func GeoColumns(provider LookupProvider, cacheConfig CacheConfig) []schema.EventColumn

GeoColumns creates a set of geo columns backed by the provided lookup provider.

func RegionColumn

func RegionColumn(t *GeoColumnFactory) schema.EventColumn

RegionColumn creates a region column from a MMDB path.

func WithDestination added in v0.47.0

func WithDestination(destinationDirectory string) managerOption

WithDestination configures DBIP files destination directory.

func WithDownloadTimeout added in v0.47.0

func WithDownloadTimeout(timeout time.Duration) managerOption

WithDownloadTimeout configures DBIP remote download timeout.

func WithDownloader added in v0.47.0

func WithDownloader(downloader Downloader) managerOption

WithDownloader configures DBIP downloader.

func WithEnabled added in v0.47.0

func WithEnabled(enabled bool) managerOption

WithEnabled configures whether DBIP manager is active.

func WithRefreshInterval added in v0.47.0

func WithRefreshInterval(interval time.Duration) managerOption

WithRefreshInterval configures remote DBIP refresh interval.

Types

type CacheConfig added in v0.7.0

type CacheConfig struct {
	MaxEntries int64
	TTL        time.Duration
}

CacheConfig is the configuration for the cache.

type Downloader

type Downloader interface {
	// Download obtains the MMDB city database and returns the path to the downloaded file
	Download(ctx context.Context, artifactName, tag, destinationDir string) (string, error)
}

Downloader downloads an MMDB city database and returns the saved file path.

func NewExtensionBasedOCIDownloader

func NewExtensionBasedOCIDownloader(creds OCIRegistryCreds, extension string) Downloader

NewExtensionBasedOCIDownloader creates a new MMDBCityDatabaseDownloader backed by an OCI registry

type GeoColumnFactory added in v0.7.0

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

GeoColumnFactory is a template for creating geo columns.

func NewGeoColumnFactory added in v0.7.0

func NewGeoColumnFactory(provider LookupProvider, cacheConfig CacheConfig) (*GeoColumnFactory, error)

NewGeoColumnFactory creates a new GeoColumnTemplate.

func (*GeoColumnFactory) Column added in v0.7.0

func (t *GeoColumnFactory) Column(
	column schema.InterfaceID,
	field *arrow.Field,
	getValue func(event *schema.Event, record *LookupResult) (any, schema.D8AColumnWriteError),
	options ...columns.EventColumnOptions,
) schema.EventColumn

Column creates a new event column from a GeoColumnTemplate.

type LookupProvider added in v0.47.0

type LookupProvider interface {
	Lookup(ip netip.Addr) (*LookupResult, error)
}

LookupProvider returns geolocation values for IP addresses.

func NewStaticLookupProvider added in v0.47.0

func NewStaticLookupProvider(result *LookupResult, err error) LookupProvider

NewStaticLookupProvider returns a provider with deterministic behavior for tests.

func NewUnavailableLookupProvider added in v0.47.0

func NewUnavailableLookupProvider() LookupProvider

NewUnavailableLookupProvider always reports unavailable lookups.

type LookupResult added in v0.47.0

type LookupResult struct {
	City      string
	Country   string
	Continent string
	Region    string
}

LookupResult stores normalized geolocation values extracted from DBIP.

type ManagedLookupProvider added in v0.47.0

type ManagedLookupProvider interface {
	LookupProvider
	Runner
	Close() error
}

ManagedLookupProvider combines lookup and refresh lifecycle.

func NewManagedLookupProvider added in v0.47.0

func NewManagedLookupProvider(options ...managerOption) ManagedLookupProvider

NewManagedLookupProvider creates a DBIP lookup provider with optional background refresh.

type OCIRegistryCreds

type OCIRegistryCreds struct {
	User string
	// nolint:gosec // This is not a credential, but a token used for OCI authentication
	Password string
	Repo     string

	IgnoreCert bool
}

OCIRegistryCreds contains credentials and settings for accessing an OCI registry.

type Runner added in v0.47.0

type Runner interface {
	Run(ctx context.Context)
}

Runner starts background DBIP refresh work.

Jump to

Keyboard shortcuts

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