GoIPQSDBReader

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 9 Imported by: 0

README

IPQualityScore IP Address Reputation & Proxy Detection Golang DB Reader

Flat File Version 1.0

Our flat file proxy detection database allows you to lookup important details about any IP address using a straight forward library. Simply install the reader, download a database and instantly check IP addresses against our large volume of data.

Click here to see the full Golang IPQualityScore flat file database documentation or click here for a more in depth explanation of what our proxy detection database does.
Installation

Installation can be achieved via go's built in package manager like such:


go get github.com/IPQualityScore/GoIPQSDBReader
			
Usage

Using our flat file database system to lookup an IP address is simple:


ip := "8.8.0.0";

reader, err := GoIPQSDBReader.Open("IPQualityScore-Reputation-IPV4-Database.ipqs"); if(err != nil){ panic(err); }

record, err := reader.Fetch(ip); // Returns a IPQSRecord struct. See further documentation below. if(err != nil){ panic(err); }

if(record.IsProxy){ fmt.Println(ip + " is a proxy!"); }

IPQSRecord Struct Fields

Depending on which database file you receive some of these fields may be unavailable. If the field in question is unavailable in your database it will default to Golang's default value for that type.

Field Type Description
record.IsProxy bool Is this IP address suspected to be a proxy? (SOCKS, Elite, Anonymous, VPN, Tor, etc.)
record.IsVPN bool Is this IP suspected of being a VPN connection? This can include data center ranges which can become active VPNs at any time. The "proxy" status will always be true when this value is true.
record.IsTOR bool Is this IP suspected of being a TOR connection? This can include previously active TOR nodes and exits which can become active TOR exits at any time. The "proxy" status will always be true when this value is true.
record.IsCrawler bool Is this IP associated with being a confirmed crawler from a mainstream search engine such as Googlebot, Bingbot, Yandex, etc. based on hostname or IP address verification.
record.IsBot bool Indicates if bots or non-human traffic has recently used this IP address to engage in automated fraudulent behavior. Provides stronger confidence that the IP address is suspicious.
record.RecentAbuse bool This value will indicate if there has been any recently verified abuse across our network for this IP address. Abuse could be a confirmed chargeback, compromised device, fake app install, or similar malicious behavior within the past few days.
record.IsBlacklisted bool This value will indicate if the IP has been blacklisted by any 3rd party agency for spam, abuse or fraud.
record.IsPrivate bool This value will indicate if the IP is a private, nonrouteable IP address.
record.IsMobile bool This value will indicate if the IP is likely owned by a mobile carrier.
record.HasOpenPorts bool This value will indicate if the IP has recently had open (listening) ports.
record.IsHostingProvider bool This value will indicate if the IP is likely owned by a hosting provider or is leased to a hosting company.
record.ActiveVPN bool Identifies active VPN connections used by popular VPN services and private VPN servers.
record.ActiveTOR bool Identifies active TOR exits on the TOR network.
record.PublicAccessPoint bool Indicates if this IP is likely to be a public access point such as a coffee shop, college or library.
record.ConnectionType.Raw int

A numerical representation for the suspected type of connection for this IP address. It is generally reccomended you call the ToString() function listed below instead of using this value, but it is available as an option.

# Enum Description
1 Residential IP
2 Mobile IP
3 Corporate IP
4 Data Center IP
5 Educational IP
record.ConnectionType.ToString() int

A string representation for the suspected type of connection for this IP address. (Residential, Mobile, Corporate, Data Center, Education or Unknown)

record.AbuseVelocity.Raw int

How frequently the IP address is engaging in abuse across the IPQS threat network. Can be used in combination with the Fraud Score to identify bad behavior. It is generally reccomended you call the ToString() function listed below instead of using this value, but it is available as an option.

# Enum Description
1 Low Recent Abuse IP
2 Medium Recent Abuse IP
3 High Recent Abuse IP
record.AbuseVelocity.ToString() int

How frequently the IP address is engaging in abuse across the IPQS threat network. Values can be "high", "medium", "low", or "none".

record.Country string

Two character country code of IP address or "N/A" if unknown.

record.City string

City of IP address if available or "N/A" if unknown.

record.ISP string

ISP if one is known. Otherwise "N/A".

record.Organization string

Organization if one is known. Can be parent company or sub company of the listed ISP. Otherwise "N/A".

