Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

feat(discovery): auto-suggest web interface URLs for discovered services

rcourtman3ea3f0f82763
diff --git a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
index 1405435698..eeb66b5d23 100644
--- a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
+++ b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
@@ -757,6 +757,27 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
</button>
</Show>
</div>
+ {/* Suggested URL from discovery */}
+ <Show when={d().suggested_url && !props.customUrl}>
+ <div class="mt-2 p-2 rounded bg-blue-50 border border-blue-200 dark:bg-blue-900/20 dark:border-blue-800/50">
+ <div class="text-[10px] font-medium text-blue-700 dark:text-blue-300 mb-1">
+ Suggested URL
+ </div>
+ <div class="flex items-center gap-2">
+ <code class="flex-1 text-xs text-blue-800 dark:text-blue-200 font-mono truncate" title={d().suggested_url}>
+ {d().suggested_url}
+ </code>
+ <button
+ type="button"
+ class="px-2 py-1 text-xs font-medium rounded bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 transition-colors flex-shrink-0"
+ onClick={() => setUrlValue(d().suggested_url || '')}
+ disabled={urlSaving()}
+ >
+ Use this
+ </button>
+ </div>
+ </div>
+ </Show>
<p class="mt-1.5 text-[10px] text-gray-400 dark:text-gray-500">
Add a URL to quickly access this guest's web interface from the dashboard.
</p>
diff --git a/frontend-modern/src/types/discovery.ts b/frontend-modern/src/types/discovery.ts
index e9b5b79d27..c6e28bfca2 100644
--- a/frontend-modern/src/types/discovery.ts
+++ b/frontend-modern/src/types/discovery.ts
@@ -74,6 +74,8 @@ export interface ResourceDiscovery {
fingerprint?: string; // Hash when discovery was done
fingerprinted_at?: string; // When fingerprint was captured
fingerprint_schema_version?: number; // Schema version when fingerprint was captured
+ // Auto-suggested web interface URL
+ suggested_url?: string;
}
export interface DiscoverySummary {
diff --git a/internal/servicediscovery/service.go b/internal/servicediscovery/service.go
index 3dfb6bf70f..d57e392a90 100644
--- a/internal/servicediscovery/service.go
+++ b/internal/servicediscovery/service.go
@@ -816,6 +816,9 @@ func (s *Service) discoverDockerContainers(ctx context.Context, hosts []DockerHo
discovery = s.enhanceWithDeepScan(ctx, discovery, host)
}
+ // Suggest web interface URL using Docker host hostname
+ discovery.SuggestedURL = SuggestWebURL(discovery, host.Hostname)
+
if err := s.store.Save(discovery); err != nil {
log.Warn().Err(err).Str("id", id).Msg("Failed to save discovery")
}
@@ -1230,6 +1233,13 @@ func (s *Service) DiscoverResource(ctx context.Context, req DiscoveryRequest) (*
}
}
+ // Suggest web interface URL based on service type and external IP
+ if s.stateProvider != nil {
+ if externalIP := s.getResourceExternalIP(req); externalIP != "" {
+ discovery.SuggestedURL = SuggestWebURL(discovery, externalIP)
+ }
+ }
+
// Save discovery
if err := s.store.Save(discovery); err != nil {
inProg.err = fmt.Errorf("failed to save discovery: %w", err)
@@ -1289,6 +1299,65 @@ func (s *Service) getResourceMetadata(req DiscoveryRequest) map[string]any {
return metadata
}
+// getResourceExternalIP retrieves the external IP address for a resource from the state.
+// For LXC/VM, this is the first IP from the Proxmox guest agent.
+// For Docker containers, this is the Docker host's IP/hostname.
+func (s *Service) getResourceExternalIP(req DiscoveryRequest) string {
+ if s.stateProvider == nil {
+ return ""
+ }
+
+ state := s.stateProvider.GetState()
+
+ switch req.ResourceType {
+ case ResourceTypeLXC:
+ for _, c := range state.Containers {
+ if fmt.Sprintf("%d", c.VMID) == req.ResourceID && c.Node == req.HostID {
+ if len(c.IPAddresses) > 0 {
+ return c.IPAddresses[0]
+ }
+ return ""
+ }
+ }
+ case ResourceTypeVM:
+ for _, vm := range state.VMs {
+ if fmt.Sprintf("%d", vm.VMID) == req.ResourceID && vm.Node == req.HostID {
+ if len(vm.IPAddresses) > 0 {
+ return vm.IPAddresses[0]
+ }
+ return ""
+ }
+ }
+ case ResourceTypeDocker:
+ // For Docker containers, use the Docker host's hostname/IP
+ for _, host := range state.DockerHosts {
+ if host.AgentID == req.HostID || host.Hostname == req.HostID {
+ // Use hostname if it looks like an IP, otherwise it's a hostname
+ return host.Hostname
+ }
+ }
+ case ResourceTypeDockerVM, ResourceTypeDockerLXC:
+ // For Docker containers inside VMs/LXCs, find the VM/LXC's IP
+ // The hostID contains the parent resource info
+ for _, vm := range state.VMs {
+ if fmt.Sprintf("%d", vm.VMID) == req.HostID || vm.Name == req.HostID {
+ if len(vm.IPAddresses) > 0 {
+ return vm.IPAddresses[0]
+ }
+ }
+ }
+ for _, c := range state.Containers {
+ if fmt.Sprintf("%d", c.VMID) == req.HostID || c.Name == req.HostID {
+ if len(c.IPAddresses) > 0 {
+ return c.IPAddresses[0]
+ }
+ }
+ }
+ }
+
+ return ""
+}
+
// formatCLIAccess formats the CLI access string with actual values.
func (s *Service) formatCLIAccess(resourceType ResourceType, resourceID, cliTemplate string) string {
if cliTemplate == "" {
diff --git a/internal/servicediscovery/types.go b/internal/servicediscovery/types.go
index 64b8906fa9..8a9fa25104 100644
--- a/internal/servicediscovery/types.go
+++ b/internal/servicediscovery/types.go
@@ -100,6 +100,9 @@ type ResourceDiscovery struct {
// Raw data for debugging/re-analysis
RawCommandOutput map[string]string `json:"raw_command_output,omitempty"`
+
+ // Auto-suggested web interface URL based on service type and discovered ports
+ SuggestedURL string `json:"suggested_url,omitempty"`
}
// DiscoveryFact represents a single discovered fact about a resource.
diff --git a/internal/servicediscovery/url_suggestion.go b/internal/servicediscovery/url_suggestion.go
new file mode 100644
index 0000000000..1ab150f6aa
--- /dev/null
+++ b/internal/servicediscovery/url_suggestion.go
@@ -0,0 +1,229 @@
+// Package servicediscovery provides infrastructure discovery capabilities.
+package servicediscovery
+
+import (
+ "fmt"
+ "strings"
+)
+
+// webServiceDefault defines the default web interface configuration for a service.
+type webServiceDefault struct {
+ Port int // Default port
+ Protocol string // http or https
+ Path string // Path suffix (e.g., "/web" for Plex)
+}
+
+// webServiceDefaults maps service types to their default web interface configurations.
+// These are used to construct suggested URLs when a service is discovered.
+var webServiceDefaults = map[string]webServiceDefault{
+ // Media
+ "frigate": {5000, "http", ""},
+ "jellyfin": {8096, "http", ""},
+ "plex": {32400, "http", "/web"},
+ "emby": {8096, "http", ""},
+ "kodi": {8080, "http", ""},
+ "sonarr": {8989, "http", ""},
+ "radarr": {7878, "http", ""},
+ "lidarr": {8686, "http", ""},
+ "prowlarr": {9696, "http", ""},
+ "bazarr": {6767, "http", ""},
+ "overseerr": {5055, "http", ""},
+ "tautulli": {8181, "http", ""},
+ "ombi": {3579, "http", ""},
+ "navidrome": {4533, "http", ""},
+ "audiobookshelf": {13378, "http", ""},
+
+ // Home Automation
+ "home-assistant": {8123, "http", ""},
+ "homeassistant": {8123, "http", ""},
+ "openhab": {8080, "http", ""},
+ "domoticz": {8080, "http", ""},
+ "node-red": {1880, "http", ""},
+ "nodered": {1880, "http", ""},
+
+ // Monitoring
+ "grafana": {3000, "http", ""},
+ "prometheus": {9090, "http", ""},
+ "influxdb": {8086, "http", ""},
+ "uptime-kuma": {3001, "http", ""},
+ "uptimekuma": {3001, "http", ""},
+ "netdata": {19999, "http", ""},
+ "zabbix": {80, "http", ""},
+
+ // Web Servers / Reverse Proxies
+ "nginx": {80, "http", ""},
+ "apache": {80, "http", ""},
+ "caddy": {80, "http", ""},
+ "traefik": {8080, "http", "/dashboard/"},
+ "haproxy": {8404, "http", "/stats"},
+ "nginx-proxy-manager": {81, "http", ""},
+
+ // Backup
+ "proxmox-backup-server": {8007, "https", ""},
+ "pbs": {8007, "https", ""},
+ "duplicati": {8200, "http", ""},
+ "urbackup": {55414, "http", ""},
+ "veeam": {9443, "https", ""},
+
+ // Virtualization
+ "proxmox": {8006, "https", ""},
+ "proxmox-ve": {8006, "https", ""},
+ "portainer": {9000, "http", ""},
+ "cockpit": {9090, "https", ""},
+ "unraid": {80, "http", ""},
+ "truenas": {80, "http", ""},
+ "openmediavault": {80, "http", ""},
+
+ // NVR / Security
+ "blue-iris": {81, "http", ""},
+ "shinobi": {8080, "http", ""},
+ "zoneminder": {80, "http", "/zm"},
+ "scrypted": {10443, "https", ""},
+ "motioneye": {8765, "http", ""},
+
+ // Storage / File Sharing
+ "nextcloud": {80, "http", ""},
+ "owncloud": {80, "http", ""},
+ "syncthing": {8384, "http", ""},
+ "filebrowser": {80, "http", ""},
+ "seafile": {80, "http", ""},
+
+ // Download / Torrents
+ "qbittorrent": {8080, "http", ""},
+ "transmission": {9091, "http", ""},
+ "deluge": {8112, "http", ""},
+ "rtorrent": {8080, "http", ""},
+ "sabnzbd": {8080, "http", ""},
+ "nzbget": {6789, "http", ""},
+ "jackett": {9117, "http", ""},
+
+ // Network / DNS
+ "pihole": {80, "http", "/admin"},
+ "adguard-home": {3000, "http", ""},
+ "adguardhome": {3000, "http", ""},
+ "unifi": {8443, "https", ""},
+ "unifi-controller": {8443, "https", ""},
+ "opnsense": {443, "https", ""},
+ "pfsense": {443, "https", ""},
+
+ // Database Admin
+ "phpmyadmin": {80, "http", ""},
+ "pgadmin": {80, "http", ""},
+ "adminer": {8080, "http", ""},
+
+ // Other
+ "gitea": {3000, "http", ""},
+ "gitlab": {80, "http", ""},
+ "jenkins": {8080, "http", ""},
+ "vaultwarden": {80, "http", ""},
+ "bitwarden": {80, "http", ""},
+ "paperless": {8000, "http", ""},
+ "paperless-ngx": {8000, "http", ""},
+ "mealie": {9000, "http", ""},
+ "photoprism": {2342, "http", ""},
+ "immich": {2283, "http", ""},
+ "homepage": {3000, "http", ""},
+ "dashy": {80, "http", ""},
+ "homarr": {7575, "http", ""},
+ "organizr": {80, "http", ""},
+}
+
+// webEnabledCategories defines which service categories typically have web interfaces.
+var webEnabledCategories = map[ServiceCategory]bool{
+ CategoryWebServer: true,
+ CategoryMedia: true,
+ CategoryHomeAuto: true,
+ CategoryMonitoring: true,
+ CategoryNVR: true,
+ CategoryBackup: true,
+ CategoryVirtualizer: true,
+ CategoryStorage: true,
+ CategoryNetwork: true,
+}
+
+// commonWebPorts defines ports commonly used for web interfaces.
+// Used as fallback when service type is not in the defaults table.
+var commonWebPorts = []int{80, 443, 8080, 8443, 3000, 5000, 8000, 8888, 9000}
+
+// SuggestWebURL generates a suggested web interface URL for a discovered resource.
+// It uses service defaults when available, falling back to discovered ports.
+// Returns empty string if no suitable URL can be constructed.
+//
+// Note: For Docker containers with non-standard port mappings, the fallback logic
+// uses internal container ports. However, this only affects unknown services not
+// in the defaults table - known services use their standard ports.
+func SuggestWebURL(discovery *ResourceDiscovery, hostIP string) string {
+ if discovery == nil || hostIP == "" {
+ return ""
+ }
+
+ // Skip if category doesn't typically have web UI
+ if !webEnabledCategories[discovery.Category] && discovery.Category != CategoryUnknown {
+ return ""
+ }
+
+ // Normalize service type for lookup
+ serviceType := strings.ToLower(discovery.ServiceType)
+ serviceType = strings.ReplaceAll(serviceType, "_", "-")
+ serviceType = strings.ReplaceAll(serviceType, " ", "-")
+
+ // Try service defaults first
+ if defaults, ok := webServiceDefaults[serviceType]; ok {
+ return buildURL(defaults.Protocol, hostIP, defaults.Port, defaults.Path)
+ }
+
+ // Try variations of service type
+ variations := []string{
+ serviceType,
+ strings.ReplaceAll(serviceType, "-", ""),
+ strings.TrimSuffix(serviceType, "-server"),
+ strings.TrimSuffix(serviceType, "server"),
+ }
+ for _, variation := range variations {
+ if defaults, ok := webServiceDefaults[variation]; ok {
+ return buildURL(defaults.Protocol, hostIP, defaults.Port, defaults.Path)
+ }
+ }
+
+ // Fallback: use discovered ports
+ if len(discovery.Ports) > 0 {
+ // First, check if any discovered port is a known web port
+ for _, port := range discovery.Ports {
+ if port.Protocol == "tcp" && isCommonWebPort(port.Port) {
+ protocol := "http"
+ if port.Port == 443 || port.Port == 8443 {
+ protocol = "https"
+ }
+ return buildURL(protocol, hostIP, port.Port, "")
+ }
+ }
+ }
+
+ // No suitable URL could be determined
+ return ""
+}
+
+// buildURL constructs a URL from components.
+func buildURL(protocol, host string, port int, path string) string {
+ // Default ports don't need to be included
+ if (protocol == "http" && port == 80) || (protocol == "https" && port == 443) {
+ return fmt.Sprintf("%s://%s%s", protocol, host, path)
+ }
+ return fmt.Sprintf("%s://%s:%d%s", protocol, host, port, path)
+}
+
+// isCommonWebPort checks if a port is commonly used for web interfaces.
+func isCommonWebPort(port int) bool {
+ for _, p := range commonWebPorts {
+ if port == p {
+ return true
+ }
+ }
+ // Also check common ranges
+ return (port >= 80 && port <= 90) ||
+ (port >= 443 && port <= 450) ||
+ (port >= 8000 && port <= 8100) ||
+ (port >= 3000 && port <= 3100) ||
+ (port >= 5000 && port <= 5100) ||
+ (port >= 9000 && port <= 9100)
+}
diff --git a/internal/servicediscovery/url_suggestion_test.go b/internal/servicediscovery/url_suggestion_test.go
new file mode 100644
index 0000000000..83e50f793e
--- /dev/null
+++ b/internal/servicediscovery/url_suggestion_test.go
@@ -0,0 +1,212 @@
+package servicediscovery
+
+import (
+ "testing"
+)
+
+func TestSuggestWebURL(t *testing.T) {
+ tests := []struct {
+ name string
+ discovery *ResourceDiscovery
+ hostIP string
+ wantURL string
+ wantEmpty bool
+ }{
+ {
+ name: "jellyfin with known service type",
+ discovery: &ResourceDiscovery{
+ ServiceType: "jellyfin",
+ Category: CategoryMedia,
+ },
+ hostIP: "192.168.1.50",
+ wantURL: "http://192.168.1.50:8096",
+ },
+ {
+ name: "plex with path",
+ discovery: &ResourceDiscovery{
+ ServiceType: "plex",
+ Category: CategoryMedia,
+ },
+ hostIP: "192.168.1.50",
+ wantURL: "http://192.168.1.50:32400/web",
+ },
+ {
+ name: "proxmox with https",
+ discovery: &ResourceDiscovery{
+ ServiceType: "proxmox",
+ Category: CategoryVirtualizer,
+ },
+ hostIP: "192.168.1.10",
+ wantURL: "https://192.168.1.10:8006",
+ },
+ {
+ name: "home-assistant",
+ discovery: &ResourceDiscovery{
+ ServiceType: "home-assistant",
+ Category: CategoryHomeAuto,
+ },
+ hostIP: "192.168.1.100",
+ wantURL: "http://192.168.1.100:8123",
+ },
+ {
+ name: "service type with underscores (normalized)",
+ discovery: &ResourceDiscovery{
+ ServiceType: "home_assistant",
+ Category: CategoryHomeAuto,
+ },
+ hostIP: "192.168.1.100",
+ wantURL: "http://192.168.1.100:8123",
+ },
+ {
+ name: "traefik with path",
+ discovery: &ResourceDiscovery{
+ ServiceType: "traefik",
+ Category: CategoryWebServer,
+ },
+ hostIP: "10.0.0.5",
+ wantURL: "http://10.0.0.5:8080/dashboard/",
+ },
+ {
+ name: "pihole with path",
+ discovery: &ResourceDiscovery{
+ ServiceType: "pihole",
+ Category: CategoryNetwork,
+ },
+ hostIP: "192.168.1.1",
+ wantURL: "http://192.168.1.1/admin",
+ },
+ {
+ name: "unknown service with web port discovered",
+ discovery: &ResourceDiscovery{
+ ServiceType: "myapp",
+ Category: CategoryUnknown,
+ Ports: []PortInfo{
+ {Port: 8080, Protocol: "tcp"},
+ },
+ },
+ hostIP: "192.168.1.50",
+ wantURL: "http://192.168.1.50:8080",
+ },
+ {
+ name: "unknown service with https port",
+ discovery: &ResourceDiscovery{
+ ServiceType: "myapp",
+ Category: CategoryUnknown,
+ Ports: []PortInfo{
+ {Port: 443, Protocol: "tcp"},
+ },
+ },
+ hostIP: "192.168.1.50",
+ wantURL: "https://192.168.1.50",
+ },
+ {
+ name: "database - no web UI expected",
+ discovery: &ResourceDiscovery{
+ ServiceType: "postgres",
+ Category: CategoryDatabase,
+ Ports: []PortInfo{
+ {Port: 5432, Protocol: "tcp"},
+ },
+ },
+ hostIP: "192.168.1.50",
+ wantEmpty: true,
+ },
+ {
+ name: "cache service - no web UI expected",
+ discovery: &ResourceDiscovery{
+ ServiceType: "redis",
+ Category: CategoryCache,
+ },
+ hostIP: "192.168.1.50",
+ wantEmpty: true,
+ },
+ {
+ name: "nil discovery",
+ discovery: nil,
+ hostIP: "192.168.1.50",
+ wantEmpty: true,
+ },
+ {
+ name: "empty host IP",
+ discovery: &ResourceDiscovery{
+ ServiceType: "jellyfin",
+ Category: CategoryMedia,
+ },
+ hostIP: "",
+ wantEmpty: true,
+ },
+ {
+ name: "frigate NVR",
+ discovery: &ResourceDiscovery{
+ ServiceType: "frigate",
+ Category: CategoryNVR,
+ },
+ hostIP: "192.168.1.200",
+ wantURL: "http://192.168.1.200:5000",
+ },
+ {
+ name: "grafana monitoring",
+ discovery: &ResourceDiscovery{
+ ServiceType: "grafana",
+ Category: CategoryMonitoring,
+ },
+ hostIP: "10.0.0.10",
+ wantURL: "http://10.0.0.10:3000",
+ },
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got := SuggestWebURL(tt.discovery, tt.hostIP)
+ if tt.wantEmpty {
+ if got != "" {
+ t.Errorf("SuggestWebURL() = %q, want empty string", got)
+ }
+ } else if got != tt.wantURL {
+ t.Errorf("SuggestWebURL() = %q, want %q", got, tt.wantURL)
+ }
+ })
+ }
+}
+
+func TestBuildURL(t *testing.T) {
+ tests := []struct {
+ protocol string
+ host string
+ port int
+ path string
+ want string
+ }{
+ {"http", "192.168.1.1", 8080, "", "http://192.168.1.1:8080"},
+ {"https", "192.168.1.1", 443, "", "https://192.168.1.1"},
+ {"http", "192.168.1.1", 80, "", "http://192.168.1.1"},
+ {"http", "192.168.1.1", 80, "/admin", "http://192.168.1.1/admin"},
+ {"https", "example.com", 8443, "/dashboard/", "https://example.com:8443/dashboard/"},
+ }
+
+ for _, tt := range tests {
+ t.Run(tt.want, func(t *testing.T) {
+ got := buildURL(tt.protocol, tt.host, tt.port, tt.path)
+ if got != tt.want {
+ t.Errorf("buildURL() = %q, want %q", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestIsCommonWebPort(t *testing.T) {
+ webPorts := []int{80, 443, 8080, 8443, 3000, 5000, 8000, 8888, 9000}
+ nonWebPorts := []int{22, 25, 3306, 5432, 6379, 27017}
+
+ for _, port := range webPorts {
+ if !isCommonWebPort(port) {
+ t.Errorf("isCommonWebPort(%d) = false, want true", port)
+ }
+ }
+
+ for _, port := range nonWebPorts {
+ if isCommonWebPort(port) {
+ t.Errorf("isCommonWebPort(%d) = true, want false", port)
+ }
+ }
+}