ipisp

package module
v0.0.0-...-e21c1e5 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: MIT Imports: 9 Imported by: 1

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

Example

A more thorough example is in the examples/ folder.

client, _ := ipisp.NewDNSClient()

resp, _ := client.LookupIP(net.ParseIP("4.2.2.2"))

fmt.Printf("IP: %v\n", resp.IP)
fmt.Printf("ASN: %v\n", resp.ASN)
fmt.Printf("Range: %v\n", resp.Range)
fmt.Printf("Country: %v\n", resp.Country)
fmt.Printf("Registry: %v\n", resp.Registry)
fmt.Printf("ISP: %v\n", resp.Name)

Documentation

Overview

Package ipisp provides a wrapper to team-cymru.com 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 contains an Autonomous Systems Number

func ParseASN

func ParseASN(asn string) (ASN, error)

ParseASN parses a string like AS2341 into an ASN

func (ASN) String

func (a ASN) String() string

String implements fmt.Stringer

type Client

type Client interface {
	LookupIPs([]net.IP) ([]Response, error)
	LookupIP(net.IP) (*Response, error)
	LookupASNs([]ASN) ([]Response, error)
	LookupASN(ASN) (*Response, error)
	Close() error
}

Client is a lookup client

type DNSClient

type DNSClient struct {
}

func NewDNSClient

func NewDNSClient() (client *DNSClient, err error)

NewDNSClient returns a dns client

func (*DNSClient) Close

func (c *DNSClient) Close() error

func (*DNSClient) LookupASN

func (c *DNSClient) LookupASN(asn ASN) (*Response, error)

func (*DNSClient) LookupASNs

func (c *DNSClient) LookupASNs(asns []ASN) ([]Response, error)

func (*DNSClient) LookupIP

func (c *DNSClient) LookupIP(ip net.IP) (*Response, error)

func (*DNSClient) LookupIPs

func (c *DNSClient) LookupIPs(ips []net.IP) ([]Response, error)

type Name

type Name struct {
	Raw   string
	Short string
	Long  string
}

Name contains an IPISP ISP name

func ParseName

func ParseName(raw string) Name

ParseName returns a pointer to a new name

func (Name) String

func (n Name) String() string

String returns a human friendly representation of n

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

func (*Response) String

func (r *Response) String() string

String provides an easy to read version of r

type WhoisClient

type WhoisClient struct {
	Conn net.Conn
	// contains filtered or unexported fields
}

WhoisClient uses the whois client

func NewWhoisClient

func NewWhoisClient() (client *WhoisClient, err error)

NewWhoisClient returns a pointer to a new connected whois client

func (*WhoisClient) Close

func (c *WhoisClient) Close() error

Close closes a client.

func (*WhoisClient) LookupASN

func (c *WhoisClient) LookupASN(asn ASN) (*Response, error)

LookupASN is a single ASN convenience proxy of LookupASNs

func (*WhoisClient) LookupASNs

func (c *WhoisClient) LookupASNs(asns []ASN) (resp []Response, err error)

LookupASNs looks up ASNs. Response IP and Range fields are zeroed

func (*WhoisClient) LookupIP

func (c *WhoisClient) LookupIP(ip net.IP) (*Response, error)

LookupIP is a single IP convenience proxy of LookupIPs

func (*WhoisClient) LookupIPs

func (c *WhoisClient) LookupIPs(ips []net.IP) (resp []Response, err error)

LookupIPs looks up IPs and returns a slice of responses the same size as the input slice of IPs The response slice will be in the same order as the input IPs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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