--- httpd.c.orig 2005-08-03 13:32:50.000000000 +0200 +++ httpd.c 2007-01-11 00:46:25.000000000 +0100 @@ -70,6 +70,12 @@ * equal sign ('='), fnord will throw away the URI part. */ #define REDIRECT +/* uncomment the following line to get apache-style common log file + * format. Please note that that format is not usable for ad-hoc + * analysis using awk and friends, but you will be able to use Apache + * log analysis tools. */ +/* #define COLF */ + /* uncomment the following line to make fnord tarpit queries from * EmailSiphon (an email harvester for spammers) */ #define TARPIT @@ -694,6 +700,10 @@ { "xbm", "image/x-xbitmap" }, { "xpm", "image/x-xpixmap" }, { "xwd", "image/x-xwindowdump" }, + { "ico", "image/x-icon" }, + { "rpm", "application/x-rpm" }, + { "gz", "application/x-gzip" }, + { "tgz", "application/x-gzip" }, { 0 } }; /* try to find out MIME type and content encoding. @@ -819,12 +829,31 @@ static struct stat st; +static void redirectboilerplate() { + buffer_puts(buffer_1,"HTTP/1.0 301 Go Away\r\nConnection: close\r\nContent-Length: 0\r\nLocation: "); +} + /* try to return a file */ static int doit(char* buf,int buflen,char* url,int explicit) { int fd=-1; char* accept; time_t ims; while (url[0]=='/') ++url; + if (stat(url,&st)==0) { + if (S_ISDIR(st.st_mode)) { + /* el-cheapo redirection */ + redirectboilerplate(); + buffer_puts(buffer_1,"http://"); + buffer_puts(buffer_1,host); + buffer_puts(buffer_1,"/"); + buffer_puts(buffer_1,url); + buffer_puts(buffer_1,"/\r\n\r\n"); + retcode=301; + dolog(0); + buffer_flush(buffer_1); + exit(0); + } + } getmimetype(url,explicit); { char *b=buf; @@ -879,10 +908,6 @@ return -1; } -static void redirectboilerplate() { - buffer_puts(buffer_1,"HTTP/1.0 301 Go Away\r\nConnection: close\r\nLocation: "); -} - static void handleredirect(const char *url,const char* origurl) { char symlink[1024]; int len;