maxmind

package
v0.0.0-...-770b5d6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoDatabases = errors.New("no databases")

Functions

This section is empty.

Types

type CSVDumper

type CSVDumper interface {
	Database
	WriteCSVTo(ctx context.Context, w io.Writer) error
	CSV(ctx context.Context, gzipCompress bool) (io.Reader, error)
}

type CSVEntity

type CSVEntity interface {
	MarshalCSV() (names, row []string, err error)
}

type CustomDatabase

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

func NewCustomDatabase

func NewCustomDatabase(ctx context.Context, source *source.TSUpdatableFile) *CustomDatabase

func (*CustomDatabase) CheckUpdates

func (*CustomDatabase) Lookup

func (db *CustomDatabase) Lookup(ctx context.Context, ip net.IP, result interface{}) error

func (*CustomDatabase) MetaData

func (db *CustomDatabase) MetaData(ctx context.Context) (*maxminddb.Metadata, error)

func (*CustomDatabase) Networks

func (db *CustomDatabase) Networks(ctx context.Context, options ...maxminddb.NetworksOption) (*maxminddb.Networks, error)

func (*CustomDatabase) RawData

func (db *CustomDatabase) RawData(ctx context.Context) (io.Reader, error)

func (*CustomDatabase) Update

func (db *CustomDatabase) Update(ctx context.Context, force bool) error

type Database

type Database interface {
	Lookup(ctx context.Context, ip net.IP, result interface{}) error
	// LookupNetwork(ip net.IP, result interface{}) (network *net.IPNet, ok bool, err error)
	// LookupOffset(ip net.IP) (uintptr, error)
	Networks(ctx context.Context, options ...maxminddb.NetworksOption) (*maxminddb.Networks, error)

	RawData(ctx context.Context) (io.Reader, error) // mmdb
	MetaData(ctx context.Context) (*maxminddb.Metadata, error)
}

func NewDatabasePatchesFromTarGz

func NewDatabasePatchesFromTarGz(source *source.TSUpdatableFile) ([]Database, error)

type DatabasePatch

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

func NewDatabasePatch

func NewDatabasePatch(reader MMDBRecordReader) (*DatabasePatch, error)

func NewDatabasePatchFromJSON

func NewDatabasePatchFromJSON(source *source.TSUpdatableFile) (*DatabasePatch, error)

func (*DatabasePatch) Available

func (db *DatabasePatch) Available() bool

func (*DatabasePatch) Lookup

func (db *DatabasePatch) Lookup(ctx context.Context, ip net.IP, result interface{}) error

func (*DatabasePatch) MetaData

func (db *DatabasePatch) MetaData(ctx context.Context) (*maxminddb.Metadata, error)

func (*DatabasePatch) Networks

func (db *DatabasePatch) Networks(ctx context.Context, options ...maxminddb.NetworksOption) (*maxminddb.Networks, error)

func (*DatabasePatch) RawData

func (db *DatabasePatch) RawData(ctx context.Context) (io.Reader, error)

func (*DatabasePatch) WithMetadata

func (db *DatabasePatch) WithMetadata(meta maxminddb.Metadata) *DatabasePatch

type JSONRecordReader

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

func NewJSONRecordReader

func NewJSONRecordReader(r io.Reader) (recordReader *JSONRecordReader, err error)

func (*JSONRecordReader) ReadMMDBRecord

func (r *JSONRecordReader) ReadMMDBRecord() (record MMDBRecord, err error)

type MMDBRecord

type MMDBRecord struct {
	Network *net.IPNet
	Data    mmdbtype.Map
}

type MMDBRecordReader

type MMDBRecordReader interface {
	ReadMMDBRecord() (MMDBRecord, error)
}

type MaxmindCSVDumper

type MaxmindCSVDumper[T CSVEntity] struct {
	Database
}

func NewCSVDumper

func NewCSVDumper[T CSVEntity](db Database) *MaxmindCSVDumper[T]

func (MaxmindCSVDumper[T]) CSV

func (db MaxmindCSVDumper[T]) CSV(ctx context.Context, gzipCompress bool) (io.Reader, error)

func (MaxmindCSVDumper[T]) WriteCSVTo

func (db MaxmindCSVDumper[T]) WriteCSVTo(ctx context.Context, w io.Writer) error

type MaxmindDatabase

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

func Open

func Open(ctx context.Context, source *source.MMDBSource) (*MaxmindDatabase, error)

func (*MaxmindDatabase) CheckUpdates

func (db *MaxmindDatabase) CheckUpdates(ctx context.Context) (entity.Update[entity.MMDBVersion], error)

func (*MaxmindDatabase) Lookup

func (db *MaxmindDatabase) Lookup(ctx context.Context, ip net.IP, result interface{}) error

func (*MaxmindDatabase) MetaData

func (db *MaxmindDatabase) MetaData(ctx context.Context) (*maxminddb.Metadata, error)

func (*MaxmindDatabase) Networks

func (db *MaxmindDatabase) Networks(ctx context.Context, options ...maxminddb.NetworksOption) (*maxminddb.Networks, error)

func (*MaxmindDatabase) RawData

func (db *MaxmindDatabase) RawData(ctx context.Context) (io.Reader, error)

func (*MaxmindDatabase) Update

func (db *MaxmindDatabase) Update(ctx context.Context, force bool) error

type MultiMaxMindDB

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

func NewMultiMaxMindDB

func NewMultiMaxMindDB(dbs ...Database) *MultiMaxMindDB

func (*MultiMaxMindDB) Add

func (db *MultiMaxMindDB) Add(dbs ...Database) *MultiMaxMindDB

func (*MultiMaxMindDB) Lookup

func (db *MultiMaxMindDB) Lookup(ctx context.Context, ip net.IP, result interface{}) error

func (*MultiMaxMindDB) MetaData

func (db *MultiMaxMindDB) MetaData(ctx context.Context) (*maxminddb.Metadata, error)

func (*MultiMaxMindDB) Networks

func (db *MultiMaxMindDB) Networks(ctx context.Context, options ...maxminddb.NetworksOption) (*maxminddb.Networks, error)

func (*MultiMaxMindDB) RawData

func (db *MultiMaxMindDB) RawData(ctx context.Context) (io.Reader, error)

func (*MultiMaxMindDB) Reader

func (db *MultiMaxMindDB) Reader(ctx context.Context) (*maxminddb.Reader, error)

type PatchedDatabase

type PatchedDatabase struct {
	*MultiMaxMindDB
	// contains filtered or unexported fields
}

func NewPatchedDatabase

func NewPatchedDatabase(db *MaxmindDatabase) *PatchedDatabase

func (*PatchedDatabase) CheckUpdates

func (*PatchedDatabase) SetCustom

func (db *PatchedDatabase) SetCustom(custom *CustomDatabase) *PatchedDatabase

func (*PatchedDatabase) Update

func (db *PatchedDatabase) Update(ctx context.Context, force bool) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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