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

whois

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package whois provides WHOIS functionality.

Index

Constants

View Source
const (
	// DefaultServer is the default WHOIS server.
	DefaultServer = "whois.arin.net"

	// DefaultPort is the default port for WHOIS requests.
	DefaultPort = 43
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DialContext is used to create TCP connections to WHOIS servers.
	DialContext aghnet.DialContextFunc

	// ServerAddr is the address of the WHOIS server.
	ServerAddr string

	// Timeout is the timeout for WHOIS requests.
	Timeout time.Duration

	// CacheTTL is the Time to Live duration for cached IP addresses.
	CacheTTL time.Duration

	// MaxConnReadSize is an upper limit in bytes for reading from net.Conn.
	MaxConnReadSize int64

	// MaxRedirects is the maximum redirects count.
	MaxRedirects int

	// MaxInfoLen is the maximum length of Info fields returned by Process.
	MaxInfoLen int

	// CacheSize is the maximum size of the cache.  It must be greater than
	// zero.
	CacheSize int

	// Port is the port for WHOIS requests.
	Port uint16
}

Config is the configuration structure for Default.

type Default

type Default struct {
	// contains filtered or unexported fields
}

Default is the default WHOIS information processor.

func New

func New(conf *Config) (w *Default)

New returns a new default WHOIS information processor. conf must not be nil.

func (*Default) Process

func (w *Default) Process(ctx context.Context, ip netip.Addr) (wi *Info, changed bool)

Process makes WHOIS request and returns WHOIS information or nil. changed indicates that Info was updated since last request.

type Empty

type Empty struct{}

Empty is an empty Interface implementation which does nothing.

func (Empty) Process

func (Empty) Process(_ context.Context, _ netip.Addr) (info *Info, changed bool)

Process implements the Interface interface for Empty.

type Info

type Info struct {
	City    string `json:"city,omitempty"`
	Country string `json:"country,omitempty"`
	Orgname string `json:"orgname,omitempty"`
}

Info is the filtered WHOIS data for a runtime client.

type Interface

type Interface interface {
	// Process makes WHOIS request and returns WHOIS information or nil.
	// changed indicates that Info was updated since last request.
	Process(ctx context.Context, ip netip.Addr) (info *Info, changed bool)
}

Interface provides WHOIS functionality.

Jump to

Keyboard shortcuts

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