9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] iwhois(1) patch
@ 2021-05-08 14:48 gall0ws
  2021-05-09 13:19 ` cinap_lenrek
  0 siblings, 1 reply; 2+ messages in thread
From: gall0ws @ 2021-05-08 14:48 UTC (permalink / raw)
  To: 9front

It's impossible to get whois right and probably nobody cares about it,
nevertheless this small patch fixes some issues with the current version:

* use a more common filter for default boilerplate (useful when
  following the referral chain)
* updated boilerplate for *.co.uk *.net.uk *.org.uk
* added case *.com *.net (got it from iana.org)
* use ARIN for IPv6 addresses
* when unsure, check first whether whois.nic.$tld exists otherwise
  usual fallback to InterNIC
* fixed regexp for the referral chain (case, extra spaces or /)


diff -r 9f569a2f16eb rc/bin/iwhois
--- a/rc/bin/iwhois	Wed May 05 16:57:19 2021 +0200
+++ b/rc/bin/iwhois	Sat May 08 14:54:32 2021 +0200
@@ -7,7 +7,7 @@
 	shift
 }
 person=`{echo $1|sed s/@.*//}
-fn boilerplate { sed -n '/^[	 ]*[A-Za-z][A-Za-z]*:$/,$p' $* }
+fn boilerplate { sed '/>>> ?Last update of ..... database:/,$d' $* }
 
 switch($1){
 case *@*
@@ -20,7 +20,7 @@
 	fn boilerplate { sed '/^>* Whois database was last updated on/,$d' $* }
 case *.co.uk *.net.uk *.org.uk
 	machine=whois.nic.uk
-	fn boilerplate { sed '/^ +WHOIS database last updated at/,$d' $* }
+	fn boilerplate { sed '/^-- /,$d' $* }
 case *.ac.uk
 	machine=whois.ja.net
 case *.au
@@ -30,6 +30,8 @@
 	machine=whois.dns.be
 	person='-T dn '^$person
 	fn boilerplate { cat $* }
+case *.com *.net
+	machine=whois.verisign-grs.com
 case *.cn
 	machine=whois.cnnic.net.cn
 	fn boilerplate { cat $* }
@@ -55,16 +57,20 @@
 	fn boilerplate { cat $* }
 case *.org
 	machine=whois.pir.org
-	fn boilerplate { sed '/^>>> Last update of WHOIS database/,$d' $* }
 case *.se
 	machine=whois.nic-se.se
 	fn boilerplate { grep -v '^#' $* | uniq }
-case [0-9]*.[0-9]*.[0-9]*.[0-9]*
+case [0-9]*.[0-9]*.[0-9]*.[0-9]* *:*:*
 	machine=whois.arin.net
 	fn boilerplate { cat $* }
 case *
-	machine=whois.internic.net	# alternate: whois.networksolutions.com
-	fn boilerplate { cat $* }
+	tld=`{echo $1 | sed 's;.*\.(.*)$;\1;'}
+	if(ndb/dnsgetip whois.nic.$tld >/dev/null >[2=1])
+		machine=whois.nic.$tld
+	if not{
+		machine=whois.internic.net	# alternate: whois.networksolutions.com
+		fn boilerplate { cat $* }
+	}
 }
 if(! ~ $#noboiler 0)
 	fn boilerplate { cat $* }
@@ -73,8 +79,8 @@
 	rm -f $file
 }
 echo $person | telnet -nr tcp!$machine!whois > $file
-x=`{ sed -n -e 's/.*Whois Server: (.*)/\1/p' \
-	-e 's;.*ReferralServer: whois://(.*)(:43)?;\1;p' $file }
+x=`{ tr A-Z a-z < $file | sed -n -e 's;.*whois server: ([^ /]+).*$;\1;p' \
+	-e 's;.*referralserver: +whois://(.*)(:43)?;\1;p'}
 switch($#x){
 case 0
 	;			# e.g., for .ca



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-09 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08 14:48 [9front] iwhois(1) patch gall0ws
2021-05-09 13:19 ` cinap_lenrek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).