Skip to content

Commit 94c820e

Browse files
committed
fix: 修复 doh
1 parent 039bf88 commit 94c820e

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.20.5",
3+
"version": "2.20.6",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/utils/dns.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ export async function doh({ url, domain, type = 'A', timeout, edns }) {
3131
},
3232
],
3333
});
34+
35+
const b64 = Buffer.from(buf).toString('base64');
36+
const b64url = b64
37+
.replace(/\+/g, '-')
38+
.replace(/\//g, '_')
39+
.replace(/=+$/, '');
40+
3441
const res = await $.http.get({
35-
url: `${url}?dns=${buf
36-
.toString('base64')
37-
.toString('utf-8')
38-
.replace(/=/g, '')}`,
42+
url: `${url}?dns=${encodeURIComponent(b64url)}`,
3943
headers: {
4044
Accept: 'application/dns-message',
4145
// 'Content-Type': 'application/dns-message',

0 commit comments

Comments
 (0)