perf: Add support for sending http requests using specific nodes

Only supported on Loon & Surge
This commit is contained in:
Peng-YM
2022-08-11 01:07:16 +08:00
parent e93332048e
commit c073870f24
5 changed files with 256 additions and 2 deletions

View File

@@ -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({