maxmind

package
v0.0.0-...-8d8f565 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 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 CustomMaxMindDB

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

func NewCustomMaxMindDB

func NewCustomMaxMindDB(reader MMDBRecordReader) (*CustomMaxMindDB, error)

func NewCustomMaxMindDBFromFile

func NewCustomMaxMindDBFromFile(path string) (*CustomMaxMindDB, error)

func (*CustomMaxMindDB) Available

func (db *CustomMaxMindDB) Available() bool

func (*CustomMaxMindDB) Lookup

func (db *CustomMaxMindDB) Lookup(ip net.IP, result interface{}) error

func (*CustomMaxMindDB) MetaData

func (db *CustomMaxMindDB) MetaData() (*maxminddb.Metadata, error)

func (*CustomMaxMindDB) Networks

func (db *CustomMaxMindDB) Networks(options ...maxminddb.NetworksOption) (*maxminddb.Networks, error)

func (*CustomMaxMindDB) RawData

func (db *CustomMaxMindDB) RawData() (io.Reader, error)

func (*CustomMaxMindDB) WithMetadata

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

type Database

type Database interface {
	Lookup(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(options ...maxminddb.NetworksOption) (*maxminddb.Networks, error)

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

func NewCustomDatabasesFromDir

func NewCustomDatabasesFromDir(dir, customDBPrefix string) []Database

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(path string) (*MaxmindDatabase, error)

func (*MaxmindDatabase) Lookup

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

func (*MaxmindDatabase) MetaData

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

func (*MaxmindDatabase) Networks

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

func (*MaxmindDatabase) RawData

func (db *MaxmindDatabase) RawData() (io.Reader, 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(ip net.IP, result interface{}) error

func (*MultiMaxMindDB) MetaData

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

func (*MultiMaxMindDB) Networks

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

func (*MultiMaxMindDB) RawData

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

func (*MultiMaxMindDB) Reader

func (db *MultiMaxMindDB) Reader() (*maxminddb.Reader, error)

func (*MultiMaxMindDB) WithLogger

func (db *MultiMaxMindDB) WithLogger(logger log.ServiceLogger) *MultiMaxMindDB

Jump to

Keyboard shortcuts

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