@stacksjs/whois 0.74.33 → 0.74.35
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/dist/index.d.ts +20 -0
- package/dist/index.js +6 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,26 @@ export type { SocksClientOptions } from './socks';
|
|
|
10
10
|
* @returns WhoIs server which hosts the information for the domains of the TLD
|
|
11
11
|
*/
|
|
12
12
|
export declare function findWhoIsServer(tld: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* The whois server named in an IANA TLD record, or `''` when there is none.
|
|
15
|
+
*
|
|
16
|
+
* Split out of {@link findWhoIsServer} so the parsing can be tested without
|
|
17
|
+
* reaching IANA over the network. It was inlined, so the only coverage it had
|
|
18
|
+
* was a test that made a live request - which turned this repository's CI red
|
|
19
|
+
* whenever IANA was slow, with `Expected: > 0` as the whole explanation.
|
|
20
|
+
*
|
|
21
|
+
* IANA's response is a plain-text record with one `field: value` per line. The
|
|
22
|
+
* pattern is anchored to the start of a line: `whois:` also appears inside the
|
|
23
|
+
* prose of some records ("...contact the whois: server..."), and an unanchored
|
|
24
|
+
* match picked the first of those instead of the field.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* parseIanaWhoisServer('domain: app\nwhois: whois.nic.google\n') // 'whois.nic.google'
|
|
29
|
+
* parseIanaWhoisServer('domain: example\n') // ''
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseIanaWhoisServer(body: string): string;
|
|
13
33
|
/**
|
|
14
34
|
* Get whois server of the tld from servers list
|
|
15
35
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import z from"net";import{log as f}from"@stacksjs/logging";var y="https://www.iana.org/whois?q=",b={"whois.denic.de":"-T dn,ace","whois.nic.fr":"-V Md5.2"},p={"br.com":"whois.centralnic.net","cn.com":"whois.centralnic.net","de.com":"whois.centralnic.net","eu.com":"whois.centralnic.net","gb.com":"whois.centralnic.net","gb.net":"whois.centralnic.net","gr.com":"whois.centralnic.net","hu.com":"whois.centralnic.net","in.net":"whois.centralnic.net","no.com":"whois.centralnic.net","qc.com":"whois.centralnic.net","ru.com":"whois.centralnic.net","sa.com":"whois.centralnic.net","se.com":"whois.centralnic.net","se.net":"whois.centralnic.net","uk.com":"whois.centralnic.net","uk.net":"whois.centralnic.net","us.com":"whois.centralnic.net","uy.com":"whois.centralnic.net","za.com":"whois.centralnic.net","jpn.com":"whois.centralnic.ne","web.com":"whois.centralnic.ne",com:"whois.verisign-grs.com","za.net":"whois.za.net",net:"whois.verisign-grs.com","eu.org":"whois.eu.org","za.org":"whois.za.org",org:"whois.pir.org","llyw.cymru":"whois.nic.llyw.cymru","gov.scot":"whois.nic.gov.scot","gov.wales":"whois.nic.gov.wales",edu:"whois.educause.edu",gov:"whois.dotgov.gov",int:"whois.iana.org","e164.arpa":"whois.ripe.net",arpa:"whois.iana.org",aero:"whois.aero",asia:"whois.nic.asia",biz:"whois.nic.biz",cat:"whois.nic.cat",coop:"whois.nic.coop",info:"whois.afilias.net",jobs:"whois.nic.jobs",mobi:"whois.afilias.net",museum:"whois.nic.museum",name:"whois.nic.name",post:"whois.dotpostregistry.net",pro:"whois.nic.pro",tel:"whois.nic.tel",travel:"whois.nic.travel",xxx:"whois.nic.xxx",ac:"whois.nic.ac",ae:"whois.aeda.net.ae",af:"whois.nic.af",ag:"whois.nic.ag",ai:"whois.nic.ai",am:"whois.amnic.net",ar:"whois.nic.ar",as:"whois.nic.as","priv.at":"whois.nic.priv.at",at:"whois.nic.at",au:"whois.auda.org.au",aw:"whois.nic.aw",ax:"whois.ax",be:"whois.dns.be",bf:"whois.registre.bf",bg:"whois.register.bg",bh:"whois.nic.bh",bi:"whois1.nic.bi",bj:"whois.nic.bj",bm:"whois.afilias-srs.net",bn:"whois.bnnic.bn",bo:"whois.nic.bo",br:"whois.registro.br",by:"whois.cctld.by",bw:"whois.nic.net.bw",bz:"whois.afilias-grs.info","co.ca":"whois.co.ca",ca:"whois.cira.ca",cc:"ccwhois.verisign-grs.com",cd:"whois.nic.cd",ch:"whois.nic.ch",ci:"whois.nic.ci",cl:"whois.nic.cl",cm:"whois.netcom.cm","edu.cn":"whois.edu.cn",cn:"whois.cnnic.cn","uk.co":"whois.uk.co",co:"whois.nic.co",cr:"whois.nic.cr",cx:"whois.nic.cx",cz:"whois.nic.cz",de:"whois.denic.de",dk:"whois.dk-hostmaster.dk",dm:"whois.dmdomains.dm",do:"whois.nic.do",dz:"whois.nic.dz",ec:"whois.nic.ec",ee:"whois.tld.ee",eu:"whois.eu",fi:"whois.fi",fj:"www.whois.fj",fm:"whois.nic.fm",fo:"whois.nic.fo",fr:"whois.nic.fr",gd:"whois.nic.gd",ge:"whois.nic.ge",gf:"whois.mediaserv.net",gg:"whois.gg",gh:"whois.nic.gh",gi:"whois2.afilias-grs.net",gl:"whois.nic.gl",gp:"whois.nic.gp",gq:"whois.dominio.gq",gs:"whois.nic.gs",gy:"whois.registry.gy",hk:"whois.hkirc.hk",hm:"whois.registry.hm",hn:"whois.nic.hn",hr:"whois.dns.hr",ht:"whois.nic.ht",hu:"whois.nic.hu",id:"whois.id",ie:"whois.weare.ie",il:"whois.isoc.org.il",im:"whois.nic.im",in:"whois.registry.in",io:"whois.nic.io",iq:"whois.cmc.iq",ir:"whois.nic.ir",is:"whois.isnic.is",it:"whois.nic.it",je:"whois.je",jp:"whois.jprs.jp",ke:"whois.kenic.or.ke",kg:"whois.kg",ki:"whois.nic.ki",kn:"whois.nic.kn",kr:"whois.kr",kw:"whois.nic.kw",ky:"whois.kyregistry.ky",kz:"whois.nic.kz",la:"whois.nic.la",lb:"whois.lbdr.org.lb",lc:"whois2.afilias-grs.net",li:"whois.nic.li",lk:"whois.nic.lk",ls:"whois.nic.ls",lt:"whois.domreg.lt",lu:"whois.dns.lu",lv:"whois.nic.lv",ly:"whois.nic.ly",ma:"whois.registre.ma",md:"whois.nic.md",me:"whois.nic.me",mg:"whois.nic.mg",mk:"whois.marnet.mk",ml:"whois.dot.ml",mm:"whois.registry.gov.mm",mn:"whois.nic.mn",mq:"whois.mediaserv.net",mr:"whois.nic.mr",ms:"whois.nic.ms",mt:"whois.nic.org.mt",mu:"whois.nic.mu",mw:"whois.nic.mw",mx:"whois.mx",my:"whois.mynic.my",mz:"whois.nic.mz",na:"whois.na-nic.com.na",nc:"whois.nc",nf:"whois.nic.nf",ng:"whois.nic.net.ng",nl:"whois.domain-registry.nl",no:"whois.norid.no",nu:"whois.iis.nu",nz:"whois.irs.net.nz",om:"whois.registry.om",pe:"kero.yachay.pe",pf:"whois.registry.pf",pk:"whois.pknic.net.pk","co.pl":"whois.co.pl",pl:"whois.dns.pl",pm:"whois.nic.pm",pr:"whois.afilias-srs.net",ps:"whois.pnina.ps",pt:"whois.dns.pt",pw:"whois.nic.pw",qa:"whois.registry.qa",re:"whois.nic.re",ro:"whois.rotld.ro",rs:"whois.rnids.rs","ac.ru":"whois.free.net","edu.ru":"whois.informika.ru","com.ru":"whois.flexireg.net","msk.ru":"whois.flexireg.net","net.ru":"whois.nic.net.ru","nov.ru":"whois.flexireg.net","org.ru":"whois.nic.net.ru","pp.ru":"whois.nic.net.ru","spb.ru":"whois.flexireg.net",ru:"whois.tcinet.ru",rw:"whois.ricta.org.rw",sa:"whois.nic.net.sa",sb:"whois.nic.net.sb",sc:"whois2.afilias-grs.net",sd:"whois.sdnic.sd",se:"whois.iis.se",sg:"whois.sgnic.sg",sh:"whois.nic.sh",si:"whois.register.si",sk:"whois.sk-nic.sk",sl:"whois.nic.sl",sm:"whois.nic.sm",sn:"whois.nic.sn",so:"whois.nic.so",ss:"whois.nic.ss",st:"whois.nic.st","msk.su":"whois.flexireg.net","nov.su":"whois.flexireg.net","spb.su":"whois.flexireg.net",su:"whois.tcinet.ru",sx:"whois.sx",sy:"whois.tld.sy",tc:"whois.nic.tc",td:"whois.nic.td",tf:"whois.nic.tf",tg:"whois.nic.tg",th:"whois.thnic.co.th",tk:"whois.dot.tk",tl:"whois.nic.tl",tm:"whois.nic.tm",tn:"whois.ati.tn",to:"whois.tonic.to",tr:"whois.trabis.gov.tr",tv:"whois.nic.tv",tw:"whois.twnic.net.tw",tz:"whois.tznic.or.tz","biz.ua":"whois.biz.ua","co.ua":"whois.co.ua","pp.ua":"whois.pp.ua",ua:"whois.ua",ug:"whois.co.ug","ac.uk":"whois.nic.ac.uk","gov.uk":"whois.gov.uk",uk:"whois.nic.uk","fed.us":"whois.nic.gov",us:"whois.nic.us",uy:"whois.nic.org.uy",uz:"whois.cctld.uz",vc:"whois2.afilias-grs.net",ve:"whois.nic.ve",vg:"whois.nic.vg",vu:"whois.dnrs.vu",wf:"whois.nic.wf",ws:"whois.website.ws",yt:"whois.nic.yt","ac.za":"whois.ac.za","co.za":"whois.registry.net.za","gov.za":"whois.gov.za","net.za":"net-whois.registry.net.za","org.za":"org-whois.registry.net.za","web.za":"web-whois.registry.net.za",zm:"whois.zicta.zm","xn--2scrj9c":"whois.registry.in","xn--3e0b707e":"whois.kr","xn--3hcrj9c":"whois.registry.in","xn--45br5cyl":"whois.registry.in","xn--45brj9c":"whois.registry.in","xn--4dbrk0ce":"whois.isoc.org.il","xn--80ao21a":"whois.nic.kz","xn--90a3ac":"whois.rnids.rs","xn--90ae":"whois.imena.bg","xn--90ais":"whois.cctld.by","xn--clchc0ea0b2g2a9gcd":"whois.sgnic.sg","xn--d1alf":"whois.marnet.mk","xn--e1a4c":"whois.eu","xn--fiqs8s":"cwhois.cnnic.cn","xn--fiqz9s":"cwhois.cnnic.cn","xn--fpcrj9c3d":"whois.registry.in","xn--fzc2c9e2c":"whois.nic.lk","xn--gecrj9c":"whois.registry.in","xn--h2breg3eve":"whois.registry.in","xn--h2brj9c8c":"whois.registry.in","xn--h2brj9c":"whois.registry.in","xn--j1amh":"whois.dotukr.com","xn--j6w193g":"whois.hkirc.hk","xn--kprw13d":"whois.twnic.net.tw","xn--kpry57d":"whois.twnic.net.tw","xn--lgbbat1ad8j":"whois.nic.dz","xn--mgb9awbf":"whois.registry.om","xn--mgba3a4f16a":"whois.nic.ir","xn--mgbaam7a8h":"whois.aeda.net.ae","xn--mgbah1a3hjkrd":"whois.nic.mr","xn--mgbbh1a71e":"whois.registry.in","xn--mgbbh1a":"whois.registry.in","xn--mgberp4a5d4ar":"whois.nic.net.sa","xn--mgbgu82a":"whois.registry.in","xn--mgbtx2b":"whois.cmc.iq","xn--mgbx4cd0ab":"whois.mynic.my","xn--node":"whois.itdc.ge","xn--o3cw4h":"whois.thnic.co.th","xn--ogbpf8fl":"whois.tld.sy","xn--p1ai":"whois.tcinet.ru","xn--pgbs0dh":"whois.ati.tn","xn--q7ce6a":"whois.nic.la","xn--qxa6a":"whois.eu","xn--rvc1e0am3e":"whois.registry.in","xn--s9brj9c":"whois.registry.in","xn--wgbh1c":"whois.dotmasr.eg","xn--wgbl6a":"whois.registry.qa","xn--xkc2al3hye2a":"whois.nic.lk","xn--xkc2dl3a5ee0h":"whois.registry.in","xn--y9a3aq":"whois.amnic.net","xn--yfro4i67o":"whois.sgnic.sg","xn--ygbi2ammx":"whois.pnina.ps"};import S from"net";class g{options;constructor(i){this.options=i}static createConnection(i,o){new g(i).connect(o)}connect(i){let o=new S.Socket,{proxy:s,destination:e}=this.options;o.connect({port:s.port,host:s.host},()=>{if(s.type===5)this.connectSocks5(o,i);else this.connectSocks4(o,i)}),o.on("error",(t)=>{i(t)})}connectSocks4(i,o){let{destination:s,proxy:e}=this.options,t=s.port,n=e.userId||"",r;if(this.isIPv4(s.host)){let h=s.host.split(".").map(Number);r=Buffer.from(h)}else r=Buffer.from([0,0,0,1]);let c=Buffer.concat([Buffer.from([4]),Buffer.from([1]),Buffer.from([t>>8&255,t&255]),r,Buffer.from(n),Buffer.from([0])]);if(!this.isIPv4(s.host)){let h=Buffer.concat([c,Buffer.from(s.host),Buffer.from([0])]);i.write(h)}else i.write(c);i.once("data",(h)=>{if(h.length<8){o(Error("Invalid SOCKS4 response"));return}let l=h[1];if(l!==90){o(Error(`SOCKS4 connection failed with status: ${l}`));return}o(null,{socket:i})})}connectSocks5(i,o){let{destination:s,proxy:e}=this.options,t;if(e.userId&&e.password)t=[0,2];else t=[0];let n=Buffer.from([5,t.length,...t]);i.write(n),i.once("data",(r)=>{if(r.length<2||r[0]!==5){o(Error("Invalid SOCKS5 greeting response"));return}let c=r[1];if(c===255){o(Error("No acceptable authentication methods"));return}if(c===2)this.authenticateSocks5(i,o);else this.sendConnectRequest(i,o)})}authenticateSocks5(i,o){let{proxy:s}=this.options,e=s.userId||"",t=s.password||"",n=Buffer.concat([Buffer.from([1]),Buffer.from([e.length]),Buffer.from(e),Buffer.from([t.length]),Buffer.from(t)]);i.write(n),i.once("data",(r)=>{if(r.length<2||r[0]!==1){o(Error("Invalid SOCKS5 auth response"));return}if(r[1]!==0){o(Error("SOCKS5 authentication failed"));return}this.sendConnectRequest(i,o)})}sendConnectRequest(i,o){let{destination:s}=this.options,e=s.port,t,n;if(this.isIPv4(s.host)){n=1;let c=s.host.split(".").map(Number);t=Buffer.from(c)}else if(this.isIPv6(s.host)){n=4;let c=s.host.split(":"),h=[];for(let l of c){let w=Number.parseInt(l,16);h.push(w>>8&255,w&255)}t=Buffer.from(h)}else n=3,t=Buffer.concat([Buffer.from([s.host.length]),Buffer.from(s.host)]);let r=Buffer.concat([Buffer.from([5,1,0,n]),t,Buffer.from([e>>8&255,e&255])]);i.write(r),i.once("data",(c)=>{if(c.length<10||c[0]!==5){o(Error("Invalid SOCKS5 connect response"));return}let h=c[1];if(h!==0){let w=h===void 0?"No SOCKS5 status returned":{1:"General SOCKS server failure",2:"Connection not allowed by ruleset",3:"Network unreachable",4:"Host unreachable",5:"Connection refused",6:"TTL expired",7:"Command not supported",8:"Address type not supported"}[h]||`Unknown error (${h})`;o(Error(`SOCKS5 connection failed: ${w}`));return}o(null,{socket:i})})}isIPv4(i){if(!/^(?:\d{1,3}\.){3}\d{1,3}$/.test(i))return!1;return i.split(".").map(Number).every((e)=>e>=0&&e<=255)}isIPv6(i){return i.includes(":")&&i.split(":").length>=3}}var E;((s)=>{s[s.SOCKS4=0]="SOCKS4";s[s.SOCKS5=1]="SOCKS5"})(E||={});function d(i){if(Array.isArray(i))return i.slice();if(typeof i==="object"&&i!==null){let o={};for(let s in i)if(Object.prototype.hasOwnProperty.call(i,s))o[s]=d(i[s]);return o}return i}async function C(i){let o=y+i;try{let s=await fetch(o);if(s.ok){let t=(await s.text()).match(/whois:\s+(\S+)/);if(t?.[1])return t[1]}}catch(s){console.error("Error in getting WhoIs server data from IANA",s)}return""}function I(i){if(i==="com")return"whois.verisign-grs.com";return p[i]}function v(i){let o=i.split(".");for(let s=o.length-1;s>0;s--){let e=o.slice(s).join(".");if(p[e])return e}return o[o.length-1]}function R(i){return b[i]}class m{static iterParse(i,o){let s="",e=null,t="";for(let n=0;n<i.length;n++){let r=i[n];if(r===`
|
|
3
|
-
`||
|
|
4
|
-
`));else l.write(
|
|
5
|
-
`))}),l.on("data",(a)=>{w(typeof a==="string"?a:r.decode(new Uint8Array(a.buffer,a.byteOffset,a.byteLength)))}),l.on("error",(a)=>{u(a)}),l.on("timeout",()=>{l.destroy(),u(Error(`WHOIS request to ${s}:${e} timed out after 30s`))})}catch(a){u(a)}})}let h={proxy:{host:n.ip,port:n.port,type:n.type===1?5:4},command:"connect",destination:{host:s,port:e}};if(n.username&&n.password)h.proxy.userId=n.username,h.proxy.password=n.password;return new Promise((l,w)=>{g.createConnection(h,(u,a)=>{if(u)w(u);else{if(!a)w(Error("No socket info received!"));if(o!=="")a?.socket.write(
|
|
6
|
-
`));else a?.socket.write(
|
|
7
|
-
`));a?.socket.on("data",(k)=>{l(r.decode(k))}),a?.socket.resume()}})})}async function x(i,o=!1,s=null){let e,
|
|
2
|
+
import z from"net";import{log as f}from"@stacksjs/logging";var y="https://www.iana.org/whois?q=",b={"whois.denic.de":"-T dn,ace","whois.nic.fr":"-V Md5.2"},p={"br.com":"whois.centralnic.net","cn.com":"whois.centralnic.net","de.com":"whois.centralnic.net","eu.com":"whois.centralnic.net","gb.com":"whois.centralnic.net","gb.net":"whois.centralnic.net","gr.com":"whois.centralnic.net","hu.com":"whois.centralnic.net","in.net":"whois.centralnic.net","no.com":"whois.centralnic.net","qc.com":"whois.centralnic.net","ru.com":"whois.centralnic.net","sa.com":"whois.centralnic.net","se.com":"whois.centralnic.net","se.net":"whois.centralnic.net","uk.com":"whois.centralnic.net","uk.net":"whois.centralnic.net","us.com":"whois.centralnic.net","uy.com":"whois.centralnic.net","za.com":"whois.centralnic.net","jpn.com":"whois.centralnic.ne","web.com":"whois.centralnic.ne",com:"whois.verisign-grs.com","za.net":"whois.za.net",net:"whois.verisign-grs.com","eu.org":"whois.eu.org","za.org":"whois.za.org",org:"whois.pir.org","llyw.cymru":"whois.nic.llyw.cymru","gov.scot":"whois.nic.gov.scot","gov.wales":"whois.nic.gov.wales",edu:"whois.educause.edu",gov:"whois.dotgov.gov",int:"whois.iana.org","e164.arpa":"whois.ripe.net",arpa:"whois.iana.org",aero:"whois.aero",asia:"whois.nic.asia",biz:"whois.nic.biz",cat:"whois.nic.cat",coop:"whois.nic.coop",info:"whois.afilias.net",jobs:"whois.nic.jobs",mobi:"whois.afilias.net",museum:"whois.nic.museum",name:"whois.nic.name",post:"whois.dotpostregistry.net",pro:"whois.nic.pro",tel:"whois.nic.tel",travel:"whois.nic.travel",xxx:"whois.nic.xxx",ac:"whois.nic.ac",ae:"whois.aeda.net.ae",af:"whois.nic.af",ag:"whois.nic.ag",ai:"whois.nic.ai",am:"whois.amnic.net",ar:"whois.nic.ar",as:"whois.nic.as","priv.at":"whois.nic.priv.at",at:"whois.nic.at",au:"whois.auda.org.au",aw:"whois.nic.aw",ax:"whois.ax",be:"whois.dns.be",bf:"whois.registre.bf",bg:"whois.register.bg",bh:"whois.nic.bh",bi:"whois1.nic.bi",bj:"whois.nic.bj",bm:"whois.afilias-srs.net",bn:"whois.bnnic.bn",bo:"whois.nic.bo",br:"whois.registro.br",by:"whois.cctld.by",bw:"whois.nic.net.bw",bz:"whois.afilias-grs.info","co.ca":"whois.co.ca",ca:"whois.cira.ca",cc:"ccwhois.verisign-grs.com",cd:"whois.nic.cd",ch:"whois.nic.ch",ci:"whois.nic.ci",cl:"whois.nic.cl",cm:"whois.netcom.cm","edu.cn":"whois.edu.cn",cn:"whois.cnnic.cn","uk.co":"whois.uk.co",co:"whois.nic.co",cr:"whois.nic.cr",cx:"whois.nic.cx",cz:"whois.nic.cz",de:"whois.denic.de",dk:"whois.dk-hostmaster.dk",dm:"whois.dmdomains.dm",do:"whois.nic.do",dz:"whois.nic.dz",ec:"whois.nic.ec",ee:"whois.tld.ee",eu:"whois.eu",fi:"whois.fi",fj:"www.whois.fj",fm:"whois.nic.fm",fo:"whois.nic.fo",fr:"whois.nic.fr",gd:"whois.nic.gd",ge:"whois.nic.ge",gf:"whois.mediaserv.net",gg:"whois.gg",gh:"whois.nic.gh",gi:"whois2.afilias-grs.net",gl:"whois.nic.gl",gp:"whois.nic.gp",gq:"whois.dominio.gq",gs:"whois.nic.gs",gy:"whois.registry.gy",hk:"whois.hkirc.hk",hm:"whois.registry.hm",hn:"whois.nic.hn",hr:"whois.dns.hr",ht:"whois.nic.ht",hu:"whois.nic.hu",id:"whois.id",ie:"whois.weare.ie",il:"whois.isoc.org.il",im:"whois.nic.im",in:"whois.registry.in",io:"whois.nic.io",iq:"whois.cmc.iq",ir:"whois.nic.ir",is:"whois.isnic.is",it:"whois.nic.it",je:"whois.je",jp:"whois.jprs.jp",ke:"whois.kenic.or.ke",kg:"whois.kg",ki:"whois.nic.ki",kn:"whois.nic.kn",kr:"whois.kr",kw:"whois.nic.kw",ky:"whois.kyregistry.ky",kz:"whois.nic.kz",la:"whois.nic.la",lb:"whois.lbdr.org.lb",lc:"whois2.afilias-grs.net",li:"whois.nic.li",lk:"whois.nic.lk",ls:"whois.nic.ls",lt:"whois.domreg.lt",lu:"whois.dns.lu",lv:"whois.nic.lv",ly:"whois.nic.ly",ma:"whois.registre.ma",md:"whois.nic.md",me:"whois.nic.me",mg:"whois.nic.mg",mk:"whois.marnet.mk",ml:"whois.dot.ml",mm:"whois.registry.gov.mm",mn:"whois.nic.mn",mq:"whois.mediaserv.net",mr:"whois.nic.mr",ms:"whois.nic.ms",mt:"whois.nic.org.mt",mu:"whois.nic.mu",mw:"whois.nic.mw",mx:"whois.mx",my:"whois.mynic.my",mz:"whois.nic.mz",na:"whois.na-nic.com.na",nc:"whois.nc",nf:"whois.nic.nf",ng:"whois.nic.net.ng",nl:"whois.domain-registry.nl",no:"whois.norid.no",nu:"whois.iis.nu",nz:"whois.irs.net.nz",om:"whois.registry.om",pe:"kero.yachay.pe",pf:"whois.registry.pf",pk:"whois.pknic.net.pk","co.pl":"whois.co.pl",pl:"whois.dns.pl",pm:"whois.nic.pm",pr:"whois.afilias-srs.net",ps:"whois.pnina.ps",pt:"whois.dns.pt",pw:"whois.nic.pw",qa:"whois.registry.qa",re:"whois.nic.re",ro:"whois.rotld.ro",rs:"whois.rnids.rs","ac.ru":"whois.free.net","edu.ru":"whois.informika.ru","com.ru":"whois.flexireg.net","msk.ru":"whois.flexireg.net","net.ru":"whois.nic.net.ru","nov.ru":"whois.flexireg.net","org.ru":"whois.nic.net.ru","pp.ru":"whois.nic.net.ru","spb.ru":"whois.flexireg.net",ru:"whois.tcinet.ru",rw:"whois.ricta.org.rw",sa:"whois.nic.net.sa",sb:"whois.nic.net.sb",sc:"whois2.afilias-grs.net",sd:"whois.sdnic.sd",se:"whois.iis.se",sg:"whois.sgnic.sg",sh:"whois.nic.sh",si:"whois.register.si",sk:"whois.sk-nic.sk",sl:"whois.nic.sl",sm:"whois.nic.sm",sn:"whois.nic.sn",so:"whois.nic.so",ss:"whois.nic.ss",st:"whois.nic.st","msk.su":"whois.flexireg.net","nov.su":"whois.flexireg.net","spb.su":"whois.flexireg.net",su:"whois.tcinet.ru",sx:"whois.sx",sy:"whois.tld.sy",tc:"whois.nic.tc",td:"whois.nic.td",tf:"whois.nic.tf",tg:"whois.nic.tg",th:"whois.thnic.co.th",tk:"whois.dot.tk",tl:"whois.nic.tl",tm:"whois.nic.tm",tn:"whois.ati.tn",to:"whois.tonic.to",tr:"whois.trabis.gov.tr",tv:"whois.nic.tv",tw:"whois.twnic.net.tw",tz:"whois.tznic.or.tz","biz.ua":"whois.biz.ua","co.ua":"whois.co.ua","pp.ua":"whois.pp.ua",ua:"whois.ua",ug:"whois.co.ug","ac.uk":"whois.nic.ac.uk","gov.uk":"whois.gov.uk",uk:"whois.nic.uk","fed.us":"whois.nic.gov",us:"whois.nic.us",uy:"whois.nic.org.uy",uz:"whois.cctld.uz",vc:"whois2.afilias-grs.net",ve:"whois.nic.ve",vg:"whois.nic.vg",vu:"whois.dnrs.vu",wf:"whois.nic.wf",ws:"whois.website.ws",yt:"whois.nic.yt","ac.za":"whois.ac.za","co.za":"whois.registry.net.za","gov.za":"whois.gov.za","net.za":"net-whois.registry.net.za","org.za":"org-whois.registry.net.za","web.za":"web-whois.registry.net.za",zm:"whois.zicta.zm","xn--2scrj9c":"whois.registry.in","xn--3e0b707e":"whois.kr","xn--3hcrj9c":"whois.registry.in","xn--45br5cyl":"whois.registry.in","xn--45brj9c":"whois.registry.in","xn--4dbrk0ce":"whois.isoc.org.il","xn--80ao21a":"whois.nic.kz","xn--90a3ac":"whois.rnids.rs","xn--90ae":"whois.imena.bg","xn--90ais":"whois.cctld.by","xn--clchc0ea0b2g2a9gcd":"whois.sgnic.sg","xn--d1alf":"whois.marnet.mk","xn--e1a4c":"whois.eu","xn--fiqs8s":"cwhois.cnnic.cn","xn--fiqz9s":"cwhois.cnnic.cn","xn--fpcrj9c3d":"whois.registry.in","xn--fzc2c9e2c":"whois.nic.lk","xn--gecrj9c":"whois.registry.in","xn--h2breg3eve":"whois.registry.in","xn--h2brj9c8c":"whois.registry.in","xn--h2brj9c":"whois.registry.in","xn--j1amh":"whois.dotukr.com","xn--j6w193g":"whois.hkirc.hk","xn--kprw13d":"whois.twnic.net.tw","xn--kpry57d":"whois.twnic.net.tw","xn--lgbbat1ad8j":"whois.nic.dz","xn--mgb9awbf":"whois.registry.om","xn--mgba3a4f16a":"whois.nic.ir","xn--mgbaam7a8h":"whois.aeda.net.ae","xn--mgbah1a3hjkrd":"whois.nic.mr","xn--mgbbh1a71e":"whois.registry.in","xn--mgbbh1a":"whois.registry.in","xn--mgberp4a5d4ar":"whois.nic.net.sa","xn--mgbgu82a":"whois.registry.in","xn--mgbtx2b":"whois.cmc.iq","xn--mgbx4cd0ab":"whois.mynic.my","xn--node":"whois.itdc.ge","xn--o3cw4h":"whois.thnic.co.th","xn--ogbpf8fl":"whois.tld.sy","xn--p1ai":"whois.tcinet.ru","xn--pgbs0dh":"whois.ati.tn","xn--q7ce6a":"whois.nic.la","xn--qxa6a":"whois.eu","xn--rvc1e0am3e":"whois.registry.in","xn--s9brj9c":"whois.registry.in","xn--wgbh1c":"whois.dotmasr.eg","xn--wgbl6a":"whois.registry.qa","xn--xkc2al3hye2a":"whois.nic.lk","xn--xkc2dl3a5ee0h":"whois.registry.in","xn--y9a3aq":"whois.amnic.net","xn--yfro4i67o":"whois.sgnic.sg","xn--ygbi2ammx":"whois.pnina.ps"};import S from"net";class g{options;constructor(i){this.options=i}static createConnection(i,o){new g(i).connect(o)}connect(i){let o=new S.Socket,{proxy:s,destination:e}=this.options;o.connect({port:s.port,host:s.host},()=>{if(s.type===5)this.connectSocks5(o,i);else this.connectSocks4(o,i)}),o.on("error",(c)=>{i(c)})}connectSocks4(i,o){let{destination:s,proxy:e}=this.options,c=s.port,n=e.userId||"",r;if(this.isIPv4(s.host)){let h=s.host.split(".").map(Number);r=Buffer.from(h)}else r=Buffer.from([0,0,0,1]);let t=Buffer.concat([Buffer.from([4]),Buffer.from([1]),Buffer.from([c>>8&255,c&255]),r,Buffer.from(n),Buffer.from([0])]);if(!this.isIPv4(s.host)){let h=Buffer.concat([t,Buffer.from(s.host),Buffer.from([0])]);i.write(h)}else i.write(t);i.once("data",(h)=>{if(h.length<8){o(Error("Invalid SOCKS4 response"));return}let l=h[1];if(l!==90){o(Error(`SOCKS4 connection failed with status: ${l}`));return}o(null,{socket:i})})}connectSocks5(i,o){let{destination:s,proxy:e}=this.options,c;if(e.userId&&e.password)c=[0,2];else c=[0];let n=Buffer.from([5,c.length,...c]);i.write(n),i.once("data",(r)=>{if(r.length<2||r[0]!==5){o(Error("Invalid SOCKS5 greeting response"));return}let t=r[1];if(t===255){o(Error("No acceptable authentication methods"));return}if(t===2)this.authenticateSocks5(i,o);else this.sendConnectRequest(i,o)})}authenticateSocks5(i,o){let{proxy:s}=this.options,e=s.userId||"",c=s.password||"",n=Buffer.concat([Buffer.from([1]),Buffer.from([e.length]),Buffer.from(e),Buffer.from([c.length]),Buffer.from(c)]);i.write(n),i.once("data",(r)=>{if(r.length<2||r[0]!==1){o(Error("Invalid SOCKS5 auth response"));return}if(r[1]!==0){o(Error("SOCKS5 authentication failed"));return}this.sendConnectRequest(i,o)})}sendConnectRequest(i,o){let{destination:s}=this.options,e=s.port,c,n;if(this.isIPv4(s.host)){n=1;let t=s.host.split(".").map(Number);c=Buffer.from(t)}else if(this.isIPv6(s.host)){n=4;let t=s.host.split(":"),h=[];for(let l of t){let w=Number.parseInt(l,16);h.push(w>>8&255,w&255)}c=Buffer.from(h)}else n=3,c=Buffer.concat([Buffer.from([s.host.length]),Buffer.from(s.host)]);let r=Buffer.concat([Buffer.from([5,1,0,n]),c,Buffer.from([e>>8&255,e&255])]);i.write(r),i.once("data",(t)=>{if(t.length<10||t[0]!==5){o(Error("Invalid SOCKS5 connect response"));return}let h=t[1];if(h!==0){let w=h===void 0?"No SOCKS5 status returned":{1:"General SOCKS server failure",2:"Connection not allowed by ruleset",3:"Network unreachable",4:"Host unreachable",5:"Connection refused",6:"TTL expired",7:"Command not supported",8:"Address type not supported"}[h]||`Unknown error (${h})`;o(Error(`SOCKS5 connection failed: ${w}`));return}o(null,{socket:i})})}isIPv4(i){if(!/^(?:\d{1,3}\.){3}\d{1,3}$/.test(i))return!1;return i.split(".").map(Number).every((e)=>e>=0&&e<=255)}isIPv6(i){return i.includes(":")&&i.split(":").length>=3}}var E;((s)=>{s[s.SOCKS4=0]="SOCKS4";s[s.SOCKS5=1]="SOCKS5"})(E||={});function d(i){if(Array.isArray(i))return i.slice();if(typeof i==="object"&&i!==null){let o={};for(let s in i)if(Object.prototype.hasOwnProperty.call(i,s))o[s]=d(i[s]);return o}return i}async function C(i){let o=y+i;try{let s=await fetch(o);if(s.ok)return I(await s.text())}catch(s){console.error("Error in getting WhoIs server data from IANA",s)}return""}function I(i){return i.match(/^whois:\s+(\S+)/m)?.[1]??""}function R(i){if(i==="com")return"whois.verisign-grs.com";return p[i]}function v(i){let o=i.split(".");for(let s=o.length-1;s>0;s--){let e=o.slice(s).join(".");if(p[e])return e}return o[o.length-1]}function O(i){return b[i]}class m{static iterParse(i,o){let s="",e=null,c="";for(let n=0;n<i.length;n++){let r=i[n];if(r===`
|
|
3
|
+
`||c===":"&&r===" "){if(s.trim()in o)e=s.trim();else if(e!==null){let t=s.trim();if(t!==""){let h=o[e];if(Array.isArray(h))h.push(t);else o[e]=t;e=null}}s=""}else if(r!==":")s=s+r;if(c=r,s==="Record maintained by"||s===">>>")break}return o}static parseData(i,o){if(!o)o={"Domain Name":"","Creation Date":"","Updated Date":"","Registry Expiry Date":"","Domain Status":[],Registrar:""};return o=m.iterParse(i,o),o}}async function B(i,o,s,e,c,n){let r=new TextDecoder(c),t=new TextEncoder;if(!n){let l=new z.Socket;return l.setTimeout(30000),new Promise((w,u)=>{try{l.connect({port:e,host:s},()=>{if(o!=="")l.write(t.encode(`${o} ${i}\r
|
|
4
|
+
`));else l.write(t.encode(`${i}\r
|
|
5
|
+
`))}),l.on("data",(a)=>{w(typeof a==="string"?a:r.decode(new Uint8Array(a.buffer,a.byteOffset,a.byteLength)))}),l.on("error",(a)=>{u(a)}),l.on("timeout",()=>{l.destroy(),u(Error(`WHOIS request to ${s}:${e} timed out after 30s`))})}catch(a){u(a)}})}let h={proxy:{host:n.ip,port:n.port,type:n.type===1?5:4},command:"connect",destination:{host:s,port:e}};if(n.username&&n.password)h.proxy.userId=n.username,h.proxy.password=n.password;return new Promise((l,w)=>{g.createConnection(h,(u,a)=>{if(u)w(u);else{if(!a)w(Error("No socket info received!"));if(o!=="")a?.socket.write(t.encode(`${o} ${i}\r
|
|
6
|
+
`));else a?.socket.write(t.encode(`${i}\r
|
|
7
|
+
`));a?.socket.on("data",(k)=>{l(r.decode(k))}),a?.socket.resume()}})})}async function x(i,o=!1,s=null){let e,c=43,n="",r,t="utf-8";if(!s)e=v(i),r=null;else e=s.tld?s.tld:v(i),t=s.encoding?s.encoding:"utf-8",r=s.proxy?s.proxy:null,n=s.server?s.server:"",c=s.serverPort?s.serverPort:43;if(n===""){let w=R(e);if(!w){if(f.debug(`No WhoIs server found for TLD: ${e}! Attempting IANA WhoIs database for server!`),w=await C(e),!w)return f.debug("WhoIs server could not be found!"),{_raw:"",parsedData:null};f.debug(`WhoIs sever found for ${e}: ${n}`)}n=w}let l=O(n)||"";try{f.debug(`Attempting WHOIS lookup for ${i} on server ${n}`);let w=await B(i,l,n,c,t,r);if(f.debug("Raw WHOIS data received:",w),!o){let a=m.parseData(w,null);return{_raw:w,parsedData:a}}let u=null;if(s?.parseData)u=d(s.parseData);try{let a=m.parseData(w,u);return{_raw:w,parsedData:a}}catch(a){return console.error("Error in parsing WhoIs data!",a),{_raw:w,parsedData:null}}}catch(w){return f.debug(`Error in WHOIS lookup for ${i} on server ${n}`,w),{_raw:"",parsedData:null}}}function _(i,o=null){return f.debug(`Lookup called for ${i}`),x(i,!0,o)}async function L(i,o=!1,s=1,e=!1,c=null){let n=[];if(o){if(s>i.length)s=i.length;for(let r=0;r<i.length;r+=s){let t=i.slice(r,r+s),h=await Promise.all(t.map(async(l)=>await x(l,e,c)));n.push(...h)}}else for(let r=0;r<i.length;r++){let t=await x(i[r],e,c);n.push(t)}return n}export{y as IANA_CHK_URL,b as PARAMETERS,E as ProxyType,p as SERVERS,g as SocksClient,m as WhoIsParser,L as batchWhois,C as findWhoIsServer,O as getParameters,v as getTLD,R as getWhoIsServer,_ as lookup,I as parseIanaWhoisServer,B as tcpWhois,x as whois};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/whois",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.74.
|
|
5
|
+
"version": "0.74.35",
|
|
6
6
|
"description": "Easily get whois info.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"prepublishOnly": "bun run build"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@stacksjs/logging": "0.74.
|
|
63
|
+
"@stacksjs/logging": "0.74.35"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"better-dx": "^0.2.24"
|