mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-18 02:55:00 +03:00
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:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user