[PR #6613] [MERGED] feat(sub): make external subscription fetch User-Agent configurable #6379

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

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6613
Author: @mrchatam
Created: 9/19/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @MHSanaei

Base: main ← Head: feat/external-sub-custom-user-agent


📝 Commits (4)

  • 383fff4 feat(sub): make external subscription fetch User-Agent configurable
  • 870e73d ci: retrigger frontend after npm registry maintenance
  • e1252c6 Merge origin/main into feat/external-sub-custom-user-agent
  • 7f54dd3 fix(sub): fall back to the default UA when the DB is not initialised

📊 Changes

26 files changed (+161 additions, -1 deletions)

View changed files

📝 docs/public/openapi.json (+8 -0)
📝 frontend/public/openapi.json (+8 -0)
📝 frontend/src/generated/examples.ts (+2 -0)
📝 frontend/src/generated/schemas.ts (+8 -0)
📝 frontend/src/generated/types.ts (+2 -0)
📝 frontend/src/generated/zod.ts (+2 -0)
📝 frontend/src/models/setting.ts (+1 -0)
📝 frontend/src/pages/settings/SubscriptionGeneralTab.tsx (+20 -0)
📝 frontend/src/schemas/setting.ts (+1 -0)
📝 internal/sub/external_subscription.go (+14 -1)
📝 internal/sub/external_subscription_test.go (+55 -0)
📝 internal/web/entity/entity.go (+1 -0)
📝 internal/web/service/setting.go (+13 -0)
📝 internal/web/translation/ar-EG.json (+2 -0)
📝 internal/web/translation/en-US.json (+2 -0)
📝 internal/web/translation/es-ES.json (+2 -0)
📝 internal/web/translation/fa-IR.json (+2 -0)
📝 internal/web/translation/id-ID.json (+2 -0)
📝 internal/web/translation/ja-JP.json (+2 -0)
📝 internal/web/translation/pt-BR.json (+2 -0)

...and 6 more files

📄 Description

Summary

Some subscription providers reject fetches unless the request sends a known client User-Agent. Client external subscription fetches still used a hardcoded v2rayNG/1.8.5.

This adds a panel setting externalSubUserAgent (Settings → Subscription → General) that is sent when fetching those URLs. The default remains v2rayNG/1.8.5 for backward compatibility; blank values also fall back to that default.

Outbound subscriptions already support a per-row User-Agent (#6398). This covers the remaining client external-subscription path called out in #6383.

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?

  • go test ./internal/sub/ -run 'TestFetchUsesConfiguredExternalSubUserAgent|TestFetchFallsBackToDefaultExternalSubUserAgent|TestFetchSendsStableHwid'
  • go test ./internal/sub/ ./internal/web/service/ ./internal/web/entity/
  • go test ./internal/web/service/ -run 'FactoryDefaults|GetAllSetting'
  • npm run gen (zod + openapi)
  • npm run format:check
  • npm run typecheck

Breaking changes

None. Existing installs keep the previous User-Agent until the setting is changed.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • For frontend changes: npm run typecheck and npm run format:check pass.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

Fixes #6383


🔄 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/6613 **Author:** [@mrchatam](https://github.com/mrchatam) **Created:** 9/19/2026 **Status:** ✅ Merged **Merged:** 9/26/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/external-sub-custom-user-agent` --- ### 📝 Commits (4) - [`383fff4`](https://github.com/MHSanaei/3x-ui/commit/383fff43b3cd9a5afb6a42c9834422db07e017ab) feat(sub): make external subscription fetch User-Agent configurable - [`870e73d`](https://github.com/MHSanaei/3x-ui/commit/870e73df9363aa85e1007fe3c3fe6d23bf42a666) ci: retrigger frontend after npm registry maintenance - [`e1252c6`](https://github.com/MHSanaei/3x-ui/commit/e1252c6aeab3e109f642e3a647beb0cc3132cabc) Merge origin/main into feat/external-sub-custom-user-agent - [`7f54dd3`](https://github.com/MHSanaei/3x-ui/commit/7f54dd3ac94fb01a350ca78570137e31b8538d66) fix(sub): fall back to the default UA when the DB is not initialised ### 📊 Changes **26 files changed** (+161 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/public/openapi.json` (+8 -0) 📝 `frontend/public/openapi.json` (+8 -0) 📝 `frontend/src/generated/examples.ts` (+2 -0) 📝 `frontend/src/generated/schemas.ts` (+8 -0) 📝 `frontend/src/generated/types.ts` (+2 -0) 📝 `frontend/src/generated/zod.ts` (+2 -0) 📝 `frontend/src/models/setting.ts` (+1 -0) 📝 `frontend/src/pages/settings/SubscriptionGeneralTab.tsx` (+20 -0) 📝 `frontend/src/schemas/setting.ts` (+1 -0) 📝 `internal/sub/external_subscription.go` (+14 -1) 📝 `internal/sub/external_subscription_test.go` (+55 -0) 📝 `internal/web/entity/entity.go` (+1 -0) 📝 `internal/web/service/setting.go` (+13 -0) 📝 `internal/web/translation/ar-EG.json` (+2 -0) 📝 `internal/web/translation/en-US.json` (+2 -0) 📝 `internal/web/translation/es-ES.json` (+2 -0) 📝 `internal/web/translation/fa-IR.json` (+2 -0) 📝 `internal/web/translation/id-ID.json` (+2 -0) 📝 `internal/web/translation/ja-JP.json` (+2 -0) 📝 `internal/web/translation/pt-BR.json` (+2 -0) _...and 6 more files_ </details> ### 📄 Description ## Summary Some subscription providers reject fetches unless the request sends a known client `User-Agent`. Client external subscription fetches still used a hardcoded `v2rayNG/1.8.5`. This adds a panel setting `externalSubUserAgent` (Settings → Subscription → General) that is sent when fetching those URLs. The default remains `v2rayNG/1.8.5` for backward compatibility; blank values also fall back to that default. Outbound subscriptions already support a per-row User-Agent (#6398). This covers the remaining client external-subscription path called out in #6383. ## 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 - [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? - `go test ./internal/sub/ -run 'TestFetchUsesConfiguredExternalSubUserAgent|TestFetchFallsBackToDefaultExternalSubUserAgent|TestFetchSendsStableHwid'` - `go test ./internal/sub/ ./internal/web/service/ ./internal/web/entity/` - `go test ./internal/web/service/ -run 'FactoryDefaults|GetAllSetting'` - `npm run gen` (zod + openapi) - `npm run format:check` - `npm run typecheck` ## Breaking changes None. Existing installs keep the previous User-Agent until the setting is changed. ## 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] For frontend changes: `npm run typecheck` and `npm run format:check` pass. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. Fixes #6383 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:21 +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#6379
No description provided.