sub-store-convert 2.24.7 → 2.24.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +342 -232
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -438,7 +438,7 @@ ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (serv
|
|
|
438
438
|
proxy.type = "ssh";
|
|
439
439
|
handleShadowTLS();
|
|
440
440
|
}
|
|
441
|
-
snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
441
|
+
snell = tag equals "snell" address (snell_version/snell_mode/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* {
|
|
442
442
|
proxy.type = "snell";
|
|
443
443
|
// handle obfs
|
|
444
444
|
if (obfs.type == "http" || obfs.type === "tls") {
|
|
@@ -561,6 +561,12 @@ client_cert = comma "client-cert" equals match:[^,]+ { proxy["keystore-client-ce
|
|
|
561
561
|
|
|
562
562
|
snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
563
563
|
snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); }
|
|
564
|
+
snell_mode = comma "mode" equals match:[^,]+ {
|
|
565
|
+
const mode = stripQuotes(match.join("")).trim();
|
|
566
|
+
if (["default", "unshaped", "unsafe-raw"].includes(mode)) {
|
|
567
|
+
proxy.mode = mode;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
564
570
|
|
|
565
571
|
usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
566
572
|
passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); }
|
|
@@ -730,11 +736,11 @@ vless = tag equals "vless"i address uuid (transport/transport_host/transport_pat
|
|
|
730
736
|
proxy.type = "vless";
|
|
731
737
|
handleTransport();
|
|
732
738
|
}
|
|
733
|
-
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)* {
|
|
739
|
+
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/public_key/short_id/block_quic/others)* {
|
|
734
740
|
proxy.type = "trojan";
|
|
735
741
|
handleTransport();
|
|
736
742
|
}
|
|
737
|
-
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)* {
|
|
743
|
+
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/public_key/short_id/block_quic/idle_session_check_interval/idle_session_timeout/min_idle_session/max_stream_count/others)* {
|
|
738
744
|
proxy.type = "anytls";
|
|
739
745
|
handleTransport();
|
|
740
746
|
}
|
|
@@ -1494,7 +1500,7 @@ import _ from "lodash";
|
|
|
1494
1500
|
import { Base64 } from "js-base64";
|
|
1495
1501
|
|
|
1496
1502
|
// src/vendors/Sub-Store/backend/src/core/proxy-utils/xhttp-utils.js
|
|
1497
|
-
function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } = {}) {
|
|
1503
|
+
function parseNormalizedXhttpRangeBounds(value, { allowZeroLowerBound = true, allowZeroUpperBound = true } = {}) {
|
|
1498
1504
|
if (typeof value !== "string" && typeof value !== "number") {
|
|
1499
1505
|
return void 0;
|
|
1500
1506
|
}
|
|
@@ -1508,9 +1514,14 @@ function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } =
|
|
|
1508
1514
|
};
|
|
1509
1515
|
const normalizedValue = `${value}`.trim();
|
|
1510
1516
|
const rangeParts = normalizedValue.split("-");
|
|
1517
|
+
const minimumAllowedLowerBound = allowZeroLowerBound ? 0 : 1;
|
|
1518
|
+
const minimumAllowedUpperBound = allowZeroUpperBound ? 0 : 1;
|
|
1511
1519
|
if (rangeParts.length === 1) {
|
|
1512
1520
|
const normalizedInteger = parseUnsignedIntegerToken(rangeParts[0]);
|
|
1513
|
-
const minimumAllowedValue =
|
|
1521
|
+
const minimumAllowedValue = Math.max(
|
|
1522
|
+
minimumAllowedLowerBound,
|
|
1523
|
+
minimumAllowedUpperBound
|
|
1524
|
+
);
|
|
1514
1525
|
return normalizedInteger >= minimumAllowedValue ? {
|
|
1515
1526
|
lowerBound: normalizedInteger,
|
|
1516
1527
|
upperBound: normalizedInteger
|
|
@@ -1524,8 +1535,7 @@ function parseNormalizedXhttpRangeBounds(value, { allowZeroUpperBound = true } =
|
|
|
1524
1535
|
if (lowerBound == null || upperBound == null) {
|
|
1525
1536
|
return void 0;
|
|
1526
1537
|
}
|
|
1527
|
-
|
|
1528
|
-
return upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
1538
|
+
return lowerBound >= minimumAllowedLowerBound && upperBound >= minimumAllowedUpperBound && upperBound >= lowerBound ? {
|
|
1529
1539
|
lowerBound,
|
|
1530
1540
|
upperBound
|
|
1531
1541
|
} : void 0;
|
|
@@ -1535,9 +1545,11 @@ function parseNormalizedXhttpPositiveRangeBounds(value) {
|
|
|
1535
1545
|
allowZeroUpperBound: false
|
|
1536
1546
|
});
|
|
1537
1547
|
}
|
|
1538
|
-
function
|
|
1539
|
-
|
|
1540
|
-
|
|
1548
|
+
function parseNormalizedXhttpStrictPositiveRangeBounds(value) {
|
|
1549
|
+
return parseNormalizedXhttpRangeBounds(value, {
|
|
1550
|
+
allowZeroLowerBound: false,
|
|
1551
|
+
allowZeroUpperBound: false
|
|
1552
|
+
});
|
|
1541
1553
|
}
|
|
1542
1554
|
function normalizeXhttpPositiveRange(value) {
|
|
1543
1555
|
const normalizedBounds = parseNormalizedXhttpPositiveRangeBounds(value);
|
|
@@ -1547,6 +1559,22 @@ function normalizeXhttpPositiveRange(value) {
|
|
|
1547
1559
|
const { lowerBound, upperBound } = normalizedBounds;
|
|
1548
1560
|
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
1549
1561
|
}
|
|
1562
|
+
function normalizeXhttpStrictPositiveRangeString(value) {
|
|
1563
|
+
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
1564
|
+
if (!normalizedBounds) {
|
|
1565
|
+
return void 0;
|
|
1566
|
+
}
|
|
1567
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
1568
|
+
return lowerBound === upperBound ? `${upperBound}` : `${lowerBound}-${upperBound}`;
|
|
1569
|
+
}
|
|
1570
|
+
function normalizeXhttpStrictPositiveRangeValue(value) {
|
|
1571
|
+
const normalizedBounds = parseNormalizedXhttpStrictPositiveRangeBounds(value);
|
|
1572
|
+
if (!normalizedBounds) {
|
|
1573
|
+
return void 0;
|
|
1574
|
+
}
|
|
1575
|
+
const { lowerBound, upperBound } = normalizedBounds;
|
|
1576
|
+
return lowerBound === upperBound ? upperBound : `${lowerBound}-${upperBound}`;
|
|
1577
|
+
}
|
|
1550
1578
|
function normalizeXhttpNonNegativeRange(value) {
|
|
1551
1579
|
const normalizedBounds = parseNormalizedXhttpRangeBounds(value);
|
|
1552
1580
|
if (!normalizedBounds) {
|
|
@@ -2630,7 +2658,7 @@ function URI_VLESS() {
|
|
|
2630
2658
|
}
|
|
2631
2659
|
const parsedHeaders = {};
|
|
2632
2660
|
for (const [key, value] of Object.entries(headers)) {
|
|
2633
|
-
if (typeof value === "string"
|
|
2661
|
+
if (typeof value === "string") {
|
|
2634
2662
|
parsedHeaders[key] = value;
|
|
2635
2663
|
}
|
|
2636
2664
|
}
|
|
@@ -2682,7 +2710,7 @@ function URI_VLESS() {
|
|
|
2682
2710
|
}
|
|
2683
2711
|
const unsupportedHeaders = {};
|
|
2684
2712
|
for (const [key, value] of Object.entries(headers)) {
|
|
2685
|
-
if (typeof value === "string"
|
|
2713
|
+
if (typeof value === "string") {
|
|
2686
2714
|
continue;
|
|
2687
2715
|
}
|
|
2688
2716
|
setUnsupportedXhttpField(unsupportedHeaders, key, value);
|
|
@@ -2748,18 +2776,37 @@ function URI_VLESS() {
|
|
|
2748
2776
|
}
|
|
2749
2777
|
break;
|
|
2750
2778
|
case "xPaddingBytes":
|
|
2779
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2780
|
+
setUnsupportedXhttpField(
|
|
2781
|
+
unsupportedExtra,
|
|
2782
|
+
key,
|
|
2783
|
+
value
|
|
2784
|
+
);
|
|
2785
|
+
}
|
|
2786
|
+
break;
|
|
2751
2787
|
case "xPaddingKey":
|
|
2752
2788
|
case "xPaddingHeader":
|
|
2753
2789
|
case "xPaddingPlacement":
|
|
2754
2790
|
case "xPaddingMethod":
|
|
2755
2791
|
case "uplinkHTTPMethod":
|
|
2792
|
+
case "sessionIDPlacement":
|
|
2756
2793
|
case "sessionPlacement":
|
|
2794
|
+
case "sessionIDKey":
|
|
2757
2795
|
case "sessionKey":
|
|
2758
2796
|
case "seqPlacement":
|
|
2759
2797
|
case "seqKey":
|
|
2760
2798
|
case "uplinkDataPlacement":
|
|
2761
2799
|
case "uplinkDataKey":
|
|
2762
|
-
if (
|
|
2800
|
+
if (typeof value !== "string") {
|
|
2801
|
+
setUnsupportedXhttpField(
|
|
2802
|
+
unsupportedExtra,
|
|
2803
|
+
key,
|
|
2804
|
+
value
|
|
2805
|
+
);
|
|
2806
|
+
}
|
|
2807
|
+
break;
|
|
2808
|
+
case "sessionIDTable":
|
|
2809
|
+
if (typeof value !== "string") {
|
|
2763
2810
|
setUnsupportedXhttpField(
|
|
2764
2811
|
unsupportedExtra,
|
|
2765
2812
|
key,
|
|
@@ -2777,7 +2824,7 @@ function URI_VLESS() {
|
|
|
2777
2824
|
}
|
|
2778
2825
|
break;
|
|
2779
2826
|
case "scMaxEachPostBytes":
|
|
2780
|
-
if (
|
|
2827
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2781
2828
|
setUnsupportedXhttpField(
|
|
2782
2829
|
unsupportedExtra,
|
|
2783
2830
|
key,
|
|
@@ -2794,6 +2841,15 @@ function URI_VLESS() {
|
|
|
2794
2841
|
);
|
|
2795
2842
|
}
|
|
2796
2843
|
break;
|
|
2844
|
+
case "sessionIDLength":
|
|
2845
|
+
if (normalizeXhttpStrictPositiveRangeString(value) == null) {
|
|
2846
|
+
setUnsupportedXhttpField(
|
|
2847
|
+
unsupportedExtra,
|
|
2848
|
+
key,
|
|
2849
|
+
value
|
|
2850
|
+
);
|
|
2851
|
+
}
|
|
2852
|
+
break;
|
|
2797
2853
|
case "xmux": {
|
|
2798
2854
|
const unsupportedXmux = collectUnsupportedXmux(value);
|
|
2799
2855
|
if (unsupportedXmux !== void 0) {
|
|
@@ -3106,8 +3162,11 @@ function URI_VLESS() {
|
|
|
3106
3162
|
if (extra.noGRPCHeader === true) {
|
|
3107
3163
|
target["no-grpc-header"] = true;
|
|
3108
3164
|
}
|
|
3109
|
-
|
|
3110
|
-
|
|
3165
|
+
const xPaddingBytes = normalizeXhttpStrictPositiveRangeString(
|
|
3166
|
+
extra.xPaddingBytes
|
|
3167
|
+
);
|
|
3168
|
+
if (xPaddingBytes != null) {
|
|
3169
|
+
target["x-padding-bytes"] = xPaddingBytes;
|
|
3111
3170
|
}
|
|
3112
3171
|
if (extra.xPaddingObfsMode === true) {
|
|
3113
3172
|
target["x-padding-obfs-mode"] = true;
|
|
@@ -3127,12 +3186,25 @@ function URI_VLESS() {
|
|
|
3127
3186
|
if (isNotBlank(extra.uplinkHTTPMethod)) {
|
|
3128
3187
|
target["uplink-http-method"] = extra.uplinkHTTPMethod;
|
|
3129
3188
|
}
|
|
3130
|
-
if (isNotBlank(extra.
|
|
3189
|
+
if (isNotBlank(extra.sessionIDPlacement)) {
|
|
3190
|
+
target["session-placement"] = extra.sessionIDPlacement;
|
|
3191
|
+
} else if (isNotBlank(extra.sessionPlacement)) {
|
|
3131
3192
|
target["session-placement"] = extra.sessionPlacement;
|
|
3132
3193
|
}
|
|
3133
|
-
if (isNotBlank(extra.
|
|
3194
|
+
if (isNotBlank(extra.sessionIDKey)) {
|
|
3195
|
+
target["session-key"] = extra.sessionIDKey;
|
|
3196
|
+
} else if (isNotBlank(extra.sessionKey)) {
|
|
3134
3197
|
target["session-key"] = extra.sessionKey;
|
|
3135
3198
|
}
|
|
3199
|
+
if (typeof extra.sessionIDTable === "string") {
|
|
3200
|
+
target["session-table"] = extra.sessionIDTable;
|
|
3201
|
+
}
|
|
3202
|
+
const sessionIDLength = normalizeXhttpStrictPositiveRangeString(
|
|
3203
|
+
extra.sessionIDLength
|
|
3204
|
+
);
|
|
3205
|
+
if (sessionIDLength != null) {
|
|
3206
|
+
target["session-length"] = sessionIDLength;
|
|
3207
|
+
}
|
|
3136
3208
|
if (isNotBlank(extra.seqPlacement)) {
|
|
3137
3209
|
target["seq-placement"] = extra.seqPlacement;
|
|
3138
3210
|
}
|
|
@@ -3151,7 +3223,7 @@ function URI_VLESS() {
|
|
|
3151
3223
|
if (uplinkChunkSize != null) {
|
|
3152
3224
|
target["uplink-chunk-size"] = uplinkChunkSize;
|
|
3153
3225
|
}
|
|
3154
|
-
const scMaxEachPostBytes =
|
|
3226
|
+
const scMaxEachPostBytes = normalizeXhttpStrictPositiveRangeValue(
|
|
3155
3227
|
extra.scMaxEachPostBytes
|
|
3156
3228
|
);
|
|
3157
3229
|
if (scMaxEachPostBytes != null) {
|
|
@@ -4738,7 +4810,19 @@ function quoteSurgeValue(value) {
|
|
|
4738
4810
|
function hasNonBlankValue(value) {
|
|
4739
4811
|
return value != null && `${value}`.trim().length > 0;
|
|
4740
4812
|
}
|
|
4741
|
-
function
|
|
4813
|
+
function appendTlsProxyParams(result, proxy, enabled = true) {
|
|
4814
|
+
if (!enabled) {
|
|
4815
|
+
return;
|
|
4816
|
+
}
|
|
4817
|
+
result.appendIfPresent(
|
|
4818
|
+
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4819
|
+
"tls-fingerprint"
|
|
4820
|
+
);
|
|
4821
|
+
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4822
|
+
result.appendIfPresent(
|
|
4823
|
+
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4824
|
+
"skip-cert-verify"
|
|
4825
|
+
);
|
|
4742
4826
|
const clientCert = isPresent2(proxy, "keystore-client-cert") ? proxy["keystore-client-cert"] : proxy["client-cert"];
|
|
4743
4827
|
if (isPresent2(proxy, "keystore-client-cert") || isPresent2(proxy, "client-cert")) {
|
|
4744
4828
|
result.append(`,client-cert=${quoteSurgeValue(clientCert)}`);
|
|
@@ -4758,6 +4842,12 @@ function warnMaxStreamsIfNeeded(proxy) {
|
|
|
4758
4842
|
`Surge ${proxy.type} proxy ${proxy.name}: max-streams=${maxStreams} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`
|
|
4759
4843
|
);
|
|
4760
4844
|
}
|
|
4845
|
+
function hasSnellObfs(proxy) {
|
|
4846
|
+
return isPresent2(proxy, "obfs-opts.mode") || isPresent2(proxy, "obfs-opts.host") || isPresent2(proxy, "obfs-opts.path");
|
|
4847
|
+
}
|
|
4848
|
+
function isUnsupportedSnellV6Obfs(proxy) {
|
|
4849
|
+
return Number(proxy.version) === 6 && hasSnellObfs(proxy);
|
|
4850
|
+
}
|
|
4761
4851
|
function Surge_Producer() {
|
|
4762
4852
|
const produce2 = (proxy, type, opts = {}) => {
|
|
4763
4853
|
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -4947,16 +5037,7 @@ function trojan(proxy) {
|
|
|
4947
5037
|
);
|
|
4948
5038
|
handleTransport(result, proxy);
|
|
4949
5039
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
4950
|
-
result
|
|
4951
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
4952
|
-
"tls-fingerprint"
|
|
4953
|
-
);
|
|
4954
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
4955
|
-
result.appendIfPresent(
|
|
4956
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
4957
|
-
"skip-cert-verify"
|
|
4958
|
-
);
|
|
4959
|
-
appendClientCert(result, proxy);
|
|
5040
|
+
appendTlsProxyParams(result, proxy);
|
|
4960
5041
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
4961
5042
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
4962
5043
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5004,16 +5085,7 @@ function anytls(proxy) {
|
|
|
5004
5085
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5005
5086
|
"no-error-alert"
|
|
5006
5087
|
);
|
|
5007
|
-
result
|
|
5008
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5009
|
-
"tls-fingerprint"
|
|
5010
|
-
);
|
|
5011
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5012
|
-
result.appendIfPresent(
|
|
5013
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5014
|
-
"skip-cert-verify"
|
|
5015
|
-
);
|
|
5016
|
-
appendClientCert(result, proxy);
|
|
5088
|
+
appendTlsProxyParams(result, proxy);
|
|
5017
5089
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5018
5090
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5019
5091
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5058,16 +5130,7 @@ function trusttunnel(proxy) {
|
|
|
5058
5130
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5059
5131
|
"no-error-alert"
|
|
5060
5132
|
);
|
|
5061
|
-
result
|
|
5062
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5063
|
-
"tls-fingerprint"
|
|
5064
|
-
);
|
|
5065
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5066
|
-
result.appendIfPresent(
|
|
5067
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5068
|
-
"skip-cert-verify"
|
|
5069
|
-
);
|
|
5070
|
-
appendClientCert(result, proxy);
|
|
5133
|
+
appendTlsProxyParams(result, proxy);
|
|
5071
5134
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5072
5135
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5073
5136
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5112,16 +5175,7 @@ function h2Connect(proxy) {
|
|
|
5112
5175
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5113
5176
|
"no-error-alert"
|
|
5114
5177
|
);
|
|
5115
|
-
result
|
|
5116
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5117
|
-
"tls-fingerprint"
|
|
5118
|
-
);
|
|
5119
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5120
|
-
result.appendIfPresent(
|
|
5121
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5122
|
-
"skip-cert-verify"
|
|
5123
|
-
);
|
|
5124
|
-
appendClientCert(result, proxy);
|
|
5178
|
+
appendTlsProxyParams(result, proxy);
|
|
5125
5179
|
if (proxy.tfo) {
|
|
5126
5180
|
app_default.info(`Option tfo is not supported by Surge, thus omitted`);
|
|
5127
5181
|
}
|
|
@@ -5181,17 +5235,8 @@ function vmess(proxy, includeUnsupportedProxy) {
|
|
|
5181
5235
|
} else {
|
|
5182
5236
|
result.append(`,vmess-aead=${proxy.alterId === 0}`);
|
|
5183
5237
|
}
|
|
5184
|
-
result.appendIfPresent(
|
|
5185
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5186
|
-
"tls-fingerprint"
|
|
5187
|
-
);
|
|
5188
5238
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
5189
|
-
result
|
|
5190
|
-
result.appendIfPresent(
|
|
5191
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5192
|
-
"skip-cert-verify"
|
|
5193
|
-
);
|
|
5194
|
-
appendClientCert(result, proxy);
|
|
5239
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5195
5240
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5196
5241
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5197
5242
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5288,16 +5333,7 @@ function http(proxy) {
|
|
|
5288
5333
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5289
5334
|
"no-error-alert"
|
|
5290
5335
|
);
|
|
5291
|
-
result.
|
|
5292
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5293
|
-
"tls-fingerprint"
|
|
5294
|
-
);
|
|
5295
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5296
|
-
result.appendIfPresent(
|
|
5297
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5298
|
-
"skip-cert-verify"
|
|
5299
|
-
);
|
|
5300
|
-
appendClientCert(result, proxy);
|
|
5336
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5301
5337
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
5302
5338
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
5303
5339
|
result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
|
|
@@ -5383,16 +5419,7 @@ function socks5(proxy) {
|
|
|
5383
5419
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5384
5420
|
"no-error-alert"
|
|
5385
5421
|
);
|
|
5386
|
-
result.
|
|
5387
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5388
|
-
"tls-fingerprint"
|
|
5389
|
-
);
|
|
5390
|
-
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
5391
|
-
result.appendIfPresent(
|
|
5392
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5393
|
-
"skip-cert-verify"
|
|
5394
|
-
);
|
|
5395
|
-
appendClientCert(result, proxy);
|
|
5422
|
+
appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
|
|
5396
5423
|
if (proxy.tfo) {
|
|
5397
5424
|
app_default.info(`Option tfo is not supported by Surge, thus omitted`);
|
|
5398
5425
|
}
|
|
@@ -5448,10 +5475,19 @@ function formatHeaderMap(headers, separator) {
|
|
|
5448
5475
|
return Object.entries(headers).filter(([key, value]) => isNotBlank(key) && value != null).map(([key, value]) => `${key}:${quoteSurgeValue(value)}`).join(separator);
|
|
5449
5476
|
}
|
|
5450
5477
|
function snell(proxy) {
|
|
5478
|
+
if (isUnsupportedSnellV6Obfs(proxy)) {
|
|
5479
|
+
app_default.error(
|
|
5480
|
+
`Platform ${targetPlatform} does not support Snell version ${proxy.version} with obfs`
|
|
5481
|
+
);
|
|
5482
|
+
return "";
|
|
5483
|
+
}
|
|
5451
5484
|
const result = new Result(proxy);
|
|
5452
5485
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
5453
5486
|
result.appendIfPresent(`,version=${proxy.version}`, "version");
|
|
5454
5487
|
result.appendIfPresent(`,psk="${proxy.psk}"`, "psk");
|
|
5488
|
+
if (Number(proxy.version) === 6) {
|
|
5489
|
+
result.appendIfPresent(`,mode=${proxy.mode}`, "mode");
|
|
5490
|
+
}
|
|
5455
5491
|
const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
|
|
5456
5492
|
result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
|
|
5457
5493
|
result.appendIfPresent(
|
|
@@ -5536,16 +5572,7 @@ function tuic(proxy) {
|
|
|
5536
5572
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5537
5573
|
"no-error-alert"
|
|
5538
5574
|
);
|
|
5539
|
-
result
|
|
5540
|
-
result.appendIfPresent(
|
|
5541
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5542
|
-
"skip-cert-verify"
|
|
5543
|
-
);
|
|
5544
|
-
appendClientCert(result, proxy);
|
|
5545
|
-
result.appendIfPresent(
|
|
5546
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5547
|
-
"tls-fingerprint"
|
|
5548
|
-
);
|
|
5575
|
+
appendTlsProxyParams(result, proxy);
|
|
5549
5576
|
if (isPresent2(proxy, "tfo")) {
|
|
5550
5577
|
result.append(`,tfo=${proxy["tfo"]}`);
|
|
5551
5578
|
} else if (isPresent2(proxy, "fast-open")) {
|
|
@@ -5755,16 +5782,7 @@ function hysteria2(proxy) {
|
|
|
5755
5782
|
`,no-error-alert=${proxy["no-error-alert"]}`,
|
|
5756
5783
|
"no-error-alert"
|
|
5757
5784
|
);
|
|
5758
|
-
result
|
|
5759
|
-
result.appendIfPresent(
|
|
5760
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
5761
|
-
"skip-cert-verify"
|
|
5762
|
-
);
|
|
5763
|
-
appendClientCert(result, proxy);
|
|
5764
|
-
result.appendIfPresent(
|
|
5765
|
-
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
5766
|
-
"tls-fingerprint"
|
|
5767
|
-
);
|
|
5785
|
+
appendTlsProxyParams(result, proxy);
|
|
5768
5786
|
if (isPresent2(proxy, "tfo")) {
|
|
5769
5787
|
result.append(`,tfo=${proxy["tfo"]}`);
|
|
5770
5788
|
} else if (isPresent2(proxy, "fast-open")) {
|
|
@@ -6764,9 +6782,9 @@ function Loon_Producer() {
|
|
|
6764
6782
|
return hysteria22(proxy);
|
|
6765
6783
|
}
|
|
6766
6784
|
if (proxy.type === "anytls") {
|
|
6767
|
-
if (proxy.network &&
|
|
6785
|
+
if (proxy.network && !["tcp"].includes(proxy.network)) {
|
|
6768
6786
|
throw new Error(
|
|
6769
|
-
`Platform ${targetPlatform3} does not support proxy type ${proxy.type} with network
|
|
6787
|
+
`Platform ${targetPlatform3} does not support proxy type ${proxy.type} with network ${proxy.network}`
|
|
6770
6788
|
);
|
|
6771
6789
|
}
|
|
6772
6790
|
return anytls2(proxy);
|
|
@@ -6785,6 +6803,17 @@ function appendAlpn(result, proxy) {
|
|
|
6785
6803
|
const alpn = getLoonAlpn(proxy);
|
|
6786
6804
|
if (alpn) result.append(`,alpn="${alpn}"`);
|
|
6787
6805
|
}
|
|
6806
|
+
function appendReality(result, proxy) {
|
|
6807
|
+
result.appendIfPresent(`,sni=${proxy.sni}`, "sni");
|
|
6808
|
+
result.appendIfPresent(
|
|
6809
|
+
`,public-key="${proxy["reality-opts"]["public-key"]}"`,
|
|
6810
|
+
"reality-opts.public-key"
|
|
6811
|
+
);
|
|
6812
|
+
result.appendIfPresent(
|
|
6813
|
+
`,short-id=${proxy["reality-opts"]["short-id"]}`,
|
|
6814
|
+
"reality-opts.short-id"
|
|
6815
|
+
);
|
|
6816
|
+
}
|
|
6788
6817
|
function getLoonAlpn(proxy) {
|
|
6789
6818
|
const values = Array.isArray(proxy.alpn) ? proxy.alpn : `${proxy.alpn || ""}`.split(",");
|
|
6790
6819
|
return values.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
|
|
@@ -6834,11 +6863,6 @@ function shadowsocks2(proxy) {
|
|
|
6834
6863
|
);
|
|
6835
6864
|
if (isPresent2(proxy, "plugin")) {
|
|
6836
6865
|
if (proxy.plugin === "obfs") {
|
|
6837
|
-
if (proxy["plugin-opts"]?.mode && proxy.cipher.startsWith("2022-")) {
|
|
6838
|
-
throw new Error(
|
|
6839
|
-
`${proxy.cipher} ${proxy.plugin} is not supported`
|
|
6840
|
-
);
|
|
6841
|
-
}
|
|
6842
6866
|
result.append(`,obfs-name=${proxy["plugin-opts"].mode}`);
|
|
6843
6867
|
result.appendIfPresent(
|
|
6844
6868
|
`,obfs-host=${proxy["plugin-opts"].host}`,
|
|
@@ -6853,7 +6877,7 @@ function shadowsocks2(proxy) {
|
|
|
6853
6877
|
}
|
|
6854
6878
|
}
|
|
6855
6879
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
6856
|
-
result.append(`,shadow-tls-password
|
|
6880
|
+
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
6857
6881
|
result.appendIfPresent(
|
|
6858
6882
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
6859
6883
|
"shadow-tls-version"
|
|
@@ -6868,7 +6892,7 @@ function shadowsocks2(proxy) {
|
|
|
6868
6892
|
const host = proxy["plugin-opts"].host;
|
|
6869
6893
|
const version = proxy["plugin-opts"].version;
|
|
6870
6894
|
if (password) {
|
|
6871
|
-
result.append(`,shadow-tls-password
|
|
6895
|
+
result.append(`,shadow-tls-password=${password}`);
|
|
6872
6896
|
if (host) {
|
|
6873
6897
|
result.append(`,shadow-tls-sni=${host}`);
|
|
6874
6898
|
}
|
|
@@ -6927,7 +6951,7 @@ function shadowsocksr(proxy) {
|
|
|
6927
6951
|
result.appendIfPresent(`,obfs=${proxy.obfs}`, "obfs");
|
|
6928
6952
|
result.appendIfPresent(`,obfs-param=${proxy["obfs-param"]}`, "obfs-param");
|
|
6929
6953
|
if (isPresent2(proxy, "shadow-tls-password")) {
|
|
6930
|
-
result.append(`,shadow-tls-password
|
|
6954
|
+
result.append(`,shadow-tls-password=${proxy["shadow-tls-password"]}`);
|
|
6931
6955
|
result.appendIfPresent(
|
|
6932
6956
|
`,shadow-tls-version=${proxy["shadow-tls-version"]}`,
|
|
6933
6957
|
"shadow-tls-version"
|
|
@@ -6942,7 +6966,7 @@ function shadowsocksr(proxy) {
|
|
|
6942
6966
|
const host = proxy["plugin-opts"].host;
|
|
6943
6967
|
const version = proxy["plugin-opts"].version;
|
|
6944
6968
|
if (password) {
|
|
6945
|
-
result.append(`,shadow-tls-password
|
|
6969
|
+
result.append(`,shadow-tls-password=${password}`);
|
|
6946
6970
|
if (host) {
|
|
6947
6971
|
result.append(`,shadow-tls-sni=${host}`);
|
|
6948
6972
|
}
|
|
@@ -6974,6 +6998,7 @@ function shadowsocksr(proxy) {
|
|
|
6974
6998
|
return result.toString();
|
|
6975
6999
|
}
|
|
6976
7000
|
function trojan2(proxy) {
|
|
7001
|
+
const isReality = !!proxy["reality-opts"];
|
|
6977
7002
|
const result = new Result(proxy);
|
|
6978
7003
|
result.append(
|
|
6979
7004
|
`${proxy.name}=trojan,${proxy.server},${proxy.port},"${proxy.password}"`
|
|
@@ -7002,15 +7027,19 @@ function trojan2(proxy) {
|
|
|
7002
7027
|
);
|
|
7003
7028
|
appendTlsProfile(result, proxy);
|
|
7004
7029
|
appendAlpn(result, proxy);
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7030
|
+
if (isReality) {
|
|
7031
|
+
appendReality(result, proxy);
|
|
7032
|
+
} else {
|
|
7033
|
+
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
7034
|
+
result.appendIfPresent(
|
|
7035
|
+
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
7036
|
+
"tls-fingerprint"
|
|
7037
|
+
);
|
|
7038
|
+
result.appendIfPresent(
|
|
7039
|
+
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
7040
|
+
"tls-pubkey-sha256"
|
|
7041
|
+
);
|
|
7042
|
+
}
|
|
7014
7043
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
7015
7044
|
if (proxy["block-quic"] === "on") {
|
|
7016
7045
|
result.append(",block-quic=true");
|
|
@@ -7025,6 +7054,7 @@ function trojan2(proxy) {
|
|
|
7025
7054
|
return result.toString();
|
|
7026
7055
|
}
|
|
7027
7056
|
function anytls2(proxy) {
|
|
7057
|
+
const isReality = !!proxy["reality-opts"];
|
|
7028
7058
|
const result = new Result(proxy);
|
|
7029
7059
|
result.append(
|
|
7030
7060
|
`${proxy.name}=anytls,${proxy.server},${proxy.port},"${proxy.password}"`
|
|
@@ -7045,15 +7075,19 @@ function anytls2(proxy) {
|
|
|
7045
7075
|
);
|
|
7046
7076
|
appendTlsProfile(result, proxy);
|
|
7047
7077
|
appendAlpn(result, proxy);
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7078
|
+
if (isReality) {
|
|
7079
|
+
appendReality(result, proxy);
|
|
7080
|
+
} else {
|
|
7081
|
+
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
7082
|
+
result.appendIfPresent(
|
|
7083
|
+
`,tls-cert-sha256=${proxy["tls-fingerprint"]}`,
|
|
7084
|
+
"tls-fingerprint"
|
|
7085
|
+
);
|
|
7086
|
+
result.appendIfPresent(
|
|
7087
|
+
`,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
|
|
7088
|
+
"tls-pubkey-sha256"
|
|
7089
|
+
);
|
|
7090
|
+
}
|
|
7057
7091
|
result.appendIfPresent(`,fast-open=${proxy.tfo}`, "tfo");
|
|
7058
7092
|
if (proxy["block-quic"] === "on") {
|
|
7059
7093
|
result.append(",block-quic=true");
|
|
@@ -7116,15 +7150,7 @@ function vmess2(proxy) {
|
|
|
7116
7150
|
appendAlpn(result, proxy);
|
|
7117
7151
|
}
|
|
7118
7152
|
if (isReality) {
|
|
7119
|
-
result
|
|
7120
|
-
result.appendIfPresent(
|
|
7121
|
-
`,public-key="${proxy["reality-opts"]["public-key"]}"`,
|
|
7122
|
-
"reality-opts.public-key"
|
|
7123
|
-
);
|
|
7124
|
-
result.appendIfPresent(
|
|
7125
|
-
`,short-id=${proxy["reality-opts"]["short-id"]}`,
|
|
7126
|
-
"reality-opts.short-id"
|
|
7127
|
-
);
|
|
7153
|
+
appendReality(result, proxy);
|
|
7128
7154
|
} else {
|
|
7129
7155
|
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
7130
7156
|
result.appendIfPresent(
|
|
@@ -7215,15 +7241,7 @@ function vless(proxy) {
|
|
|
7215
7241
|
result.appendIfPresent(`,flow=${proxy.flow}`, "flow");
|
|
7216
7242
|
}
|
|
7217
7243
|
if (isReality) {
|
|
7218
|
-
result
|
|
7219
|
-
result.appendIfPresent(
|
|
7220
|
-
`,public-key="${proxy["reality-opts"]["public-key"]}"`,
|
|
7221
|
-
"reality-opts.public-key"
|
|
7222
|
-
);
|
|
7223
|
-
result.appendIfPresent(
|
|
7224
|
-
`,short-id=${proxy["reality-opts"]["short-id"]}`,
|
|
7225
|
-
"reality-opts.short-id"
|
|
7226
|
-
);
|
|
7244
|
+
appendReality(result, proxy);
|
|
7227
7245
|
} else {
|
|
7228
7246
|
result.appendIfPresent(`,tls-name=${proxy.sni}`, "sni");
|
|
7229
7247
|
result.appendIfPresent(
|
|
@@ -7417,7 +7435,7 @@ function toStringHeaderMap(headers, { excludeHost = false } = {}) {
|
|
|
7417
7435
|
}
|
|
7418
7436
|
const parsedHeaders = {};
|
|
7419
7437
|
for (const [key, value] of Object.entries(headers)) {
|
|
7420
|
-
if (typeof value !== "string"
|
|
7438
|
+
if (typeof value !== "string") {
|
|
7421
7439
|
continue;
|
|
7422
7440
|
}
|
|
7423
7441
|
if (excludeHost && /^host$/i.test(key)) {
|
|
@@ -7556,10 +7574,21 @@ function applyStructuredXhttpExtraFields(target, xhttpOpts, { excludeHostHeader
|
|
|
7556
7574
|
target.uplinkHTTPMethod = xhttpOpts["uplink-http-method"];
|
|
7557
7575
|
}
|
|
7558
7576
|
if (xhttpOpts["session-placement"]) {
|
|
7559
|
-
target.
|
|
7577
|
+
target.sessionIDPlacement = xhttpOpts["session-placement"];
|
|
7560
7578
|
}
|
|
7561
7579
|
if (xhttpOpts["session-key"]) {
|
|
7562
|
-
target.
|
|
7580
|
+
target.sessionIDKey = xhttpOpts["session-key"];
|
|
7581
|
+
}
|
|
7582
|
+
if (typeof xhttpOpts["session-table"] === "string") {
|
|
7583
|
+
target.sessionIDTable = xhttpOpts["session-table"];
|
|
7584
|
+
}
|
|
7585
|
+
if (xhttpOpts["session-length"] != null) {
|
|
7586
|
+
const sessionIDLength = normalizeXhttpStrictPositiveRangeValue(
|
|
7587
|
+
xhttpOpts["session-length"]
|
|
7588
|
+
);
|
|
7589
|
+
if (sessionIDLength != null) {
|
|
7590
|
+
target.sessionIDLength = sessionIDLength;
|
|
7591
|
+
}
|
|
7563
7592
|
}
|
|
7564
7593
|
if (xhttpOpts["seq-placement"]) {
|
|
7565
7594
|
target.seqPlacement = xhttpOpts["seq-placement"];
|
|
@@ -7580,7 +7609,7 @@ function applyStructuredXhttpExtraFields(target, xhttpOpts, { excludeHostHeader
|
|
|
7580
7609
|
target.uplinkChunkSize = uplinkChunkSize;
|
|
7581
7610
|
}
|
|
7582
7611
|
if (xhttpOpts["sc-max-each-post-bytes"] != null) {
|
|
7583
|
-
const scMaxEachPostBytes =
|
|
7612
|
+
const scMaxEachPostBytes = normalizeXhttpStrictPositiveRangeValue(
|
|
7584
7613
|
xhttpOpts["sc-max-each-post-bytes"]
|
|
7585
7614
|
);
|
|
7586
7615
|
if (scMaxEachPostBytes != null) {
|
|
@@ -9384,6 +9413,20 @@ var targetPlatform5 = "Surfboard";
|
|
|
9384
9413
|
function hasNonBlankValue2(value) {
|
|
9385
9414
|
return value != null && `${value}`.trim().length > 0;
|
|
9386
9415
|
}
|
|
9416
|
+
function appendTlsProxyParams2(result, proxy, enabled = true) {
|
|
9417
|
+
if (!enabled) {
|
|
9418
|
+
return;
|
|
9419
|
+
}
|
|
9420
|
+
result.appendIfPresent(
|
|
9421
|
+
`,server-cert-fingerprint-sha256=${proxy["tls-fingerprint"]}`,
|
|
9422
|
+
"tls-fingerprint"
|
|
9423
|
+
);
|
|
9424
|
+
result.appendIfPresent(`,sni="${proxy.sni}"`, "sni");
|
|
9425
|
+
result.appendIfPresent(
|
|
9426
|
+
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9427
|
+
"skip-cert-verify"
|
|
9428
|
+
);
|
|
9429
|
+
}
|
|
9387
9430
|
function Surfboard_Producer() {
|
|
9388
9431
|
const produce2 = (proxy) => {
|
|
9389
9432
|
if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
@@ -9439,34 +9482,28 @@ function hysteria23(proxy) {
|
|
|
9439
9482
|
if (hasNonBlankValue2(proxy["hop-interval"])) {
|
|
9440
9483
|
result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
|
|
9441
9484
|
}
|
|
9442
|
-
result
|
|
9443
|
-
result.appendIfPresent(
|
|
9444
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9445
|
-
"skip-cert-verify"
|
|
9446
|
-
);
|
|
9485
|
+
appendTlsProxyParams2(result, proxy);
|
|
9447
9486
|
result.appendIfPresent(
|
|
9448
9487
|
`,download-bandwidth=${`${proxy["down"]}`.match(/\d+/)?.[0] || 0}`,
|
|
9449
9488
|
"down"
|
|
9450
9489
|
);
|
|
9451
9490
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9491
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9452
9492
|
return result.toString();
|
|
9453
9493
|
}
|
|
9454
9494
|
function anytls4(proxy) {
|
|
9455
9495
|
const result = new Result(proxy);
|
|
9456
9496
|
result.append(`${proxy.name}=${proxy.type},${proxy.server},${proxy.port}`);
|
|
9457
9497
|
result.appendIfPresent(`,password="${proxy.password}"`, "password");
|
|
9458
|
-
result
|
|
9459
|
-
result.appendIfPresent(
|
|
9460
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9461
|
-
"skip-cert-verify"
|
|
9462
|
-
);
|
|
9498
|
+
appendTlsProxyParams2(result, proxy);
|
|
9463
9499
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
9464
9500
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9465
9501
|
result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
|
|
9502
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9466
9503
|
return result.toString();
|
|
9467
9504
|
}
|
|
9468
9505
|
function snell2(proxy) {
|
|
9469
|
-
if (proxy
|
|
9506
|
+
if (isPresent2(proxy, "version") && ![1, 2, 3, 4, 5].includes(Number(proxy.version))) {
|
|
9470
9507
|
throw new Error(
|
|
9471
9508
|
`Platform ${targetPlatform5} does not support snell version ${proxy.version}`
|
|
9472
9509
|
);
|
|
@@ -9491,6 +9528,7 @@ function snell2(proxy) {
|
|
|
9491
9528
|
if (proxy.version >= 3) {
|
|
9492
9529
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9493
9530
|
}
|
|
9531
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9494
9532
|
return result.toString();
|
|
9495
9533
|
}
|
|
9496
9534
|
function shadowsocks4(proxy) {
|
|
@@ -9540,6 +9578,7 @@ function shadowsocks4(proxy) {
|
|
|
9540
9578
|
}
|
|
9541
9579
|
}
|
|
9542
9580
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9581
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9543
9582
|
return result.toString();
|
|
9544
9583
|
}
|
|
9545
9584
|
function trojan4(proxy) {
|
|
@@ -9548,13 +9587,10 @@ function trojan4(proxy) {
|
|
|
9548
9587
|
result.appendIfPresent(`,password=${proxy.password}`, "password");
|
|
9549
9588
|
handleTransport2(result, proxy);
|
|
9550
9589
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
9551
|
-
result
|
|
9552
|
-
result.appendIfPresent(
|
|
9553
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9554
|
-
"skip-cert-verify"
|
|
9555
|
-
);
|
|
9590
|
+
appendTlsProxyParams2(result, proxy);
|
|
9556
9591
|
result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
|
|
9557
9592
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9593
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9558
9594
|
return result.toString();
|
|
9559
9595
|
}
|
|
9560
9596
|
function vmess4(proxy) {
|
|
@@ -9568,12 +9604,9 @@ function vmess4(proxy) {
|
|
|
9568
9604
|
result.append(`,vmess-aead=${proxy.alterId === 0}`);
|
|
9569
9605
|
}
|
|
9570
9606
|
result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
|
|
9571
|
-
result
|
|
9572
|
-
result.appendIfPresent(
|
|
9573
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9574
|
-
"skip-cert-verify"
|
|
9575
|
-
);
|
|
9607
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9576
9608
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9609
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9577
9610
|
return result.toString();
|
|
9578
9611
|
}
|
|
9579
9612
|
function http4(proxy) {
|
|
@@ -9582,12 +9615,9 @@ function http4(proxy) {
|
|
|
9582
9615
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
9583
9616
|
result.appendIfPresent(`,${proxy.username}`, "username");
|
|
9584
9617
|
result.appendIfPresent(`,${proxy.password}`, "password");
|
|
9585
|
-
result
|
|
9586
|
-
result.appendIfPresent(
|
|
9587
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9588
|
-
"skip-cert-verify"
|
|
9589
|
-
);
|
|
9618
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9590
9619
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9620
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9591
9621
|
return result.toString();
|
|
9592
9622
|
}
|
|
9593
9623
|
function socks54(proxy) {
|
|
@@ -9596,12 +9626,9 @@ function socks54(proxy) {
|
|
|
9596
9626
|
result.append(`${proxy.name}=${type},${proxy.server},${proxy.port}`);
|
|
9597
9627
|
result.appendIfPresent(`,${proxy.username}`, "username");
|
|
9598
9628
|
result.appendIfPresent(`,${proxy.password}`, "password");
|
|
9599
|
-
result
|
|
9600
|
-
result.appendIfPresent(
|
|
9601
|
-
`,skip-cert-verify=${proxy["skip-cert-verify"]}`,
|
|
9602
|
-
"skip-cert-verify"
|
|
9603
|
-
);
|
|
9629
|
+
appendTlsProxyParams2(result, proxy, Boolean(proxy.tls));
|
|
9604
9630
|
result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
|
|
9631
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9605
9632
|
return result.toString();
|
|
9606
9633
|
}
|
|
9607
9634
|
function wireguard3(proxy) {
|
|
@@ -9611,6 +9638,7 @@ function wireguard3(proxy) {
|
|
|
9611
9638
|
`,section-name=${proxy["section-name"]}`,
|
|
9612
9639
|
"section-name"
|
|
9613
9640
|
);
|
|
9641
|
+
result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
|
|
9614
9642
|
return result.toString();
|
|
9615
9643
|
}
|
|
9616
9644
|
function handleTransport2(result, proxy) {
|
|
@@ -10938,7 +10966,8 @@ function Egern_Producer() {
|
|
|
10938
10966
|
"tuic",
|
|
10939
10967
|
"wireguard",
|
|
10940
10968
|
"anytls",
|
|
10941
|
-
"ssh"
|
|
10969
|
+
"ssh",
|
|
10970
|
+
"snell"
|
|
10942
10971
|
].includes(proxy.type) || proxy.type === "ss" && (proxy.plugin === "obfs" && !["http", "tls"].includes(
|
|
10943
10972
|
proxy["plugin-opts"]?.mode
|
|
10944
10973
|
) || ![
|
|
@@ -10970,13 +10999,22 @@ function Egern_Producer() {
|
|
|
10970
10999
|
"chacha20-ietf",
|
|
10971
11000
|
"2022-blake3-aes-128-gcm",
|
|
10972
11001
|
"2022-blake3-aes-256-gcm"
|
|
10973
|
-
].includes(proxy.cipher)) || proxy.type === "vmess" && !["h2", "http", "ws", "tcp"
|
|
11002
|
+
].includes(proxy.cipher)) || proxy.type === "vmess" && (!["h2", "http", "ws", "tcp", "grpc"].includes(
|
|
11003
|
+
proxy.network
|
|
11004
|
+
) && proxy.network || !isEgernGrpcGun(proxy)) || proxy.type === "trojan" && !["http", "ws", "tcp"].includes(proxy.network) && proxy.network || proxy.type === "vless" && (!["h2", "http", "ws", "tcp", "grpc"].includes(
|
|
10974
11005
|
proxy.network
|
|
10975
|
-
) && proxy.network || typeof proxy.flow !== "undefined" && !["xtls-rprx-vision", ""].includes(
|
|
11006
|
+
) && proxy.network || !isEgernGrpcGun(proxy) || typeof proxy.flow !== "undefined" && !["xtls-rprx-vision", ""].includes(
|
|
10976
11007
|
proxy.flow
|
|
10977
11008
|
)) || proxy.type === "tuic" && proxy.token && proxy.token.length !== 0) {
|
|
10978
11009
|
return false;
|
|
10979
|
-
} else if (
|
|
11010
|
+
} else if (proxy.type === "snell" && normalizeSnellVersion(proxy.version) === null) {
|
|
11011
|
+
return false;
|
|
11012
|
+
} else if (proxy.type === "snell" && hasShadowTls(proxy)) {
|
|
11013
|
+
app_default.error(
|
|
11014
|
+
`Platform Egern does not support Snell shadow-tls proxy ${proxy.name}. Proxy has been filtered.`
|
|
11015
|
+
);
|
|
11016
|
+
return false;
|
|
11017
|
+
} else if (["anytls"].includes(proxy.type) && proxy.network && !["tcp"].includes(proxy.network)) {
|
|
10980
11018
|
return false;
|
|
10981
11019
|
} else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
|
|
10982
11020
|
return false;
|
|
@@ -11002,10 +11040,11 @@ function Egern_Producer() {
|
|
|
11002
11040
|
...hasHeaders(proxy) ? {
|
|
11003
11041
|
headers: proxy.headers
|
|
11004
11042
|
} : {},
|
|
11005
|
-
tfo: proxy
|
|
11043
|
+
tfo: getTfo(proxy),
|
|
11006
11044
|
...proxy.tls ? {
|
|
11007
11045
|
sni: proxy.sni,
|
|
11008
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11046
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11047
|
+
reality: getReality(proxy)
|
|
11009
11048
|
} : {}
|
|
11010
11049
|
};
|
|
11011
11050
|
} else if (proxy.type === "https") {
|
|
@@ -11019,20 +11058,26 @@ function Egern_Producer() {
|
|
|
11019
11058
|
...hasHeaders(proxy) ? {
|
|
11020
11059
|
headers: proxy.headers
|
|
11021
11060
|
} : {},
|
|
11022
|
-
tfo: proxy
|
|
11061
|
+
tfo: getTfo(proxy),
|
|
11023
11062
|
sni: proxy.sni,
|
|
11024
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11063
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11064
|
+
reality: getReality(proxy)
|
|
11025
11065
|
};
|
|
11026
11066
|
} else if (proxy.type === "socks5") {
|
|
11027
11067
|
proxy = {
|
|
11028
|
-
type: "socks5",
|
|
11068
|
+
type: proxy.tls ? "socks5_tls" : "socks5",
|
|
11029
11069
|
name: proxy.name,
|
|
11030
11070
|
server: proxy.server,
|
|
11031
11071
|
port: proxy.port,
|
|
11032
11072
|
username: proxy.username,
|
|
11033
11073
|
password: proxy.password,
|
|
11034
|
-
tfo: proxy
|
|
11035
|
-
udp_relay: proxy
|
|
11074
|
+
tfo: getTfo(proxy),
|
|
11075
|
+
udp_relay: getUdpRelay(proxy),
|
|
11076
|
+
...proxy.tls ? {
|
|
11077
|
+
sni: proxy.sni,
|
|
11078
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11079
|
+
reality: getReality(proxy)
|
|
11080
|
+
} : {}
|
|
11036
11081
|
};
|
|
11037
11082
|
} else if (proxy.type === "ss") {
|
|
11038
11083
|
proxy = {
|
|
@@ -11042,8 +11087,8 @@ function Egern_Producer() {
|
|
|
11042
11087
|
server: proxy.server,
|
|
11043
11088
|
port: proxy.port,
|
|
11044
11089
|
password: proxy.password,
|
|
11045
|
-
tfo: proxy
|
|
11046
|
-
udp_relay: proxy
|
|
11090
|
+
tfo: getTfo(proxy),
|
|
11091
|
+
udp_relay: getUdpRelay(proxy)
|
|
11047
11092
|
};
|
|
11048
11093
|
if (isPresent2(original, "plugin")) {
|
|
11049
11094
|
if (original.plugin === "obfs") {
|
|
@@ -11069,8 +11114,8 @@ function Egern_Producer() {
|
|
|
11069
11114
|
10
|
|
11070
11115
|
)
|
|
11071
11116
|
} : {},
|
|
11072
|
-
tfo: proxy
|
|
11073
|
-
udp_relay: proxy
|
|
11117
|
+
tfo: getTfo(proxy),
|
|
11118
|
+
udp_relay: getUdpRelay(proxy),
|
|
11074
11119
|
sni: proxy.sni,
|
|
11075
11120
|
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11076
11121
|
port_hopping: proxy.ports,
|
|
@@ -11107,10 +11152,11 @@ function Egern_Producer() {
|
|
|
11107
11152
|
server: proxy.server,
|
|
11108
11153
|
port: proxy.port,
|
|
11109
11154
|
password: proxy.password,
|
|
11110
|
-
tfo: proxy
|
|
11111
|
-
udp_relay: proxy
|
|
11155
|
+
tfo: getTfo(proxy),
|
|
11156
|
+
udp_relay: getUdpRelay(proxy),
|
|
11112
11157
|
sni: proxy.sni,
|
|
11113
11158
|
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11159
|
+
reality: getReality(proxy),
|
|
11114
11160
|
websocket: proxy.websocket
|
|
11115
11161
|
};
|
|
11116
11162
|
} else if (proxy.type === "anytls") {
|
|
@@ -11120,10 +11166,11 @@ function Egern_Producer() {
|
|
|
11120
11166
|
server: proxy.server,
|
|
11121
11167
|
port: proxy.port,
|
|
11122
11168
|
password: proxy.password,
|
|
11123
|
-
tfo: proxy
|
|
11124
|
-
udp_relay: proxy
|
|
11169
|
+
tfo: getTfo(proxy),
|
|
11170
|
+
udp_relay: getUdpRelay(proxy),
|
|
11125
11171
|
sni: proxy.sni,
|
|
11126
|
-
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11172
|
+
skip_tls_verify: proxy["skip-cert-verify"],
|
|
11173
|
+
reality: getReality(proxy)
|
|
11127
11174
|
};
|
|
11128
11175
|
} else if (proxy.type === "vmess") {
|
|
11129
11176
|
const security = normalizeVmessSecurity(proxy.cipher);
|
|
@@ -11163,6 +11210,8 @@ function Egern_Producer() {
|
|
|
11163
11210
|
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11164
11211
|
}
|
|
11165
11212
|
};
|
|
11213
|
+
} else if (proxy.network === "grpc") {
|
|
11214
|
+
proxy.transport = getGrpcTransport(proxy);
|
|
11166
11215
|
} else if ((proxy.network === "tcp" || !proxy.network) && proxy.tls) {
|
|
11167
11216
|
proxy.transport = {
|
|
11168
11217
|
tls: {
|
|
@@ -11171,10 +11220,10 @@ function Egern_Producer() {
|
|
|
11171
11220
|
}
|
|
11172
11221
|
};
|
|
11173
11222
|
}
|
|
11174
|
-
let legacy;
|
|
11223
|
+
let legacy = false;
|
|
11175
11224
|
if (isPresent2(proxy, "aead") && !proxy.aead) {
|
|
11176
11225
|
legacy = true;
|
|
11177
|
-
} else if (proxy.alterId !== 0) {
|
|
11226
|
+
} else if (isPresent2(proxy, "alterId") && proxy.alterId !== 0) {
|
|
11178
11227
|
legacy = true;
|
|
11179
11228
|
}
|
|
11180
11229
|
proxy = {
|
|
@@ -11184,9 +11233,9 @@ function Egern_Producer() {
|
|
|
11184
11233
|
port: proxy.port,
|
|
11185
11234
|
user_id: proxy.uuid,
|
|
11186
11235
|
security,
|
|
11187
|
-
tfo: proxy
|
|
11236
|
+
tfo: getTfo(proxy),
|
|
11188
11237
|
legacy,
|
|
11189
|
-
udp_relay: proxy
|
|
11238
|
+
udp_relay: getUdpRelay(proxy),
|
|
11190
11239
|
transport: proxy.transport
|
|
11191
11240
|
};
|
|
11192
11241
|
} else if (proxy.type === "vless") {
|
|
@@ -11230,19 +11279,14 @@ function Egern_Producer() {
|
|
|
11230
11279
|
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11231
11280
|
}
|
|
11232
11281
|
};
|
|
11282
|
+
} else if (proxy.network === "grpc") {
|
|
11283
|
+
proxy.transport = getGrpcTransport(proxy);
|
|
11233
11284
|
} else if (proxy.network === "tcp" || !proxy.network) {
|
|
11234
|
-
let reality;
|
|
11235
|
-
if (proxy["reality-opts"]?.["short-id"] || proxy["reality-opts"]?.["public-key"]) {
|
|
11236
|
-
reality = {
|
|
11237
|
-
short_id: proxy["reality-opts"]["short-id"],
|
|
11238
|
-
public_key: proxy["reality-opts"]["public-key"]
|
|
11239
|
-
};
|
|
11240
|
-
}
|
|
11241
11285
|
proxy.transport = {
|
|
11242
11286
|
[proxy.tls ? "tls" : "tcp"]: {
|
|
11243
11287
|
sni: proxy.tls ? proxy.sni : void 0,
|
|
11244
11288
|
skip_tls_verify: proxy.tls ? proxy["skip-cert-verify"] : void 0,
|
|
11245
|
-
reality
|
|
11289
|
+
reality: getReality(proxy)
|
|
11246
11290
|
}
|
|
11247
11291
|
};
|
|
11248
11292
|
flow = proxy.flow;
|
|
@@ -11255,8 +11299,8 @@ function Egern_Producer() {
|
|
|
11255
11299
|
port: proxy.port,
|
|
11256
11300
|
user_id: proxy.uuid,
|
|
11257
11301
|
security: proxy.cipher,
|
|
11258
|
-
tfo: proxy
|
|
11259
|
-
udp_relay: proxy
|
|
11302
|
+
tfo: getTfo(proxy),
|
|
11303
|
+
udp_relay: getUdpRelay(proxy),
|
|
11260
11304
|
transport: proxy.transport,
|
|
11261
11305
|
flow
|
|
11262
11306
|
};
|
|
@@ -11303,7 +11347,26 @@ function Egern_Producer() {
|
|
|
11303
11347
|
private_key: proxy["private-key"],
|
|
11304
11348
|
// private_key_passphrase: proxy['private-key-passphrase'],
|
|
11305
11349
|
host_keys: proxy["host-key"],
|
|
11306
|
-
tfo: proxy
|
|
11350
|
+
tfo: getTfo(proxy)
|
|
11351
|
+
};
|
|
11352
|
+
} else if (proxy.type === "snell") {
|
|
11353
|
+
const snellVersion = normalizeSnellVersion(
|
|
11354
|
+
proxy.version
|
|
11355
|
+
);
|
|
11356
|
+
proxy = {
|
|
11357
|
+
type: "snell",
|
|
11358
|
+
name: proxy.name,
|
|
11359
|
+
server: proxy.server,
|
|
11360
|
+
port: proxy.port,
|
|
11361
|
+
psk: proxy.psk,
|
|
11362
|
+
version: snellVersion,
|
|
11363
|
+
...snellVersion == null || snellVersion >= 3 ? {
|
|
11364
|
+
udp_relay: getUdpRelay(proxy)
|
|
11365
|
+
} : {},
|
|
11366
|
+
reuse: proxy.reuse,
|
|
11367
|
+
obfs: proxy["obfs-opts"]?.mode || proxy.obfs,
|
|
11368
|
+
obfs_host: proxy["obfs-opts"]?.host || proxy["obfs-host"] || proxy.obfs_host,
|
|
11369
|
+
tfo: getTfo(proxy)
|
|
11307
11370
|
};
|
|
11308
11371
|
}
|
|
11309
11372
|
if ([
|
|
@@ -11357,7 +11420,8 @@ function Egern_Producer() {
|
|
|
11357
11420
|
"tuic",
|
|
11358
11421
|
"hysteria2",
|
|
11359
11422
|
"anytls",
|
|
11360
|
-
"ssh"
|
|
11423
|
+
"ssh",
|
|
11424
|
+
"snell"
|
|
11361
11425
|
].includes(original.type)) {
|
|
11362
11426
|
if (["on", "true", true, "1", 1].includes(
|
|
11363
11427
|
original["block-quic"]
|
|
@@ -11379,9 +11443,9 @@ function Egern_Producer() {
|
|
|
11379
11443
|
delete proxy["no-resolve"];
|
|
11380
11444
|
if (proxy.transport) {
|
|
11381
11445
|
for (const key in proxy.transport) {
|
|
11382
|
-
if (Object.keys(proxy.transport[key]).length === 0 || Object.values(proxy.transport[key]).every(
|
|
11446
|
+
if (key !== "grpc" && (Object.keys(proxy.transport[key]).length === 0 || Object.values(proxy.transport[key]).every(
|
|
11383
11447
|
(value) => value == null
|
|
11384
|
-
)) {
|
|
11448
|
+
))) {
|
|
11385
11449
|
delete proxy.transport[key];
|
|
11386
11450
|
}
|
|
11387
11451
|
}
|
|
@@ -11418,6 +11482,52 @@ Reason: ${err}`
|
|
|
11418
11482
|
function hasHeaders(proxy) {
|
|
11419
11483
|
return proxy?.headers && typeof proxy.headers === "object" && Object.keys(proxy.headers).length > 0;
|
|
11420
11484
|
}
|
|
11485
|
+
function getTfo(proxy) {
|
|
11486
|
+
return proxy.tfo ?? proxy["fast-open"];
|
|
11487
|
+
}
|
|
11488
|
+
function getUdpRelay(proxy) {
|
|
11489
|
+
return proxy.udp ?? proxy.udp_relay;
|
|
11490
|
+
}
|
|
11491
|
+
function hasShadowTls(proxy) {
|
|
11492
|
+
return proxy.plugin === "shadow-tls" || isPresent2(proxy, "shadow-tls-password") || isPresent2(proxy, "shadow-tls-sni") || isPresent2(proxy, "shadow-tls-version");
|
|
11493
|
+
}
|
|
11494
|
+
function getNonEmptyValue(value) {
|
|
11495
|
+
if (value == null) return void 0;
|
|
11496
|
+
if (typeof value === "string" && value.length === 0) return void 0;
|
|
11497
|
+
return value;
|
|
11498
|
+
}
|
|
11499
|
+
function getReality(proxy) {
|
|
11500
|
+
const realityOpts = proxy?.["reality-opts"];
|
|
11501
|
+
if (!realityOpts) return void 0;
|
|
11502
|
+
const reality = {};
|
|
11503
|
+
const publicKey = getNonEmptyValue(realityOpts["public-key"]);
|
|
11504
|
+
const shortId = getNonEmptyValue(realityOpts["short-id"]);
|
|
11505
|
+
if (publicKey != null) reality.public_key = publicKey;
|
|
11506
|
+
if (shortId != null) reality.short_id = shortId;
|
|
11507
|
+
return Object.keys(reality).length > 0 ? reality : void 0;
|
|
11508
|
+
}
|
|
11509
|
+
function getGrpcTransport(proxy) {
|
|
11510
|
+
return {
|
|
11511
|
+
grpc: {
|
|
11512
|
+
service_name: proxy["grpc-opts"]?.["grpc-service-name"],
|
|
11513
|
+
sni: proxy.sni,
|
|
11514
|
+
reality: getReality(proxy),
|
|
11515
|
+
skip_tls_verify: proxy["skip-cert-verify"]
|
|
11516
|
+
}
|
|
11517
|
+
};
|
|
11518
|
+
}
|
|
11519
|
+
function isEgernGrpcGun(proxy) {
|
|
11520
|
+
if (proxy.network !== "grpc") return true;
|
|
11521
|
+
const grpcType = proxy["grpc-opts"]?.["_grpc-type"];
|
|
11522
|
+
if (grpcType == null) return true;
|
|
11523
|
+
return `${grpcType}`.trim().toLowerCase() === "gun";
|
|
11524
|
+
}
|
|
11525
|
+
function normalizeSnellVersion(version) {
|
|
11526
|
+
if (version == null) return void 0;
|
|
11527
|
+
const normalized = `${version}`.trim();
|
|
11528
|
+
if (!/^[1-5]$/.test(normalized)) return null;
|
|
11529
|
+
return parseInt(normalized, 10);
|
|
11530
|
+
}
|
|
11421
11531
|
function getFirstHeaderValue(headers, ...keys) {
|
|
11422
11532
|
for (const key of keys) {
|
|
11423
11533
|
const value = getFirstValue(headers?.[key]);
|
|
@@ -11459,11 +11569,11 @@ function getFingerprintSha256(proxy) {
|
|
|
11459
11569
|
function supportsRootFingerprintSha256(original, proxy) {
|
|
11460
11570
|
return ["anytls", "https", "hysteria2", "trojan", "tuic"].includes(
|
|
11461
11571
|
original.type
|
|
11462
|
-
) || original.type === "http" && proxy.type === "https";
|
|
11572
|
+
) || original.type === "socks5" && proxy.type === "socks5_tls" || original.type === "http" && proxy.type === "https";
|
|
11463
11573
|
}
|
|
11464
11574
|
function addTransportFingerprintSha256(transport, fingerprintSha256) {
|
|
11465
11575
|
if (!transport) return;
|
|
11466
|
-
for (const key of ["http2", "tls", "wss"]) {
|
|
11576
|
+
for (const key of ["grpc", "http2", "tls", "wss"]) {
|
|
11467
11577
|
if (transport[key]) {
|
|
11468
11578
|
transport[key].fingerprint_sha256 = fingerprintSha256;
|
|
11469
11579
|
}
|