sdk

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PreProcessFieldAlias = map[string]string{

	"location_accuracy_radius":              "accuracy_radius",
	"location_latitude":                     "latitude",
	"location_longitude":                    "longitude",
	"location_metro_code":                   "metro_code",
	"location_time_zone":                    "time_zone",
	"traits_autonomous_system_number":       "autonomous_system_number",
	"traits_autonomous_system_organization": "autonomous_system_organization",
	"traits_connection_type":                "connection_type",
	"traits_domain":                         "domain",
	"traits_is_anonymous_proxy":             "is_anonymous_proxy",
	"traits_is_legitimate_proxy":            "is_legitimate_proxy",
	"traits_is_satellite_provider":          "is_satellite_provider",
	"traits_isp":                            "isp",
	"traits_mobile_country_code":            "mobile_country_code",
	"traits_mobile_network_code":            "mobile_network_code",
	"traits_organization":                   "organization",
	"traits_static_ip_score":                "static_ip_score",
	"traits_user_type":                      "user_type",

	"continent_name": "continent",
	"country_name":   "country",
	"asn":            "autonomous_system_number",
	"as_name":        "autonomous_system_organization",
	"as_domain":      "domain",
}

PreProcessFieldAlias maps fields from various sources to a standardized format. This is useful for normalizing field names from different IP information providers.

Functions

func ConvertMapToFields

func ConvertMapToFields(m map[string]interface{}, useFullField bool) (map[string]string, error)

ConvertMapToFields converts a map of data from MMDB into a map of strings, optionally using full fields (combining all data into a JSON string).

func DoPreProcessFieldAlias

func DoPreProcessFieldAlias(data map[string]string) map[string]string

DoPreProcessFieldAlias takes a map of data fields and standardizes their names using the PreProcessFieldAlias mapping. This helps ensure consistency in field names regardless of the data source.

func ParseReflectValue

func ParseReflectValue(value interface{}) (interface{}, error)

ParseReflectValue processes an interface value and returns its converted string or map representation.

Types

type Reader

type Reader struct {
	IPVersion        int      // IP versions supported by the database (IPv4, IPv6, or both)
	Fields           []string // Fields present in the database
	DisableExtraData bool     // Whether to disable the use of extra data matched by GeoNameID
	UseFullField     bool     // Whether to use full field. If enabled, all data is combined into a single field as a JSON string.
	// contains filtered or unexported fields
}

Reader wraps the maxminddb Reader and provides additional functionalities for reading and parsing IP related data.

func NewReader

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

NewReader initializes a new Reader for the given MMDB file.

func (*Reader) Close

func (r *Reader) Close() error

Close closes the underlying maxminddb Reader.

func (*Reader) Find

func (r *Reader) Find(ip net.IP) (*ipnet.Range, map[string]string, error)

Find looks up the given IP in the database and returns its associated range and data.

Jump to

Keyboard shortcuts

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