ipio

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HybridComparisonMode is used in scenarios where the goal is to compare data
	// across multiple IP database readers. In this mode, the output includes data
	// from all readers, facilitating a comprehensive comparison of the differences
	// between each data source. This mode is particularly useful for analyzing
	// discrepancies and inconsistencies across various IP databases.
	HybridComparisonMode = "comparison"

	// HybridAggregationMode is designed for situations where a unified view of data
	// is needed. In this mode, the output is a single, aggregated set of data that
	// combines information from all the IP database readers. If a particular field is
	// missing from one reader, it is supplemented by another, ensuring a more
	// complete and cohesive dataset. This mode is ideal for creating a comprehensive
	// and enriched view of IP information by leveraging the strengths of multiple databases.
	HybridAggregationMode = "aggregation"
)
View Source
const ChannelBufferSize = 1000

ChannelBufferSize why 1000? I don't know :)

Variables

This section is empty.

Functions

func Dump

func Dump(r format.Reader, w format.Writer) error

Dump is a convenience method to transfer IP data from a reader to a writer. It is equivalent to calling NewStandardDumper(r, w).Dump().

Types

type HybridReader added in v0.3.0

type HybridReader struct {
	OperateChain *operate.IPOperateChain // Chain of operations to be applied to IP information.
	// contains filtered or unexported fields
}

HybridReader integrates multiple IP database readers into a single entity. It supports various operational modes (like comparison and aggregation) for querying and combining results from different IP databases.

func NewHybridReader added in v0.3.0

func NewHybridReader(operateChain *operate.IPOperateChain, dbReaders ...format.Reader) (*HybridReader, error)

NewHybridReader constructs a new HybridReader with the provided IP operation chain and database readers. It initializes the reader's metadata by merging metadata from all provided readers.

func (*HybridReader) Close added in v0.3.0

func (h *HybridReader) Close() error

Close method ensures that all underlying database readers are properly closed.

func (*HybridReader) Find added in v0.3.0

func (h *HybridReader) Find(ip net.IP) (*model.IPInfo, error)

Find performs parallel queries across all underlying database readers using the specified IP address. It combines the results based on the operational mode of the HybridReader: either comparing data or aggregating it.

func (*HybridReader) Meta added in v0.3.0

func (h *HybridReader) Meta() *model.Meta

Meta returns the combined metadata of the IP databases attached to the HybridReader.

func (*HybridReader) SetOption added in v0.3.0

func (h *HybridReader) SetOption(option interface{}) error

SetOption configures the HybridReader with the provided option, particularly the operational mode.

type HybridReaderOption added in v0.3.0

type HybridReaderOption struct {
	Mode string
}

type SimpleDumper added in v0.3.1

type SimpleDumper struct {
	format.Reader
	// contains filtered or unexported fields
}

SimpleDumper is a structure that facilitates the extraction of IP information within a specified range.

func (*SimpleDumper) Dump added in v0.3.1

func (d *SimpleDumper) Dump(ctx context.Context, retChan chan<- *model.IPInfo) error

Dump iterates over IP addresses in the specified range, sending IP information to retChan. The operation is context-aware and will stop if the context is cancelled.

type StandardDumper

type StandardDumper struct {
	format.Reader
	format.Writer
	// contains filtered or unexported fields
}

StandardDumper serves as a standard mechanism to transfer IP database from one format to another.

func NewStandardDumper

func NewStandardDumper(r format.Reader, w format.Writer) *StandardDumper

NewStandardDumper initializes and returns a new StandardDumper.

func (*StandardDumper) Dump

func (d *StandardDumper) Dump(readerJobs int) error

Dump transfers IP data from the Reader to the Writer.

type StandardReader

type StandardReader struct {
	DBReader     format.Reader
	OperateChain *operate.IPOperateChain
	// contains filtered or unexported fields
}

StandardReader is a Reader designed for IP databases. Unlike the Reader in the format package, this reader processes the IP information it reads, such as filtering fields, rewriting data, supplementing data, etc., controlled by operate.IPOperateChain.

func NewStandardReader

func NewStandardReader(dbReader format.Reader, operateChain *operate.IPOperateChain) *StandardReader

NewStandardReader initializes and returns a new StandardReader.

func (*StandardReader) Close

func (s *StandardReader) Close() error

Close closes the IP database.

func (*StandardReader) Find

func (s *StandardReader) Find(ip net.IP) (*model.IPInfo, error)

Find retrieves IP information based on the given IP address.

func (*StandardReader) Meta

func (s *StandardReader) Meta() *model.Meta

Meta returns the meta-information of the IP database.

func (*StandardReader) SetOption

func (s *StandardReader) SetOption(option interface{}) error

SetOption configures the StandardReader with the provided option.

type StandardReaderOption

type StandardReaderOption struct {
	IPVersion int

	Fields []string
}

Jump to

Keyboard shortcuts

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