'
' Simple implementation of the WHOIS protocol.
'
' Can lookup most used TLD's. November 2010, PvE - GPL.
'
'-------------------------------------------------------------------
SPLIT ARGUMENT$ BY " " TO arg$ SIZE dim
IF dim < 2 THEN
PRINT NL$, "Usage: whois <domain>"
PRINT
PRINT "Examples:"
PRINT TAB$(1), "whois linux.org"
PRINT TAB$(1), "whois amazon.com"
PRINT
END
ENDIF
domain$ = arg$[1]
tld$ = MID$(domain$, INSTRREV(domain$, "."))
info$ = ""
SELECT tld$
CASE ".org"
server$ = "whois.pir.org:43"
CASE ".net";
CASE ".edu";
CASE ".com"
server$ = "whois.verisign-grs.net:43"
CASE ".mobi"
server$ = "whois.dotmobiregistry.net:43"
CASE ".pro"
server$ = "whois.registrypro.pro:43"
CASE ".name"
server$ = "whois.nic.name:43"
CASE ".biz"
server$ = "whois.pacificroot.com:43"
CASE ".aero"
server$ = "whois.information.aero:43"
CASE ".info"
server$ = "whois.afilias.info:43"
CASE ".coop"
server$ = "whois.nic.coop:43"
CASE ".us"
server$ = "whois.us:43"
CASE ".ca"
server$ = "whois.cira.ca:43"
CASE ".eu"
server$ = "whois.eu:43"
CASE ".nl"
server$ = "whois.domain-registry.nl:43"
CASE ".de"
server$ = "whois.denic.de:43"
CASE ".uk"
server$ = "whois.nic.uk:43"
CASE ".ws"
server$ = "whois.nic.ws:43"
CASE ".in"
server$ = "whois.inregistry.net:43"
CASE ".nu"
server$ = "whois.nic.nu:43"
CASE ".tv"
server$ = "tvwhois.verisign-grs.com:43"
DEFAULT
PRINT "Sorry, cannot lookup domain '", domain$, "'!"
END
END SELECT
OPEN server$ FOR NETWORK AS connection
SEND CONCAT$(domain$, "\r\n") TO connection
REPEAT
RECEIVE data$ FROM connection
info$ = CONCAT$(info$, data$)
UNTIL ISFALSE(WAIT(connection, 500)) OR LEN(data$) IS 0
CLOSE NETWORK connection
PRINT info$