Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Detection of clash proxy #267

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

CapitaineJSparrow
Copy link
Owner

@CapitaineJSparrow CapitaineJSparrow commented Jun 28, 2022

@rookieKing Can you take a look to this ?
Contributes to #256

src/index.ts Outdated
Comment on lines 21 to 24
fetch("https://localhost:7890").then(() => {
HttpService.hasClashProxy = true;
console.log("Clash proxy detected");
}).catch(() => ({}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make it stronger

const checkProxyList = [
  ["https://localhost:7890", "Clash"],
  ["https://localhost:10809", "V2ray"],
  ["https://localhost:1080", "Shadowsocks"],
  // ...
];

const checkProxy = ([proxy, proxyName = ""]) => {
  console.log(`Check ${proxyName} at ${proxy}`);
  return fetch(proxy).then(() => [proxy, proxyName]);
};

Promise.race(checkProxyList.map(checkProxy)).then(([proxy, proxyName]) => {
  console.log(`${proxyName} proxy detected`);
  HttpService.proxy = proxy;
}, () => ({}));

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You rock

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rookieKing
Copy link
Contributor

Good jobs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants