mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-16 23:27:14 +00:00
c0c2dd274c
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.
29 lines
995 B
TypeScript
29 lines
995 B
TypeScript
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);
|
|
});
|
|
});
|