[PR #5480] [MERGED] feat(xray): add tunnel health monitor #5894

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5480
Author: @m4tinbeigi-official
Created: 6/22/2026
Status: ✅ Merged
Merged: 6/24/2026
Merged by: @MHSanaei

Base: main ← Head: feat/tunnel-health-monitor


📝 Commits (7)

  • 61aa410 feat(xray): add tunnel health monitor
  • 6a9a5ab Merge branch 'main' into feat/tunnel-health-monitor
  • 87644d5 Merge branch 'main' into feat/tunnel-health-monitor
  • cd0eaef Merge branch 'main' into feat/tunnel-health-monitor
  • 98efa43 Merge branch 'main' into feat/tunnel-health-monitor
  • 768ba1a fix(tunnelmonitor): reuse netproxy client and init logger in tests
  • c268b91 fix(tunnelmonitor): observable recovery, signal headroom, and hardening

📊 Changes

5 files changed (+773 additions, -1 deletions)

View changed files

📝 .env.example (+13 -0)
📝 README.md (+7 -0)
➕ internal/tunnelmonitor/monitor.go (+271 -0)
➕ internal/tunnelmonitor/monitor_test.go (+454 -0)
📝 main.go (+28 -1)

📄 Description

Refs #3633

Summary

  • Add an optional tunnel health monitor.
  • Probe a configurable HTTP/HTTPS endpoint at a configurable interval.
  • Support direct, HTTP proxy, HTTPS proxy, SOCKS5 and SOCKS5H proxy probing.
  • Restart Xray core only after a configurable number of consecutive failures.
  • Add a cooldown window to avoid restart loops.
  • Keep the feature disabled by default and controlled through service environment variables.

Configuration

The monitor is disabled by default. It can be enabled with:

XUI_TUNNEL_HEALTH_MONITOR=true
XUI_TUNNEL_HEALTH_URL=https://www.cloudflare.com/cdn-cgi/trace
XUI_TUNNEL_HEALTH_PROXY=socks5://127.0.0.1:1080
XUI_TUNNEL_HEALTH_INTERVAL=30s
XUI_TUNNEL_HEALTH_TIMEOUT=10s
XUI_TUNNEL_HEALTH_FAILURES=3
XUI_TUNNEL_HEALTH_COOLDOWN=5m

Test

  • Not completed locally: Go dependency download/test failed in the local environment.

Notes

This is a safe MVP for tunnel recovery: it does not change Xray config, does not restart on a single transient failure, and rate-limits recovery through cooldown.


🔄 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/5480 **Author:** [@m4tinbeigi-official](https://github.com/m4tinbeigi-official) **Created:** 6/22/2026 **Status:** ✅ Merged **Merged:** 6/24/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/tunnel-health-monitor` --- ### 📝 Commits (7) - [`61aa410`](https://github.com/MHSanaei/3x-ui/commit/61aa410a134d688d7a22a3066af22173036291a7) feat(xray): add tunnel health monitor - [`6a9a5ab`](https://github.com/MHSanaei/3x-ui/commit/6a9a5abd07951721dc4438d70739a84422a55bff) Merge branch 'main' into feat/tunnel-health-monitor - [`87644d5`](https://github.com/MHSanaei/3x-ui/commit/87644d5d440a2c3aaf437ee34f2a0783919ecac6) Merge branch 'main' into feat/tunnel-health-monitor - [`cd0eaef`](https://github.com/MHSanaei/3x-ui/commit/cd0eaefee66c5986108e681c128adff2fcbaf6b6) Merge branch 'main' into feat/tunnel-health-monitor - [`98efa43`](https://github.com/MHSanaei/3x-ui/commit/98efa432203f25dc698549a2906e9b995a3cf5d2) Merge branch 'main' into feat/tunnel-health-monitor - [`768ba1a`](https://github.com/MHSanaei/3x-ui/commit/768ba1a6f577dcaeb91c69b2081aba8f1414abbb) fix(tunnelmonitor): reuse netproxy client and init logger in tests - [`c268b91`](https://github.com/MHSanaei/3x-ui/commit/c268b91ef8133382f71c6301c7a4f2652d435013) fix(tunnelmonitor): observable recovery, signal headroom, and hardening ### 📊 Changes **5 files changed** (+773 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+13 -0) 📝 `README.md` (+7 -0) ➕ `internal/tunnelmonitor/monitor.go` (+271 -0) ➕ `internal/tunnelmonitor/monitor_test.go` (+454 -0) 📝 `main.go` (+28 -1) </details> ### 📄 Description Refs #3633 ## Summary - Add an optional tunnel health monitor. - Probe a configurable HTTP/HTTPS endpoint at a configurable interval. - Support direct, HTTP proxy, HTTPS proxy, SOCKS5 and SOCKS5H proxy probing. - Restart Xray core only after a configurable number of consecutive failures. - Add a cooldown window to avoid restart loops. - Keep the feature disabled by default and controlled through service environment variables. ## Configuration The monitor is disabled by default. It can be enabled with: ``` XUI_TUNNEL_HEALTH_MONITOR=true XUI_TUNNEL_HEALTH_URL=https://www.cloudflare.com/cdn-cgi/trace XUI_TUNNEL_HEALTH_PROXY=socks5://127.0.0.1:1080 XUI_TUNNEL_HEALTH_INTERVAL=30s XUI_TUNNEL_HEALTH_TIMEOUT=10s XUI_TUNNEL_HEALTH_FAILURES=3 XUI_TUNNEL_HEALTH_COOLDOWN=5m ``` ## Test - Not completed locally: Go dependency download/test failed in the local environment. ## Notes This is a safe MVP for tunnel recovery: it does not change Xray config, does not restart on a single transient failure, and rate-limits recovery through cooldown. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:50 +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#5894
No description provided.