reader

package
v0.0.1-draft Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FieldsSep = ":"

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter interface {

	// Key 条件字段
	Key() string

	// Fields 查询字段列表
	// 根据条件字段对应的值不同,输出不同的字段
	Fields(key string) []string

	// FieldsCollection 字段集合
	// 返回过滤器完整的字段列表
	FieldsCollection() string
}

Filter 字段过滤工具

type FilterReader

type FilterReader struct {

	// Calibrate 数据校验
	// 用于做数据对比与校准
	Calibrate func(ip net.IP, data map[string]string) (ipNet *net.IPNet, ret map[string]string, updated bool)
	// contains filtered or unexported fields
}

FilterReader 支持字段过滤的IP库读取器

func NewFilterReader

func NewFilterReader(database db.Database, filter Filter, mapper mapper.Mapper) *FilterReader

NewFilterReader 初始化IP库读取器

func (*FilterReader) FieldsCollection

func (r *FilterReader) FieldsCollection() string

FieldsCollection 字段集合

func (*FilterReader) LookupNetwork

func (r *FilterReader) LookupNetwork(ip net.IP) (*net.IPNet, string, error)

LookupNetwork 查询IP所在网段和对应数据

type KeyFieldsFilter

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

KeyFieldsFilter 字段过滤工具

func NewKeyFieldsFilter

func NewKeyFieldsFilter(arg string) *KeyFieldsFilter

NewKeyFieldsFilter 初始化字段过滤器 语法: <key>#<value1>:<filed1>,<field2>,<field3>|<value2>:<filed1>,<field2>,<field3>

  • <key>: 用于匹配value的字段,默认为country
  • <value>: 用于匹配fields的值,允许缺省,缺省时表示默认fields
  • <filed>: 输出的字段内容

举例: country#中国:country,province,city,isp|country,-,-,isp

  • 当country为中国时,输出country,province,city,isp;country为其他时,输出 country,-,-,isp (-表示缺省,不输出)

约束: 每组的字段数量需要保持一致

func (*KeyFieldsFilter) Fields

func (f *KeyFieldsFilter) Fields(key string) []string

Fields 查询字段列表

func (*KeyFieldsFilter) FieldsCollection

func (f *KeyFieldsFilter) FieldsCollection() string

FieldsCollection 字段集合

func (*KeyFieldsFilter) Key

func (f *KeyFieldsFilter) Key() string

Key 条件字段

type Reader

type Reader interface {

	// LookupNetwork 查询IP所在网段和对应数据
	LookupNetwork(ip net.IP) (*net.IPNet, string, error)

	// FieldsCollection 字段集合
	FieldsCollection() string
}

Reader IP库读取工具 从数据库中获取IP的地理位置信息,并格式化数据

Jump to

Keyboard shortcuts

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