Added len argument.

This commit is contained in:
Bradley M. Kuhn 2010-06-27 12:12:10 -04:00
parent 829bc7ef12
commit b294b91450

View file

@ -21,10 +21,10 @@ use warnings;
use Net::WhoisNG; use Net::WhoisNG;
if (@ARGV != 2) { if (@ARGV != 3) {
print STDERR "usage: $0 <TLD> <CACHE_FILE>\n"; print STDERR "usage: $0 <TLD> <LEN> <CACHE_FILE>\n";
} }
my($TLD, $CACHE_FILE) = @ARGV; my($TLD, $LENGTH, $CACHE_FILE) = @ARGV;
my %cache; my %cache;
@ -36,25 +36,43 @@ while (my $line = <CACHE>) {
unless $line =~ /^\s*(\S+)\s*\:\s*((?:available|expires:\s*\S+))/; unless $line =~ /^\s*(\S+)\s*\:\s*((?:available|expires:\s*\S+))/;
$cache{$1} = $2; $cache{$1} = $2;
} }
close CACHE;
foreach my $let1 ('a' .. 'z', '0' .. '9') { sub CheckDomain ($$$) {
foreach my $let2 ('a' .. 'z', '0' .. '9', '-') { my($let1, $let2, $let3) = @ARGV;
foreach my $let3 ('a' .. 'z', '0' .. '9') {
my $domain = "$let1$let2$let3" . "." . $TLD;
next if defined $cache{$domain};
my $w = new Net::WhoisNG($domain); my $domain = "$let1$let2$let3" . "." . $TLD;
if(!$w->lookUp()){ next if defined $cache{$domain};
print "$domain is not in use\n";
} else { my $w = new Net::WhoisNG($domain);
my $exp_date=$w->getExpirationDate(); if(!$w->lookUp()){
if (not defined $exp_date) { print "$domain is not in use\n";
print "$domain: available\n"; } else {
} my $exp_date=$w->getExpirationDate();
else { if (not defined $exp_date) {
print "$domain: expires: $exp_date\n"; print "$domain: available\n";
} }
} else {
print "$domain: expires: $exp_date\n";
} }
} }
} }
if ($LENGTH == 3) {
foreach my $let1 ('a' .. 'z', '0' .. '9') {
foreach my $let2 ('a' .. 'z', '0' .. '9', '-') {
foreach my $let3 ('a' .. 'z', '0' .. '9') {
CheckDomain($let1, $let2, $let3);
}
}
}
} elsif ($LENGTH == 2) {
foreach my $let1 ('a' .. 'z', '0' .. '9') {
foreach my $let2 ('a' .. 'z', '0' .. '9') {
CheckDomain("", $let1, $let2);
}
} else {
print STDERR "domain length of $LENGTH is unsupported\n";
exit 1;
}
}