mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-08 00:26:52 +00:00
ipn/ipnlocal: add owner-only debug handler to get process env
For debugging Synology. Like the existing goroutines handler, in that it's owner-only. Change-Id: I852f0626be8e1c0b6794c1e062111d14adc3e6ac Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
6d82a18916
commit
c7bff35fee
@ -6,6 +6,7 @@ package ipnlocal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
@ -29,6 +30,7 @@ import (
|
|||||||
|
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
"tailscale.com/client/tailscale/apitype"
|
"tailscale.com/client/tailscale/apitype"
|
||||||
|
"tailscale.com/hostinfo"
|
||||||
"tailscale.com/ipn"
|
"tailscale.com/ipn"
|
||||||
"tailscale.com/logtail/backoff"
|
"tailscale.com/logtail/backoff"
|
||||||
"tailscale.com/net/interfaces"
|
"tailscale.com/net/interfaces"
|
||||||
@ -504,6 +506,10 @@ func (h *peerAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
h.handleServeGoroutines(w, r)
|
h.handleServeGoroutines(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if r.URL.Path == "/v0/env" {
|
||||||
|
h.handleServeEnv(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
who := h.peerUser.DisplayName
|
who := h.peerUser.DisplayName
|
||||||
fmt.Fprintf(w, `<html>
|
fmt.Fprintf(w, `<html>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
@ -710,3 +716,23 @@ func (h *peerAPIHandler) handleServeGoroutines(w http.ResponseWriter, r *http.Re
|
|||||||
}
|
}
|
||||||
w.Write(buf)
|
w.Write(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *peerAPIHandler) handleServeEnv(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if !h.isSelf {
|
||||||
|
http.Error(w, "not owner", http.StatusForbidden)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var data struct {
|
||||||
|
Hostinfo *tailcfg.Hostinfo
|
||||||
|
Uid int
|
||||||
|
Args []string
|
||||||
|
Env []string
|
||||||
|
}
|
||||||
|
data.Hostinfo = hostinfo.New()
|
||||||
|
data.Uid = os.Getuid()
|
||||||
|
data.Args = os.Args
|
||||||
|
data.Env = os.Environ()
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
json.NewEncoder(w).Encode(data)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user