[PR #5273] [CLOSED] feat(node): add per-node SOCKS/HTTP proxy support #5839

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5273
Author: @NikanZeyaei
Created: 6/13/2026
Status: ❌ Closed

Base: main ← Head: feature/per-node-proxy


📝 Commits (5)

  • 9b8501c feat(node): add proxy_url field and service support
  • 603fbc8 feat(runtime): add per-node proxy support to Remote
  • d9388ab feat(ui): add proxy URL form field and indicator
  • be14404 i18n(ui): add proxy-related translation keys
  • 7d600ea i18n(ui): mention proxy auth in placeholder

📊 Changes

20 files changed (+271 additions, -30 deletions)

View changed files

📝 frontend/src/pages/nodes/NodeFormModal.tsx (+11 -0)
📝 frontend/src/pages/nodes/NodeList.tsx (+16 -0)
📝 frontend/src/schemas/node.ts (+2 -0)
📝 internal/database/model/model.go (+1 -0)
📝 internal/web/runtime/remote.go (+59 -1)
📝 internal/web/service/node.go (+84 -29)
📝 internal/web/service/node_test.go (+46 -0)
📝 internal/web/translation/ar-EG.json (+4 -0)
📝 internal/web/translation/en-US.json (+4 -0)
📝 internal/web/translation/es-ES.json (+4 -0)
📝 internal/web/translation/fa-IR.json (+4 -0)
📝 internal/web/translation/id-ID.json (+4 -0)
📝 internal/web/translation/ja-JP.json (+4 -0)
📝 internal/web/translation/pt-BR.json (+4 -0)
📝 internal/web/translation/ru-RU.json (+4 -0)
📝 internal/web/translation/tr-TR.json (+4 -0)
📝 internal/web/translation/uk-UA.json (+4 -0)
📝 internal/web/translation/vi-VN.json (+4 -0)
📝 internal/web/translation/zh-CN.json (+4 -0)
📝 internal/web/translation/zh-TW.json (+4 -0)

📄 Description

Summary

Closes #5256

Adds an optional per-node proxy URL so the central panel can route outbound API calls to a remote node through a SOCKS5 (socks5/socks5h) or HTTP/HTTPS proxy. This helps users in restricted network environments reach nodes that are not directly accessible.

Why

Users in regions with restricted connectivity may have nodes outside the country that are hard to reach directly. A panel-wide proxy is not always desirable; per-node proxy allows routing only the necessary node traffic through a local or remote proxy. Credentials can be embedded in the URL (socks5://user:pass@host:port).

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  1. go build ./... — passes.
  2. go test ./internal/web/service/... ./internal/web/runtime/... — passes.
  3. cd frontend && npm run typecheck — passes.
  4. cd frontend && npm run test — passes.
  5. cd frontend && npm run build — passes.
  6. Manual proxy scenarios tested:
    • Empty proxy URL (direct connection).
    • HTTP proxy without authentication.
    • HTTP proxy with authentication (http://user:pass@host:port).
    • SOCKS5 proxy without authentication.
    • SOCKS5 proxy with authentication (socks5://user:pass@host:port).

Implementation details

Backend (Go):

  • Added ProxyUrl field to the Node model (internal/database/model/model.go); GORM auto-migration adds the proxy_url column.
  • Added proxy URL validation in NodeService.normalize() and persistence in Update() (internal/web/service/node.go).
  • Updated nodeHTTPClientFor() to build proxy-aware clients via netproxy.NewHTTPClient() while preserving the shared global client for the no-proxy default case.
  • Updated FetchCertFingerprint() to route certificate fingerprint fetching through the proxy when configured.
  • Updated Remote in internal/web/runtime/remote.go to build a per-node HTTP client honoring the proxy URL and TLS skip/pin settings.
  • Added normalize tests for proxy URL validation (internal/web/service/node_test.go).

Frontend (TypeScript/React):

  • Added proxyUrl to NodeRecordSchema and NodeFormSchema (frontend/src/schemas/node.ts).
  • Added proxy URL input to NodeFormModal.tsx with placeholder and hint.
  • Added proxy indicator icon in NodeList.tsx table and mobile card views.

Translations:

  • Added proxyUrl, proxyUrlPlaceholder, proxyUrlHint, and proxyTooltip keys to all 13 supported language files.

Files changed

  • internal/database/model/model.go
  • internal/web/service/node.go
  • internal/web/service/node_test.go
  • internal/web/runtime/remote.go
  • frontend/src/schemas/node.ts
  • frontend/src/pages/nodes/NodeFormModal.tsx
  • frontend/src/pages/nodes/NodeList.tsx
  • internal/web/translation/en-US.json
  • internal/web/translation/ar-EG.json
  • internal/web/translation/es-ES.json
  • internal/web/translation/fa-IR.json
  • internal/web/translation/id-ID.json
  • internal/web/translation/ja-JP.json
  • internal/web/translation/pt-BR.json
  • internal/web/translation/ru-RU.json
  • internal/web/translation/tr-TR.json
  • internal/web/translation/uk-UA.json
  • internal/web/translation/vi-VN.json
  • internal/web/translation/zh-CN.json
  • internal/web/translation/zh-TW.json

Screenshots / recordings

2026-06-13 13 40 59 2026-06-13 13 40 56

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run typecheck and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • 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/5273 **Author:** [@NikanZeyaei](https://github.com/NikanZeyaei) **Created:** 6/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/per-node-proxy` --- ### 📝 Commits (5) - [`9b8501c`](https://github.com/MHSanaei/3x-ui/commit/9b8501c5fc9002405b1060261d41fc74e42c50f6) feat(node): add proxy_url field and service support - [`603fbc8`](https://github.com/MHSanaei/3x-ui/commit/603fbc8185fd0b0e3557811724f4c39e8094a79d) feat(runtime): add per-node proxy support to Remote - [`d9388ab`](https://github.com/MHSanaei/3x-ui/commit/d9388abd40c113d3ea22a0d75b796b8a0259c529) feat(ui): add proxy URL form field and indicator - [`be14404`](https://github.com/MHSanaei/3x-ui/commit/be1440460bb3fc1948585875daf018b78e64e428) i18n(ui): add proxy-related translation keys - [`7d600ea`](https://github.com/MHSanaei/3x-ui/commit/7d600ea130d5bf3ac452c328e45ade580ed57798) i18n(ui): mention proxy auth in placeholder ### 📊 Changes **20 files changed** (+271 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/nodes/NodeFormModal.tsx` (+11 -0) 📝 `frontend/src/pages/nodes/NodeList.tsx` (+16 -0) 📝 `frontend/src/schemas/node.ts` (+2 -0) 📝 `internal/database/model/model.go` (+1 -0) 📝 `internal/web/runtime/remote.go` (+59 -1) 📝 `internal/web/service/node.go` (+84 -29) 📝 `internal/web/service/node_test.go` (+46 -0) 📝 `internal/web/translation/ar-EG.json` (+4 -0) 📝 `internal/web/translation/en-US.json` (+4 -0) 📝 `internal/web/translation/es-ES.json` (+4 -0) 📝 `internal/web/translation/fa-IR.json` (+4 -0) 📝 `internal/web/translation/id-ID.json` (+4 -0) 📝 `internal/web/translation/ja-JP.json` (+4 -0) 📝 `internal/web/translation/pt-BR.json` (+4 -0) 📝 `internal/web/translation/ru-RU.json` (+4 -0) 📝 `internal/web/translation/tr-TR.json` (+4 -0) 📝 `internal/web/translation/uk-UA.json` (+4 -0) 📝 `internal/web/translation/vi-VN.json` (+4 -0) 📝 `internal/web/translation/zh-CN.json` (+4 -0) 📝 `internal/web/translation/zh-TW.json` (+4 -0) </details> ### 📄 Description ## Summary Closes #5256 Adds an optional per-node proxy URL so the central panel can route outbound API calls to a remote node through a SOCKS5 (`socks5`/`socks5h`) or HTTP/HTTPS proxy. This helps users in restricted network environments reach nodes that are not directly accessible. ## Why Users in regions with restricted connectivity may have nodes outside the country that are hard to reach directly. A panel-wide proxy is not always desirable; per-node proxy allows routing only the necessary node traffic through a local or remote proxy. Credentials can be embedded in the URL (`socks5://user:pass@host:port`). ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [x] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [x] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? 1. `go build ./...` — passes. 2. `go test ./internal/web/service/... ./internal/web/runtime/...` — passes. 3. `cd frontend && npm run typecheck` — passes. 4. `cd frontend && npm run test` — passes. 5. `cd frontend && npm run build` — passes. 6. Manual proxy scenarios tested: - Empty proxy URL (direct connection). - HTTP proxy without authentication. - HTTP proxy with authentication (`http://user:pass@host:port`). - SOCKS5 proxy without authentication. - SOCKS5 proxy with authentication (`socks5://user:pass@host:port`). ## Implementation details **Backend (Go):** - Added `ProxyUrl` field to the `Node` model (`internal/database/model/model.go`); GORM auto-migration adds the `proxy_url` column. - Added proxy URL validation in `NodeService.normalize()` and persistence in `Update()` (`internal/web/service/node.go`). - Updated `nodeHTTPClientFor()` to build proxy-aware clients via `netproxy.NewHTTPClient()` while preserving the shared global client for the no-proxy default case. - Updated `FetchCertFingerprint()` to route certificate fingerprint fetching through the proxy when configured. - Updated `Remote` in `internal/web/runtime/remote.go` to build a per-node HTTP client honoring the proxy URL and TLS skip/pin settings. - Added normalize tests for proxy URL validation (`internal/web/service/node_test.go`). **Frontend (TypeScript/React):** - Added `proxyUrl` to `NodeRecordSchema` and `NodeFormSchema` (`frontend/src/schemas/node.ts`). - Added proxy URL input to `NodeFormModal.tsx` with placeholder and hint. - Added proxy indicator icon in `NodeList.tsx` table and mobile card views. **Translations:** - Added `proxyUrl`, `proxyUrlPlaceholder`, `proxyUrlHint`, and `proxyTooltip` keys to all 13 supported language files. ## Files changed - `internal/database/model/model.go` - `internal/web/service/node.go` - `internal/web/service/node_test.go` - `internal/web/runtime/remote.go` - `frontend/src/schemas/node.ts` - `frontend/src/pages/nodes/NodeFormModal.tsx` - `frontend/src/pages/nodes/NodeList.tsx` - `internal/web/translation/en-US.json` - `internal/web/translation/ar-EG.json` - `internal/web/translation/es-ES.json` - `internal/web/translation/fa-IR.json` - `internal/web/translation/id-ID.json` - `internal/web/translation/ja-JP.json` - `internal/web/translation/pt-BR.json` - `internal/web/translation/ru-RU.json` - `internal/web/translation/tr-TR.json` - `internal/web/translation/uk-UA.json` - `internal/web/translation/vi-VN.json` - `internal/web/translation/zh-CN.json` - `internal/web/translation/zh-TW.json` ## Screenshots / recordings <img width="558" height="236" alt="2026-06-13 13 40 59" src="https://github.com/user-attachments/assets/43abce25-81e7-4645-b242-edfc341c0ec4" /> <img width="1252" height="208" alt="2026-06-13 13 40 56" src="https://github.com/user-attachments/assets/abb17fc6-ef21-461d-9031-6e08c9c6a7ef" /> ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run typecheck` and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [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:04:27 +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#5839
No description provided.