Morton Fox (mortonfox) wrote,
Morton Fox
mortonfox

  • Mood:
  • Music:

Who wants aa0.net?

Back in the year 2000, I was interested in acquiring some short domain names so I wrote a Perl script to search Internic domain space. I found two consecutive unregistered domains, qslv.com and qslw.com, and so I registered them. Back then, I pointed the two domains to a simple webpage containing links to the websites I used most frequently. My reasoning was with PDA browsers, public net terminals, cell phones and other devices where character input is slow or tedious, it would be easier to enter a short URL and then follow a link than to enter the website URLs themselves.

I think that idea still has merit so I may set up those domains again one day.

Anyway, I was curious to see how many short domain names are still available so I updated the script. The rules have changed a little. Queries for .org domains now have to go to PIR instead of Internic.


#!perl -w
#
# Search for unregistered domains.
#
# Usage: perl searchdom.pl <where to start searching>
#
# e.g. perl searchdom.pl aaa
# will check aaa.com/net/org, aab.com/net/org, aac.com/net/org, and so on
#
# The search string cycles from 'a' to 'z' and then from '0' to '9'.

use strict;
use IO::Socket;
use IO::File;
use Carp;

BEGIN {
    my $pir_addr;
    my $nic_addr;

    sub getaddr {
	my $name = shift;
	my $a = gethostbyname $name 
	    or croak "Can't get address of server $name: $!\n";
	inet_ntoa($a);
    }

    # Query the domain registry. For now, it only uses PIR for .org and
    # Internic for .com and .net.
    sub whois {
	my $dom = shift;
	my $server_addr = ($dom =~ /\.org$/i) ? $pir_addr : $nic_addr;

	my $sock = IO::Socket::INET->new(PeerAddr => $server_addr,
					 PeerPort => 'whois',
					 Proto => 'tcp')
	    or croak "Can't connect to $server_addr: $@";
	$sock->autoflush;

	print $sock "$dom\x0d\x0a";
	my $out;
	{
	    local $/; $out = <$sock>;
	}
	$out or croak "No data returned from server";
    }
    
    $pir_addr = getaddr 'whois.publicinterestregistry.net';
    $nic_addr = getaddr 'whois.internic.net';
}

# Cycle through all the letters and digits. Returns the next character
# after this one.
sub incrchar {
    my $c = shift;

    if (ord($c) >= ord('a') and ord($c) < ord('z')) {
	$c = chr(ord($c) + 1);
    }
    elsif ($c eq 'z') {
	$c = '0';
    }
    elsif (ord($c) >= ord('0') and ord($c) < ord('9')) {
	$c = chr(ord($c) + 1);
    }
    elsif ($c eq '9') {
	$c = 'a';
    }
    $c;
}

# Increments a string with "carry".
sub increment {
    my $index;
    my $str = shift;

    for ($index = length($$str) - 1; $index >= 0; --$index) {
	my $c = substr($$str, $index, 1);
	$c = incrchar $c;
	substr($$str, $index, 1) = $c;
	# If incrchar has wrapped back to 'a', we have to carry one to the
	# character to the left.
	last if $c ne 'a';
    }
    return undef if $index < 0;
    1;
}

my $str = 'aaa';
if (@ARGV) {
    $str = lc shift;
}

do {
    for my $tld ('.com', '.net', '.org') {
	my $dom = "$str$tld";
	my $text = whois $dom;

	print "Checking $dom...\r";

	# This will break very badly if domain registries change the output
	# format. Currently, PIR returns the former and Internic returns
	# the latter for unregistered domains.
	if ($text =~ /NOT FOUND/ or $text =~ /No match for/) {
	    print "$dom is available\n";
	}
    }
    sleep 1;
} while (increment \$str);

__END__

So what's still available? Based on what I've searched so far, there are some 4-character .com domains available. If you want something that is 3 characters, you will have to go with .net or .org. There are no 2-character domains available in .com, .net or .org.

Subscribe

  • Virtual Conventions

    The COVID-19 pandemic has forced a number of furry conventions to cancel this year due to state and local emergency regulations and also out of…

  • FA United 2019

    Last weekend was FA United 2019 in Northern Virginia. That was my fourth and last furry convention for the year. It'll be hard to cut one convention…

  • Metro Gathering 2019

    The last few years, Metro Gathering was in October and had a Halloween theme. This year though, the geocaching mega event is in September and has a…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 4 comments