// i'm sorry package main import ( "flag" "log" "os" "net" "net/http" "net/http/cgi" "net/http/fcgi" ) var ( cmd = flag.String("c", "", "CGI program to run") pwd = flag.String("w", "", "Working dir for CGI") serveFcgi = flag.Bool("f", false, "Run as a FCGI 'server' instead of HTTP") debug = flag.Bool("debug", false, "Print debug msgs to stderr.") address = flag.String("a", ":3333", "Listen address") ) func usage() { os.Stderr.WriteString("usage: cgd [-s] -c prog [-w wdir] [-a addr]\n") flag.PrintDefaults() os.Exit(2) } func main() { flag.Usage = usage flag.Parse() if *cmd == "" { usage() } // This is a hack to make p9p's rc happier for some unknown reason. c := *cmd if c[0] != '/' { c = "./" + c } os.Setenv("PATH", os.Getenv("PATH")+":.") h := &cgi.Handler{ Path: c, Root: "/", Dir: *pwd, InheritEnv: []string{"PATH", "PLAN9"}, } var err error if *serveFcgi { if l, err := net.Listen("tcp", *address); err == nil { log.Println("Starting FastCGI daemon listening on", *address) err = fcgi.Serve(l, h) } } else { log.Println("Starting HTTP server listening on", *address) http.Handle("cpu.stanleylieber.com/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/cpu.stanleylieber.com"))) http.Handle("1oct1993.com/", h) http.Handle("233c.cat-v.org/", h) http.Handle("9front.cat-v.org/", h) http.Handle("9front.org/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/9front.org"))) http.Handle("9grid.fr/", h) http.Handle("9p.cat-v.org/", h) http.Handle("9times.cat-v.org/", h) http.Handle("acme.cat-v.org/", h) http.Handle("amyearles.com/", h) http.Handle("archeology.cat-v.org/", h) http.Handle("art.cat-v.org/", h) http.Handle("azure.osuny.co.uk/", h) http.Handle("bell-labs.co/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/bell-labs.co"))) http.Handle("binarydream.org/", h) http.Handle("blog.pushedunder.com/", h) http.Handle("boobquake.us/", h) http.Handle("books.cat-v.org/", h) http.Handle("boyd.cat-v.org/", h) http.Handle("cabal-v.org/", h) http.Handle("cat--show-nonprinting.org/", h) http.Handle("cat-v.org/", h) http.Handle("csp.cat-v.org/", h) http.Handle("default.cat-v.org/", h) http.Handle("doc.bell-labs.co/", h) http.Handle("doc.cat-v.org/", h) http.Handle("dontstopthenight.com/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/dontstopthenight.com"))) http.Handle("drm-fail.com/", h) http.Handle("emma.stanleylieber.com/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/emma.stanleylieber.com"))) http.Handle("flamesgif.com/", h) http.Handle("flesh.stanleylieber.com/", h) http.Handle("fortunes.cat-v.org/", h) http.Handle("genius.cat-v.org/", h) http.Handle("gl.inri.net/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/gl.inri.net"))) http.Handle("glenda.cat-v.org/", h) http.Handle("go-lang.cat-v.org/", h) http.Handle("gofy.cat-v.org/", h) http.Handle("golang.cat-v.org/", h) http.Handle("gsoc.cat-v.org/", h) http.Handle("hardware.9front.org/", h) http.Handle("harmful.cat-v.org/", h) http.Handle("harmless.cat-v.org/", h) http.Handle("http02.cat-v.org/", h) http.Handle("iawtp.com/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/iawtp.com"))) http.Handle("img.pushedunder.com/", h) http.Handle("img.stanleylieber.com/", h) http.Handle("inferno.cat-v.org/", h) http.Handle("inri.net/", h) http.Handle("iwp9.cat-v.org/", h) http.Handle("kencc.cat-v.org/", h) http.Handle("limbo.cat-v.org/", h) http.Handle("linux.stanleylieber.com/", h) http.Handle("ln.inri.net/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/ln.inri.net"))) http.Handle("log.bell-labs.co/", h) http.Handle("love.cat-v.org/", h) http.Handle("man.cat-v.org/", h) http.Handle("marvin.cat-v.org/", h) http.Handle("massivefictions.com/", h) http.Handle("mk.cat-v.org/", h) http.Handle("naggum.cat-v.org/", h) http.Handle("ninetimes.cat-v.org/", h) http.Handle("notreally.info/", h) http.Handle("nsacom.net/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/nsacom.net"))) http.Handle("okturing.com/", h) http.Handle("osuny.co.uk/", h) http.Handle("other.stanleylieber.com/", h) http.Handle("ph.inri.net/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/ph.inri.net"))) http.Handle("plan9.cat-v.org/", h) http.Handle("plan9.stanleylieber.com/", h) http.Handle("plan9front.cat-v.org/", h) http.Handle("planet5.cat-v.org/", h) http.Handle("planet9.cat-v.org/", h) http.Handle("pop.inri.net/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/pop.inri.net"))) http.Handle("pushedunder.com/", h) http.Handle("qualitycountrylyrics.com/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/qualitycountrylyrics.com"))) http.Handle("quotes.cat-v.org/", h) http.Handle("rc-httpd.cat-v.org/", h) http.Handle("rc.cat-v.org/", h) http.Handle("read.stanleylieber.com/", h) http.Handle("reading.cat-v.org/", h) http.Handle("regulatory-capture.cat-v.org/", h) http.Handle("repo.cat-v.org/", h) http.Handle("sam.cat-v.org/", h) http.Handle("scandisk.bell-labs.co/", h) http.Handle("sl.cat-v.org/", h) http.Handle("soma.cat-v.org_/", h) http.Handle("sp.inri.net/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/sp.inri.net"))) http.Handle("stanleylieber.com/", h) http.Handle("swag.cat-v.org/", h) http.Handle("sysinfo.9front.org/", h) http.Handle("tcasey.inri.net/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/tcasey.inri.net"))) http.Handle("tems.bell-labs.co/", h) http.Handle("test.pushedunder.com/", h) http.Handle("textadventure.stanleylieber.com/", h) http.Handle("tip.9front.org/", h) http.Handle("trackon.org/", h) http.Handle("tst.cat-v.org/", h) http.Handle("ttr.inri.net/", http.FileServer(http.Dir("/usr/sl/t"))) http.Handle("tumblr.stanleylieber.com/", h) http.Handle("unix-kb.cat-v.org/", h) http.Handle("uriel.cat-v.org/", h) http.Handle("url.pushedunder.com/", h) http.Handle("url.stanleylieber.com/", h) http.Handle("utf-8.cat-v.org/", h) http.Handle("utf8.cat-v.org/", h) http.Handle("volksutils.com/", http.FileServer(http.Dir("/usr/sl/www/werc/sites/volksutils.com"))) http.Handle("vr.stanleylieber.com/", h) http.Handle("weekly.9front.org/", h) http.Handle("werc.cat-v.org/", h) http.Handle("wmii.cat-v.org/", h) err = http.ListenAndServe(*address, nil) } if err != nil { log.Fatal(err) } }