mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-03-20 08:12:42 +08:00
perf: Add support for sending http requests using specific nodes
Only supported on Loon & Surge
This commit is contained in:
@@ -5,6 +5,7 @@ import { getFlag } from '@/utils/geo';
|
||||
import lodash from 'lodash';
|
||||
import $ from '@/core/app';
|
||||
import { hex_md5 } from '@/vendor/md5';
|
||||
import {ProxyUtils} from '@/core/proxy-utils';
|
||||
|
||||
/**
|
||||
The rule "(name CONTAINS "🇨🇳") AND (port IN [80, 443])" can be expressed as follows:
|
||||
@@ -631,6 +632,7 @@ function createDynamicFunction(name, script, $arguments) {
|
||||
'$persistentStore',
|
||||
'$httpClient',
|
||||
'$notification',
|
||||
'ProxyUtils',
|
||||
`${script}\n return ${name}`,
|
||||
)(
|
||||
$arguments,
|
||||
@@ -642,13 +644,15 @@ function createDynamicFunction(name, script, $arguments) {
|
||||
$httpClient,
|
||||
// eslint-disable-next-line no-undef
|
||||
$notification,
|
||||
ProxyUtils
|
||||
);
|
||||
} else {
|
||||
return new Function(
|
||||
'$arguments',
|
||||
'$substore',
|
||||
'lodash',
|
||||
'ProxyUtils',
|
||||
`${script}\n return ${name}`,
|
||||
)($arguments, $, lodash);
|
||||
)($arguments, $, lodash, ProxyUtils);
|
||||
}
|
||||
}
|
||||
|
||||
11
backend/src/vendor/open-api.js
vendored
11
backend/src/vendor/open-api.js
vendored
@@ -253,6 +253,17 @@ export function HTTP(defaultOptions = { baseURL: '' }) {
|
||||
|
||||
events.onRequest(method, options);
|
||||
|
||||
if (options.node) {
|
||||
// Surge & Loon allow connecting to a server using a specified proxy node
|
||||
if (isSurge) {
|
||||
const build = $environment['surge-build'];
|
||||
if (build && parseInt(build) >= 2407) {
|
||||
options['policy-descriptor'] = options.node;
|
||||
delete options.node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let worker;
|
||||
if (isQX) {
|
||||
worker = $task.fetch({
|
||||
|
||||
Reference in New Issue
Block a user