Giter VIP home page Giter VIP logo

whois's Introduction

Whois

License GoDoc Go Report Card Build Status Code Cover

Whois is a simple Go module for domain and ip whois information query.

Overview

All of domain, IP include IPv4 and IPv6, ASN are supported.

You can directly using the binary distributions whois, follow whois release tool.

Or you can do development by using this golang module as below.

Installation

go get -u github.com/likexian/whois

Importing

import (
    "github.com/likexian/whois"
)

Documentation

Visit the docs on GoDoc

Example

whois query for domain

result, err := whois.Whois("likexian.com")
if err == nil {
    fmt.Println(result)
}

whois query for IPv6

result, err := whois.Whois("2001:dc7::1")
if err == nil {
    fmt.Println(result)
}

whois query for IPv4

result, err := whois.Whois("1.1.1.1")
if err == nil {
    fmt.Println(result)
}

whois query for ASN

// or whois.Whois("AS60614")
result, err := whois.Whois("60614")
if err == nil {
    fmt.Println(result)
}

Whois information parsing

Please refer to whois-parser

License

Copyright 2014-2024 Li Kexian

Licensed under the Apache License 2.0

Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can give me a cup of coffee.

whois's People

Contributors

csnitker-godaddy avatar dependabot[bot] avatar gabe565 avatar happyfacade avatar lapubell avatar likexian avatar rissson avatar steveyiyo avatar yizero avatar zcalusic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

whois's Issues

what annoys me the most as a cyber weapons dev with this lib

sure its great and all but do you REALLY have to put

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar.  Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability.  VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

sure i get you want protection beleieve me i do to but it hurts when some people are trying to control the output for our own uses, i think you should remove it. it makes it a very annoying module to work with and something i just dont want to use. i would at this point just remake the module 👎

Error while Installing Package

When I do go get I get the following error

go get -u github.com/likexian/whois
github.com/likexian/whois
../github.com/likexian/whois/whois.go:100:21: time.Since(start).Milliseconds undefined (type time.Duration has no field or method Milliseconds)

go version go1.10.4 linux/amd64

批量查询时出现 goroutine 907686 [runnable]:

goroutine 908118 [IO wait]:
internal/poll.runtime_pollWait(0x7fb8d8d13b48, 0x72)
/usr/local/go/src/runtime/netpoll.go:302 +0x89
internal/poll.(*pollDesc).wait(0xc020a74880?, 0xc01f233200?, 0x0)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:83 +0x32
internal/poll.(*pollDesc).waitRead(...)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Read(0xc020a74880, {0xc01f233200, 0x200, 0x200})
/usr/local/go/src/internal/poll/fd_unix.go:167 +0x25a
net.(*netFD).Read(0xc020a74880, {0xc01f233200?, 0xc004c4f458?, 0x44be12?})
/usr/local/go/src/net/fd_posix.go:55 +0x29
net.(*conn).Read(0xc011e78848, {0xc01f233200?, 0xe359636833?, 0xda1160?})
/usr/local/go/src/net/net.go:183 +0x45
io.ReadAll({0xaa2c20, 0xc011e78848})
/usr/local/go/src/io/io.go:645 +0xfe
io/ioutil.ReadAll(...)
/usr/local/go/src/io/ioutil/ioutil.go:27
name/internal/whois.(*Client).rawQuery(0xc01d25e1e0, {0xc002dd9ad0, 0x8}, {0xc01caf5965, 0xe}, {0x9a907f, 0x2})
/home/name/internal/whois/li.go:203 +0x5f4
name/internal/whois.(*Client).Whois(0x9b58f8?, {0xc002dd9ad0, 0x8}, {0xc00b7f7758, 0x1, 0x3?})
/home/name/internal/whois/li.go:156 +0x4ab
name/internal/whois.ProxyWhois({0x9b58f8?, 0x16?}, {0xc002dd9ad0, 0x8}, {0x9bdc4b, 0x16})
/home/name/internal/whois/li.go:105 +0x68
name/internal/whois.GetBulkNormalWhois({0xc002dd9ad0?, 0x8})
/home/name/internal/whois/whois.go:501 +0x4b0
name/internal/whoislookup.getwhoisme({0xc002dd9ad0, 0x8}, 0x1, 0xc00061e018)
/home/name/internal/whoislookup/mywhois.go:232 +0x4d
name/internal/whoislookup.getInfome({0xc002dd9ad0?, 0x0?}, 0x9af93d?, 0xd?, 0x9bd0c9?, 0x15?, 0x9afb38?)
/home/name/internal/whoislookup/mywhois.go:269 +0x65
created by name/internal/whoislookup.collectme
/home/name/internal/whoislookup/mywhois.go:296 +0x26d

