Powered By Blogger

Donnerstag, 23. Februar 2012

Shortest URLs of the Internet

Some TLD operators have DNS entries of type "A" directly on their DNS, so these are the shortest possible URLs in the Internet. I wrote a small program in just ten minutes that finds all of them using a list from IANA:

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace TldDns
{
class Program
{
static void Main(string[] args)
{
WebClient wc = new WebClient();
string TldList = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt";
string[] allTlds;
using (StreamReader sr = new StreamReader(wc.OpenRead(TldList)))
{
allTlds = sr.ReadToEnd().Split('\n');
}
int cnt = 0;
IPAddress[] addresses;
foreach (string tld in allTlds)
{
if (cnt > 0)
{
try
{
addresses = Dns.GetHostAddresses(tld + ".");
if (addresses.Length > 0)
{
Console.WriteLine("Entries for {0}", tld);
foreach (IPAddress address in addresses)
{
Console.WriteLine(" " + address.ToString());
}
}
}
catch (Exception ex)
{
Console.WriteLine("Quering host entry for {0} caused an error.", tld);
}
}
cnt++;
}
Console.WriteLine("\nFinished.");
Console.ReadKey(true);
}
}
}

Unfortunately, if a domain has no A entry, Dns.GetHostAddresses throws an exception which slows execution down dramatically. The programs needs about 15 minutes (!) on my PC to run.

Here are the TLDs I found and if a web site is available too (having an A entry doesn't necessarly mean that a web server runs on that address):

http://ac/
http://ai/
cm (points to 195.24.205.60, no web site available)
http://dk/
gg (points to 87.117.196.80, no web site available)
http://io/
je (points to 193.223.78.212, no web site available)
kh (points to 203.223.32.21, no web site available)
ph (points to 203.119.4.7, no web site available)
http://pn/ (404?)
http://sh/ (forwards to http://www.nic.sh/)
tk (points to 217.119.57.22, no web site available)
http://tm/
to (points to 216.74.32.107, no web site available)
http://uz/
vi (points to 193.0.0.198, no web site available)
http://ws/ (forwards to http://www.website.ws/)
XN--O3CW4H (that's a IDN in some non-ASCII coding)

Interesting, isn't it? :-)

Keine Kommentare:

Kommentar veröffentlichen