fix(monitoring): refresh cached public IP addresses (#6933)

The public IPv4/IPv6 lookup was cached for the life of the panel process, so
Overview kept showing an old address after the server's external IP changed,
and a failed first lookup pinned N/A until a restart. Addresses now refresh
every five minutes, a failed IPv4 lookup retries after a minute, failed IPv6
lookups back off 1/2/5/15 minutes, and a temporary failure keeps the last
known address. Status sampling still never waits on the lookup.
This commit is contained in:
VAIO73
2026-10-25 13:50:29 +01:00
committed by GitHub
parent 56ac8d0fc7
commit be25314157
4 changed files with 586 additions and 40 deletions
@@ -3,6 +3,7 @@ package service
import (
"path/filepath"
"testing"
"time"
"github.com/mhsanaei/3x-ui/v3/internal/database/dbtest"
)
@@ -16,7 +17,7 @@ func TestCurrentStatusSamplesBeforeFirstTick(t *testing.T) {
// A settled IP cache keeps GetStatus from starting a public-IP resolver that
// outlives this test and races http.DefaultTransport in later ones.
svc := &ServerService{cachedIPv4: "192.0.2.1", noIPv6: true}
svc := &ServerService{cachedIPv4: "192.0.2.1", cachedIPv6: "N/A", nextIPv4Lookup: time.Now().Add(time.Hour), nextIPv6Lookup: time.Now().Add(time.Hour)}
if svc.LastStatus() != nil {
t.Fatal("a fresh ServerService should hold no snapshot yet")
}