mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-01 19:52:09 +03:00
feat(hosts): add a cipher suites override and accept custom suites
The inbound TLS form offered cipherSuites as a closed single-choice list, but xray reads the value as a colon-separated list and accepts any name Go knows, so several suites or one missing from the list could not be set. Both the inbound and the new host field now use a tag picker that keeps the stored value as the colon-joined string xray expects; old single values open unchanged. A host's cipher suites replace the inbound's in the JSON subscription stream, and a blank field inherits them. Share links and Clash carry no cipher suite parameter, so their output is unchanged.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
|
||||
import { CipherSuitesSelect } from '@/components/form';
|
||||
|
||||
function renderSelect(value: string) {
|
||||
const onChange = vi.fn();
|
||||
render(<CipherSuitesSelect aria-label="cipher suites" value={value} onChange={onChange} />);
|
||||
return onChange;
|
||||
}
|
||||
|
||||
describe('CipherSuitesSelect', () => {
|
||||
it('shows each colon-separated suite as its own tag', () => {
|
||||
renderSelect('TLS_AES_256_GCM_SHA384:MY_CUSTOM_SUITE');
|
||||
expect(screen.getByText('TLS_AES_256_GCM_SHA384')).toBeTruthy();
|
||||
expect(screen.getByText('MY_CUSTOM_SUITE')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('stores a typed custom suite joined with colons after the existing one', () => {
|
||||
const onChange = renderSelect('TLS_AES_256_GCM_SHA384');
|
||||
const input = screen.getByRole('combobox', { name: 'cipher suites' });
|
||||
fireEvent.change(input, { target: { value: 'MY_CUSTOM_SUITE' } });
|
||||
fireEvent.keyDown(input, { key: 'Enter', code: 'Enter', keyCode: 13 });
|
||||
expect(onChange).toHaveBeenLastCalledWith('TLS_AES_256_GCM_SHA384:MY_CUSTOM_SUITE');
|
||||
});
|
||||
|
||||
it('stores an empty string once every suite is removed', () => {
|
||||
const onChange = renderSelect('TLS_AES_256_GCM_SHA384');
|
||||
const remove = document.querySelector('.ant-select-selection-item-remove');
|
||||
expect(remove).not.toBeNull();
|
||||
fireEvent.click(remove as Element);
|
||||
expect(onChange).toHaveBeenLastCalledWith('');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user