Skip to content

Commit 6905cf3

Browse files
author
Taois
committed
feat: 设置中心增加配置
doh和系统代理自动启用 可通过配置手动关闭
1 parent c6910af commit 6905cf3

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

spider/js/设置中心.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,10 @@ var rule = {
435435
vod_pic: images.lives,
436436
vod_desc: "流式代理mp4等视频"
437437
});
438+
d.push(genMultiInput('enable_doh', '设置DOH启用状态', '设置为0关闭(默认1开启)', images.settings));
439+
d.push(getInput('get_enable_doh', '查看DOH启用状态', images.settings));
440+
d.push(genMultiInput('enable_system_proxy', '设置系统代理启用状态', '设置为0关闭(默认1开启)', images.settings));
441+
d.push(getInput('get_enable_system_proxy', '查看系统代理启用状态', images.settings));
438442
break;
439443
case 'apiLink':
440444
d.push(genMultiInput('link_url', '设置挂载地址', '可以挂载t4配置链接如 hipy-t4、不夜t4', images.settings));
@@ -1275,6 +1279,8 @@ var rule = {
12751279
'thread',
12761280
'play_local_proxy_type',
12771281
'play_proxy_mode',
1282+
'enable_doh',
1283+
'enable_system_proxy',
12781284
'enable_dr2',
12791285
'enable_py',
12801286
'enable_php',
@@ -1311,6 +1317,8 @@ var rule = {
13111317
'get_thread',
13121318
'play_local_proxy_type',
13131319
'get_play_proxy_mode',
1320+
'get_enable_doh',
1321+
'get_enable_system_proxy',
13141322
'get_enable_dr2',
13151323
'get_enable_py',
13161324
'get_enable_php',

utils/dns_doh.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {fileURLToPath} from 'url';
1515
import {HttpsProxyAgent} from 'https-proxy-agent';
1616
import {exec} from 'child_process';
1717
import util from 'util';
18+
import {ENV} from './env.js'; // Import ENV utility
1819

1920
const execAsync = util.promisify(exec);
2021
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -26,6 +27,13 @@ const configPath = path.resolve(__dirname, '../config/player.json');
2627

2728
// Initialize Resolver Lazy
2829
function getResolver() {
30+
// Check if DOH is enabled via ENV (default: 1/true)
31+
const enableDoh = ENV.get('enable_doh', '1') === '1' || ENV.get('enable_doh') === 'true';
32+
if (!enableDoh) {
33+
// console.log('[DOH] DOH is disabled via ENV.');
34+
return null;
35+
}
36+
2937
if (resolver) return resolver;
3038
try {
3139
// Load config if not loaded
@@ -65,6 +73,13 @@ let checkPromise = null;
6573
const PROXY_CACHE_TTL = 60000; // 60 seconds cache
6674

6775
export function getSystemProxy() {
76+
// Check if system proxy detection is enabled via ENV (default: 1/true)
77+
const enableProxy = ENV.get('enable_system_proxy', '1') === '1' || ENV.get('enable_system_proxy') === 'true';
78+
if (!enableProxy) {
79+
// console.log('[DOH] System proxy detection is disabled via ENV.');
80+
return Promise.resolve(null);
81+
}
82+
6883
const now = Date.now();
6984
// 1. If cache is valid (checked within 60s), return immediately
7085
if (lastCheckTime > 0 && (now - lastCheckTime < PROXY_CACHE_TTL)) {

0 commit comments

Comments
 (0)