ipisp

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2018 License: MIT Imports: 10 Imported by: 16

README

IPISP

IPISP provides a Go client for Team Cymru's ASN resolution service.

Features

  • Programmatically resolve IP addresses or ASNs to network information.
  • Allows bulk conversion.
  • DNS and Netcat/Whois client.
  • Thread-safe.

GoDoc

Documentation

Overview

Package ipisp provides a wrapper to team-cymru.com's IP to ASN service.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnexpectedTokens = errors.New("Unexpected tokens while reading Cymru response.")
)

Common errors

View Source
var Timeout = time.Second * 10

Timeout is the TCP connection timeout

Functions

This section is empty.

Types

type ASN

type ASN int

ASN represents an Autonomous Systems Number. See https://en.wikipedia.org/wiki/Autonomous_system_(Internet).

func ParseASN

func ParseASN(asn string) (ASN, error)

ParseASN parses a string like `AS2341` into ASN `2341`.

func (ASN) String

func (a ASN) String() string

String represents an ASN like `5544“ as `AS5544`.`

type Client

type Client interface {
	// LookupIPs looks up IPs and returns a slice of responses the same size as the input slice of IPs
	// in the same order.
	LookupIPs([]net.IP) ([]Response, error)
	LookupIP(net.IP) (*Response, error)
	LookupASNs([]ASN) ([]Response, error)
	LookupASN(ASN) (*Response, error)
	Close() error
}

Client represents an IP or ASN lookup client.

func NewDNSClient

func NewDNSClient() (Client, error)

NewDNSClient returns a DNS lookup client. It is recommended to use this client for many individual lookups.

func NewWhoisClient

func NewWhoisClient() (Client, error)

NewWhoisClient returns a connected WHOIS client. This client should be used for bulk lookups.

type Name

type Name struct {
	Raw   string
	Short string
	Long  string
}

Name contains an ISP's name.

func ParseName

func ParseName(raw string) Name

ParseName attempts to parse the provided raw name. The returned Short and Long names are subject to change. Use Raw if you require determinism.

func (Name) String

func (n Name) String() string

String returns a human readable representation of the name.

type Response

type Response struct {
	IP          net.IP
	ASN         ASN
	Name        Name
	Country     string
	Registry    string
	Range       *net.IPNet
	AllocatedAt time.Time
}

Response contains a response from Cymru.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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