mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-12 04:49:02 +08:00
Fix Surge TCP connection shortage. (#110)
This commit is contained in:
parent
1c5903cda1
commit
9e05c8d7f0
4
backend/dist/sub-store-parser.loon.min.js
vendored
4
backend/dist/sub-store-parser.loon.min.js
vendored
File diff suppressed because one or more lines are too long
@ -286,14 +286,17 @@ function ResolveDomainOperator({ provider }) {
|
|||||||
name: 'Resolve Domain Operator',
|
name: 'Resolve Domain Operator',
|
||||||
func: async (proxies) => {
|
func: async (proxies) => {
|
||||||
const results = {};
|
const results = {};
|
||||||
const resolves = new Map();
|
const limit = 15; // more than 20 concurrency may result in surge TCP connection shortage.
|
||||||
|
const totalDomain = [
|
||||||
for (const proxy of proxies) {
|
...new Set(
|
||||||
const domain = proxy.server;
|
proxies.filter((p) => !isIP(p.server)).map((c) => c.server),
|
||||||
if (isIP(domain)) continue;
|
),
|
||||||
if (!resolves.has(domain)) {
|
];
|
||||||
resolves.set(
|
const totalBatch = Math.ceil(totalDomain.length / limit);
|
||||||
domain,
|
for (let i = 0; i < totalBatch; i++) {
|
||||||
|
const currentBatch = [];
|
||||||
|
for (let domain of totalDomain.splice(0, limit)) {
|
||||||
|
currentBatch.push(
|
||||||
resolver(domain)
|
resolver(domain)
|
||||||
.then((ip) => {
|
.then((ip) => {
|
||||||
results[domain] = ip;
|
results[domain] = ip;
|
||||||
@ -308,10 +311,8 @@ function ResolveDomainOperator({ provider }) {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
await Promise.all(currentBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolve domains
|
|
||||||
await Promise.all([...resolves.values()]);
|
|
||||||
proxies.forEach((proxy) => {
|
proxies.forEach((proxy) => {
|
||||||
proxy.server = results[proxy.server] || proxy.server;
|
proxy.server = results[proxy.server] || proxy.server;
|
||||||
});
|
});
|
||||||
|
4
backend/sub-store.min.js
vendored
4
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user