WHOIS server: inform users if a domain is reserved

This commit is contained in:
Al Beano 2017-09-27 20:04:59 +01:00
parent c0906f3880
commit 9fd09b34bf
1 changed files with 8 additions and 1 deletions

View File

@ -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);