mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-12-02 17:32:46 +00:00
feat: Loon 支持 alpn; Loon tls-profile 和 sing-box client-fingerprint 规范化
This commit is contained in:
7 files changed
+329
-21
No files matched your search
@@ -40,6 +40,16 @@ const grammars = String.raw`
|
||||
if (!supported.includes(normalized)) return "auto";
|
||||
return normalized === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : normalized;
|
||||
}
|
||||
|
||||
function loonClientFingerprint(tlsProfile) {
|
||||
switch (String(tlsProfile || "").trim()) {
|
||||
case "chrome":
|
||||
return "chrome";
|
||||
case "ios18":
|
||||
case "ios26":
|
||||
return "ios";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2/anytls) {
|
||||
@@ -61,35 +71,35 @@ shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs
|
||||
$set(proxy, "plugin-opts.path", obfs.path);
|
||||
}
|
||||
}
|
||||
vmess = tag equals "vmess"i address vmess_method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* {
|
||||
vmess = tag equals "vmess"i address vmess_method uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/block_quic/others)* {
|
||||
proxy.type = "vmess";
|
||||
proxy.cipher = proxy.cipher || "auto";
|
||||
proxy.alterId = proxy.alterId || 0;
|
||||
handleTransport();
|
||||
}
|
||||
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* {
|
||||
vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/flow/public_key/short_id/block_quic/others)* {
|
||||
proxy.type = "vless";
|
||||
handleTransport();
|
||||
}
|
||||
trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
proxy.type = "trojan";
|
||||
handleTransport();
|
||||
}
|
||||
anytls = tag equals "anytls"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/fast_open/udp_relay/ip_mode/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* {
|
||||
anytls = tag equals "anytls"i address password (transport/transport_host/transport_path/over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* {
|
||||
proxy.type = "anytls";
|
||||
handleTransport();
|
||||
}
|
||||
hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/udp_relay/fast_open/download_bandwidth/server_ports/hop_interval/salamander_password/ecn/ip_mode/block_quic/others)* {
|
||||
hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/udp_relay/fast_open/download_bandwidth/server_ports/hop_interval/salamander_password/ecn/ip_mode/block_quic/others)* {
|
||||
proxy.type = "hysteria2";
|
||||
}
|
||||
https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
https = tag equals "https"i address (username password)? (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
proxy.type = "http";
|
||||
proxy.tls = true;
|
||||
}
|
||||
http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
proxy.type = "http";
|
||||
}
|
||||
socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/tls_profile/alpn/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
proxy.type = "socks5";
|
||||
}
|
||||
|
||||
@@ -194,7 +204,19 @@ sni = comma "sni" equals match:[^,]+ { proxy.sni = match.join("").replace(/^"(.*
|
||||
tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; }
|
||||
tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||
tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||
tls_profile = comma "tls-profile" equals match:[^,]+ { proxy["client-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||
tls_profile = comma "tls-profile" equals match:[^,]+ {
|
||||
const tlsProfile = match.join("").replace(/^"(.*)"$/, '$1').trim();
|
||||
proxy["_loon_tls_profile"] = tlsProfile;
|
||||
const clientFingerprint = loonClientFingerprint(tlsProfile);
|
||||
if (clientFingerprint) proxy["client-fingerprint"] = clientFingerprint;
|
||||
}
|
||||
alpn = comma "alpn" equals '"' match:$[^"]* '"' {
|
||||
const values = match
|
||||
.split(",")
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item !== "");
|
||||
if (values.length > 0) proxy.alpn = values;
|
||||
}
|
||||
|
||||
flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||
public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); }
|
||||
|
||||
@@ -64,11 +64,36 @@ export default function Loon_Producer() {
|
||||
}
|
||||
|
||||
function appendTlsProfile(result, proxy) {
|
||||
if (
|
||||
isPresent(proxy, 'client-fingerprint') &&
|
||||
`${proxy['client-fingerprint']}`.trim() !== ''
|
||||
) {
|
||||
result.append(`,tls-profile=${proxy['client-fingerprint']}`);
|
||||
const tlsProfile = getLoonTlsProfile(proxy);
|
||||
if (tlsProfile) result.append(`,tls-profile=${tlsProfile}`);
|
||||
}
|
||||
|
||||
function appendAlpn(result, proxy) {
|
||||
const alpn = getLoonAlpn(proxy);
|
||||
if (alpn) result.append(`,alpn="${alpn}"`);
|
||||
}
|
||||
|
||||
function getLoonAlpn(proxy) {
|
||||
const values = Array.isArray(proxy.alpn)
|
||||
? proxy.alpn
|
||||
: `${proxy.alpn || ''}`.split(',');
|
||||
return values
|
||||
.map((item) => `${item}`.trim())
|
||||
.filter((item) => item !== '')
|
||||
.join(',');
|
||||
}
|
||||
|
||||
function getLoonTlsProfile(proxy) {
|
||||
const tlsProfile = `${proxy._loon_tls_profile || ''}`.trim();
|
||||
if (['default', 'chrome', 'ios18', 'ios26'].includes(tlsProfile)) {
|
||||
return tlsProfile;
|
||||
}
|
||||
|
||||
switch (`${proxy['client-fingerprint'] || ''}`.trim()) {
|
||||
case 'chrome':
|
||||
return 'chrome';
|
||||
case 'ios':
|
||||
return 'ios26';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +341,7 @@ function trojan(proxy) {
|
||||
'skip-cert-verify',
|
||||
);
|
||||
appendTlsProfile(result, proxy);
|
||||
appendAlpn(result, proxy);
|
||||
|
||||
// sni
|
||||
result.appendIfPresent(`,tls-name=${proxy.sni}`, 'sni');
|
||||
@@ -372,6 +398,7 @@ function anytls(proxy) {
|
||||
'skip-cert-verify',
|
||||
);
|
||||
appendTlsProfile(result, proxy);
|
||||
appendAlpn(result, proxy);
|
||||
|
||||
// sni
|
||||
result.appendIfPresent(`,tls-name=${proxy.sni}`, 'sni');
|
||||
@@ -456,6 +483,7 @@ function vmess(proxy) {
|
||||
);
|
||||
if (proxy.tls || isReality) {
|
||||
appendTlsProfile(result, proxy);
|
||||
appendAlpn(result, proxy);
|
||||
}
|
||||
|
||||
if (isReality) {
|
||||
@@ -569,6 +597,7 @@ function vless(proxy) {
|
||||
);
|
||||
if (proxy.tls || isReality || isXtls) {
|
||||
appendTlsProfile(result, proxy);
|
||||
appendAlpn(result, proxy);
|
||||
}
|
||||
|
||||
if (isXtls) {
|
||||
@@ -633,6 +662,7 @@ function http(proxy) {
|
||||
);
|
||||
if (proxy.tls) {
|
||||
appendTlsProfile(result, proxy);
|
||||
appendAlpn(result, proxy);
|
||||
}
|
||||
|
||||
// tfo
|
||||
@@ -669,6 +699,7 @@ function socks5(proxy) {
|
||||
);
|
||||
if (proxy.tls) {
|
||||
appendTlsProfile(result, proxy);
|
||||
appendAlpn(result, proxy);
|
||||
}
|
||||
|
||||
// tfo
|
||||
@@ -800,6 +831,7 @@ function hysteria2(proxy) {
|
||||
'skip-cert-verify',
|
||||
);
|
||||
appendTlsProfile(result, proxy);
|
||||
appendAlpn(result, proxy);
|
||||
|
||||
if (proxy['obfs-password'] && proxy.obfs == 'salamander') {
|
||||
result.append(`,salamander-password=${proxy['obfs-password']}`);
|
||||
|
||||
@@ -290,6 +290,24 @@ const normalizePemLines = (value, label) => {
|
||||
return [`-----BEGIN ${label}-----`, ...lines, `-----END ${label}-----`];
|
||||
};
|
||||
|
||||
const singBoxUtlsFingerprints = [
|
||||
'chrome',
|
||||
'firefox',
|
||||
'edge',
|
||||
'safari',
|
||||
'360',
|
||||
'qq',
|
||||
'ios',
|
||||
'android',
|
||||
'random',
|
||||
'randomized',
|
||||
];
|
||||
|
||||
const getSingBoxUtlsFingerprint = (value) => {
|
||||
const fingerprint = `${value || ''}`.trim().toLowerCase();
|
||||
if (singBoxUtlsFingerprints.includes(fingerprint)) return fingerprint;
|
||||
};
|
||||
|
||||
const tlsParser = (proxy, parsedProxy) => {
|
||||
if (proxy.tls) parsedProxy.tls.enabled = true;
|
||||
if (proxy.servername && proxy.servername !== '')
|
||||
@@ -320,11 +338,17 @@ const tlsParser = (proxy, parsedProxy) => {
|
||||
!['hysteria', 'hysteria2', 'tuic'].includes(proxy.type) &&
|
||||
proxy['client-fingerprint'] &&
|
||||
proxy['client-fingerprint'] !== ''
|
||||
)
|
||||
parsedProxy.tls.utls = {
|
||||
enabled: true,
|
||||
fingerprint: proxy['client-fingerprint'],
|
||||
};
|
||||
) {
|
||||
const fingerprint = getSingBoxUtlsFingerprint(
|
||||
proxy['client-fingerprint'],
|
||||
);
|
||||
if (fingerprint)
|
||||
parsedProxy.tls.utls = {
|
||||
...parsedProxy.tls.utls,
|
||||
enabled: true,
|
||||
fingerprint,
|
||||
};
|
||||
}
|
||||
if (proxy._ech && isPlainObject(proxy._ech)) {
|
||||
parsedProxy.tls.ech = proxy._ech;
|
||||
} else if (proxy['ech-opts'] && isPlainObject(proxy['ech-opts'])) {
|
||||
@@ -532,6 +556,7 @@ const normalizeALPN = (alpn) => {
|
||||
|
||||
const shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
||||
if (!pluginOpts) throw new Error('shadow-tls plugin options are missing');
|
||||
const fingerprint = getSingBoxUtlsFingerprint(proxy['client-fingerprint']);
|
||||
|
||||
const stPart = {
|
||||
tag: getShadowTLSTag(proxy),
|
||||
@@ -545,7 +570,7 @@ const shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
|
||||
server_name: pluginOpts.host,
|
||||
utls: {
|
||||
enabled: true,
|
||||
fingerprint: proxy['client-fingerprint'],
|
||||
fingerprint,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2707,7 +2707,7 @@ describe('Platform raw-format parser coverage', function () {
|
||||
},
|
||||
{
|
||||
title: 'parses vmess http tls lines',
|
||||
input: `Loon VMess=vmess,loon-vmess.example.com,443,auto,"${UUID}",transport=http,host=cdn.example.com,path=/http,over-tls=true,tls-name=sni.example.com,skip-cert-verify=true,tls-profile=chrome,alterId=0`,
|
||||
input: `Loon VMess=vmess,loon-vmess.example.com,443,auto,"${UUID}",transport=http,host=cdn.example.com,path=/http,over-tls=true,tls-name=sni.example.com,skip-cert-verify=true,tls-profile=chrome,alpn="http/1.1,h2,h3",alterId=0`,
|
||||
expected: {
|
||||
type: 'vmess',
|
||||
name: 'Loon VMess',
|
||||
@@ -2719,7 +2719,9 @@ describe('Platform raw-format parser coverage', function () {
|
||||
tls: true,
|
||||
sni: 'sni.example.com',
|
||||
'skip-cert-verify': true,
|
||||
_loon_tls_profile: 'chrome',
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn: ['http/1.1', 'h2', 'h3'],
|
||||
network: 'http',
|
||||
'http-opts': {
|
||||
path: ['/http'],
|
||||
@@ -2978,6 +2980,37 @@ describe('Platform raw-format parser coverage', function () {
|
||||
},
|
||||
]);
|
||||
|
||||
it('normalizes Loon tls-profile values into client fingerprints', function () {
|
||||
const cases = [
|
||||
['default'],
|
||||
['chrome', 'chrome'],
|
||||
['ios18', 'ios'],
|
||||
['ios26', 'ios'],
|
||||
];
|
||||
|
||||
for (const [profile, fingerprint] of cases) {
|
||||
const proxy = parseOne(
|
||||
`Loon ${profile}=vmess,loon-${profile}.example.com,443,auto,"${UUID}",over-tls=true,tls-profile=${profile},alterId=0`,
|
||||
);
|
||||
|
||||
expect(proxy._loon_tls_profile).to.equal(profile);
|
||||
if (fingerprint) {
|
||||
expect(proxy['client-fingerprint']).to.equal(fingerprint);
|
||||
} else {
|
||||
expect(proxy).to.not.have.property('client-fingerprint');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps unknown Loon tls-profile values out of client-fingerprint', function () {
|
||||
const proxy = parseOne(
|
||||
`Loon Unknown Profile=vmess,loon-unknown.example.com,443,auto,"${UUID}",over-tls=true,tls-profile=unknown-browser,alterId=0`,
|
||||
);
|
||||
|
||||
expect(proxy._loon_tls_profile).to.equal('unknown-browser');
|
||||
expect(proxy).to.not.have.property('client-fingerprint');
|
||||
});
|
||||
|
||||
it('rejects hysteria2 hop interval ranges', function () {
|
||||
expect(
|
||||
parseAll(
|
||||
|
||||
@@ -94,6 +94,19 @@ describe('Proxy structured producers', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('normalizes Loon tls-profile before emitting Mihomo client fingerprints', function () {
|
||||
const [proxy] = ProxyUtils.parse(
|
||||
`Loon IOS26=vmess,loon-ios26.example.com,443,auto,"${UUID}",over-tls=true,tls-profile=ios26,alterId=0`,
|
||||
);
|
||||
const output = loadProducedYaml('Mihomo', proxy);
|
||||
|
||||
expect(proxy._loon_tls_profile).to.equal('ios26');
|
||||
expect(proxy['client-fingerprint']).to.equal('ios');
|
||||
expect(output.proxies[0]['client-fingerprint']).to.equal('ios');
|
||||
expect(output.proxies[0]['client-fingerprint']).to.not.equal('ios26');
|
||||
expect(output.proxies[0]).to.not.have.property('_loon_tls_profile');
|
||||
});
|
||||
|
||||
it('normalizes VMess security values for documented target platforms', function () {
|
||||
const invalidSecurityProxy = {
|
||||
type: 'vmess',
|
||||
@@ -635,6 +648,38 @@ describe('Proxy structured producers', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('omits unsupported sing-box ShadowTLS uTLS fingerprints', function () {
|
||||
const [proxy] = ProxyUtils.parse(`proxies:
|
||||
- name: SS ShadowTLS Unsupported Fingerprint
|
||||
type: ss
|
||||
server: ss.example.com
|
||||
port: 443
|
||||
cipher: chacha20-ietf-poly1305
|
||||
password: password
|
||||
plugin: shadow-tls
|
||||
client-fingerprint: chrome120
|
||||
plugin-opts:
|
||||
host: cloud.tencent.com
|
||||
password: shadow_tls_password
|
||||
version: 2`);
|
||||
|
||||
const output = loadProducedJson('sing-box', proxy);
|
||||
const shadowtls = output.outbounds.find(
|
||||
(item) =>
|
||||
item.tag === 'SS ShadowTLS Unsupported Fingerprint_shadowtls',
|
||||
);
|
||||
|
||||
expectSubset(shadowtls, {
|
||||
tls: {
|
||||
enabled: true,
|
||||
utls: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(shadowtls.tls.utls).to.not.have.property('fingerprint');
|
||||
});
|
||||
|
||||
it('keeps only Shadowsocks shadow-tls versions 1 through 3 for Mihomo', function () {
|
||||
const buildShadowTlsProxy = (name, version) => ({
|
||||
type: 'ss',
|
||||
@@ -3797,6 +3842,80 @@ describe('Proxy structured producers', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('validates sing-box uTLS fingerprints for regular TLS and Reality outbounds', function () {
|
||||
const output = loadProducedJson('sing-box', [
|
||||
{
|
||||
type: 'vmess',
|
||||
name: 'VMess Supported Fingerprint',
|
||||
server: 'vmess-supported.example.com',
|
||||
port: 443,
|
||||
uuid: UUID,
|
||||
cipher: 'auto',
|
||||
alterId: 0,
|
||||
tls: true,
|
||||
'client-fingerprint': 'chrome',
|
||||
},
|
||||
{
|
||||
type: 'vmess',
|
||||
name: 'VMess Unsupported Fingerprint',
|
||||
server: 'vmess-unsupported.example.com',
|
||||
port: 443,
|
||||
uuid: UUID,
|
||||
cipher: 'auto',
|
||||
alterId: 0,
|
||||
tls: true,
|
||||
'client-fingerprint': 'chrome120',
|
||||
},
|
||||
{
|
||||
type: 'vless',
|
||||
name: 'Reality Unsupported Fingerprint',
|
||||
server: 'reality-unsupported.example.com',
|
||||
port: 443,
|
||||
uuid: UUID,
|
||||
tls: true,
|
||||
flow: 'xtls-rprx-vision',
|
||||
'client-fingerprint': 'chrome120',
|
||||
'reality-opts': {
|
||||
'public-key': 'pubkey',
|
||||
'short-id': '08',
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const supported = output.outbounds.find(
|
||||
(item) => item.tag === 'VMess Supported Fingerprint',
|
||||
);
|
||||
const unsupported = output.outbounds.find(
|
||||
(item) => item.tag === 'VMess Unsupported Fingerprint',
|
||||
);
|
||||
const reality = output.outbounds.find(
|
||||
(item) => item.tag === 'Reality Unsupported Fingerprint',
|
||||
);
|
||||
|
||||
expectSubset(supported, {
|
||||
tls: {
|
||||
utls: {
|
||||
enabled: true,
|
||||
fingerprint: 'chrome',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(unsupported.tls).to.not.have.property('utls');
|
||||
expectSubset(reality, {
|
||||
tls: {
|
||||
reality: {
|
||||
enabled: true,
|
||||
public_key: 'pubkey',
|
||||
short_id: '08',
|
||||
},
|
||||
utls: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(reality.tls.utls).to.not.have.property('fingerprint');
|
||||
});
|
||||
|
||||
it('emits sing-box VMess and VLESS packet protocol options', function () {
|
||||
const output = loadProducedJson('sing-box', [
|
||||
{
|
||||
|
||||
@@ -433,7 +433,8 @@ describe('Proxy text producers', function () {
|
||||
);
|
||||
});
|
||||
|
||||
it('emits Loon tls-profile for TLS protocol outputs', function () {
|
||||
it('emits Loon tls-profile and alpn for TLS protocol outputs', function () {
|
||||
const alpn = ['http/1.1', 'h2', 'h3'];
|
||||
const output = produceExternal('Loon', [
|
||||
{
|
||||
type: 'vmess',
|
||||
@@ -446,6 +447,7 @@ describe('Proxy text producers', function () {
|
||||
tls: true,
|
||||
sni: 'sni.example.com',
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
{
|
||||
type: 'vless',
|
||||
@@ -456,6 +458,7 @@ describe('Proxy text producers', function () {
|
||||
tls: true,
|
||||
sni: 'sni.example.com',
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
{
|
||||
type: 'vless',
|
||||
@@ -471,6 +474,7 @@ describe('Proxy text producers', function () {
|
||||
'short-id': '08',
|
||||
},
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
{
|
||||
type: 'vless',
|
||||
@@ -481,6 +485,7 @@ describe('Proxy text producers', function () {
|
||||
flow: 'xtls-rprx-vision',
|
||||
sni: 'sni.example.com',
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
{
|
||||
type: 'trojan',
|
||||
@@ -489,6 +494,7 @@ describe('Proxy text producers', function () {
|
||||
port: 443,
|
||||
password: 'secret',
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
{
|
||||
type: 'anytls',
|
||||
@@ -497,6 +503,7 @@ describe('Proxy text producers', function () {
|
||||
port: 443,
|
||||
password: 'secret',
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
{
|
||||
type: 'http',
|
||||
@@ -505,6 +512,7 @@ describe('Proxy text producers', function () {
|
||||
port: 443,
|
||||
tls: true,
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
{
|
||||
type: 'socks5',
|
||||
@@ -513,6 +521,7 @@ describe('Proxy text producers', function () {
|
||||
port: 1080,
|
||||
tls: true,
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
{
|
||||
type: 'hysteria2',
|
||||
@@ -521,10 +530,72 @@ describe('Proxy text producers', function () {
|
||||
port: 443,
|
||||
password: 'secret',
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn,
|
||||
},
|
||||
]);
|
||||
|
||||
expect(output.match(/tls-profile=chrome/g)).to.have.length(9);
|
||||
expect(output.match(/alpn="http\/1\.1,h2,h3"/g)).to.have.length(9);
|
||||
});
|
||||
|
||||
it('selects Loon tls-profile before client fingerprint fallback', function () {
|
||||
const buildTrojan = (name, fields) => ({
|
||||
type: 'trojan',
|
||||
name,
|
||||
server: `${name.toLowerCase().replace(/\s+/g, '-')}.example.com`,
|
||||
port: 443,
|
||||
password: 'secret',
|
||||
...fields,
|
||||
});
|
||||
const output = produceExternal('Loon', [
|
||||
buildTrojan('Loon Source IOS18', {
|
||||
_loon_tls_profile: 'ios18',
|
||||
'client-fingerprint': 'ios',
|
||||
}),
|
||||
buildTrojan('Loon Source Default', {
|
||||
_loon_tls_profile: 'default',
|
||||
'client-fingerprint': 'chrome',
|
||||
}),
|
||||
buildTrojan('Loon Source Chrome', {
|
||||
_loon_tls_profile: 'chrome',
|
||||
'client-fingerprint': 'ios',
|
||||
}),
|
||||
buildTrojan('Loon Fallback Chrome', {
|
||||
'client-fingerprint': 'chrome',
|
||||
}),
|
||||
buildTrojan('Loon Fallback IOS', {
|
||||
'client-fingerprint': 'ios',
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(output).to.include('Loon Source IOS18=trojan');
|
||||
expect(output).to.include('tls-profile=ios18');
|
||||
expect(output).to.include('tls-profile=default');
|
||||
expect(output).to.include('tls-profile=chrome');
|
||||
expect(output).to.include('tls-profile=ios26');
|
||||
expect(output.match(/tls-profile=/g)).to.have.length(5);
|
||||
});
|
||||
|
||||
it('omits invalid Loon tls-profile fallback values', function () {
|
||||
const buildTrojan = (fingerprint) => ({
|
||||
type: 'trojan',
|
||||
name: `Loon ${fingerprint || 'Blank'} Profile`,
|
||||
server: 'trojan-profile.example.com',
|
||||
port: 443,
|
||||
password: 'secret',
|
||||
'client-fingerprint': fingerprint,
|
||||
});
|
||||
const output = produceExternal('Loon', [
|
||||
buildTrojan('default'),
|
||||
buildTrojan('ios18'),
|
||||
buildTrojan('ios26'),
|
||||
buildTrojan('firefox'),
|
||||
buildTrojan('random'),
|
||||
buildTrojan('chrome120'),
|
||||
buildTrojan(''),
|
||||
]);
|
||||
|
||||
expect(output).to.not.include('tls-profile=');
|
||||
});
|
||||
|
||||
it('omits Loon tls-profile for non-TLS outputs and empty fingerprints', function () {
|
||||
@@ -535,6 +606,7 @@ describe('Proxy text producers', function () {
|
||||
server: 'http.example.com',
|
||||
port: 80,
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn: ['http/1.1', 'h2'],
|
||||
},
|
||||
{
|
||||
type: 'socks5',
|
||||
@@ -542,6 +614,7 @@ describe('Proxy text producers', function () {
|
||||
server: 'socks.example.com',
|
||||
port: 1080,
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn: ['http/1.1', 'h2'],
|
||||
},
|
||||
{
|
||||
type: 'vmess',
|
||||
@@ -552,6 +625,7 @@ describe('Proxy text producers', function () {
|
||||
uuid: UUID,
|
||||
alterId: 0,
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn: ['http/1.1', 'h2'],
|
||||
},
|
||||
{
|
||||
type: 'vless',
|
||||
@@ -560,6 +634,7 @@ describe('Proxy text producers', function () {
|
||||
port: 80,
|
||||
uuid: UUID,
|
||||
'client-fingerprint': 'chrome',
|
||||
alpn: ['http/1.1', 'h2'],
|
||||
},
|
||||
{
|
||||
type: 'trojan',
|
||||
@@ -572,6 +647,7 @@ describe('Proxy text producers', function () {
|
||||
]);
|
||||
|
||||
expect(output).to.not.include('tls-profile=');
|
||||
expect(output).to.not.include('alpn=');
|
||||
});
|
||||
|
||||
it('produces Loon Hysteria2 lines with port hopping', function () {
|
||||
|
||||
@@ -52,6 +52,7 @@ function operator(proxies = [], targetPlatform, context) {
|
||||
// 28. sing-box 1.14.0 起才有 `control_http_client` , 暂时可使用 `control-http-client` 字段设置 sing-box 的 `control_http_client`
|
||||
// 若 `control-http-client` 非空, 输出 sing-box Tailscale endpoint 时会跳过旧版拨号字段映射, 避免和 `detour`/`dialer-proxy` 等 legacy dialer options 冲突. 需要给控制面设置前置代理时, 请写到 `control-http-client.detour`(1.14.0-alpha.26 又改回去了...)
|
||||
// 29. sing-box 支持使用 `ssh-server` 给 tailscale 设置 `ssh_server`, 直接设为 `true` 或 `{ "enabled": true, "disable-pty": true, "disable-sftp": true, "disable-forwarding": true }`
|
||||
// 30. Loon 支持使用 `_loon_tls_profile` 设置 `tls-profile` 字段('default', 'chrome', 'ios18', 'ios26'), 否则则使用 client-fingerprint 自动转换部分对应的值
|
||||
|
||||
// require 为 Node.js 的 require, 在 Node.js 运行环境下 可以用来引入模块
|
||||
// 例如在 Node.js 环境下, 将文件内容写入 /tmp/1.txt 文件
|
||||
|
||||
Reference in new issue
Block a user