Help us shape the future of Go! Take the 2026 Go Developer Survey

ripelookup

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

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

Go to latest
Published: Oct 27, 2018 License: MIT Imports: 9 Imported by: 0

README

Overview

ripelookup is used to lookup IP ownership information for an IP address. It uses IANA registration information to determine which server to query for more information.

Generating Tables

The v4/v6 tables files are generated from IANA data and allow looking up the appropriate server for a particular IP address. To regenerate the table, run:

go run gen/gen.go

Usage

        ip := "8.8.8.8"
        server, _ := ripelookup.DetermineServer(net.ParseIP(ip))
        records, _ := ripelookup.WhoisIP(ip, server)
        fmt.Println(records[0])

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("server not found")

ErrNotFound is returned when a WHOIS server cannot be found for a given IP

Functions

func DetermineServer

func DetermineServer(ip net.IP) (string, error)

DetermineServer determines the appropriate whois server to query for a particular IP

Example
package main

import (
	"fmt"
	"net"

	"github.com/tzneal/ripelookup"
)

func main() {
	server, _ := ripelookup.DetermineServer(net.ParseIP("8.8.8.8"))
	fmt.Println(server)
}
Output:
whois.arin.net

Types

type Record

type Record map[string]string

Record is a single WHOIS record for an IP Address

func WhoisIP

func WhoisIP(query string, server string) ([]Record, error)

WhoisIP performs a WHOIS against a server for an IP Address, returning the matching records

Example
package main

import (
	"fmt"
	"net"

	"github.com/tzneal/ripelookup"
)

func main() {
	ip := "8.8.8.8"
	server, _ := ripelookup.DetermineServer(net.ParseIP(ip))
	records, _ := ripelookup.WhoisIP(ip, server)
	fmt.Println(records[0])
}

func (Record) String

func (r Record) String() string

Jump to

Keyboard shortcuts

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