MCPcopy Index your code
hub / github.com/tailscale/tailscale / runLocalAPIProxy

Function runLocalAPIProxy

cmd/tailscale/cli/debug.go:593–614  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

591}
592
593func runLocalAPIProxy() {
594 rp := httputil.NewSingleHostReverseProxy(&url.URL{
595 Scheme: "http",
596 Host: apitype.LocalAPIHost,
597 Path: "/",
598 })
599 dir := rp.Director
600 rp.Director = func(req *http.Request) {
601 dir(req)
602 req.Host = ""
603 req.RequestURI = ""
604 }
605 rp.Transport = localClientRoundTripper{}
606 lc, err := net.Listen("tcp", "localhost:0")
607 if err != nil {
608 log.Fatal(err)
609 }
610 fmt.Printf("Serving LocalAPI proxy on http://%s\n", lc.Addr())
611 fmt.Printf("curl.exe http://%v/localapi/v0/status\n", lc.Addr())
612 fmt.Printf("Ctrl+C to stop")
613 http.Serve(lc, rp)
614}
615
616var prefsArgs struct {
617 pretty bool

Callers 1

runLocalCredsFunction · 0.85

Calls 5

PrintfMethod · 0.80
ListenMethod · 0.65
FatalMethod · 0.65
AddrMethod · 0.45
ServeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…