Debian Codegraph @

README.md

raw symbols SCIP
1 # whois
2 ![test](https://github.com/TwiN/whois/actions/workflows/test.yml/badge.svg)
3
4 > **WARNING**: WHOIS has been deprecated in favor of RDAP. Some TLDs may have already removed their WHOIS server.
5
6 Lightweight library for retrieving WHOIS information on a domain.
7
8 It automatically retrieves the appropriate WHOIS server based on the domain's TLD by first querying IANA.
9
10
11 ## Usage
12 ### As an executable
13 To install it:
14 ```console
15 go install github.com/TwiN/whois/cmd/whois@latest
16 ```
17 Alternatively, you can download whois from the [release](https://github.com/TwiN/whois/releases) section, though you'll have to unzip the file first.
18
19 To run it:
20 ```console
21 whois example.com
22 ```
23
24 ### As a library
25 ```console
26 go get github.com/TwiN/whois
27 ```
28
29 #### Query
30 If all you want is the text a WHOIS server would return you, you can use the `Query` method of the `whois.Client` type:
31 ```go
32 package main
33
34 import "github.com/TwiN/whois"
35
36 func main() {
37 client := whois.NewClient()
38 output, err := client.Query("example.com")
39 if err != nil {
40 panic(err)
41 }
42 println(output)
43 }
44 ```
45
46 #### QueryAndParse
47 If you want specific pieces of information, you can use the `QueryAndParse` method of the `whois.Client` type:
48 ```go
49 package main
50
51 import "github.com/TwiN/whois"
52
53 func main() {
54 client := whois.NewClient()
55 response, err := client.QueryAndParse("example.com")
56 if err != nil {
57 panic(err)
58 }
59 println(response.ExpirationDate.String())
60 }
61 ```
62 Note that because there is no standardized format for WHOIS responses, this parsing may not be successful for every single TLD.
63
64 Currently, the only fields parsed are:
65 - `ExpirationDate`: The time.Time at which the domain will expire
66 - `DomainStatuses`: The statuses that the domain currently has (e.g. `clientTransferProhibited`)
67 - `NameServers`: The nameservers currently tied to the domain
68
69 If you'd like one or more other fields to be parsed, please don't be shy and create an issue or a pull request.
70
71 #### Caching referral WHOIS servers
72 The way that WHOIS scales is by having one "main" WHOIS server, namely `whois.iana.org:43`, refer to other WHOIS server
73 on a per-TLD basis.
74
75 In other word, let's say that you wanted to have the WHOIS information for `example.com`.
76 The first step would be to query `whois.iana.org:43` with `com`, which would return `whois.verisign-grs.com`.
77 Then, you would query `whois.verisign-grs.com:43` for the WHOIS information on `example.com`.
78
79 If you're querying a lot of servers, making two queries instead of one can be a little wasteful, hence `WithReferralCache(true)`:
80 ```go
81 client := whois.NewClient().WithReferralCache(true)
82 ```
83 The above will cache the referral WHOIS server for each TLD, so that you can directly query the appropriate WHOIS server
84 instead of first querying `whois.iana.org:43` for the referral.
85