whois

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

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

Go to latest
Published: Aug 7, 2018 License: MIT Imports: 8 Imported by: 2

README

whois - a go wrapper for whois command

go report card MIT license GoDoc

Examples

Query by URL:

url := "http://github.com/xellio/whois"
res, err := whois.Query(url)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(strings.Join(res.Output["Registrant City"], ","))
//Output:
//San Francisco

Query by hostname:

host := "golang.org"
res, err := whois.QueryHost(host)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(strings.Join(res.Output["Registrant Country"], ","))
// Output:
// US

Query by IP:

ip := net.ParseIP("8.8.8.8")
res, err := whois.QueryIp(ip)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(strings.Join(res.Output["CIDR"], ","))
// Output:
// 8.0.0.0/8,8.8.8.0/24

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	IP         net.IP
	Host       string
	Raw        []byte
	Output     map[string][]string
	GatherTime time.Duration
}

Result struct

func Query

func Query(urlToQuery string, args ...string) (r *Result, err error)

Query whois data for given url

Example

ExampleQuery - An example of using the Query function

package main

import (
	"fmt"
	"strings"

	"github.com/xellio/whois"
)

func main() {
	url := "http://github.com/xellio/whois"
	res, err := whois.Query(url)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(strings.Join(res.Output["Registrant City"], ","))
}
Output:

San Francisco

func QueryHost

func QueryHost(host string, args ...string) (r *Result, err error)

QueryHost queries whois data for given host

Example

ExampleQueryHost - An example of using the QueryHost function

package main

import (
	"fmt"
	"strings"

	"github.com/xellio/whois"
)

func main() {
	host := "golang.org"
	res, err := whois.QueryHost(host)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(strings.Join(res.Output["Registrant Country"], ","))
}
Output:

US

func QueryIP

func QueryIP(ip net.IP, args ...string) (r *Result, err error)

QueryIP queries whois data for given net.IP

Example

ExampleQueryIp - An example of using the QueryIp function

package main

import (
	"fmt"
	"net"
	"strings"

	"github.com/xellio/whois"
)

func main() {
	ip := net.ParseIP("8.8.8.8")
	res, err := whois.QueryIP(ip)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(strings.Join(res.Output["CIDR"], ","))
}
Output:

8.0.0.0/8,8.8.8.0/24

func (*Result) JSON

func (r *Result) JSON() (data []byte, err error)

JSON returns r,Output parsed as JSON

func (*Result) String

func (r *Result) String() string

String return r.Outout as string (json)

Jump to

Keyboard shortcuts

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