goroutine 907686 [runnable]:
internal/poll.runtime_pollWait(0x7fb8d8d13e18, 0x72)
/usr/local/go/src/runtime/netpoll.go:302 +0x89
internal/poll.(*pollDesc).wait(0xc01fe96100?, 0xc01df0e200?, 0x0)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:83 +0x32
internal/poll.(*pollDesc).waitRead(...)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Read(0xc01fe96100, {0xc01df0e200, 0x200, 0x200})
/usr/local/go/src/internal/poll/fd_unix.go:167 +0x25a
net.(*netFD).Read(0xc01fe96100, {0xc01df0e200?, 0xc0138fb458?, 0x44be12?})
/usr/local/go/src/net/fd_posix.go:55 +0x29
net.(*conn).Read(0xc0118fe6b8, {0xc01df0e200?, 0xe33d8ccdaf?, 0xda1160?})
/usr/local/go/src/net/net.go:183 +0x45
io.ReadAll({0xaa2c20, 0xc0118fe6b8})
/usr/local/go/src/io/io.go:645 +0xfe
io/ioutil.ReadAll(...)
/usr/local/go/src/io/ioutil/ioutil.go:27
name/internal/whois.(*Client).rawQuery(0xc01edbd540, {0xc002dd83a0, 0xd}, {0xc015d65c6a, 0xe}, {0x9a907f, 0x2})
/home/name/internal/whois/li.go:203 +0x5f4
name/internal/whois.(*Client).Whois(0x9bae92?, {0xc002dd83a0, 0xd}, {0xc00b7fb758, 0x1, 0x3?})
/home/name/internal/whois/li.go:156 +0x4ab
name/internal/whois.ProxyWhois({0x9bae92?, 0x16?}, {0xc002dd83a0, 0xd}, {0x9bdc4b, 0x16})
/home/name/internal/whois/li.go:105 +0x68
name/internal/whois.GetBulkNormalWhois({0xc002dd83a0?, 0xd})
/home/name/internal/whois/whois.go:501 +0x4b0
name/internal/whoislookup.getwhoisme({0xc002dd83a0, 0xd}, 0x1, 0xc00061e018)
/home/name/internal/whoislookup/mywhois.go:232 +0x4d
name/internal/whoislookup.getInfome({0xc002dd83a0?, 0x3c3c3c205a32313a?}, 0x726f6d20726f4620?, 0x6d726f666e692065?, 0x6e6f206e6f697461?, 0x20?, 0x6f63207375746174?)
/home/name/internal/whoislookup/mywhois.go:269 +0x65
created by name/internal/whoislookup.collectme
/home/name/internal/whoislookup/mywhois.go:296 +0x26d

buffer, err := ioutil.ReadAll(conn)

jp response

The default whois response for .jp TLD (whois server: whois.jprs.jp) contains Japanese characters.
It is really not readable and is not parsed well using likexian/whois-parser.
Note: Adding the "/e" suffix to the query gives English charcters only.

example - google.jp vs google.jp/e:
google.jp

[ JPRS database provides information on network administration. Its use is ]
[ restricted to network administration purposes. For further information, ]
[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ]
[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ]

Domain Information: [ドメイン情報]
[Domain Name] GOOGLE.JP

[登録者名] Google LLC
[Registrant] Google LLC

[Name Server] ns1.google.com
[Name Server] ns2.google.com
[Name Server] ns3.google.com
[Name Server] ns4.google.com
[Signing Key]

[登録年月日] 2005/05/30
[有効期限] 2022/05/31
[状態] Active
[最終更新] 2021/06/01 01:05:09 (JST)

Contact Information: [公開連絡窓口]
[名前] Google LLC
[Name] Google LLC
[Email] [email protected]
[Web Page]
[郵便番号] 94043
[住所] Mountain View
1600 Amphitheatre Parkway
CA
[Postal Address] Mountain View
1600 Amphitheatre Parkway
CA
[電話番号] 16502530000
[FAX番号] 16502530001

parsed using whois-parser:
{"domain":{"domain":"google.jp","punycode":"google.jp","name":"google","extension":"jp","name_servers":["ns1.google.com","ns2.google.com","ns3.google.com","ns4.google.com"]},"registrant":{"name":"Google LLC"},"administrative":{"name":"Google LLC","street":"Mountain View, 1600 Amphitheatre Parkway, CA","email":"[email protected]"}}

