whois

package module
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

README

Who-GO WHOIS/RDAP Lookup Service

License

Who-GO is a WHOIS lookup service implemented in Go, providing an easy-to-use interface for querying domain information using both the WHOIS and RDAP protocols. It offers a flexible configuration through command-line arguments and environment variables to suit various deployment needs.

Features

  • WHOIS and RDAP protocol support.
  • Configurable server port.
  • External configuration for WHOIS and RDAP services.
  • ASCII art logo on startup.

Installation

go get -u github.com/darkqiank/whois

License

Copyright 2024 darkqiank

modified from: https://github.com/likexian/whois Copyright by Li Kexian

Licensed under the Apache License 2.0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDomainEmpty is domain is an empty string
	ErrDomainEmpty = errors.New("whois: domain is empty")

	// ErrWhoisServerNotFound is no whois server found
	ErrWhoisServerNotFound = errors.New("whois: no whois server found for domain")
)
View Source
var DefaultClient = NewClient()

DefaultClient is default whois client

View Source
var DefaultRDAPClient = NewRDAPClient()

DefaultRDAPClient is default RDAP client

Functions

func Author

func Author() string

Author returns package author

func GetRelURL added in v0.5.0

func GetRelURL(res map[string]interface{}) (string, bool)

func InitRDAP added in v0.5.0

func InitRDAP(configFile string)

InitRDAP sync.Once的作用是确保在多线程环境下一个操作只被执行一次

func InitWhois added in v0.5.0

func InitWhois(configFile string)

sync.Once的作用是确保在多线程环境下一个操作只被执行一次

func IsASN

func IsASN(resource string) bool

IsASN function is used to check if the given resource is an Autonomous System Number (ASN).

func License

func License() string

License returns package license

func NewServerMap added in v0.4.1

func NewServerMap() *serverMap

NewServerMap creates a new serverMap instance

func RDAP added in v0.5.0

func RDAP(domain string) (result map[string]interface{}, err error)

RDAP do the RDAP query and returns RDAP information

func Version

func Version() string

Version returns package version

func Whois

func Whois(domain string, servers ...string) (result string, err error)

Whois do the whois query and returns whois information

Types

type ASNRange added in v0.5.0

type ASNRange struct {
	Start int
	End   int
	URL   string
}

ASNRange 表示ASN范围和对应的URL

func NewASNRange added in v0.5.0

func NewASNRange(rangeStr, url string) (ASNRange, error)

通过ASN范围字符串创建ASNRange实例

type Client

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

Client is whois client

func NewClient

func NewClient() *Client

NewClient returns new whois client

func (*Client) SetDialer

func (c *Client) SetDialer(dialer proxy.Dialer) *Client

SetDialer set query net dialer

func (*Client) SetDisableReferral

func (c *Client) SetDisableReferral(disabled bool) *Client

SetDisableReferral if set to true, will not query the referral server.

func (*Client) SetDisableStats

func (c *Client) SetDisableStats(disabled bool) *Client

SetDisableStats set disable stats

func (*Client) SetTimeout

func (c *Client) SetTimeout(timeout time.Duration) *Client

SetTimeout set query timeout

func (*Client) Whois

func (c *Client) Whois(domain string, servers ...string) (result string, err error)

Whois do the whois query and returns whois information

type RDAPBootstrap added in v0.5.0

type RDAPBootstrap struct {
	IPv4 RDAPData `json:"ipv4"`
	IPv6 RDAPData `json:"ipv6"`
	ASN  RDAPData `json:"asn"`
	DNS  RDAPData `json:"dns"`
}

RDAPBootstrap 定义一个结构体来映射原始JSON数据的最外层

type RDAPClient added in v0.5.0

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

RDAPClient is RDAP client

func NewRDAPClient added in v0.5.0

func NewRDAPClient() *RDAPClient

NewRDAPClient returns new RDAP client

func (*RDAPClient) RDAP added in v0.5.0

func (c *RDAPClient) RDAP(q string) (map[string]interface{}, error)

func (*RDAPClient) SetDisableReferral added in v0.5.0

func (c *RDAPClient) SetDisableReferral(disabled bool) *RDAPClient

SetDisableReferral if set to true, will not query the referral server.

type RDAPData added in v0.5.0

type RDAPData struct {
	Description string       `json:"description"`
	Publication string       `json:"publication"`
	Services    [][][]string `json:"services"`
	Version     string       `json:"version"`
}

RDAPData 结构体用于映射IPv4、IPv6、dns、asn的数据

type RdapConfig added in v0.5.0

type RdapConfig struct {
	IP  map[string]string `json:"ip"`
	ASN map[string]string `json:"asn"`
	TLD map[string]string `json:"tld"`
	// contains filtered or unexported fields
}

type RdapMap added in v0.5.0

type RdapMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRdapMap added in v0.5.0

func NewRdapMap() *RdapMap

NewRdapMap creates a new rdapMap instance

func (*RdapMap) GetRdapServer added in v0.5.0

func (rm *RdapMap) GetRdapServer(query string) (string, string, bool)

func (*RdapMap) LoadBootstrap added in v0.5.0

func (rm *RdapMap) LoadBootstrap(bootstrap RDAPBootstrap) error

LoadBootstrap loads the server map from Bootstrap

func (*RdapMap) LoadFromFile added in v0.5.0

func (rm *RdapMap) LoadFromFile(filename string) error

LoadFromFile loads the server map from a JSON file

func (*RdapMap) LoadFromIANA added in v0.5.0

func (rm *RdapMap) LoadFromIANA() error

type ServerConfig added in v0.4.1

type ServerConfig struct {
	Rewrite map[string]string `json:"rewrite"`
	Servers map[string]string `json:"servers"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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