mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-17 15:47:14 +00:00
feat(outbounds): support custom subscription user agents (#6398)
Some subscription providers require a client-specific User-Agent before returning outbound links. Persist an optional value per subscription and use it for refreshes and previews while preserving the existing default for blank values.
This commit is contained in:
@@ -62,6 +62,8 @@ import { useOutboundColumns } from './useOutboundColumns';
|
||||
import OutboundCardList from './OutboundCardList';
|
||||
import SubscriptionOutbounds from './SubscriptionOutbounds';
|
||||
|
||||
const defaultOutboundSubscriptionUserAgent = '3x-ui-outbound-sub/1.0';
|
||||
|
||||
interface OutboundSub {
|
||||
id: number;
|
||||
remark?: string;
|
||||
@@ -69,6 +71,7 @@ interface OutboundSub {
|
||||
enabled?: boolean;
|
||||
allowPrivate?: boolean;
|
||||
allowInsecure?: boolean;
|
||||
userAgent?: string;
|
||||
prepend?: boolean;
|
||||
priority?: number;
|
||||
tagPrefix?: string;
|
||||
@@ -136,6 +139,7 @@ export default function OutboundsTab({
|
||||
remark: '',
|
||||
url: '',
|
||||
tagPrefix: '',
|
||||
userAgent: '',
|
||||
updateInterval: 600,
|
||||
enabled: true,
|
||||
allowPrivate: false,
|
||||
@@ -334,6 +338,7 @@ export default function OutboundsTab({
|
||||
remark?: string;
|
||||
url?: string;
|
||||
tagPrefix?: string;
|
||||
userAgent?: string;
|
||||
updateInterval?: number;
|
||||
enabled?: boolean;
|
||||
allowPrivate?: boolean;
|
||||
@@ -344,6 +349,7 @@ export default function OutboundsTab({
|
||||
remark: src.remark ?? '',
|
||||
url: src.url ?? '',
|
||||
tagPrefix: src.tagPrefix ?? '',
|
||||
userAgent: src.userAgent ?? '',
|
||||
updateInterval: src.updateInterval ?? 600,
|
||||
enabled: src.enabled ?? true,
|
||||
allowPrivate: src.allowPrivate ?? false,
|
||||
@@ -356,6 +362,7 @@ export default function OutboundsTab({
|
||||
remark: '',
|
||||
url: '',
|
||||
tagPrefix: '',
|
||||
userAgent: '',
|
||||
updateInterval: 600,
|
||||
enabled: true,
|
||||
allowPrivate: false,
|
||||
@@ -370,6 +377,7 @@ export default function OutboundsTab({
|
||||
remark: sub.remark ?? '',
|
||||
url: sub.url ?? '',
|
||||
tagPrefix: sub.tagPrefix ?? '',
|
||||
userAgent: sub.userAgent ?? '',
|
||||
updateInterval: sub.updateInterval ?? 600,
|
||||
enabled: sub.enabled ?? true,
|
||||
allowPrivate: sub.allowPrivate ?? false,
|
||||
@@ -423,7 +431,12 @@ export default function OutboundsTab({
|
||||
try {
|
||||
const r = await HttpUtil.post<{ tag?: string; protocol?: string }[]>(
|
||||
'/panel/api/xray/outbound-subs/parse',
|
||||
{ url: newSub.url, allowPrivate: newSub.allowPrivate },
|
||||
{
|
||||
url: newSub.url,
|
||||
userAgent: newSub.userAgent,
|
||||
allowPrivate: newSub.allowPrivate,
|
||||
allowInsecure: newSub.allowInsecure,
|
||||
},
|
||||
);
|
||||
if (r?.success && Array.isArray(r.obj)) {
|
||||
setPreviewData(r.obj);
|
||||
@@ -721,6 +734,13 @@ export default function OutboundsTab({
|
||||
placeholder={t('pages.xray.outboundSub.tagPrefixPlaceholder')}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('pages.xray.outboundSub.userAgent')}>
|
||||
<Input
|
||||
value={newSub.userAgent}
|
||||
onChange={(e) => setNewSub({ ...newSub, userAgent: e.target.value })}
|
||||
placeholder={defaultOutboundSubscriptionUserAgent}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label={t('pages.xray.outboundSub.interval')}>
|
||||
<Space>
|
||||
<InputNumber
|
||||
|
||||
Reference in New Issue
Block a user