Skip to content

Commit 492fa32

Browse files
committed
feat: 读取节点的 ca-str 字段, 自动计算 fingerprint
1 parent 3ad42f2 commit 492fa32

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

backend/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.14.337",
3+
"version": "2.14.338",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
55
"main": "src/main.js",
66
"scripts": {
@@ -25,6 +25,7 @@
2525
"express": "^4.17.1",
2626
"http-proxy-middleware": "^2.0.6",
2727
"js-base64": "^3.7.2",
28+
"jsrsasign": "^11.1.0",
2829
"lodash": "^4.17.21",
2930
"request": "^2.88.2",
3031
"requests": "^0.3.0",

backend/pnpm-lock.yaml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/src/core/proxy-utils/index.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import rs from '@/utils/rs';
12
import YAML from '@/utils/yaml';
23
import download from '@/utils/download';
34
import {
@@ -463,6 +464,19 @@ function lastParse(proxy) {
463464
if (['', 'off'].includes(proxy.sni)) {
464465
proxy['disable-sni'] = true;
465466
}
467+
let caStr = proxy['ca_str'];
468+
if (proxy['ca-str']) {
469+
caStr = proxy['ca-str'];
470+
} else if (caStr) {
471+
delete proxy['ca_str'];
472+
proxy['ca-str'] = caStr;
473+
}
474+
// if ($.env.isNode && !caStr && proxy.ca) {
475+
// caStr = $.node.fs.readFileSync(proxy.ca, { encoding: 'utf8' });
476+
// }
477+
if (!proxy.fingerprint && caStr) {
478+
proxy.fingerprint = rs.generateFingerprint(caStr);
479+
}
466480
return proxy;
467481
}
468482

backend/src/utils/rs.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import rs from 'jsrsasign';
2+
3+
export function generateFingerprint(caStr) {
4+
const hex = rs.pemtohex(caStr);
5+
const fingerPrint = rs.KJUR.crypto.Util.hashHex(hex, 'sha256');
6+
return fingerPrint.match(/.{2}/g).join(':').toUpperCase();
7+
}
8+
9+
export default {
10+
generateFingerprint,
11+
};

0 commit comments

Comments
 (0)