From 14f068eddb205da897a6ab84de3109e7a8aa3ce6 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Mon, 23 Jan 2017 07:58:28 -0800 Subject: [PATCH] cmd/*: make windows-local fixes --- cmd/helloserver/main.go | 11 +++++++++++ cmd/httpagent/main.go | 1 + 2 files changed, 12 insertions(+) diff --git a/cmd/helloserver/main.go b/cmd/helloserver/main.go index 65244c9..5a3de5a 100644 --- a/cmd/helloserver/main.go +++ b/cmd/helloserver/main.go @@ -3,21 +3,32 @@ package main import ( "flag" "fmt" + "log" "net/http" + "os" + "runtime" "github.com/kr/pretty" + "go.uber.org/atomic" ) var ( port = flag.String("port", "9090", "HTTP port to listen on") + + hits *atomic.Int64 ) func main() { flag.Parse() + hits = atomic.NewInt64(0) http.ListenAndServe(":"+*port, http.HandlerFunc(handle)) } func handle(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Route is go!") fmt.Fprintf(w, "%s\n", pretty.Sprint(r.Header)) + hn, _ := os.Hostname() + fmt.Fprintf(w, "Served by %s running %s\n", hn, runtime.GOOS) + fmt.Fprintf(w, "Hit count: %d", hits.Inc()) + log.Printf("Hit from %s: %s", r.Header.Get("X-Remote-Ip"), r.RequestURI) } diff --git a/cmd/httpagent/main.go b/cmd/httpagent/main.go index 8abcee7..001f70e 100644 --- a/cmd/httpagent/main.go +++ b/cmd/httpagent/main.go @@ -20,6 +20,7 @@ func main() { Identifier: *token, LocalAddr: *backend, ServerAddr: *serverAddr, + Debug: true, } client, err := tunnel.NewClient(cfg)