Compare commits

...

4 Commits

6 changed files with 32 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.97",
"version": "2.14.103",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {

View File

@@ -33,7 +33,9 @@ function URI_SS() {
const serverAndPort = serverAndPortArray[1];
const portIdx = serverAndPort.lastIndexOf(':');
proxy.server = serverAndPort.substring(0, portIdx);
proxy.port = serverAndPort.substring(portIdx + 1);
proxy.port = `${serverAndPort.substring(portIdx + 1)}`.match(
/\d+/,
)?.[0];
const userInfo = userInfoStr.split(':');
proxy.cipher = userInfo[0];

View File

@@ -451,7 +451,9 @@ function ResolveDomainOperator({ provider }) {
const limit = 15; // more than 20 concurrency may result in surge TCP connection shortage.
const totalDomain = [
...new Set(
proxies.filter((p) => !isIP(p.server)).map((c) => c.server),
proxies
.filter((p) => !isIP(p.server) && !p['no-resolve'])
.map((c) => c.server),
),
];
const totalBatch = Math.ceil(totalDomain.length / limit);
@@ -475,8 +477,15 @@ function ResolveDomainOperator({ provider }) {
}
await Promise.all(currentBatch);
}
proxies.forEach((proxy) => {
proxy.server = results[proxy.server] || proxy.server;
proxies.forEach((p) => {
if (!p['no-resolve']) {
if (results[p.server]) {
p.server = results[p.server];
p.resolved = true;
} else {
p.resolved = false;
}
}
});
return proxies;

View File

@@ -15,8 +15,13 @@ import registerMiscRoutes from './miscs';
import registerNodeInfoRoutes from './node-info';
export default function serve() {
const $app = express({ substore: $ });
let port;
let host;
if ($.env.isNode) {
port = eval('process.env.SUB_STORE_BACKEND_API_PORT');
host = eval('process.env.SUB_STORE_BACKEND_API_HOST');
}
const $app = express({ substore: $, port, host });
// register routes
registerCollectionRoutes($app);
registerSubscriptionRoutes($app);

View File

@@ -1,4 +1,4 @@
import { FILES_KEY, MODULES_KEY } from '@/constants';
import { FILES_KEY, MODULES_KEY, SETTINGS_KEY } from '@/constants';
import { findByName } from '@/utils/database';
import { HTTP, ENV } from '@/vendor/open-api';
import { hex_md5 } from '@/vendor/md5';
@@ -45,7 +45,8 @@ export default async function download(url, ua) {
}
const { isNode } = ENV();
ua = ua || 'Quantumult%20X/1.0.29 (iPhone14,5; iOS 15.4.1)';
const { defaultUserAgent } = $.read(SETTINGS_KEY);
ua = ua || defaultUserAgent || 'clash.meta';
const id = hex_md5(ua + url);
if (!isNode && tasks.has(id)) {
return tasks.get(id);
@@ -63,6 +64,7 @@ export default async function download(url, ua) {
if (!$arguments?.noCache && cached) {
resolve(cached);
} else {
$.info(`Downloading...\nUser-Agent: ${ua}\nURL: ${url}`);
http.get(url)
.then((resp) => {
const body = resp.body;

View File

@@ -1,8 +1,9 @@
/* eslint-disable no-undef */
import { ENV } from './open-api';
export default function express({ substore: $, port }) {
export default function express({ substore: $, port, host }) {
port = port || 3000;
host = host || '::';
const { isNode } = ENV();
const DEFAULT_HEADERS = {
'Content-Type': 'text/plain;charset=UTF-8',
@@ -29,8 +30,9 @@ export default function express({ substore: $, port }) {
// adapter
app.start = () => {
app.listen(port, () => {
$.info(`Express started on port: ${port}`);
const listener = app.listen(port, host, () => {
const { address, port } = listener.address();
$.info(`Express started on ${address}:${port}`);
});
};
return app;