| 1 | #!/usr/bin/env perl | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use NOLookup::DAS::DASLookup; | ||
| 6 | use Encode; | ||
| 7 | use vars qw($opt_q $opt_v $opt_h $opt_s $opt_p); | ||
| 8 | use Getopt::Std; | ||
| 9 | use Pod::Usage; | ||
| 10 | |||
| 11 | use Data::Dumper; | ||
| 12 | $Data::Dumper::Indent=1; | ||
| 13 | |||
| 14 | &getopts('hvq:s:p:'); # q:query, v=verbose dump | ||
| 15 | |||
| 16 | if ($opt_h) { | ||
| 17 | pod2usage(); | ||
| 18 | } | ||
| 19 | |||
| 20 | unless ($opt_q) { | ||
| 21 | pod2usage("A query must be specified!\n"); | ||
| 22 | } | ||
| 23 | |||
| 24 | my $q = decode('UTF-8', $opt_q); | ||
| 25 | |||
| 26 | my $SERVER = $opt_s || 'finger.norid.no'; | ||
| 27 | my $PORT = $opt_p || 79; | ||
| 28 | |||
| 29 | my $das = NOLookup::DAS::DASLookup->new($q, $SERVER, $PORT); | ||
| 30 | |||
| 31 | if ($das->errno) { | ||
| 32 | print STDERR "Error : ", $das->errno, "\n"; | ||
| 33 | if ($das->raw_text) { | ||
| 34 | print STDERR "Raw text: ", encode('UTF-8', $das->raw_text), "\n"; | ||
| 35 | } | ||
| 36 | |||
| 37 | } elsif ($das->available) { | ||
| 38 | print "Domain is available and can be registered\n"; | ||
| 39 | |||
| 40 | } elsif ($das->delegated) { | ||
| 41 | print "Domain is not available because it is already registered\n"; | ||
| 42 | |||
| 43 | } elsif ($das->prohibited) { | ||
| 44 | print "Domain cannot be registered due to local registry policy\n"; | ||
| 45 | |||
| 46 | } elsif ($das->invalid) { | ||
| 47 | print "Domain or zone is invalid\n"; | ||
| 48 | } | ||
| 49 | |||
| 50 | if ($opt_v) { | ||
| 51 | print "DAS raw data: ", encode('UTF-8', $das->raw_text), "\n"; | ||
| 52 | } | ||
| 53 | |||
| 54 | =pod | ||
| 55 | |||
| 56 | =head1 NAME | ||
| 57 | |||
| 58 | no_das.pl | ||
| 59 | |||
| 60 | =head1 DESCRIPTION | ||
| 61 | |||
| 62 | Uses NOLookup::DAS::DASLookup to perform lookup on a domain name | ||
| 63 | to check the domain availabilty status. | ||
| 64 | |||
| 65 | =head1 USAGE | ||
| 66 | |||
| 67 | no_das.pl [hvq:] <querystring> | ||
| 68 | |||
| 69 | Arguments: | ||
| 70 | |||
| 71 | -q: query string, must be a .no domain name | ||
| 72 | -v: verbose dump of the returned raw DAS response | ||
| 73 | -h: this help | ||
| 74 | |||
| 75 | Examples: | ||
| 76 | |||
| 77 | Check if 'norid.no' is available: | ||
| 78 | no_das.pl -q norid.no | ||
| 79 | |||
| 80 | Check if 'norid.no' is available, -v set to see raw response: | ||
| 81 | no_das.pl -q norid.no -v | ||
| 82 | |||
| 83 | =cut | ||
| 84 | |||
| 85 | 1; | ||
| 86 | |||
| 87 |