(w http.ResponseWriter, r *http.Request)
| 874 | } |
| 875 | |
| 876 | func (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 { |
no test coverage detected