record.ASN int

Autonomous System Number if one is known. Zero if nonexistent.

record.Timezone string

Timezone of IP address if available or "N/A" if unknown.

record.Latitude float32

Latitude of IP address if available or 0.00 if unknown.

record.Longitude float32

Longitude of IP address if available or 0.00 if unknown.

record.FraudScore map[int]int

A map containing multiple possible fraud scores. The key is the "strictness level" of the query and can be 0, 1 or 2. Some databases may contain 1 entry, others all 3. It is reccomended that you use the lowest strictness for Fraud Scoring. Increasing this value will expand the tests we perform. Levels 2+ have a higher risk of false-positives.

Usage Notes

Each database only holds either IPv4 or IPv6 data. Therefore you may need two instances of the reader available depending on your use case.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GOLANG_IPQS_READER_VERSION = byte(1)

Functions

This section is empty.

Types

type AbuseVelocity

type AbuseVelocity struct {
	Raw int
}

func (*AbuseVelocity) ToString

func (av *AbuseVelocity) ToString() string

type BinaryOption

type BinaryOption struct {
	Data Bit
}

func (*BinaryOption) Has

func (bm *BinaryOption) Has(flag Bit) bool

type Bit

type Bit uint8
const (
	IsProxy Bit = 1 << iota
	IsVPN
	IsTOR
	IsCrawler
	IsBot
	RecentAbuse
	IsBlacklisted
	IsPrivate
)

Binary Option Bit One

const (
	IsMobile Bit = 1 << iota
	HasOpenPorts
	IsHostingProvider
	ActiveVPN
	ActiveTOR
	PublicAccessPoint
	ReservedOne
	ReservedTwo
)

Binary Option Bit Two

const (
	ReservedThree Bit = 1 << iota
	ReservedFour
	ReservedFive
	ConnectionTypeOne
	ConnectionTypeTwo
	ConnectionTypeThree
	AbuseVelocityOne
	AbuseVelocityTwo
)

Bimary Option Bit Three (Bit One In Files Without BinaryData)

const (
	IPv4Map Bit = 1 << iota
	IPv6Map
	IsBlacklistFile
	ReservedSeven
	ReservedEight
	ReservedNine
	ReservedTen
	BinaryData
)
const (
	ReservedEleven Bit = 1 << iota
	ReservedTwelve
	TreeData
	StringData
	SmallIntData
	IntData
	FloatData
	ReservedThirteen
)

type Column

type Column struct {
	Name     string
	Type     *RecordType
	RawValue string
}

type ConnectionType

type ConnectionType struct {
	Raw int
}

func (*ConnectionType) ToString

func (conn *ConnectionType) ToString() string

type FileReader

type FileReader struct {
	Handler     *os.File
	TotalBytes  uint64
	RecordBytes uint64

	TreeStart int64
	TreeEnd   int64

	IPv6       bool
	Valid      bool
	BinaryData bool
	Columns    map[int]*Column

	BlacklistFile bool
}

func Open

func Open(filename string) (*FileReader, error)

func (*FileReader) Fetch

func (file *FileReader) Fetch(ip string) (*IPQSRecord, error)

type FraudScore

type FraudScore struct {
	Strictness map[int]int
}

type IPQSRecord

type IPQSRecord struct {
	IsProxy           bool
	IsVPN             bool
	IsTOR             bool
	IsCrawler         bool
	IsBot             bool
	RecentAbuse       bool
	IsBlacklisted     bool
	IsPrivate         bool
	IsMobile          bool
	HasOpenPorts      bool
	IsHostingProvider bool
	ActiveVPN         bool
	ActiveTOR         bool
	PublicAccessPoint bool

	ConnectionType *ConnectionType
	AbuseVelocity  *AbuseVelocity

	Country      string
	City         string
	Region       string
	ISP          string
	Organization string
	ASN          int
	Timezone     string
	Latitude     float32
	Longitude    float32

	FraudScore *FraudScore

	Columns []*Column
}

type RecordType

type RecordType struct {
	Data Bit
}

func (*RecordType) Has

func (bm *RecordType) Has(flag Bit) bool

func (*RecordType) Set

func (bm *RecordType) Set(flag Bit)

func (*RecordType) ToString

func (bm *RecordType) ToString() string

Jump to

Keyboard shortcuts

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