WHOIS server: display email addresses, if the user has given permission

This commit is contained in:
Al Beano 2017-10-03 22:07:36 +01:00
parent 23587a410e
commit 0e7e3c1653
1 changed files with 7 additions and 2 deletions

View File

@ -41,6 +41,10 @@ $listener.tap( -> $conn {
$sth.execute($q);
my $data = $sth.row(:hash);
$sth = $dbh.prepare("select * from user where id = ?");
$sth.execute($data.{"ownerid"});
my $user = $sth.row(:hash);
if (!$data) {
await $conn.write: "$q.$tld is not recognised by this WHOIS server.\n".encode("utf-8");
log("Domain not known; connection closed");
@ -50,7 +54,9 @@ $listener.tap( -> $conn {
my $regdate = DateTime.new($data.{"since"});
my $regurl = $config.{"whoissrv"}.{"registrar-urls"};
my $email_display = $user.{"email_pub"} == 1 ?? $user.{"email"} !! "< withheld >";
# TODO: registrant name?
await $conn.write: qq:heredoc/end/.encode("UTF-8");
Domain: $q.$tld
Domain Registered: $regdate
@ -59,8 +65,7 @@ $listener.tap( -> $conn {
Domain Status: ACTIVE
Registrar URL(s): $regurl
Registrant Name: < withheld >
Registrant Email: < withheld >
Registrant Email: $email_display
end
$conn.close;