From 9fd09b34bfd3d915bbcdc9ffc85bbf651318458f Mon Sep 17 00:00:00 2001 From: Al Beano Date: Wed, 27 Sep 2017 20:04:59 +0100 Subject: [PATCH] WHOIS server: inform users if a domain is reserved --- whoissrv/whoissrv.pl6 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/whoissrv/whoissrv.pl6 b/whoissrv/whoissrv.pl6 index bff0a5c..1ce3620 100755 --- a/whoissrv/whoissrv.pl6 +++ b/whoissrv/whoissrv.pl6 @@ -20,6 +20,8 @@ $listener.tap( -> $conn { log "Query: $q"; await $conn.write: ($motd~"\n").encode("utf-8"); + $q = $q.lc; + my $tld = $config.{"tld"}; if ($q !~~ m/\.$tld$/) { await $conn.write: "This WHOIS server does not provide data for that TLD.\n".encode("utf-8"); @@ -28,7 +30,12 @@ $listener.tap( -> $conn { next; } $q ~~ s/\.$tld$//; - $q = $q.lc; + if ($config.{'reserved_domains'}.Set{$q}) { + await $conn.write: "$q.$tld is reserved for use by the registry.".encode("utf-8"); + log("Domain reserved"); + $conn.close; + next; + } my $sth = $dbh.prepare("select * from domain where name = ?"); $sth.execute($q);