[PR #6166] [MERGED] fix(outbound): import Hysteria2 salamander properly from standard obfs params #6127

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6166
Author: @xMasterX
Created: 7/31/2026
Status: ✅ Merged
Merged: 8/14/2026
Merged by: @MHSanaei

Base: main ← Head: fix/hysteria2-obfs-import


📝 Commits (3)

  • 9e43e16 fix(outbound): import Hysteria2 salamander from standard obfs params
  • 505144d fix(outbound): address review — mport hop, password-less fm mask, tests
  • 85d608b Merge branch 'main' into fix/hysteria2-obfs-import

📊 Changes

4 files changed (+362 additions, -0 deletions)

View changed files

📝 frontend/src/lib/xray/outbound-link-parser.ts (+43 -0)
📝 frontend/src/test/outbound-link-parser.test.ts (+87 -0)
📝 internal/util/link/outbound.go (+65 -0)
📝 internal/util/link/outbound_test.go (+167 -0)

📄 Description

Problem

The outbound share-link importers only reconstructed the salamander obfuscation from 3x-ui's private fm=<json> finalmask dump. They never parsed the standard Hysteria2 obfs=salamander + obfs-password=<pw> pair.

Since the subscription/link generator (internal/sub) already emits the standard obfs/obfs-password fields (and drops fm=, which broke mihomo & other clients), the obfuscation only round-trips 3x-ui→3x-ui. Importing any normal Hysteria2 link — every other client, and even our own generated links — silently dropped the salamander config. You end up with an outbound that negotiates plain QUIC while the server expects salamander, so it just fails to connect.

This affects both import paths:

  • pasting a link into the outbound form (frontend outbound-link-parser.ts)
  • subscription / JSON import on the backend (internal/util/link)

Fix

Parse the standard obfs=salamander + obfs-password pair in both importers and fold it into finalmask.udp as { type: "salamander", settings: { password } } — the same shape the UI and generator already use. Also accept the obfs_password / obfsPassword aliases.

If a link still carries a full fm= finalmask with a salamander mask, that wins and the obfs pair is a no-op, so existing 3x-ui→3x-ui links are unchanged.

Tests

  • Go: internal/util/link/outbound_test.go — standard obfs imported, no-obfs untouched, obfs-without-password ignored, and fm= wins over obfs.
  • Frontend: outbound-link-parser.test.ts — obfs-only reconstruction, no-obfs, and obfs-without-password. npm run test and go test ./internal/util/link/ both green.

No schema/DB/route/i18n changes; make gen output unaffected.

Why

Was trying to fill the issue but found them missing completely. Why issues section are removed from repo?

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 - Import sub with hysteria into Outbounds screen
Click test, see (failed)

2 - Import hysteria link manually via JSON screen on add outbound
See no salamander was added, if you continue it will fail to connect too
If you add salamander and enter password manually after link import - everything works correctly

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.

🔄 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/6166 **Author:** [@xMasterX](https://github.com/xMasterX) **Created:** 7/31/2026 **Status:** ✅ Merged **Merged:** 8/14/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/hysteria2-obfs-import` --- ### 📝 Commits (3) - [`9e43e16`](https://github.com/MHSanaei/3x-ui/commit/9e43e160960523995ca4ce88b461ecc351e63b80) fix(outbound): import Hysteria2 salamander from standard obfs params - [`505144d`](https://github.com/MHSanaei/3x-ui/commit/505144d71a3f423853d1e987e9b2ffb3cb2834b6) fix(outbound): address review — mport hop, password-less fm mask, tests - [`85d608b`](https://github.com/MHSanaei/3x-ui/commit/85d608b47789d758850c2557f1299d6b9b55e405) Merge branch 'main' into fix/hysteria2-obfs-import ### 📊 Changes **4 files changed** (+362 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/lib/xray/outbound-link-parser.ts` (+43 -0) 📝 `frontend/src/test/outbound-link-parser.test.ts` (+87 -0) 📝 `internal/util/link/outbound.go` (+65 -0) 📝 `internal/util/link/outbound_test.go` (+167 -0) </details> ### 📄 Description ### Problem The outbound share-link importers only reconstructed the salamander obfuscation from 3x-ui's private `fm=<json>` finalmask dump. They never parsed the **standard** Hysteria2 `obfs=salamander` + `obfs-password=<pw>` pair. Since the subscription/link generator (`internal/sub`) already emits the standard `obfs`/`obfs-password` fields (and drops `fm=`, which broke mihomo & other clients), the obfuscation only round-trips 3x-ui→3x-ui. Importing **any** normal Hysteria2 link — every other client, and even our own generated links — silently dropped the salamander config. You end up with an outbound that negotiates plain QUIC while the server expects salamander, so it just fails to connect. This affects both import paths: - pasting a link into the outbound form (frontend `outbound-link-parser.ts`) - subscription / JSON import on the backend (`internal/util/link`) ### Fix Parse the standard `obfs=salamander` + `obfs-password` pair in both importers and fold it into `finalmask.udp` as `{ type: "salamander", settings: { password } }` — the same shape the UI and generator already use. Also accept the `obfs_password` / `obfsPassword` aliases. If a link still carries a full `fm=` finalmask with a salamander mask, that wins and the obfs pair is a no-op, so existing 3x-ui→3x-ui links are unchanged. ### Tests - Go: `internal/util/link/outbound_test.go` — standard obfs imported, no-obfs untouched, obfs-without-password ignored, and `fm=` wins over `obfs`. - Frontend: `outbound-link-parser.test.ts` — obfs-only reconstruction, no-obfs, and obfs-without-password. `npm run test` and `go test ./internal/util/link/` both green. No schema/DB/route/i18n changes; `make gen` output unaffected. ## Why Was trying to fill the issue but found them missing completely. Why issues section are removed from repo? ## Type of change - [X] Bug fix - [ ] 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 - [x] 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 - Import sub with hysteria into Outbounds screen Click test, see (failed) 2 - Import hysteria link manually via JSON screen on add outbound See no salamander was added, if you continue it will fail to connect too If you add salamander and enter password manually after link import - everything works correctly ## Checklist - [] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:34 +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#6127
No description provided.