Compare commits

...

7 Commits

Author SHA1 Message Date
xream
1c9ae2a079 feat: 支持 GitHub 加速代理(前端需 >= 2.15.58) 2025-07-28 14:31:39 +08:00
xream
22e39dc18f feat: 单条订阅确保没有 subscriptions 字段 2025-07-28 11:26:18 +08:00
xream
4276869033 refactor: 非 Node 环境的 req query params decode 2025-07-27 22:47:43 +08:00
xream
c902ad8c87 fix: 修复 sing-box vless 传输层
Some checks failed
build / build (push) Has been cancelled
2025-07-27 00:36:37 +08:00
xream
10fe493162 feat: Egern shadowsocks+shadow-tls 支持 udp port
Some checks failed
build / build (push) Has been cancelled
2025-07-26 15:57:47 +08:00
xream
3f9867512b feat: 流量四舍五入优化
Some checks failed
build / build (push) Has been cancelled
2025-07-22 17:40:50 +08:00
xream
8ab694efcc doc: README 2025-07-21 09:33:31 +08:00
16 changed files with 37 additions and 67 deletions

View File

@@ -99,22 +99,16 @@ Go to `backend` directories, install node dependencies:
pnpm i
```
1. In `backend`, run the backend server on http://localhost:3000
babel(old school)
```
pnpm start
```
or
esbuild(experimental)
```
SUB_STORE_BACKEND_API_PORT=3000 pnpm run --parallel "/^dev:.*/"
```
### Build
```
pnpm bundle:esbuild
```
## LICENSE
This project is under the GPL V3 LICENSE.

View File

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

View File

@@ -371,6 +371,14 @@ export default function Egern_Producer() {
};
}
}
if (
['ss'].includes(original.type) &&
proxy.shadow_tls &&
original['udp-port'] > 0 &&
original['udp-port'] <= 65535
) {
proxy['udp_port'] = original['udp-port'];
}
delete proxy.subName;
delete proxy.collectionName;

View File

@@ -181,7 +181,7 @@ const h1Parser = (proxy, parsedProxy) => {
host = `${host}`.split(',').map((i) => i.trim());
if (host.length > 0) transport.host = host;
}
if (!transport.host) return;
// if (!transport.host) return;
if (proxy['http-path'] && proxy['http-path'] !== '') {
const path = proxy['http-path'];
if (Array.isArray(path)) {
@@ -190,7 +190,7 @@ const h1Parser = (proxy, parsedProxy) => {
}
if (parsedProxy.tls.insecure)
parsedProxy.tls.server_name = transport.host[0];
if (transport.host.length === 1) transport.host = transport.host[0];
if (transport.host?.length === 1) transport.host = transport.host[0];
for (const key of Object.keys(transport.headers)) {
const value = transport.headers[key];
if (value.length === 1) transport.headers[key] = value[0];
@@ -569,6 +569,8 @@ const vlessParser = (proxy = {}) => {
// if (['xtls-rprx-vision', ''].includes(proxy.flow)) parsedProxy.flow = proxy.flow;
if (proxy.flow != null) parsedProxy.flow = proxy.flow;
if (proxy.network === 'ws') wsParser(proxy, parsedProxy);
if (proxy.network === 'h2') h2Parser(proxy, parsedProxy);
if (proxy.network === 'http') h1Parser(proxy, parsedProxy);
if (proxy.network === 'grpc') grpcParser(proxy, parsedProxy);
networkParser(proxy, parsedProxy);
tfoParser(proxy, parsedProxy);

View File

@@ -112,7 +112,6 @@ function replaceArtifact(req, res) {
async function getArtifact(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
const allArtifacts = $.read(ARTIFACTS_KEY);
const artifact = findByName(allArtifacts, name);
@@ -163,7 +162,6 @@ function createArtifact(req, res) {
function updateArtifact(req, res) {
const allArtifacts = $.read(ARTIFACTS_KEY);
let oldName = req.params.name;
oldName = decodeURIComponent(oldName);
const artifact = findByName(allArtifacts, oldName);
if (artifact) {
$.info(`正在更新远程配置:${artifact.name}`);
@@ -197,7 +195,6 @@ function updateArtifact(req, res) {
async function deleteArtifact(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
$.info(`正在删除远程配置:${name}`);
const allArtifacts = $.read(ARTIFACTS_KEY);
try {

View File

@@ -52,7 +52,6 @@ function createCollection(req, res) {
function getCollection(req, res) {
let { name } = req.params;
let { raw } = req.query;
name = decodeURIComponent(name);
const allCols = $.read(COLLECTIONS_KEY);
const collection = findByName(allCols, name);
if (collection) {
@@ -84,7 +83,6 @@ function getCollection(req, res) {
function updateCollection(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
let collection = req.body;
const allCols = $.read(COLLECTIONS_KEY);
const oldCol = findByName(allCols, name);
@@ -137,7 +135,6 @@ function updateCollection(req, res) {
function deleteCollection(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
$.info(`正在删除组合订阅:${name}`);
let allCols = $.read(COLLECTIONS_KEY);
deleteByName(allCols, name);

View File

@@ -88,8 +88,6 @@ export default function register($app) {
async function downloadSubscription(req, res) {
let { name, nezhaIndex } = req.params;
name = decodeURIComponent(name);
nezhaIndex = decodeURIComponent(nezhaIndex);
const useMihomoExternal = req.query.target === 'SurgeMac';
@@ -140,7 +138,6 @@ async function downloadSubscription(req, res) {
$.info(`传入 $options: ${JSON.stringify($options)}`);
}
if (url) {
url = decodeURIComponent(url);
$.info(`指定远程订阅 URL: ${url}`);
if (!/^https?:\/\//.test(url)) {
content = url;
@@ -148,32 +145,25 @@ async function downloadSubscription(req, res) {
}
}
if (content) {
content = decodeURIComponent(content);
$.info(`指定本地订阅: ${content}`);
}
if (proxy) {
proxy = decodeURIComponent(proxy);
$.info(`指定远程订阅使用代理/策略 proxy: ${proxy}`);
}
if (ua) {
ua = decodeURIComponent(ua);
$.info(`指定远程订阅 User-Agent: ${ua}`);
}
if (mergeSources) {
mergeSources = decodeURIComponent(mergeSources);
$.info(`指定合并来源: ${mergeSources}`);
}
if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') {
ignoreFailedRemoteSub = decodeURIComponent(ignoreFailedRemoteSub);
$.info(`指定忽略失败的远程订阅: ${ignoreFailedRemoteSub}`);
}
if (produceType) {
produceType = decodeURIComponent(produceType);
$.info(`指定生产类型: ${produceType}`);
}
if (includeUnsupportedProxy) {
includeUnsupportedProxy = decodeURIComponent(includeUnsupportedProxy);
$.info(
`包含官方/商店版/未续费订阅不支持的协议: ${includeUnsupportedProxy}`,
);
@@ -362,8 +352,6 @@ async function downloadSubscription(req, res) {
async function downloadCollection(req, res) {
let { name, nezhaIndex } = req.params;
name = decodeURIComponent(name);
nezhaIndex = decodeURIComponent(nezhaIndex);
const useMihomoExternal = req.query.target === 'SurgeMac';
@@ -416,21 +404,17 @@ async function downloadCollection(req, res) {
}
if (proxy) {
proxy = decodeURIComponent(proxy);
$.info(`指定远程订阅使用代理/策略 proxy: ${proxy}`);
}
if (ignoreFailedRemoteSub != null && ignoreFailedRemoteSub !== '') {
ignoreFailedRemoteSub = decodeURIComponent(ignoreFailedRemoteSub);
$.info(`指定忽略失败的远程订阅: ${ignoreFailedRemoteSub}`);
}
if (produceType) {
produceType = decodeURIComponent(produceType);
$.info(`指定生产类型: ${produceType}`);
}
if (includeUnsupportedProxy) {
includeUnsupportedProxy = decodeURIComponent(includeUnsupportedProxy);
$.info(
`包含官方/商店版/未续费订阅不支持的协议: ${includeUnsupportedProxy}`,
);

View File

@@ -51,7 +51,6 @@ function createFile(req, res) {
async function getFile(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
const reqUA = req.headers['user-agent'] || req.headers['User-Agent'];
$.info(`正在下载文件:${name}\n请求 User-Agent: ${reqUA}`);
let {
@@ -95,42 +94,33 @@ async function getFile(req, res) {
$.info(`传入 $options: ${JSON.stringify($options)}`);
}
if (url) {
url = decodeURIComponent(url);
$.info(`指定远程文件 URL: ${url}`);
}
if (proxy) {
proxy = decodeURIComponent(proxy);
$.info(`指定远程订阅使用代理/策略 proxy: ${proxy}`);
}
if (ua) {
ua = decodeURIComponent(ua);
$.info(`指定远程文件 User-Agent: ${ua}`);
}
if (subInfoUrl) {
subInfoUrl = decodeURIComponent(subInfoUrl);
$.info(`指定获取流量的 subInfoUrl: ${subInfoUrl}`);
}
if (subInfoUserAgent) {
subInfoUserAgent = decodeURIComponent(subInfoUserAgent);
$.info(`指定获取流量的 subInfoUserAgent: ${subInfoUserAgent}`);
}
if (content) {
content = decodeURIComponent(content);
$.info(`指定本地文件: ${content}`);
}
if (mergeSources) {
mergeSources = decodeURIComponent(mergeSources);
$.info(`指定合并来源: ${mergeSources}`);
}
if (ignoreFailedRemoteFile != null && ignoreFailedRemoteFile !== '') {
ignoreFailedRemoteFile = decodeURIComponent(ignoreFailedRemoteFile);
$.info(`指定忽略失败的远程文件: ${ignoreFailedRemoteFile}`);
}
if (noCache) {
$.info(`指定不使用缓存: ${noCache}`);
}
if (produceType) {
produceType = decodeURIComponent(produceType);
$.info(`指定生产类型: ${produceType}`);
}
@@ -225,7 +215,6 @@ async function getFile(req, res) {
function getWholeFile(req, res) {
let { name } = req.params;
let { raw } = req.query;
name = decodeURIComponent(name);
const allFiles = $.read(FILES_KEY);
const file = findByName(allFiles, name);
if (file) {
@@ -257,7 +246,6 @@ function getWholeFile(req, res) {
function updateFile(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
let file = req.body;
const allFiles = $.read(FILES_KEY);
const oldFile = findByName(allFiles, name);
@@ -299,7 +287,6 @@ function updateFile(req, res) {
function deleteFile(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
$.info(`正在删除文件:${name}`);
let allFiles = $.read(FILES_KEY);
deleteByName(allFiles, name);

View File

@@ -43,7 +43,6 @@ function createModule(req, res) {
function getModule(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
const allModules = $.read(MODULES_KEY);
const module = findByName(allModules, name);
if (module) {
@@ -64,7 +63,6 @@ function getModule(req, res) {
function updateModule(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
let module = req.body;
const allModules = $.read(MODULES_KEY);
const oldModule = findByName(allModules, name);
@@ -92,7 +90,6 @@ function updateModule(req, res) {
function deleteModule(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
$.info(`正在删除模块:${name}`);
let allModules = $.read(MODULES_KEY);
deleteByName(allModules, name);

View File

@@ -61,7 +61,7 @@ async function updateSettings(req, res) {
export async function updateAvatar() {
const settings = $.read(SETTINGS_KEY);
const { githubUser: username, syncPlatform } = settings;
const { githubUser: username, syncPlatform, githubProxy } = settings;
if (username) {
if (syncPlatform === 'gitlab') {
try {
@@ -92,7 +92,9 @@ export async function updateAvatar() {
try {
const data = await $.http
.get({
url: `https://api.github.com/users/${encodeURIComponent(
url: `${
githubProxy ? `${githubProxy}/` : ''
}https://api.github.com/users/${encodeURIComponent(
username,
)}`,
headers: {

View File

@@ -39,10 +39,8 @@ export default function register($app) {
// subscriptions API
async function getFlowInfo(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
let { url } = req.query;
if (url) {
url = decodeURIComponent(url);
$.info(`指定远程订阅 URL: ${url}`);
}
const allSubs = $.read(SUBS_KEY);
@@ -232,6 +230,7 @@ async function getFlowInfo(req, res) {
function createSubscription(req, res) {
const sub = req.body;
delete sub.subscriptions;
$.info(`正在创建订阅: ${sub.name}`);
if (/\//.test(sub.name)) {
failed(
@@ -262,9 +261,9 @@ function createSubscription(req, res) {
function getSubscription(req, res) {
let { name } = req.params;
let { raw } = req.query;
name = decodeURIComponent(name);
const allSubs = $.read(SUBS_KEY);
const sub = findByName(allSubs, name);
delete sub.subscriptions;
if (sub) {
if (raw) {
res.set('content-type', 'application/json')
@@ -294,8 +293,8 @@ function getSubscription(req, res) {
function updateSubscription(req, res) {
let { name } = req.params;
name = decodeURIComponent(name); // the original name
let sub = req.body;
delete sub.subscriptions;
const allSubs = $.read(SUBS_KEY);
const oldSub = findByName(allSubs, name);
if (oldSub) {
@@ -357,7 +356,6 @@ function updateSubscription(req, res) {
function deleteSubscription(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
$.info(`删除订阅:${name}...`);
// delete from subscriptions
let allSubs = $.read(SUBS_KEY);

View File

@@ -792,7 +792,6 @@ async function syncAllArtifacts(_, res) {
async function syncArtifact(req, res) {
let { name } = req.params;
name = decodeURIComponent(name);
$.info(`开始同步远程配置 ${name}...`);
const allArtifacts = $.read(ARTIFACTS_KEY);
const artifact = findByName(allArtifacts, name);

View File

@@ -17,7 +17,6 @@ export default function register($app) {
function deleteToken(req, res) {
let { token } = req.params;
token = decodeURIComponent(token);
$.info(`正在删除:${token}`);
let allTokens = $.read(TOKENS_KEY);
deleteByName(allTokens, token, 'token');

View File

@@ -230,7 +230,7 @@ export function flowTransfer(flow, unit = 'B') {
let unitIndex = unitList.indexOf(unit);
return flow < 1024 || unitIndex === unitList.length - 1
? { value: flow.toFixed(1), unit: unit }
? { value: (Math.round(flow * 100) / 100).toString(), unit: unit }
: flowTransfer(flow / 1024, unitList[++unitIndex]);
}

View File

@@ -9,7 +9,11 @@ import { SETTINGS_KEY } from '@/constants';
export default class Gist {
constructor({ token, key, syncPlatform }) {
const { isStash, isLoon, isShadowRocket, isQX } = ENV();
const { defaultProxy, defaultTimeout: timeout } = $.read(SETTINGS_KEY);
const {
defaultProxy,
defaultTimeout: timeout,
githubProxy,
} = $.read(SETTINGS_KEY);
let proxy = defaultProxy;
if ($.env.isNode) {
proxy =
@@ -63,7 +67,9 @@ export default class Gist {
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36',
};
this.http = HTTP({
baseURL: 'https://api.github.com',
baseURL: `${
githubProxy ? `${githubProxy}/` : ''
}https://api.github.com`,
headers: {
...this.headers,
...(isStash && proxy

View File

@@ -270,7 +270,7 @@ function extractURL(url) {
let hashes = url.slice(url.indexOf('?') + 1).split('&');
for (let i = 0; i < hashes.length; i++) {
const hash = hashes[i].split('=');
query[hash[0]] = hash[1];
query[hash[0]] = decodeURIComponent(hash[1]);
}
}
return {
@@ -294,7 +294,7 @@ function extractPathParams(pattern, path) {
while (path[j] !== '/' && j < path.length) {
val.push(path[j++]);
}
params[key.join('')] = val.join('');
params[key.join('')] = decodeURIComponent(val.join(''));
} else {
if (pattern[i] !== path[j]) {
return null;