tsnet: run the LocalAPI handler

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali
2021-10-05 21:40:19 -07:00
committed by Maisem Ali
parent 830f641c6b
commit 52be1c0c78
3 changed files with 64 additions and 48 deletions

View File

@@ -12,6 +12,7 @@ import (
"net/http"
"strings"
"tailscale.com/client/tailscale"
"tailscale.com/tsnet"
)
@@ -22,9 +23,9 @@ func main() {
log.Fatal(err)
}
log.Fatal(http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
who, ok := s.WhoIs(r.RemoteAddr)
if !ok {
http.Error(w, "WhoIs failed", 500)
who, err := tailscale.WhoIs(r.Context(), r.RemoteAddr)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
fmt.Fprintf(w, "<html><body><h1>Hello, world!</h1>\n")