@@ -3,6 +3,7 @@ import { Base64 } from 'js-base64';
33import { describe , it } from 'mocha' ;
44
55import { ProxyUtils } from '@/core/proxy-utils' ;
6+ import QX_Producer from '@/core/proxy-utils/producers/qx' ;
67import { produceExternal , UUID } from './helpers' ;
78
89describe ( 'Proxy text producers' , function ( ) {
@@ -287,6 +288,98 @@ describe('Proxy text producers', function () {
287288 ) ;
288289 } ) ;
289290
291+ it ( 'produces Quantumult X AnyTLS standard tls lines' , function ( ) {
292+ const output = produceExternal ( 'QX' , {
293+ type : 'anytls' ,
294+ name : 'anytls-standard-tls-01' ,
295+ server : 'example.com' ,
296+ port : 443 ,
297+ password : 'pwd' ,
298+ tls : true ,
299+ sni : 'apple.com' ,
300+ udp : true ,
301+ } ) ;
302+
303+ expect ( output ) . to . equal (
304+ 'anytls=example.com:443,password=pwd,over-tls=true,tls-host=apple.com,udp-relay=true,tag=anytls-standard-tls-01' ,
305+ ) ;
306+ } ) ;
307+
308+ it ( 'produces Quantumult X AnyTLS reality tls lines' , function ( ) {
309+ const output = produceExternal ( 'QX' , {
310+ type : 'anytls' ,
311+ name : 'anytls-reality-tls-01' ,
312+ server : 'example.com' ,
313+ port : 443 ,
314+ password : 'pwd' ,
315+ tls : true ,
316+ sni : 'apple.com' ,
317+ udp : true ,
318+ 'reality-opts' : {
319+ 'public-key' :
320+ 'k4Uxez0sjl8bKaZH2Vgi8-WDFshML51QkxKFLWFIONk' ,
321+ 'short-id' : '0123456789abcdef' ,
322+ } ,
323+ } ) ;
324+
325+ expect ( output ) . to . equal (
326+ 'anytls=example.com:443,password=pwd,over-tls=true,tls-host=apple.com,udp-relay=true,tag=anytls-reality-tls-01,reality-base64-pubkey=k4Uxez0sjl8bKaZH2Vgi8-WDFshML51QkxKFLWFIONk,reality-hex-shortid=0123456789abcdef' ,
327+ ) ;
328+ } ) ;
329+
330+ it ( 'produces Quantumult X AnyTLS lines and keeps only supported fields' , function ( ) {
331+ const output = produceExternal ( 'QX' , {
332+ type : 'anytls' ,
333+ name : 'QX AnyTLS Supported Fields' ,
334+ server : 'anytls.example.com' ,
335+ port : 443 ,
336+ password : 'secret' ,
337+ tls : true ,
338+ sni : 'sni.example.com' ,
339+ udp : true ,
340+ tfo : true ,
341+ 'skip-cert-verify' : true ,
342+ 'test-url' : 'https://check.example.com' ,
343+ 'idle-session-timeout' : 30 ,
344+ 'max-stream-count' : 16 ,
345+ } ) ;
346+
347+ expect ( output ) . to . equal (
348+ 'anytls=anytls.example.com:443,password=secret,over-tls=true,tls-verification=false,tls-host=sni.example.com,fast-open=true,udp-relay=true,server_check_url=https://check.example.com,tag=QX AnyTLS Supported Fields' ,
349+ ) ;
350+ } ) ;
351+
352+ it ( 'rejects Quantumult X AnyTLS transport shapes that QX cannot represent' , function ( ) {
353+ const producer = QX_Producer ( ) ;
354+
355+ expect ( ( ) =>
356+ producer . produce ( {
357+ type : 'anytls' ,
358+ name : 'QX AnyTLS WS' ,
359+ server : 'anytls.example.com' ,
360+ port : 443 ,
361+ password : 'secret' ,
362+ tls : true ,
363+ network : 'ws' ,
364+ 'ws-opts' : {
365+ path : '/anytls' ,
366+ headers : {
367+ Host : 'cdn.example.com' ,
368+ } ,
369+ } ,
370+ } ) ,
371+ ) . to . throw ( 'Platform QX does not support AnyTLS with transport ws' ) ;
372+ } ) ;
373+
374+ it ( 'round-trips Quantumult X AnyTLS reality lines without changing supported semantics' , function ( ) {
375+ const raw =
376+ 'anytls=example.com:443,password=pwd,over-tls=true,tls-host=apple.com,udp-relay=true,tag=anytls-reality-tls-01,reality-base64-pubkey=k4Uxez0sjl8bKaZH2Vgi8-WDFshML51QkxKFLWFIONk,reality-hex-shortid=0123456789abcdef' ;
377+ const [ proxy ] = ProxyUtils . parse ( raw ) ;
378+ const output = ProxyUtils . produce ( [ proxy ] , 'QX' , 'external' ) ;
379+
380+ expect ( output ) . to . equal ( raw ) ;
381+ } ) ;
382+
290383 it ( 'produces Loon VLESS reality websocket lines' , function ( ) {
291384 const output = produceExternal ( 'Loon' , {
292385 type : 'vless' ,
0 commit comments