plain

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBFormat   = "plain"
	DBExt      = ".txt"
	MetaPrefix = "# Meta: "
	FieldSep   = ","
)

Variables

This section is empty.

Functions

func ParseMeta

func ParseMeta(file string) (*model.Meta, error)

ParseMeta reads and parses the metadata from the beginning of the plain text IP database file.

Types

type Reader

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

Reader is a structure that provides functionalities to read from Plain Text.

func NewReader

func NewReader(file string) (*Reader, error)

NewReader initializes a new instance of Reader.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the IP database.

func (*Reader) Find

func (r *Reader) Find(ip net.IP) (*model.IPInfo, error)

Find retrieves IP information based on the given IP address. FIXME this method returns the next available IP info sequentially from the file.

func (*Reader) Meta

func (r *Reader) Meta() *model.Meta

Meta returns the meta-information of the IP database.

func (*Reader) Next

func (r *Reader) Next() (*model.IPInfo, error)

Next retrieves the next IP information from the file.

func (*Reader) SetOption

func (r *Reader) SetOption(option interface{}) error

SetOption configures the Reader with the provided option.

type Writer

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

Writer provides functionalities to write IP data into plain text format.

func NewWriter

func NewWriter(meta *model.Meta) (*Writer, error)

NewWriter initializes a new Writer instance for writing IP data in plain text format. If the io.Writer is not nil, it will directly write data into it.

func (*Writer) Header

func (w *Writer) Header() error

Header writes the header information for the IP database.

func (*Writer) Insert

func (w *Writer) Insert(info *model.IPInfo) error

Insert adds the given IP information into the writer.

func (*Writer) SetOption

func (w *Writer) SetOption(option interface{}) error

SetOption sets the provided options to the Writer.

func (*Writer) WriteTo

func (w *Writer) WriteTo(writer io.Writer) (int64, error)

WriteTo writes the buffered data into the provided writer.

type WriterOption

type WriterOption struct {
	// IW is for immediate output to the provided writer.
	IW io.Writer
}

WriterOption provides options for the Writer.

Jump to

Keyboard shortcuts

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