mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-17 07:37:15 +00:00
fix(panel): read outbound protocol ids case-insensitively everywhere (#6523)
Six more readers compared an outbound's protocol id exactly while the core lowercases it, so an outbound spelled "Blackhole" passed every excludeBlackhole filter (offered as an mtproto egress, a dialerProxy target and the geodata download egress, all of which then drop the traffic) and one spelled "Freedom" was queued by Test All Outbounds. They now share isOutboundProtocol.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { isOutboundProtocol } from '@/schemas/primitives';
|
||||
|
||||
// xray-core lowercases a protocol id in LoadWithID before it resolves the
|
||||
// handler, so every panel reader has to accept the spellings it accepts.
|
||||
describe('isOutboundProtocol', () => {
|
||||
it.each([
|
||||
['canonical', { protocol: 'freedom' }],
|
||||
['capitalised', { protocol: 'Freedom' }],
|
||||
['upper', { protocol: 'FREEDOM' }],
|
||||
['mixed', { protocol: 'fReEdOm' }],
|
||||
])('matches a %s id', (_name, outbound) => {
|
||||
expect(isOutboundProtocol(outbound, 'freedom')).toBe(true);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['another protocol', { protocol: 'blackhole' }],
|
||||
['another spelling of another protocol', { protocol: 'Blackhole' }],
|
||||
['missing', {}],
|
||||
['empty', { protocol: '' }],
|
||||
['not a string', { protocol: 42 }],
|
||||
['null', null],
|
||||
['undefined', undefined],
|
||||
])('rejects %s', (_name, outbound) => {
|
||||
expect(isOutboundProtocol(outbound, 'freedom')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user