[PR #6933] [MERGED] fix(monitoring): refresh cached public IP addresses #6530

Closed
opened 2026-11-02 04:09:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6933
Author: @Vaso73
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @MHSanaei

Base: main ← Head: fix/public-ip-refresh


📝 Commits (3)

  • 4a67ba7 fix(monitoring): refresh cached public IP addresses
  • f8cdc96 fix(monitoring): back off failed IPv6 lookups
  • c6084b1 Merge branch 'main' into fix/public-ip-refresh

📊 Changes

4 files changed (+586 additions, -40 deletions)

View changed files

📝 internal/web/service/server.go (+73 -38)
📝 internal/web/service/server_cold_status_test.go (+2 -1)
📝 internal/web/service/server_public_ip_async_test.go (+510 -0)
📝 internal/web/service/server_scope_test.go (+1 -1)

📄 Description

Summary

Refresh the public IPv4/IPv6 addresses shown on Overview after five minutes. Retry failed IPv4 lookups after one minute; consecutive IPv6 failures back off through one, two, five and fifteen minutes, capped at fifteen minutes. Keep the last known address during temporary failures. A successful IPv6 lookup resets its retry delay.

Why

The first lookup is currently cached for the lifetime of the panel process. After the server's external address changes, Overview continues to display the previous address until the panel restarts; an initial failure can also leave N/A permanently cached.

Status sampling stays nonblocking and concurrent callers share one lookup per service instance. Initial backup filename lookups can wait for the first result; later calls use the cached address while a refresh runs in the background. Existing Overview polling picks up refreshed values without a page reload.

Type of change

  • Bug fix

Areas affected

  • Backend (server status and public IP lookup cache)

How was this tested?

  • Reproduced stale addresses and failure to recover against the original implementation before applying the fix.
  • Added deterministic virtual-clock tests for refresh/retry boundaries, independent IPv4/IPv6 recovery, retained addresses on HTTP errors, empty responses, transport failures and timeouts, concurrent callers, and refreshed status JSON.
  • Additional virtual-clock regressions cover the IPv6 backoff boundaries and cap for all four failure modes, retained IPv6 addresses, recovery to the same or a changed address, five-minute refresh after success, reset to a one-minute retry after the next failure, and unchanged IPv4 refresh/retry timing during IPv6 backoff.
  • Passed locally on current main: full Go tests, race tests for the affected service/Telegram/Discord packages, 20 shuffled repetitions of the IP race tests, go vet ./..., go build ./..., and CI-pinned golangci-lint v2.15.0 with project formatters.
  • Earlier desktop/mobile Chromium checks of the built Overview with synthetic API responses confirmed updated IPv4/IPv6 values appear without another document request. Backend timing is covered separately by the Go tests.
  • A deployed backport was confirmed by the operator to display the current IPv4 address. This confirms the displayed value; refresh timing and IPv6 recovery are verified separately by the synthetic tests.

Automated application tests use disposable data and loopback-only networking.

Breaking changes

None. No frontend source, API schema, database, configuration or dependency changes.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior.
  • go build ./... and the test suite pass locally.
  • Frontend checks: not applicable; no frontend source changes.
  • Documentation: no new settings, API fields or setup steps.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6933 **Author:** [@Vaso73](https://github.com/Vaso73) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/public-ip-refresh` --- ### 📝 Commits (3) - [`4a67ba7`](https://github.com/MHSanaei/3x-ui/commit/4a67ba73531890292c6a15870bd6d86d7be5e6aa) fix(monitoring): refresh cached public IP addresses - [`f8cdc96`](https://github.com/MHSanaei/3x-ui/commit/f8cdc96833f49e4e96f4cbcfe78609b8e05c45f6) fix(monitoring): back off failed IPv6 lookups - [`c6084b1`](https://github.com/MHSanaei/3x-ui/commit/c6084b175411f4e73a3d0914deb1a557064ba15c) Merge branch 'main' into fix/public-ip-refresh ### 📊 Changes **4 files changed** (+586 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/server.go` (+73 -38) 📝 `internal/web/service/server_cold_status_test.go` (+2 -1) 📝 `internal/web/service/server_public_ip_async_test.go` (+510 -0) 📝 `internal/web/service/server_scope_test.go` (+1 -1) </details> ### 📄 Description ## Summary Refresh the public IPv4/IPv6 addresses shown on Overview after five minutes. Retry failed IPv4 lookups after one minute; consecutive IPv6 failures back off through one, two, five and fifteen minutes, capped at fifteen minutes. Keep the last known address during temporary failures. A successful IPv6 lookup resets its retry delay. ## Why The first lookup is currently cached for the lifetime of the panel process. After the server's external address changes, Overview continues to display the previous address until the panel restarts; an initial failure can also leave `N/A` permanently cached. Status sampling stays nonblocking and concurrent callers share one lookup per service instance. Initial backup filename lookups can wait for the first result; later calls use the cached address while a refresh runs in the background. Existing Overview polling picks up refreshed values without a page reload. ## Type of change - [x] Bug fix ## Areas affected - [x] Backend (server status and public IP lookup cache) ## How was this tested? - Reproduced stale addresses and failure to recover against the original implementation before applying the fix. - Added deterministic virtual-clock tests for refresh/retry boundaries, independent IPv4/IPv6 recovery, retained addresses on HTTP errors, empty responses, transport failures and timeouts, concurrent callers, and refreshed status JSON. - Additional virtual-clock regressions cover the IPv6 backoff boundaries and cap for all four failure modes, retained IPv6 addresses, recovery to the same or a changed address, five-minute refresh after success, reset to a one-minute retry after the next failure, and unchanged IPv4 refresh/retry timing during IPv6 backoff. - Passed locally on current main: full Go tests, race tests for the affected service/Telegram/Discord packages, 20 shuffled repetitions of the IP race tests, `go vet ./...`, `go build ./...`, and CI-pinned `golangci-lint` v2.15.0 with project formatters. - Earlier desktop/mobile Chromium checks of the built Overview with synthetic API responses confirmed updated IPv4/IPv6 values appear without another document request. Backend timing is covered separately by the Go tests. - A deployed backport was confirmed by the operator to display the current IPv4 address. This confirms the displayed value; refresh timing and IPv6 recovery are verified separately by the synthetic tests. Automated application tests use disposable data and loopback-only networking. ## Breaking changes None. No frontend source, API schema, database, configuration or dependency changes. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior. - [x] `go build ./...` and the test suite pass locally. - [x] Frontend checks: not applicable; no frontend source changes. - [x] Documentation: no new settings, API fields or setup steps. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:09:25 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6530
No description provided.