Rand Stats

Net::Whois::Async

zef:Zer0-Tolerance

Net::Whois::Async

Asynchronous Raku interface to the Whois service using IO::Socket::Async.

Installation

zef install Net::Whois::Async

Quick Start

use Net::Whois::Async;

my $w = Net::Whois::Async.new;

# Parsed key/value Hash
my %info = await $w.query('example.com', 'whois.iana.org');
say %info<domain>;

# Raw lines
my @lines = await $w.query('example.com', 'whois.iana.org', :raw);
.say for @lines;

# Query several servers concurrently
my %multi = await $w.query('example.com', 'whois.iana.org', 'whois.verisign-grs.com');
say %multi<whois.iana.org><domain>;

API Reference

Net::Whois::Async.new()

Constructor. Takes no arguments.


multi method query(Str:D $who, Str:D $server, Bool :$raw! --> Promise)

Query a single Whois server and return a Promise that resolves to a List of raw response lines (one per element, no stripping of comments).

Parameters

NameTypeDescription
$whoStr (IP or Domain)The IP address or domain name to look up
$serverStrWhois server hostname
:rawBool (required)Must be passed to select this candidate

Returns PromiseList[Str]

my @lines = await $w.query('93.184.216.34', 'whois.arin.net', :raw);

multi method query(Str:D $who, Str:D $server, Bool :$multiple = False --> Promise)

Query a single Whois server and return a Promise that resolves to a Hash of parsed key/value pairs.

Comment lines starting with % or # are skipped. If the response contains a ReferralServer: whois://... field, that server is queried automatically and its result is returned instead.

Parameters

NameTypeDescription
$whoStr (IP or Domain)The IP address or domain name to look up
$serverStrWhois server hostname
:multipleBoolWhen True, duplicate keys are concatenated with a space

Returns PromiseHash[Str,Str]

my %h = await $w.query('example.com', 'whois.iana.org');
say %h<domain>;        # example.com

my %m = await $w.query('example.com', 'whois.iana.org', :multiple);
say %m<nserver>;       # all nameservers concatenated

multi method query(Str:D $who, *@servers, Bool :$multiple = False, Bool :$raw = False --> Promise)

Query multiple Whois servers concurrently and return a Promise that resolves to a Hash keyed by server hostname.

Parameters

NameTypeDescription
$whoStr (IP or Domain)The IP address or domain name to look up
*@serversList[Str]Two or more Whois server hostnames
:multipleBoolPassed through to the per-server parsed query
:rawBoolWhen True, each value is a List of raw lines

Returns PromiseHash where each value is either a Hash (default) or a List (:raw)

my %r = await $w.query('example.com',
                        'whois.iana.org',
                        'whois.verisign-grs.com',
                        :raw);
say %r<whois.iana.org>.elems;

Exported subsets

NameMatches
IPA valid dotted-quad IPv4 address (each octet 0–255)
DomainA syntactically valid domain name (≤ 253 chars, LDH labels)
use Net::Whois::Async;

say '1.2.3.4'      ~~ IP;      # True
say '256.0.0.0'    ~~ IP;      # False
say 'example.com'  ~~ Domain;  # True

Error Handling

my %info = try { await $w.query('example.com', 'whois.iana.org') };
if $! { say "Query failed: $!" }

License

Artistic-2.0 — Copyright 2026 Zer0-Tolerance