google.jp/e:

[ JPRS database provides information on network administration. Its use is ]
[ restricted to network administration purposes. For further information, ]
[ use 'whois -h whois.jprs.jp help'. To suppress Japanese output, add'/e' ]
[ at the end of command, e.g. 'whois -h whois.jprs.jp xxx/e'. ]

Domain Information:
[Domain Name] GOOGLE.JP

[Registrant] Google LLC

[Name Server] ns1.google.com
[Name Server] ns2.google.com
[Name Server] ns3.google.com
[Name Server] ns4.google.com
[Signing Key]

[Created on] 2005/05/30
[Expires on] 2022/05/31
[Status] Active
[Last Updated] 2021/06/01 01:05:09 (JST)

Contact Information:
[Name] Google LLC
[Email] [email protected]
[Web Page]
[Postal code] 94043
[Postal Address] Mountain View
1600 Amphitheatre Parkway
CA
[Phone] 16502530000
[Fax] 16502530001

parsed using whois-parser:
{"domain":{"domain":"google.jp","punycode":"google.jp","name":"google","extension":"jp","status":["active"],"name_servers":["ns1.google.com","ns2.google.com","ns3.google.com","ns4.google.com"],"created_date":"2005/05/30","updated_date":"2021/06/01 01:05:09 (JST)","expiration_date":"2022/05/31"},"registrant":{"name":"Google LLC"},"administrative":{"name":"Google LLC","street":"Mountain View, 1600 Amphitheatre Parkway, CA","postal_code":"94043","phone":"16502530000","fax":"16502530001","email":"[email protected]"}}

Incorrect documentation

I think you meant

if err == nil {
fmt.Println(result)
}

The way it's written, result will only print if there's an error.

Request: Create new tag

The ability to disable referral lookups isn't yet available from a stable tag.

Workaround:

  1. cd /path/to/project
  2. go get github.com/likexian/whois@f92c1874d6172bd181cf08c35a5c365f1e5dad97

refs: v1.15.0...master

Many thanks for this project!

handle ReferralServer

whois for 144.200.46.16 contains a ReferralServer, a token which should be handled. A naive fix follows below. But, the result of it is that whois data from both the referring and the referred server is output. I'm not sure that it should? Perhaps only the latter should be output?

