]> git.scottworley.com Git - reliable-chat/blobdiff - server/server.go
Optionally specify an address to bind to
[reliable-chat] / server / server.go
index 1bb7c9af81935b417692ddc55b717a2ff8f4967e..adbbf8475003123e525047bb101d1730c904adc8 100644 (file)
@@ -27,6 +27,7 @@ import "strconv"
 import "time"
 
 var port = flag.Int("port", 21059, "Port to listen on")
+var localaddress = flag.String("localaddress", "", "Local address to bind to")
 
 var frame_count = expvar.NewInt("frame_count")
 var speak_count = expvar.NewInt("speak_count")
@@ -156,6 +157,10 @@ const frame_html = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 </html>
 `
 
+const robots_txt = `User-agent: *
+Disallow: /
+`
+
 func start_server(store Store) {
        http.HandleFunc("/fetch", func(w http.ResponseWriter, r *http.Request) {
                var since time.Time
@@ -195,7 +200,11 @@ func start_server(store Store) {
                w.Write([]byte(frame_html));
        })
 
-       log.Fatal(http.ListenAndServe(":"+strconv.Itoa(*port), nil))
+       http.HandleFunc("/robots.txt", func(w http.ResponseWriter, r *http.Request) {
+               w.Write([]byte(robots_txt));
+       })
+
+       log.Fatal(http.ListenAndServe(*localaddress+":"+strconv.Itoa(*port), nil))
 }
 
 func main() {