mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2026-12-03 09:45:54 +00:00
feat: Loon Hysteria 2 支持 server-ports, hop-interval
This commit is contained in:
7 files changed
+185
-20
No files matched your search
@@ -72,7 +72,7 @@ anytls = tag equals "anytls"i address password (transport/transport_host/transpo
|
||||
proxy.type = "anytls";
|
||||
handleTransport();
|
||||
}
|
||||
hysteria2 = tag equals "hysteria2"i address password (tls_name/sni/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/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/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/fast_open/udp_relay/ip_mode/block_quic/others)* {
|
||||
@@ -195,6 +195,8 @@ ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(
|
||||
|
||||
ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; }
|
||||
download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); }
|
||||
server_ports = comma "server-ports" equals '"' match:$[^"]+ '"' { proxy.ports = match.trim().replace(/\s*-\s*/g, "-").replace(/\s*,\s*/g, ","); }
|
||||
hop_interval = comma "hop-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match, 10); }
|
||||
salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; }
|
||||
|
||||
block_quic = comma "block-quic" equals flag:bool { if(flag) proxy["block-quic"] = "on"; else proxy["block-quic"] = "off"; }
|
||||
|
||||
@@ -749,6 +749,17 @@ function hysteria2(proxy) {
|
||||
|
||||
result.appendIfPresent(`,"${proxy.password}"`, 'password');
|
||||
|
||||
if (isPresent(proxy, 'ports') && `${proxy.ports}`.trim().length > 0) {
|
||||
result.append(`,server-ports="${proxy.ports}"`);
|
||||
}
|
||||
|
||||
if (
|
||||
isPresent(proxy, 'hop-interval') &&
|
||||
`${proxy['hop-interval']}`.trim().length > 0
|
||||
) {
|
||||
result.append(`,hop-interval=${proxy['hop-interval']}`);
|
||||
}
|
||||
|
||||
// sni
|
||||
result.appendIfPresent(`,tls-name=${proxy.sni}`, 'sni');
|
||||
result.appendIfPresent(
|
||||
|
||||
@@ -4,6 +4,10 @@ import { isNotBlank } from '@/utils';
|
||||
|
||||
const targetPlatform = 'Surfboard';
|
||||
|
||||
function hasNonBlankValue(value) {
|
||||
return value != null && `${value}`.trim().length > 0;
|
||||
}
|
||||
|
||||
export default function Surfboard_Producer() {
|
||||
const produce = (proxy) => {
|
||||
if (
|
||||
@@ -62,14 +66,15 @@ function hysteria2(proxy) {
|
||||
|
||||
result.appendIfPresent(`,password="${proxy.password}"`, 'password');
|
||||
|
||||
if (isPresent(proxy, 'ports')) {
|
||||
result.append(`,port-hopping="${proxy.ports.replace(/,/g, ';')}"`);
|
||||
if (hasNonBlankValue(proxy.ports)) {
|
||||
result.append(
|
||||
`,port-hopping="${String(proxy.ports).replace(/,/g, ';')}"`,
|
||||
);
|
||||
}
|
||||
|
||||
result.appendIfPresent(
|
||||
`,port-hopping-interval=${proxy['hop-interval']}`,
|
||||
'hop-interval',
|
||||
);
|
||||
if (hasNonBlankValue(proxy['hop-interval'])) {
|
||||
result.append(`,port-hopping-interval=${proxy['hop-interval']}`);
|
||||
}
|
||||
|
||||
// tls verification
|
||||
result.appendIfPresent(`,sni="${proxy.sni}"`, 'sni');
|
||||
|
||||
@@ -44,6 +44,10 @@ function quoteSurgeValue(value) {
|
||||
.replace(/"/g, '\\"')}"`;
|
||||
}
|
||||
|
||||
function hasNonBlankValue(value) {
|
||||
return value != null && `${value}`.trim().length > 0;
|
||||
}
|
||||
|
||||
function appendClientCert(result, proxy) {
|
||||
const clientCert = isPresent(proxy, 'keystore-client-cert')
|
||||
? proxy['keystore-client-cert']
|
||||
@@ -1076,14 +1080,15 @@ function tuic(proxy) {
|
||||
'alpn',
|
||||
);
|
||||
|
||||
if (isPresent(proxy, 'ports')) {
|
||||
result.append(`,port-hopping="${proxy.ports.replace(/,/g, ';')}"`);
|
||||
if (hasNonBlankValue(proxy.ports)) {
|
||||
result.append(
|
||||
`,port-hopping="${String(proxy.ports).replace(/,/g, ';')}"`,
|
||||
);
|
||||
}
|
||||
|
||||
result.appendIfPresent(
|
||||
`,port-hopping-interval=${proxy['hop-interval']}`,
|
||||
'hop-interval',
|
||||
);
|
||||
if (hasNonBlankValue(proxy['hop-interval'])) {
|
||||
result.append(`,port-hopping-interval=${proxy['hop-interval']}`);
|
||||
}
|
||||
|
||||
const ip_version = ipVersions[proxy['ip-version']] || proxy['ip-version'];
|
||||
result.appendIfPresent(`,ip-version=${ip_version}`, 'ip-version');
|
||||
@@ -1348,14 +1353,15 @@ function hysteria2(proxy) {
|
||||
|
||||
result.appendIfPresent(`,password="${proxy.password}"`, 'password');
|
||||
|
||||
if (isPresent(proxy, 'ports')) {
|
||||
result.append(`,port-hopping="${proxy.ports.replace(/,/g, ';')}"`);
|
||||
if (hasNonBlankValue(proxy.ports)) {
|
||||
result.append(
|
||||
`,port-hopping="${String(proxy.ports).replace(/,/g, ';')}"`,
|
||||
);
|
||||
}
|
||||
|
||||
result.appendIfPresent(
|
||||
`,port-hopping-interval=${proxy['hop-interval']}`,
|
||||
'hop-interval',
|
||||
);
|
||||
if (hasNonBlankValue(proxy['hop-interval'])) {
|
||||
result.append(`,port-hopping-interval=${proxy['hop-interval']}`);
|
||||
}
|
||||
|
||||
if (proxy['obfs-password'] && proxy.obfs == 'salamander') {
|
||||
result.append(`,salamander-password="${proxy['obfs-password']}"`);
|
||||
|
||||
Reference in new issue
Block a user