[PR #6849] [CLOSED] feat(xray): add supervised multi-region Psiphon outbound sidecars #6483

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6849
Author: @rqzbeh
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: feat/psiphon-outbound


📝 Commits (2)

  • 0e43258 feat(xray): add supervised multi-region Psiphon outbound sidecars
  • 5b0ea68 fix(psiphon): address golangci-lint goimports and noctx findings

📊 Changes

51 files changed (+3812 additions, -14 deletions)

View changed files

📝 DockerInit.sh (+19 -0)
📝 frontend/public/openapi.json (+468 -0)
📝 frontend/src/generated/examples.ts (+28 -0)
📝 frontend/src/generated/schemas.ts (+124 -0)
📝 frontend/src/generated/types.ts (+30 -0)
📝 frontend/src/generated/zod.ts (+36 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+74 -0)
📝 frontend/src/pages/xray/XrayPage.tsx (+8 -1)
📝 frontend/src/pages/xray/outbounds/OutboundsTab.tsx (+8 -0)
➕ frontend/src/pages/xray/overrides/PsiphonModal.css (+38 -0)
➕ frontend/src/pages/xray/overrides/PsiphonModal.tsx (+422 -0)
📝 frontend/src/pages/xray/overrides/index.ts (+1 -0)
📝 frontend/src/schemas/protocols/outbound/index.ts (+1 -0)
➕ frontend/src/schemas/protocols/outbound/psiphon.ts (+40 -0)
➕ frontend/src/test/psiphon-modal.test.tsx (+21 -0)
📝 internal/database/db.go (+1 -0)
📝 internal/database/migrate_data.go (+1 -0)
📝 internal/database/model/model.go (+14 -0)
➕ internal/psiphon/manager.go (+398 -0)
➕ internal/psiphon/manager_test.go (+162 -0)

...and 31 more files

📄 Description

Summary

Adds multi-region Psiphon outbound support to 3x-ui by supervising standalone psiphon-tunnel-core ConsoleClient daemons as isolated loopback SOCKS5 sidecars per country, integrated into Xray outbounds, routing balancers, and panel UI.

Why

Unlike NordVPN or Cloudflare WARP which expose static WireGuard endpoints, Psiphon is a multi-hop, highly-obfuscated anti-censorship tunnel (SSH, Meek, Tapdance, TLS, and QUIC). Embedding psiphon-tunnel-core directly in 3x-ui produces Go dependency conflicts due to heavy replace directives. Supervising the standalone ConsoleClient binary as a managed local daemon (similar to internal/mtproto) enables running isolated egress country instances without dependency conflicts or connection instability.

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. Backend Unit & Integration Tests:
    • internal/psiphon: port allocation in range 40001-40099, config rendering with protected overrides (EgressRegion, LocalSocksProxyPort, DataRootDirectory), notice parsing, and probe RTT/IP measurement.
    • internal/psiphon/multi_instance_test.go: verified concurrent execution of 3 country instances (US, DE, JP), independent loopback SOCKS port binding, and clean stop.
    • internal/database: verified PsiphonInstance model migration, allModels / migrationModels cross-database parity.
    • internal/web/service/xray_psiphon_inject_test.go: verified injection of SOCKS outbounds, psiphon-balancer creation (with leastPing strategy when observatory is active), and UDP/443 bypass for client TCP fallback.
    • internal/web/routes_contract_test.go: verified all /panel/api/psiphon/* endpoints match the API documentation registry.
  2. Frontend Tests & Build:
    • npm run typecheck: clean (0 errors).
    • npm run lint: clean with oxlint.
    • npm run format:check: all files formatted correctly.
    • psiphon-modal.test.tsx: tested modal rendering, controls, and closed state.
    • npm run build: built all three Vite bundles (index.html, login.html, subpage.html) into internal/web/dist/.
    • make gen: generated OpenAPI spec and Zod schemas.
  3. Docker Verification:
    • Built container image 3x-ui-psiphon-test via Dockerfile and DockerInit.sh.
    • Verified prebuilt psiphon-linux-amd64 binary extraction into /app/bin/ alongside xray and mtg.
    • Ran container and verified /app/x-ui setting execution inside container.

Credits & Acknowledgments

  • Psiphon Inc. for psiphon-tunnel-core and ConsoleClient.
  • freeb5d/regionhop for the multi-region ConsoleClient daemon supervision and loopback SOCKS5 isolation architecture.

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 lint, 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.

🤖 Generated with Claude Code


🔄 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/6849 **Author:** [@rqzbeh](https://github.com/rqzbeh) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/psiphon-outbound` --- ### 📝 Commits (2) - [`0e43258`](https://github.com/MHSanaei/3x-ui/commit/0e432589bdc613f04ba02807fb487cbe19ba8256) feat(xray): add supervised multi-region Psiphon outbound sidecars - [`5b0ea68`](https://github.com/MHSanaei/3x-ui/commit/5b0ea6869e4d158ce18a8275aa92a054c0a2422a) fix(psiphon): address golangci-lint goimports and noctx findings ### 📊 Changes **51 files changed** (+3812 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `DockerInit.sh` (+19 -0) 📝 `frontend/public/openapi.json` (+468 -0) 📝 `frontend/src/generated/examples.ts` (+28 -0) 📝 `frontend/src/generated/schemas.ts` (+124 -0) 📝 `frontend/src/generated/types.ts` (+30 -0) 📝 `frontend/src/generated/zod.ts` (+36 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+74 -0) 📝 `frontend/src/pages/xray/XrayPage.tsx` (+8 -1) 📝 `frontend/src/pages/xray/outbounds/OutboundsTab.tsx` (+8 -0) ➕ `frontend/src/pages/xray/overrides/PsiphonModal.css` (+38 -0) ➕ `frontend/src/pages/xray/overrides/PsiphonModal.tsx` (+422 -0) 📝 `frontend/src/pages/xray/overrides/index.ts` (+1 -0) 📝 `frontend/src/schemas/protocols/outbound/index.ts` (+1 -0) ➕ `frontend/src/schemas/protocols/outbound/psiphon.ts` (+40 -0) ➕ `frontend/src/test/psiphon-modal.test.tsx` (+21 -0) 📝 `internal/database/db.go` (+1 -0) 📝 `internal/database/migrate_data.go` (+1 -0) 📝 `internal/database/model/model.go` (+14 -0) ➕ `internal/psiphon/manager.go` (+398 -0) ➕ `internal/psiphon/manager_test.go` (+162 -0) _...and 31 more files_ </details> ### 📄 Description ## Summary Adds multi-region Psiphon outbound support to 3x-ui by supervising standalone `psiphon-tunnel-core` `ConsoleClient` daemons as isolated loopback SOCKS5 sidecars per country, integrated into Xray outbounds, routing balancers, and panel UI. ## Why Unlike NordVPN or Cloudflare WARP which expose static WireGuard endpoints, Psiphon is a multi-hop, highly-obfuscated anti-censorship tunnel (SSH, Meek, Tapdance, TLS, and QUIC). Embedding `psiphon-tunnel-core` directly in 3x-ui produces Go dependency conflicts due to heavy `replace` directives. Supervising the standalone ConsoleClient binary as a managed local daemon (similar to `internal/mtproto`) enables running isolated egress country instances without dependency conflicts or connection instability. ## 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) - [x] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [x] Database / migrations - [ ] Install / upgrade script - [x] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? 1. **Backend Unit & Integration Tests**: - `internal/psiphon`: port allocation in range 40001-40099, config rendering with protected overrides (`EgressRegion`, `LocalSocksProxyPort`, `DataRootDirectory`), notice parsing, and probe RTT/IP measurement. - `internal/psiphon/multi_instance_test.go`: verified concurrent execution of 3 country instances (US, DE, JP), independent loopback SOCKS port binding, and clean stop. - `internal/database`: verified `PsiphonInstance` model migration, `allModels` / `migrationModels` cross-database parity. - `internal/web/service/xray_psiphon_inject_test.go`: verified injection of SOCKS outbounds, `psiphon-balancer` creation (with `leastPing` strategy when observatory is active), and UDP/443 bypass for client TCP fallback. - `internal/web/routes_contract_test.go`: verified all `/panel/api/psiphon/*` endpoints match the API documentation registry. 2. **Frontend Tests & Build**: - `npm run typecheck`: clean (0 errors). - `npm run lint`: clean with oxlint. - `npm run format:check`: all files formatted correctly. - `psiphon-modal.test.tsx`: tested modal rendering, controls, and closed state. - `npm run build`: built all three Vite bundles (`index.html`, `login.html`, `subpage.html`) into `internal/web/dist/`. - `make gen`: generated OpenAPI spec and Zod schemas. 3. **Docker Verification**: - Built container image `3x-ui-psiphon-test` via `Dockerfile` and `DockerInit.sh`. - Verified prebuilt `psiphon-linux-amd64` binary extraction into `/app/bin/` alongside `xray` and `mtg`. - Ran container and verified `/app/x-ui setting` execution inside container. ## Credits & Acknowledgments - [Psiphon Inc.](https://github.com/Psiphon-Labs/psiphon-tunnel-core) for `psiphon-tunnel-core` and `ConsoleClient`. - [freeb5d/regionhop](https://github.com/freeb5d/regionhop) for the multi-region ConsoleClient daemon supervision and loopback SOCKS5 isolation architecture. ## 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 lint`, `npm run typecheck`, and `npm run build` pass. - [x] 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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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:06 +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#6483
No description provided.