ipisp

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

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

Go to latest
Published: Aug 6, 2016 License: MIT Imports: 10 Imported by: 1

README

IPISP

IPISP wraps Team Cymru's IP to ASN service.

Features

  • Programmatically resolve an IP address's AS number, ISP name, range, allocation time, registry, and country of registration.
  • Safe for bulk usage by using Cymru's DNS interface
  • Concurrent safe

Godoc

Example

A more thorough example is in the examples/ folder.

client, _ := ipisp.NewDnsClient()
resp, err := 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.Name)
fmt.Printf("Registry: %v\n", resp.Registry)
fmt.Printf("ISP: %v\n", resp.Name.Raw)

Documentation

Overview

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

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

func NewDnsClient

func NewDnsClient() (client *dnsClient, err error)

func NewWhoisClient

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

NewClient returns a pointer to a new connected IPISP client

Types

type ASN

type ASN int

ASN contains an Autonomous Systems Number

func ParseASN

func ParseASN(asn string) ASN

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
}

type Country

type Country struct {
	Code string
	Name string
}

Country encapsulates an ISO_3166-1 country and name

func NewCountryFromCode

func NewCountryFromCode(code string) (country *Country, err error)

NewCountryFromCode returns a country from a country code

type Name

type Name struct {
	Raw string
}

Name contains an IPISP name

func NewName

func NewName(raw string) *Name

NewName returns a pointer to a new name

func (*Name) Long

func (n *Name) Long() string

Long attempts to provide the log name of an ISP

func (*Name) Short

func (n *Name) Short() string

Short attempts to provide the short name of an ISP

type Response

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

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