diff --git a/whois.go b/whois.go
index efd763f..762ca79 100644
--- a/whois.go
+++ b/whois.go
@@ -217,6 +217,7 @@ func getServer(data string) string {
 	tokens := []string{
 		"Registrar WHOIS Server: ",
 		"whois: ",
+		"ReferralServer: ",
 	}
 
 	for _, token := range tokens {
@@ -226,6 +227,7 @@ func getServer(data string) string {
 			end := strings.Index(data[start:], "\n")
 			server := strings.TrimSpace(data[start : start+end])
 			server = strings.Trim(server, "/")
+			server = strings.TrimPrefix(server, "whois://")
 			return server
 		}
 	}

Error parsing WHOIS server when godaddy throws bad domain info

This package is great. I've been finding lots of bad info inside WHOIS info from using this, and godaddy is not returning a valid host for a few domains:

$ whois the4ccoalition.org
...
Registrar WHOIS Server: whois.godaddy
...

$ whois pgsf.org
...
Registrar WHOIS Server: whois.godaddy
...

Error using custom whois server

If we use a custom whois server, like, whois.biz

txt, err := c.Whois("excellentlife.biz", "whois.biz")

here will get a double query

whois/whois.go

Line 137 in da2a39f

result, err = c.rawQuery(domain, server, port)

The first query will go to whois.biz and return valid data, but then instead of returning this valid response, it will query the default server and return error (biz server used in this library is unstable).

Should be something like that on #L137

result, err = c.rawQuery(domain, server, port)
if err != nil {
	return "", err
} else {
	return 
}

关于 Clinet Timeout 设置无效的问题

Hi @likexian

我遇到了和 #37 相同的问题,经过测试和检查 whois.go 的源代码,我猜测:

  • 因为 SetTimeout() 只设置了 c.timeout,而 c.dialer.Timeout 没有被更新,它在 NewClient() 时已经被固定为 30 秒;
  • 所以如果超时发生在 c.dialer.Dial() 则 timeout 无效;

之所以会得出这个猜测,是因为今晚我所在的网络无法连接到 whois.nic.work 这个服务器,以下为 ping 表现:

PING whois.nic.work(2600:1f13:dde:c501::1:5 (2600:1f13:dde:c501::1:5)) 56 data bytes
^C
--- whois.nic.work ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1016ms

然后看了一下 net 包中关于 Dialer.Timeout 的解释,好像确实与连接时的超时有关:

type Dialer struct {
	// Timeout is the maximum amount of time a dial will wait for
	// a connect to complete. If Deadline is also set, it may fail
	// earlier.
	//
	// The default is no timeout.
	//
	// When using TCP and dialing a host name with multiple IP
	// addresses, the timeout may be divided between them.
	//
	// With or without a timeout, the operating system may impose
	// its own earlier timeout. For instance, TCP timeouts are
	// often around 3 minutes.
	Timeout [time](https://pkg.go.dev/time).[Duration](https://pkg.go.dev/time#Duration)

......

EDIT: 补充一个复现方法:

whois.DefaultClient.SetTimeout(time.Second * 5)
result, err := whois.Whois("example.com", "www.google.com")

如此,即可复现 5 秒超时的设置并没起作用,连接 www.google.com:43 要等到 30 秒后才超时。


由于这是第一次接触 go 语言,如果猜测错误,请见谅
感谢

Failure performing query when `Registrar WHOIS Server` line in WHOIS record has `http://`

Hi,

First of all, many thanks for this useful library. I've used it and the whois-parse library in a Nagios plugin to monitor the expiration date of WHOIS registrations.

I recently had a user of the plugin report an issue with monitoring the expiration for a specific domain. After troubleshooting, I found that this error message:

dial tcp: address tcp///whois.pairdomains.com: unknown port

is related to this line:

Registrar WHOIS Server: http://whois.pairdomains.com

If we override the WHOIS server used by explicitly specifying the whois server as whois.iana.org (which seems to be the default), the error is not encountered. This seems to be because of this code path:

whois/whois.go

Lines 122 to 124 in a48608e

if len(servers) > 0 && servers[0] != "" {
server = strings.ToLower(servers[0])
port = defaultWhoisPort

Here the port is explicitly set to the default, ignoring any potential port specified in the Registrar WHOIS Server line.

If we don't explicitly specify the whois server, then this path is taken:

whois/whois.go

Lines 125 to 134 in a48608e

} else {
ext := getExtension(domain)
result, err := c.rawQuery(ext, defaultWhoisServer, defaultWhoisPort)
if err != nil {
return "", fmt.Errorf("whois: query for whois server failed: %w", err)
}
server, port = getServer(result)
if server == "" {
return "", fmt.Errorf("%w: %s", ErrWhoisServerNotFound, domain)
}

and in the getServer function this logic is applied:

whois/whois.go

Lines 235 to 239 in a48608e

if strings.Contains(server, ":") {
v := strings.Split(server, ":")
server, port = v[0], v[1]
}
return server, port

Cant "go get whois-go"

Hello.
After ur last update there is the problem.

if i try install like "go get -u github.com/likexian/whois-go", i ll get this one
"github.com/likexian/[email protected]: unknown revision v1.0.1"

Unfortunately, getting doesnt work neither by Docker, not by hands.

Thanks for ur attention

whois for IP 34.202.253.227 fails

When querying for whois of IP 34.202.253.227 I get the following result

#
# ARIN WHOIS data and services are subject to the Terms of Use
# available at: https://www.arin.net/resources/registry/whois/tou/
#
# If you see inaccuracies in the results, please report at
# https://www.arin.net/resources/registry/whois/inaccuracy_reporting/
#
# Copyright 1997-2023, American Registry for Internet Numbers, Ltd.
#

% Query time: 992 msec
% WHEN: Fri May 26 11:07:35 CEST 2023

When querying online, I get a result

Timeout Setting Ignored in Whois Client

Issue Description

The Whois client doesn't seem to respect the timeout settings when making queries. Despite setting the timeout via SetTimeout(), the client operation doesn't timeout as expected.

Steps to Reproduce

  1. Import the Whois client.
  2. Set the timeout using SetTimeout() method.
  3. Make a Whois query.
client := whois.NewClient()
client.SetDialer(proxy.FromEnvironment())
client.SetTimeout(5 * time.Second)
output, err := client.Whois("example.com", *server)

Expected Behavior

The query should timeout after 5 seconds if the server does not respond.

Actual Behavior

The operation does not timeout even after 5 seconds.

Additional Information

  • Go version: go1.20.5
  • Operating System: Ubuntu 22.04.3 LTS

cannot lookup .taxi domains

I'm trying to get whois info for snapp.taxi but I get this error:

dial tcp: lookup taxi.whois-servers.net: no such host

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.