hostassist

What is Hostassist, you might ask? Well, if you have been using my hosts file, you may have become accustomed to "Page not found" errors, and broken IMG links in place of pop-ups and ads. Clearly, the hosts file is not a complete solution. So, here's the next step.

Hostassist is a minimalist webserver. It's set up to do one of two things, if Hostassist is convinced that an image is being requested, it returns the smallest possible transparent GIF file (yes, we read the spec, I'm pretty certain it is the smallest possible). Otherwise, Hostassist presents an empty HTML document.

As the hosts file redirects requests for ads to 127.0.0.1 (your computer), and Hostassist is a webserver that listens for local HTTP requests, your browser looks to it to serve these images and pages. As a result, pop-ups become simple innocuous empty windows, and banners become transparent and fade into the background.

The hostassist beta program is currently closed while I work on a few changes.

If you'd prefer not to wait, here's an old Perl script I whipped together a while back to handle the same tasks. It's mostly a proof of concept:

#------------------------------------------------------------
# very small http server to replace ads with nothingness
# use in conjunction with a hosts file found at http://someonewhocares.org/hosts/
# copyright 2003 Dan Pollock (pollock@theorem.ca)
# version 1.3 (May 15th 2003)
use Socket;
use strict;

my $getstring =""; 

socket(Server, PF_INET, SOCK_STREAM, getprotobyname('tcp')) or die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) or die "setsockopt: $!";
bind(Server, sockaddr_in(80, inet_aton("localhost"))) or die "bind: $!";
listen(Server, 50) or die "listen: $!";

while(accept(Client,Server) or die "accept $!")
{
	 =~/ (.+) |^()$/;
	$getstring = $1; 

	while()
	{
		if ( /^Host: ?(.+).|^(.?.?)$/i || !($1) )
		{
			print substr(localtime(),0,-5),": ",$1,$getstring,"\n";
			print Client "HTTP/1.0 200 OK\nContent-type: ",
				($getstring=~/(gif|jpg|jpeg|bmp|png)$|sz\=(468|120)x60/i)	?
				"image/gif\n\nGIF89a".pack('h74',
				  "10001000080000000000000000129f401000000000c2000000001000002020441000b3")
				:
				"text/plain\n\n ";
			close (Client);
		}
	}
	
}
Fri May 9 20:05:29 2008top