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

Method serveGetNodeData

client/web/web.go:876–991  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

874}
875
876func (s *Server) serveGetNodeData(w http.ResponseWriter, r *http.Request) {
877 st, err := s.lc.Status(r.Context())
878 if err != nil {
879 http.Error(w, err.Error(), http.StatusInternalServerError)
880 return
881 }
882 prefs, err := s.lc.GetPrefs(r.Context())
883 if err != nil {
884 http.Error(w, err.Error(), http.StatusInternalServerError)
885 return
886 }
887 filterRules, _ := s.lc.DebugPacketFilterRules(r.Context())
888 ipv4, ipv6 := s.selfNodeAddresses(r, st)
889
890 data := &nodeData{
891 ID: st.Self.ID,
892 Status: st.BackendState,
893 DeviceName: strings.Split(st.Self.DNSName, ".")[0],
894 IPv4: ipv4,
895 IPv6: ipv6,
896 OS: st.Self.OS,
897 IPNVersion: strings.Split(st.Version, "-")[0],
898 Profile: st.User[st.Self.UserID],
899 IsTagged: st.Self.IsTagged(),
900 KeyExpired: st.Self.Expired,
901 TUNMode: st.TUN,
902 IsSynology: distro.Get() == distro.Synology || envknob.Bool("TS_FAKE_SYNOLOGY"),
903 DSMVersion: distro.DSMVersion(),
904 IsUnraid: distro.Get() == distro.Unraid,
905 UnraidToken: os.Getenv("UNRAID_CSRF_TOKEN"),
906 RunningSSHServer: prefs.RunSSH,
907 URLPrefix: strings.TrimSuffix(s.pathPrefix, "/"),
908 ControlAdminURL: prefs.AdminPageURL(s.polc),
909 LicensesURL: licenses.LicensesURL(),
910 Features: availableFeatures(),
911
912 ACLAllowsAnyIncomingTraffic: s.aclsAllowAccess(filterRules),
913 }
914
915 if hostinfo.GetEnvType() == hostinfo.HomeAssistantAddOn && data.URLPrefix == "" {
916 // X-Ingress-Path is the path prefix in use for Home Assistant
917 // https://developers.home-assistant.io/docs/add-ons/presentation#ingress
918 data.URLPrefix = r.Header.Get("X-Ingress-Path")
919 }
920
921 cv, err := s.lc.CheckUpdate(r.Context())
922 if err != nil {
923 s.logf("could not check for updates: %v", err)
924 } else {
925 data.ClientVersion = cv
926 }
927
928 profile, _, err := s.lc.ProfileStatus(r.Context())
929 if err != nil {
930 s.logf("error fetching profiles: %v", err)
931 // If for some reason we can't fetch profiles,
932 // continue to use st.CurrentTailnet if set.
933 if st.CurrentTailnet != nil {

Callers 2

serveLoginAPIMethod · 0.95
serveAPIMethod · 0.95

Calls 15

selfNodeAddressesMethod · 0.95
aclsAllowAccessMethod · 0.95
logfMethod · 0.95
GetFunction · 0.92
BoolFunction · 0.92
DSMVersionFunction · 0.92
LicensesURLFunction · 0.92
GetEnvTypeFunction · 0.92
AllIPv4Function · 0.92
AllIPv6Function · 0.92
IsExitRouteFunction · 0.92
availableFeaturesFunction · 0.85

Tested by

no test coverage detected