mmdb

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package mmdb provides MMDB database reading and data extraction functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeSegments

func NormalizeSegments(path []any) ([]any, error)

NormalizeSegments normalizes path segments by converting int64 to int and validating types. Use this once during initialization and cache the result to avoid repeated allocations.

Types

type Reader

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

Reader wraps a maxminddb.Reader with additional functionality.

func Open

func Open(path string) (*Reader, error)

Open opens an MMDB database file.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the MMDB database.

func (*Reader) Metadata

func (r *Reader) Metadata() maxminddb.Metadata

Metadata returns metadata about the database.

func (*Reader) Networks

func (r *Reader) Networks(options ...maxminddb.NetworksOption) iter.Seq[maxminddb.Result]

Networks returns an iterator over all networks in the database.

func (*Reader) NetworksWithin

func (r *Reader) NetworksWithin(
	prefix netip.Prefix,
	options ...maxminddb.NetworksOption,
) iter.Seq[maxminddb.Result]

NetworksWithin returns an iterator over networks within the specified prefix.

type Readers

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

Readers manages multiple MMDB database readers.

func OpenDatabases

func OpenDatabases(databases map[string]string) (*Readers, error)

OpenDatabases opens multiple MMDB databases.

func (*Readers) Close

func (rs *Readers) Close() error

Close closes all database readers.

func (*Readers) Get

func (rs *Readers) Get(name string) (*Reader, bool)

Get returns the reader for a database by name.

Jump to

Keyboard shortcuts

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