cmd/*: make windows-local fixes
This commit is contained in:
parent
7a3414000e
commit
14f068eddb
|
@ -3,21 +3,32 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
|
||||||
"github.com/kr/pretty"
|
"github.com/kr/pretty"
|
||||||
|
"go.uber.org/atomic"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
port = flag.String("port", "9090", "HTTP port to listen on")
|
port = flag.String("port", "9090", "HTTP port to listen on")
|
||||||
|
|
||||||
|
hits *atomic.Int64
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
hits = atomic.NewInt64(0)
|
||||||
http.ListenAndServe(":"+*port, http.HandlerFunc(handle))
|
http.ListenAndServe(":"+*port, http.HandlerFunc(handle))
|
||||||
}
|
}
|
||||||
|
|
||||||
func handle(w http.ResponseWriter, r *http.Request) {
|
func handle(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintln(w, "Route is go!")
|
fmt.Fprintln(w, "Route is go!")
|
||||||
fmt.Fprintf(w, "%s\n", pretty.Sprint(r.Header))
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ func main() {
|
||||||
Identifier: *token,
|
Identifier: *token,
|
||||||
LocalAddr: *backend,
|
LocalAddr: *backend,
|
||||||
ServerAddr: *serverAddr,
|
ServerAddr: *serverAddr,
|
||||||
|
Debug: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := tunnel.NewClient(cfg)
|
client, err := tunnel.NewClient(cfg)
|
||||||
|
|
Loading…
Reference in New Issue