parser

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Only files including IPv4, IPv6, and Location (in english) will be read and parsed into lists.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEqualIPNodes

func IsEqualIPNodes(expected, node IPNode) error

Returns nil if two nodes are equal Used by the search package

func PlusOne

func PlusOne(a net.IP) net.IP

Types

type GeoDataset

type GeoDataset struct {
	IP4Nodes      []IPNode       // The IPNode list containing IP4Nodes
	IP6Nodes      []IPNode       // The IPNode list containing IP6Nodes
	LocationNodes []LocationNode // The location nodes corresponding to the IPNodes
}

The GeoDataset struct bundles all the data needed to search and find data into one common structure

func LoadGeoLite2

func LoadGeoLite2(zip *zip.Reader) (*GeoDataset, error)

type IPNode

type IPNode struct {
	IPAddressLow  net.IP
	IPAddressHigh net.IP
	LocationIndex int // Index to slice of locations
	PostalCode    string
	Latitude      float64
	Longitude     float64
}

IPNode defines IPv4 and IPv6 databases

func LoadIPListGLite1

func LoadIPListGLite1(reader io.Reader, idMap map[int]int, glite1 []gLite1HelpNode) ([]IPNode, error)

LoadIPListGLite1 creates a List of IPNodes from a GeoLite1 reader Note that GeoLite1 is IPv4 only. TODO(gfr) Update to use recursion instead of stack.

func LoadIPListGLite2

func LoadIPListGLite2(reader io.Reader, idMap map[int]int) ([]IPNode, error)

LoadIPListGLite2 creates a List of IPNodes from a GeoLite2 reader. TODO(gfr) Update to use recursion instead of stack.

type LocationNode

type LocationNode struct {
	GeonameID     int
	ContinentCode string
	CountryCode   string
	CountryName   string
	RegionCode    string
	RegionName    string
	MetroCode     int64
	CityName      string
}

locationNode defines Location databases

func LoadLocListGLite1

func LoadLocListGLite1(reader io.Reader) ([]LocationNode, []gLite1HelpNode, map[int]int, error)

Create Location list, map, and Glite1HelpNode for GLite1 databases GLiteHelpNode contains information to help populate fields in IPNode

func LoadLocListGLite2

func LoadLocListGLite2(reader io.Reader) ([]LocationNode, map[int]int, error)

Create Location list for GLite2 databases TODO This code is a bit fragile. Should probably parse the header and use that to guide the parsing of the rows.

Jump to

Keyboard shortcuts

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