whois

package
v0.0.0-...-75a31e8 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: GPL-3.0 Imports: 18 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 {
	// Logger is used for logging the operation of the WHOIS lookup queries.  It
	// must not be nil.
	Logger *slog.Logger

	// 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 uint64

	// 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.

func (*Info) Clone

func (i *Info) Clone() (c *Info)

Clone returns a deep copy of the WHOIS info.

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