@stacksjs/whois 0.58.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/index.js +601 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# whois
|
|
2
|
+
|
|
3
|
+
Find out domain whois information.
|
|
4
|
+
|
|
5
|
+
## โ๏ธ Features
|
|
6
|
+
|
|
7
|
+
- whois lookup
|
|
8
|
+
|
|
9
|
+
## ๐ค Usage
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun install -d @stacksjs/whois
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Now, you can use it in your project:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { lookup } from '@stacksjs/whois'
|
|
19
|
+
|
|
20
|
+
const result = await lookup('google.com')
|
|
21
|
+
|
|
22
|
+
console.log(result)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Learn more in the docs.
|
|
26
|
+
|
|
27
|
+
## ๐งช Testing
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
bun test
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## ๐ Changelog
|
|
34
|
+
|
|
35
|
+
Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
|
|
36
|
+
|
|
37
|
+
## ๐ Contributing
|
|
38
|
+
|
|
39
|
+
Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
|
|
40
|
+
|
|
41
|
+
## ๐ Community
|
|
42
|
+
|
|
43
|
+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
44
|
+
|
|
45
|
+
[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
|
|
46
|
+
|
|
47
|
+
For casual chit-chat with others using this package:
|
|
48
|
+
|
|
49
|
+
[Join the Stacks Discord Server](https://discord.gg/stacksjs)
|
|
50
|
+
|
|
51
|
+
## ๐ License
|
|
52
|
+
|
|
53
|
+
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
|
|
54
|
+
|
|
55
|
+
Made with ๐
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/index.ts
|
|
3
|
+
import Net from "net";
|
|
4
|
+
import fetch from "node-fetch";
|
|
5
|
+
import {SocksClient} from "socks";
|
|
6
|
+
|
|
7
|
+
// src/parameters.ts
|
|
8
|
+
var parameters_default = {
|
|
9
|
+
"whois.denic.de": "-T dn,ace",
|
|
10
|
+
"whois.nic.fr": "-V Md5.2"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/servers.ts
|
|
14
|
+
var servers_default = {
|
|
15
|
+
"br.com": "whois.centralnic.net",
|
|
16
|
+
"cn.com": "whois.centralnic.net",
|
|
17
|
+
"de.com": "whois.centralnic.net",
|
|
18
|
+
"eu.com": "whois.centralnic.net",
|
|
19
|
+
"gb.com": "whois.centralnic.net",
|
|
20
|
+
"gb.net": "whois.centralnic.net",
|
|
21
|
+
"gr.com": "whois.centralnic.net",
|
|
22
|
+
"hu.com": "whois.centralnic.net",
|
|
23
|
+
"in.net": "whois.centralnic.net",
|
|
24
|
+
"no.com": "whois.centralnic.net",
|
|
25
|
+
"qc.com": "whois.centralnic.net",
|
|
26
|
+
"ru.com": "whois.centralnic.net",
|
|
27
|
+
"sa.com": "whois.centralnic.net",
|
|
28
|
+
"se.com": "whois.centralnic.net",
|
|
29
|
+
"se.net": "whois.centralnic.net",
|
|
30
|
+
"uk.com": "whois.centralnic.net",
|
|
31
|
+
"uk.net": "whois.centralnic.net",
|
|
32
|
+
"us.com": "whois.centralnic.net",
|
|
33
|
+
"uy.com": "whois.centralnic.net",
|
|
34
|
+
"za.com": "whois.centralnic.net",
|
|
35
|
+
"jpn.com": "whois.centralnic.ne",
|
|
36
|
+
"web.com": "whois.centralnic.ne",
|
|
37
|
+
com: "whois.verisign-grs.com",
|
|
38
|
+
"za.net": "whois.za.net",
|
|
39
|
+
net: "whois.verisign-grs.com",
|
|
40
|
+
"eu.org": "whois.eu.org",
|
|
41
|
+
"za.org": "whois.za.org",
|
|
42
|
+
org: "whois.pir.org",
|
|
43
|
+
"llyw.cymru": "whois.nic.llyw.cymru",
|
|
44
|
+
"gov.scot": "whois.nic.gov.scot",
|
|
45
|
+
"gov.wales": "whois.nic.gov.wales",
|
|
46
|
+
edu: "whois.educause.edu",
|
|
47
|
+
gov: "whois.dotgov.gov",
|
|
48
|
+
int: "whois.iana.org",
|
|
49
|
+
"e164.arpa": "whois.ripe.net",
|
|
50
|
+
arpa: "whois.iana.org",
|
|
51
|
+
aero: "whois.aero",
|
|
52
|
+
asia: "whois.nic.asia",
|
|
53
|
+
biz: "whois.nic.biz",
|
|
54
|
+
cat: "whois.nic.cat",
|
|
55
|
+
coop: "whois.nic.coop",
|
|
56
|
+
info: "whois.afilias.net",
|
|
57
|
+
jobs: "whois.nic.jobs",
|
|
58
|
+
mobi: "whois.afilias.net",
|
|
59
|
+
museum: "whois.nic.museum",
|
|
60
|
+
name: "whois.nic.name",
|
|
61
|
+
post: "whois.dotpostregistry.net",
|
|
62
|
+
pro: "whois.nic.pro",
|
|
63
|
+
tel: "whois.nic.tel",
|
|
64
|
+
travel: "whois.nic.travel",
|
|
65
|
+
xxx: "whois.nic.xxx",
|
|
66
|
+
ac: "whois.nic.ac",
|
|
67
|
+
ae: "whois.aeda.net.ae",
|
|
68
|
+
af: "whois.nic.af",
|
|
69
|
+
ag: "whois.nic.ag",
|
|
70
|
+
ai: "whois.nic.ai",
|
|
71
|
+
am: "whois.amnic.net",
|
|
72
|
+
ar: "whois.nic.ar",
|
|
73
|
+
as: "whois.nic.as",
|
|
74
|
+
"priv.at": "whois.nic.priv.at",
|
|
75
|
+
at: "whois.nic.at",
|
|
76
|
+
au: "whois.auda.org.au",
|
|
77
|
+
aw: "whois.nic.aw",
|
|
78
|
+
ax: "whois.ax",
|
|
79
|
+
be: "whois.dns.be",
|
|
80
|
+
bf: "whois.registre.bf",
|
|
81
|
+
bg: "whois.register.bg",
|
|
82
|
+
bh: "whois.nic.bh",
|
|
83
|
+
bi: "whois1.nic.bi",
|
|
84
|
+
bj: "whois.nic.bj",
|
|
85
|
+
bm: "whois.afilias-srs.net",
|
|
86
|
+
bn: "whois.bnnic.bn",
|
|
87
|
+
bo: "whois.nic.bo",
|
|
88
|
+
br: "whois.registro.br",
|
|
89
|
+
by: "whois.cctld.by",
|
|
90
|
+
bw: "whois.nic.net.bw",
|
|
91
|
+
bz: "whois.afilias-grs.info",
|
|
92
|
+
"co.ca": "whois.co.ca",
|
|
93
|
+
ca: "whois.cira.ca",
|
|
94
|
+
cc: "ccwhois.verisign-grs.com",
|
|
95
|
+
cd: "whois.nic.cd",
|
|
96
|
+
ch: "whois.nic.ch",
|
|
97
|
+
ci: "whois.nic.ci",
|
|
98
|
+
cl: "whois.nic.cl",
|
|
99
|
+
cm: "whois.netcom.cm",
|
|
100
|
+
"edu.cn": "whois.edu.cn",
|
|
101
|
+
cn: "whois.cnnic.cn",
|
|
102
|
+
"uk.co": "whois.uk.co",
|
|
103
|
+
co: "whois.nic.co",
|
|
104
|
+
cr: "whois.nic.cr",
|
|
105
|
+
cx: "whois.nic.cx",
|
|
106
|
+
cz: "whois.nic.cz",
|
|
107
|
+
de: "whois.denic.de",
|
|
108
|
+
dk: "whois.dk-hostmaster.dk",
|
|
109
|
+
dm: "whois.dmdomains.dm",
|
|
110
|
+
do: "whois.nic.do",
|
|
111
|
+
dz: "whois.nic.dz",
|
|
112
|
+
ec: "whois.nic.ec",
|
|
113
|
+
ee: "whois.tld.ee",
|
|
114
|
+
eu: "whois.eu",
|
|
115
|
+
fi: "whois.fi",
|
|
116
|
+
fj: "www.whois.fj",
|
|
117
|
+
fm: "whois.nic.fm",
|
|
118
|
+
fo: "whois.nic.fo",
|
|
119
|
+
fr: "whois.nic.fr",
|
|
120
|
+
gd: "whois.nic.gd",
|
|
121
|
+
ge: "whois.nic.ge",
|
|
122
|
+
gf: "whois.mediaserv.net",
|
|
123
|
+
gg: "whois.gg",
|
|
124
|
+
gh: "whois.nic.gh",
|
|
125
|
+
gi: "whois2.afilias-grs.net",
|
|
126
|
+
gl: "whois.nic.gl",
|
|
127
|
+
gp: "whois.nic.gp",
|
|
128
|
+
gq: "whois.dominio.gq",
|
|
129
|
+
gs: "whois.nic.gs",
|
|
130
|
+
gy: "whois.registry.gy",
|
|
131
|
+
hk: "whois.hkirc.hk",
|
|
132
|
+
hm: "whois.registry.hm",
|
|
133
|
+
hn: "whois.nic.hn",
|
|
134
|
+
hr: "whois.dns.hr",
|
|
135
|
+
ht: "whois.nic.ht",
|
|
136
|
+
hu: "whois.nic.hu",
|
|
137
|
+
id: "whois.id",
|
|
138
|
+
ie: "whois.weare.ie",
|
|
139
|
+
il: "whois.isoc.org.il",
|
|
140
|
+
im: "whois.nic.im",
|
|
141
|
+
in: "whois.registry.in",
|
|
142
|
+
io: "whois.nic.io",
|
|
143
|
+
iq: "whois.cmc.iq",
|
|
144
|
+
ir: "whois.nic.ir",
|
|
145
|
+
is: "whois.isnic.is",
|
|
146
|
+
it: "whois.nic.it",
|
|
147
|
+
je: "whois.je",
|
|
148
|
+
jp: "whois.jprs.jp",
|
|
149
|
+
ke: "whois.kenic.or.ke",
|
|
150
|
+
kg: "whois.kg",
|
|
151
|
+
ki: "whois.nic.ki",
|
|
152
|
+
kn: "whois.nic.kn",
|
|
153
|
+
kr: "whois.kr",
|
|
154
|
+
kw: "whois.nic.kw",
|
|
155
|
+
ky: "whois.kyregistry.ky",
|
|
156
|
+
kz: "whois.nic.kz",
|
|
157
|
+
la: "whois.nic.la",
|
|
158
|
+
lb: "whois.lbdr.org.lb",
|
|
159
|
+
lc: "whois2.afilias-grs.net",
|
|
160
|
+
li: "whois.nic.li",
|
|
161
|
+
lk: "whois.nic.lk",
|
|
162
|
+
ls: "whois.nic.ls",
|
|
163
|
+
lt: "whois.domreg.lt",
|
|
164
|
+
lu: "whois.dns.lu",
|
|
165
|
+
lv: "whois.nic.lv",
|
|
166
|
+
ly: "whois.nic.ly",
|
|
167
|
+
ma: "whois.registre.ma",
|
|
168
|
+
md: "whois.nic.md",
|
|
169
|
+
me: "whois.nic.me",
|
|
170
|
+
mg: "whois.nic.mg",
|
|
171
|
+
mk: "whois.marnet.mk",
|
|
172
|
+
ml: "whois.dot.ml",
|
|
173
|
+
mm: "whois.registry.gov.mm",
|
|
174
|
+
mn: "whois.nic.mn",
|
|
175
|
+
mq: "whois.mediaserv.net",
|
|
176
|
+
mr: "whois.nic.mr",
|
|
177
|
+
ms: "whois.nic.ms",
|
|
178
|
+
mt: "whois.nic.org.mt",
|
|
179
|
+
mu: "whois.nic.mu",
|
|
180
|
+
mw: "whois.nic.mw",
|
|
181
|
+
mx: "whois.mx",
|
|
182
|
+
my: "whois.mynic.my",
|
|
183
|
+
mz: "whois.nic.mz",
|
|
184
|
+
na: "whois.na-nic.com.na",
|
|
185
|
+
nc: "whois.nc",
|
|
186
|
+
nf: "whois.nic.nf",
|
|
187
|
+
ng: "whois.nic.net.ng",
|
|
188
|
+
nl: "whois.domain-registry.nl",
|
|
189
|
+
no: "whois.norid.no",
|
|
190
|
+
nu: "whois.iis.nu",
|
|
191
|
+
nz: "whois.irs.net.nz",
|
|
192
|
+
om: "whois.registry.om",
|
|
193
|
+
pe: "kero.yachay.pe",
|
|
194
|
+
pf: "whois.registry.pf",
|
|
195
|
+
pk: "whois.pknic.net.pk",
|
|
196
|
+
"co.pl": "whois.co.pl",
|
|
197
|
+
pl: "whois.dns.pl",
|
|
198
|
+
pm: "whois.nic.pm",
|
|
199
|
+
pr: "whois.afilias-srs.net",
|
|
200
|
+
ps: "whois.pnina.ps",
|
|
201
|
+
pt: "whois.dns.pt",
|
|
202
|
+
pw: "whois.nic.pw",
|
|
203
|
+
qa: "whois.registry.qa",
|
|
204
|
+
re: "whois.nic.re",
|
|
205
|
+
ro: "whois.rotld.ro",
|
|
206
|
+
rs: "whois.rnids.rs",
|
|
207
|
+
"ac.ru": "whois.free.net",
|
|
208
|
+
"edu.ru": "whois.informika.ru",
|
|
209
|
+
"com.ru": "whois.flexireg.net",
|
|
210
|
+
"msk.ru": "whois.flexireg.net",
|
|
211
|
+
"net.ru": "whois.nic.net.ru",
|
|
212
|
+
"nov.ru": "whois.flexireg.net",
|
|
213
|
+
"org.ru": "whois.nic.net.ru",
|
|
214
|
+
"pp.ru": "whois.nic.net.ru",
|
|
215
|
+
"spb.ru": "whois.flexireg.net",
|
|
216
|
+
ru: "whois.tcinet.ru",
|
|
217
|
+
rw: "whois.ricta.org.rw",
|
|
218
|
+
sa: "whois.nic.net.sa",
|
|
219
|
+
sb: "whois.nic.net.sb",
|
|
220
|
+
sc: "whois2.afilias-grs.net",
|
|
221
|
+
sd: "whois.sdnic.sd",
|
|
222
|
+
se: "whois.iis.se",
|
|
223
|
+
sg: "whois.sgnic.sg",
|
|
224
|
+
sh: "whois.nic.sh",
|
|
225
|
+
si: "whois.register.si",
|
|
226
|
+
sk: "whois.sk-nic.sk",
|
|
227
|
+
sl: "whois.nic.sl",
|
|
228
|
+
sm: "whois.nic.sm",
|
|
229
|
+
sn: "whois.nic.sn",
|
|
230
|
+
so: "whois.nic.so",
|
|
231
|
+
ss: "whois.nic.ss",
|
|
232
|
+
st: "whois.nic.st",
|
|
233
|
+
"msk.su": "whois.flexireg.net",
|
|
234
|
+
"nov.su": "whois.flexireg.net",
|
|
235
|
+
"spb.su": "whois.flexireg.net",
|
|
236
|
+
su: "whois.tcinet.ru",
|
|
237
|
+
sx: "whois.sx",
|
|
238
|
+
sy: "whois.tld.sy",
|
|
239
|
+
tc: "whois.nic.tc",
|
|
240
|
+
td: "whois.nic.td",
|
|
241
|
+
tf: "whois.nic.tf",
|
|
242
|
+
tg: "whois.nic.tg",
|
|
243
|
+
th: "whois.thnic.co.th",
|
|
244
|
+
tk: "whois.dot.tk",
|
|
245
|
+
tl: "whois.nic.tl",
|
|
246
|
+
tm: "whois.nic.tm",
|
|
247
|
+
tn: "whois.ati.tn",
|
|
248
|
+
to: "whois.tonic.to",
|
|
249
|
+
tr: "whois.trabis.gov.tr",
|
|
250
|
+
tv: "whois.nic.tv",
|
|
251
|
+
tw: "whois.twnic.net.tw",
|
|
252
|
+
tz: "whois.tznic.or.tz",
|
|
253
|
+
"biz.ua": "whois.biz.ua",
|
|
254
|
+
"co.ua": "whois.co.ua",
|
|
255
|
+
"pp.ua": "whois.pp.ua",
|
|
256
|
+
ua: "whois.ua",
|
|
257
|
+
ug: "whois.co.ug",
|
|
258
|
+
"ac.uk": "whois.nic.ac.uk",
|
|
259
|
+
"gov.uk": "whois.gov.uk",
|
|
260
|
+
uk: "whois.nic.uk",
|
|
261
|
+
"fed.us": "whois.nic.gov",
|
|
262
|
+
us: "whois.nic.us",
|
|
263
|
+
uy: "whois.nic.org.uy",
|
|
264
|
+
uz: "whois.cctld.uz",
|
|
265
|
+
vc: "whois2.afilias-grs.net",
|
|
266
|
+
ve: "whois.nic.ve",
|
|
267
|
+
vg: "whois.nic.vg",
|
|
268
|
+
vu: "whois.dnrs.vu",
|
|
269
|
+
wf: "whois.nic.wf",
|
|
270
|
+
ws: "whois.website.ws",
|
|
271
|
+
yt: "whois.nic.yt",
|
|
272
|
+
"ac.za": "whois.ac.za",
|
|
273
|
+
"co.za": "whois.registry.net.za",
|
|
274
|
+
"gov.za": "whois.gov.za",
|
|
275
|
+
"net.za": "net-whois.registry.net.za",
|
|
276
|
+
"org.za": "org-whois.registry.net.za",
|
|
277
|
+
"web.za": "web-whois.registry.net.za",
|
|
278
|
+
zm: "whois.zicta.zm",
|
|
279
|
+
"xn--2scrj9c": "whois.registry.in",
|
|
280
|
+
"xn--3e0b707e": "whois.kr",
|
|
281
|
+
"xn--3hcrj9c": "whois.registry.in",
|
|
282
|
+
"xn--45br5cyl": "whois.registry.in",
|
|
283
|
+
"xn--45brj9c": "whois.registry.in",
|
|
284
|
+
"xn--4dbrk0ce": "whois.isoc.org.il",
|
|
285
|
+
"xn--80ao21a": "whois.nic.kz",
|
|
286
|
+
"xn--90a3ac": "whois.rnids.rs",
|
|
287
|
+
"xn--90ae": "whois.imena.bg",
|
|
288
|
+
"xn--90ais": "whois.cctld.by",
|
|
289
|
+
"xn--clchc0ea0b2g2a9gcd": "whois.sgnic.sg",
|
|
290
|
+
"xn--d1alf": "whois.marnet.mk",
|
|
291
|
+
"xn--e1a4c": "whois.eu",
|
|
292
|
+
"xn--fiqs8s": "cwhois.cnnic.cn",
|
|
293
|
+
"xn--fiqz9s": "cwhois.cnnic.cn",
|
|
294
|
+
"xn--fpcrj9c3d": "whois.registry.in",
|
|
295
|
+
"xn--fzc2c9e2c": "whois.nic.lk",
|
|
296
|
+
"xn--gecrj9c": "whois.registry.in",
|
|
297
|
+
"xn--h2breg3eve": "whois.registry.in",
|
|
298
|
+
"xn--h2brj9c8c": "whois.registry.in",
|
|
299
|
+
"xn--h2brj9c": "whois.registry.in",
|
|
300
|
+
"xn--j1amh": "whois.dotukr.com",
|
|
301
|
+
"xn--j6w193g": "whois.hkirc.hk",
|
|
302
|
+
"xn--kprw13d": "whois.twnic.net.tw",
|
|
303
|
+
"xn--kpry57d": "whois.twnic.net.tw",
|
|
304
|
+
"xn--lgbbat1ad8j": "whois.nic.dz",
|
|
305
|
+
"xn--mgb9awbf": "whois.registry.om",
|
|
306
|
+
"xn--mgba3a4f16a": "whois.nic.ir",
|
|
307
|
+
"xn--mgbaam7a8h": "whois.aeda.net.ae",
|
|
308
|
+
"xn--mgbah1a3hjkrd": "whois.nic.mr",
|
|
309
|
+
"xn--mgbbh1a71e": "whois.registry.in",
|
|
310
|
+
"xn--mgbbh1a": "whois.registry.in",
|
|
311
|
+
"xn--mgberp4a5d4ar": "whois.nic.net.sa",
|
|
312
|
+
"xn--mgbgu82a": "whois.registry.in",
|
|
313
|
+
"xn--mgbtx2b": "whois.cmc.iq",
|
|
314
|
+
"xn--mgbx4cd0ab": "whois.mynic.my",
|
|
315
|
+
"xn--node": "whois.itdc.ge",
|
|
316
|
+
"xn--o3cw4h": "whois.thnic.co.th",
|
|
317
|
+
"xn--ogbpf8fl": "whois.tld.sy",
|
|
318
|
+
"xn--p1ai": "whois.tcinet.ru",
|
|
319
|
+
"xn--pgbs0dh": "whois.ati.tn",
|
|
320
|
+
"xn--q7ce6a": "whois.nic.la",
|
|
321
|
+
"xn--qxa6a": "whois.eu",
|
|
322
|
+
"xn--rvc1e0am3e": "whois.registry.in",
|
|
323
|
+
"xn--s9brj9c": "whois.registry.in",
|
|
324
|
+
"xn--wgbh1c": "whois.dotmasr.eg",
|
|
325
|
+
"xn--wgbl6a": "whois.registry.qa",
|
|
326
|
+
"xn--xkc2al3hye2a": "whois.nic.lk",
|
|
327
|
+
"xn--xkc2dl3a5ee0h": "whois.registry.in",
|
|
328
|
+
"xn--y9a3aq": "whois.amnic.net",
|
|
329
|
+
"xn--yfro4i67o": "whois.sgnic.sg",
|
|
330
|
+
"xn--ygbi2ammx": "whois.pnina.ps"
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
// src/index.ts
|
|
334
|
+
async function findWhoIsServer(tld) {
|
|
335
|
+
const chkURL = IANA_CHK_URL + tld;
|
|
336
|
+
try {
|
|
337
|
+
const res = await fetch(chkURL);
|
|
338
|
+
if (res.ok) {
|
|
339
|
+
const body = await res.text();
|
|
340
|
+
const server = body.match(/whois:\s+(.*)\s+/);
|
|
341
|
+
if (server)
|
|
342
|
+
return server[1];
|
|
343
|
+
}
|
|
344
|
+
} catch (err) {
|
|
345
|
+
console.error("Error in getting WhoIs server data from IANA", err);
|
|
346
|
+
}
|
|
347
|
+
return "";
|
|
348
|
+
}
|
|
349
|
+
var shallowCopy = function(obj) {
|
|
350
|
+
if (Array.isArray(obj)) {
|
|
351
|
+
return obj.slice();
|
|
352
|
+
} else if (typeof obj === "object" && obj !== null) {
|
|
353
|
+
const copy = {};
|
|
354
|
+
for (const key in obj) {
|
|
355
|
+
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
356
|
+
copy[key] = shallowCopy(obj[key]);
|
|
357
|
+
}
|
|
358
|
+
return copy;
|
|
359
|
+
} else {
|
|
360
|
+
return obj;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
var getWhoIsServer = function(tld) {
|
|
364
|
+
return servers_default[tld];
|
|
365
|
+
};
|
|
366
|
+
var getTLD = function(domain) {
|
|
367
|
+
let tld = null;
|
|
368
|
+
let domainStr = domain;
|
|
369
|
+
while (true) {
|
|
370
|
+
const domainData2 = domainStr.split(".");
|
|
371
|
+
if (domainData2.length < 2)
|
|
372
|
+
break;
|
|
373
|
+
const tldCheck = domainData2.slice(1).join(".");
|
|
374
|
+
const server = servers_default[tldCheck];
|
|
375
|
+
if (server) {
|
|
376
|
+
tld = tldCheck;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
domainStr = tldCheck;
|
|
380
|
+
}
|
|
381
|
+
if (tld)
|
|
382
|
+
return tld;
|
|
383
|
+
console.debug("TLD is not found in server list. Returning last element after split as TLD!");
|
|
384
|
+
const domainData = domain.split(".");
|
|
385
|
+
return domainData[domainData.length - 1];
|
|
386
|
+
};
|
|
387
|
+
var getParameters = function(server) {
|
|
388
|
+
return parameters_default[server];
|
|
389
|
+
};
|
|
390
|
+
async function tcpWhois(domain, queryOptions, server, port, encoding, proxy) {
|
|
391
|
+
const decoder = new TextDecoder(encoding);
|
|
392
|
+
const encoder = new TextEncoder;
|
|
393
|
+
if (!proxy) {
|
|
394
|
+
const socket = new Net.Socket;
|
|
395
|
+
return new Promise((resolve, reject) => {
|
|
396
|
+
try {
|
|
397
|
+
socket.connect({ port, host: server }, () => {
|
|
398
|
+
if (queryOptions !== "")
|
|
399
|
+
socket.write(encoder.encode(`${queryOptions} ${domain}\r\n`));
|
|
400
|
+
else
|
|
401
|
+
socket.write(encoder.encode(`${domain}\r\n`));
|
|
402
|
+
});
|
|
403
|
+
socket.on("data", (data) => {
|
|
404
|
+
resolve(decoder.decode(data));
|
|
405
|
+
});
|
|
406
|
+
socket.on("error", (error) => {
|
|
407
|
+
reject(error);
|
|
408
|
+
});
|
|
409
|
+
} catch (e) {
|
|
410
|
+
reject(e);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
} else {
|
|
414
|
+
const options = {
|
|
415
|
+
proxy: {
|
|
416
|
+
host: proxy.ip,
|
|
417
|
+
port: proxy.port,
|
|
418
|
+
type: proxy.type === ProxyType.SOCKS5 ? 5 : 4
|
|
419
|
+
},
|
|
420
|
+
command: "connect",
|
|
421
|
+
destination: {
|
|
422
|
+
host: server,
|
|
423
|
+
port
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
if (proxy.username && proxy.password) {
|
|
427
|
+
options.proxy.userId = proxy.username;
|
|
428
|
+
options.proxy.password = proxy.password;
|
|
429
|
+
}
|
|
430
|
+
return new Promise((resolve, reject) => {
|
|
431
|
+
SocksClient.createConnection(options, (err, info) => {
|
|
432
|
+
if (err) {
|
|
433
|
+
reject(err);
|
|
434
|
+
} else {
|
|
435
|
+
if (!info)
|
|
436
|
+
reject(new Error("No socket info received!"));
|
|
437
|
+
if (queryOptions !== "") {
|
|
438
|
+
info?.socket.write(encoder.encode(`${queryOptions} ${domain}\r\n`));
|
|
439
|
+
} else {
|
|
440
|
+
info?.socket.write(encoder.encode(`${domain}\r\n`));
|
|
441
|
+
}
|
|
442
|
+
info?.socket.on("data", (data) => {
|
|
443
|
+
resolve(decoder.decode(data));
|
|
444
|
+
});
|
|
445
|
+
info?.socket.resume();
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
async function whois(domain, parse = false, options = null) {
|
|
452
|
+
let tld;
|
|
453
|
+
let port = 43;
|
|
454
|
+
let server = "";
|
|
455
|
+
let queryOptions;
|
|
456
|
+
let proxy;
|
|
457
|
+
let encoding = "utf-8";
|
|
458
|
+
if (!options) {
|
|
459
|
+
tld = getTLD(domain);
|
|
460
|
+
proxy = null;
|
|
461
|
+
} else {
|
|
462
|
+
tld = options.tld ? options.tld : getTLD(domain);
|
|
463
|
+
encoding = options.encoding ? options.encoding : "utf-8";
|
|
464
|
+
proxy = options.proxy ? options.proxy : null;
|
|
465
|
+
server = options.server ? options.server : "";
|
|
466
|
+
port = options.serverPort ? options.serverPort : 43;
|
|
467
|
+
}
|
|
468
|
+
if (server === "") {
|
|
469
|
+
let serverData = getWhoIsServer(tld);
|
|
470
|
+
if (!serverData) {
|
|
471
|
+
console.debug(`No WhoIs server found for TLD: ${tld}! Attempting IANA WhoIs database for server!`);
|
|
472
|
+
serverData = await findWhoIsServer(tld);
|
|
473
|
+
if (!serverData) {
|
|
474
|
+
console.debug("WhoIs server could not be found!");
|
|
475
|
+
return {
|
|
476
|
+
_raw: "",
|
|
477
|
+
parsedData: null
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
console.debug(`WhoIs sever found for ${tld}: ${server}`);
|
|
481
|
+
}
|
|
482
|
+
server = serverData;
|
|
483
|
+
}
|
|
484
|
+
const qOptions = getParameters(server);
|
|
485
|
+
queryOptions = qOptions || "";
|
|
486
|
+
try {
|
|
487
|
+
const rawData = await tcpWhois(domain, queryOptions, server, port, encoding, proxy);
|
|
488
|
+
if (!parse) {
|
|
489
|
+
const parsedData = WhoIsParser.parseData(rawData, null);
|
|
490
|
+
return {
|
|
491
|
+
_raw: rawData,
|
|
492
|
+
parsedData
|
|
493
|
+
};
|
|
494
|
+
} else {
|
|
495
|
+
let outputData = null;
|
|
496
|
+
if (options && options.parseData)
|
|
497
|
+
outputData = shallowCopy(options.parseData);
|
|
498
|
+
try {
|
|
499
|
+
const parsedData = WhoIsParser.parseData(rawData, outputData);
|
|
500
|
+
return {
|
|
501
|
+
_raw: rawData,
|
|
502
|
+
parsedData
|
|
503
|
+
};
|
|
504
|
+
} catch (err) {
|
|
505
|
+
console.error("Error in parsing WhoIs data!", err);
|
|
506
|
+
return {
|
|
507
|
+
_raw: rawData,
|
|
508
|
+
parsedData: null
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
} catch (err) {
|
|
513
|
+
return {
|
|
514
|
+
_raw: "",
|
|
515
|
+
parsedData: null
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function lookup(domain, options = null) {
|
|
520
|
+
return whois(domain, true, options);
|
|
521
|
+
}
|
|
522
|
+
async function batchWhois(domains, parallel = false, threads = 1, parse = false, options = null) {
|
|
523
|
+
let response = [];
|
|
524
|
+
if (parallel) {
|
|
525
|
+
if (threads > domains.length)
|
|
526
|
+
threads = domains.length;
|
|
527
|
+
for (let i = 0;i < domains.length; i += threads) {
|
|
528
|
+
const batch = domains.slice(i, i + threads);
|
|
529
|
+
response = await Promise.all(batch.map(async (domain) => {
|
|
530
|
+
return await whois(domain, parse, options);
|
|
531
|
+
}));
|
|
532
|
+
}
|
|
533
|
+
} else {
|
|
534
|
+
for (let i = 0;i < domains.length; i++) {
|
|
535
|
+
const res = await whois(domains[i], parse, options);
|
|
536
|
+
response.push(res);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return response;
|
|
540
|
+
}
|
|
541
|
+
var IANA_CHK_URL = "https://www.iana.org/whois?q=";
|
|
542
|
+
var ProxyType;
|
|
543
|
+
(function(ProxyType2) {
|
|
544
|
+
ProxyType2[ProxyType2["SOCKS4"] = 0] = "SOCKS4";
|
|
545
|
+
ProxyType2[ProxyType2["SOCKS5"] = 1] = "SOCKS5";
|
|
546
|
+
})(ProxyType || (ProxyType = {}));
|
|
547
|
+
|
|
548
|
+
class WhoIsParser {
|
|
549
|
+
static iterParse(rawData, outputData) {
|
|
550
|
+
let lastStr = "";
|
|
551
|
+
let lastField = null;
|
|
552
|
+
let lastLetter = "";
|
|
553
|
+
for (let i = 0;i < rawData.length; i++) {
|
|
554
|
+
const letter = rawData[i];
|
|
555
|
+
if (letter === "\n" || lastLetter === ":" && letter === " ") {
|
|
556
|
+
if (lastStr.trim() in outputData) {
|
|
557
|
+
lastField = lastStr.trim();
|
|
558
|
+
} else if (lastField !== null) {
|
|
559
|
+
const x = lastStr.trim();
|
|
560
|
+
if (x !== "") {
|
|
561
|
+
const obj = outputData[lastField];
|
|
562
|
+
if (Array.isArray(obj))
|
|
563
|
+
obj.push(x);
|
|
564
|
+
else
|
|
565
|
+
outputData[lastField] = x;
|
|
566
|
+
lastField = null;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
lastStr = "";
|
|
570
|
+
} else if (letter !== ":") {
|
|
571
|
+
lastStr = lastStr + letter;
|
|
572
|
+
}
|
|
573
|
+
lastLetter = letter;
|
|
574
|
+
if (lastStr === "Record maintained by" || lastStr === ">>>")
|
|
575
|
+
break;
|
|
576
|
+
}
|
|
577
|
+
return outputData;
|
|
578
|
+
}
|
|
579
|
+
static parseData(rawData, outputData) {
|
|
580
|
+
if (!outputData) {
|
|
581
|
+
outputData = {
|
|
582
|
+
"Domain Name": "",
|
|
583
|
+
"Creation Date": "",
|
|
584
|
+
"Updated Date": "",
|
|
585
|
+
"Registry Expiry Date": "",
|
|
586
|
+
"Domain Status": [],
|
|
587
|
+
Registrar: ""
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
outputData = WhoIsParser.iterParse(rawData, outputData);
|
|
591
|
+
return outputData;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
export {
|
|
595
|
+
whois,
|
|
596
|
+
tcpWhois,
|
|
597
|
+
lookup,
|
|
598
|
+
batchWhois,
|
|
599
|
+
WhoIsParser,
|
|
600
|
+
ProxyType
|
|
601
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stacksjs/whois",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.58.19",
|
|
5
|
+
"description": "Easily get whois info.",
|
|
6
|
+
"author": "Chris Breuer",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
9
|
+
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/src/whois#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/stacksjs/stacks.git",
|
|
13
|
+
"directory": "./storage/framework/core/src/whois"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/stacksjs/stacks/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"whois",
|
|
20
|
+
"domain",
|
|
21
|
+
"management",
|
|
22
|
+
"stacks",
|
|
23
|
+
"aws",
|
|
24
|
+
"typescript",
|
|
25
|
+
"javascript"
|
|
26
|
+
],
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"bun": "./src/index.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./*": {
|
|
33
|
+
"bun": "./src/*",
|
|
34
|
+
"import": "./dist/*"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"contributors": [
|
|
38
|
+
"Chris Breuer <chris@stacksjs.org>"
|
|
39
|
+
],
|
|
40
|
+
"files": [
|
|
41
|
+
"README.md",
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "bun --bun build.ts",
|
|
46
|
+
"typecheck": "bun --bun tsc --noEmit",
|
|
47
|
+
"prepublishOnly": "bun --bun run build"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"node-fetch": "^3.3.2",
|
|
51
|
+
"socks": "^2.7.1"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"node-fetch": "^3.3.2",
|
|
55
|
+
"socks": "^2.7.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@stacksjs/development": "workspace:*"
|
|
59
|
+
}
|
|
60
|
+
}
|