diff --git a/backend/.babelrc b/backend/.babelrc index 631b601..d45171f 100644 --- a/backend/.babelrc +++ b/backend/.babelrc @@ -10,5 +10,18 @@ "@babel/preset-env" ] } - } + }, + "plugins": [ + [ + "babel-plugin-relative-path-import", + { + "paths": [ + { + "rootPathPrefix": "@", + "rootPathSuffix": "src" + } + ] + } + ] + ] } \ No newline at end of file diff --git a/backend/dist/sub-store-parser.loon.min.js b/backend/dist/sub-store-parser.loon.min.js index d4ddb64..34d1001 100644 --- a/backend/dist/sub-store-parser.loon.min.js +++ b/backend/dist/sub-store-parser.loon.min.js @@ -6,8 +6,8 @@ * ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗ * ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ * Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket! - * @updated: 2022/6/16 12:57:15 - * @version: 2.0 + * @updated: 2022/6/16 14:23:56 + * @version: 2.0.1 * @author: Peng-YM * @github: https://github.com/Peng-YM/Sub-Store * @documentation: https://www.notion.so/Sub-Store-6259586994d34c11a4ced5c406264b46 diff --git a/backend/gulpfile.babel.js b/backend/gulpfile.babel.js index 8a95c30..1a2ba12 100644 --- a/backend/gulpfile.babel.js +++ b/backend/gulpfile.babel.js @@ -43,7 +43,20 @@ function scripts(src, dest) { return () => { return browserify(src) .transform('babelify', { - presets: [['@babel/preset-env']] + presets: [['@babel/preset-env']], + plugins: [ + [ + 'babel-plugin-relative-path-import', + { + paths: [ + { + 'rootPathPrefix': '@', + 'rootPathSuffix': 'src', + } + ] + } + ] + ] }) .plugin('tinyify') .bundle() diff --git a/backend/package-lock.json b/backend/package-lock.json index 72ab2c7..15d242c 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -1,12 +1,12 @@ { "name": "sub-store", - "version": "1.6", + "version": "2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "sub-store", - "version": "1.6", + "version": "2.0", "license": "GPL", "dependencies": { "body-parser": "^1.19.0", @@ -23,6 +23,7 @@ "@babel/register": "^7.17.7", "@types/gulp": "^4.0.9", "axios": "^0.20.0", + "babel-plugin-relative-path-import": "^2.0.1", "babelify": "^10.0.0", "browser-pack-flat": "^3.4.2", "browserify": "^17.0.0", @@ -2917,6 +2918,15 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/babel-plugin-relative-path-import": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/babel-plugin-relative-path-import/-/babel-plugin-relative-path-import-2.0.1.tgz", + "integrity": "sha512-jOtB/Lef7QFNAEGRV4VmUvP/VsizpvOVonrTeTTE8TxVIR0FL/wJTzFQp4ei5Jf5+EWklFORmnsXOjLxvNVeRg==", + "dev": true, + "dependencies": { + "slash": "^1.0.0" + } + }, "node_modules/babelify": { "version": "10.0.0", "resolved": "https://registry.npmmirror.com/babelify/-/babelify-10.0.0.tgz", @@ -11243,6 +11253,15 @@ "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", "dev": true }, + "node_modules/slash": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/slash/-/slash-1.0.0.tgz", + "integrity": "sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmmirror.com/snapdragon/-/snapdragon-0.8.2.tgz", @@ -15693,6 +15712,15 @@ "@babel/helper-define-polyfill-provider": "^0.3.1" } }, + "babel-plugin-relative-path-import": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/babel-plugin-relative-path-import/-/babel-plugin-relative-path-import-2.0.1.tgz", + "integrity": "sha512-jOtB/Lef7QFNAEGRV4VmUvP/VsizpvOVonrTeTTE8TxVIR0FL/wJTzFQp4ei5Jf5+EWklFORmnsXOjLxvNVeRg==", + "dev": true, + "requires": { + "slash": "^1.0.0" + } + }, "babelify": { "version": "10.0.0", "resolved": "https://registry.npmmirror.com/babelify/-/babelify-10.0.0.tgz", @@ -22607,6 +22635,12 @@ "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", "dev": true }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/slash/-/slash-1.0.0.tgz", + "integrity": "sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==", + "dev": true + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmmirror.com/snapdragon/-/snapdragon-0.8.2.tgz", diff --git a/backend/package.json b/backend/package.json index 76ce996..bc25944 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,10 +1,10 @@ { "name": "sub-store", - "version": "2.0", + "version": "2.0.1", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { - "test": "gulp peggy && npx cross-env BABEL_ENV=test mocha --require @babel/register --recursive", + "test": "gulp peggy && npx cross-env BABEL_ENV=test mocha src/test/**/*.spec.js --require @babel/register --recursive", "serve": "node sub-store.min.js", "start": "nodemon --exec node_modules/.bin/babel-node src/main.js", "build": "gulp" @@ -26,6 +26,7 @@ "@babel/register": "^7.17.7", "@types/gulp": "^4.0.9", "axios": "^0.20.0", + "babel-plugin-relative-path-import": "^2.0.1", "babelify": "^10.0.0", "browser-pack-flat": "^3.4.2", "browserify": "^17.0.0", diff --git a/backend/src/core/proxy-utils/processors/index.js b/backend/src/core/proxy-utils/processors/index.js index 1450700..1d5e50c 100644 --- a/backend/src/core/proxy-utils/processors/index.js +++ b/backend/src/core/proxy-utils/processors/index.js @@ -1,8 +1,8 @@ -import { isIPv4, isIPv6 } from '../../../utils'; -import { FULL } from '../../../utils/logical'; -import { getFlag } from '../../../utils/geo'; +import { isIPv4, isIPv6 } from '@/utils'; +import { FULL } from '@/utils/logical'; +import { getFlag } from '@/utils/geo'; import lodash from 'lodash'; -import $ from '../../app'; +import $ from '@/core/app'; // force to set some properties (e.g., skip-cert-verify, udp, tfo, etc.) function SetPropertyOperator({ key, value }) { diff --git a/backend/src/core/rule-utils/index.js b/backend/src/core/rule-utils/index.js index 031ef17..0152d71 100644 --- a/backend/src/core/rule-utils/index.js +++ b/backend/src/core/rule-utils/index.js @@ -1,7 +1,7 @@ import RULE_PREPROCESSORS from './preprocessors'; import RULE_PRODUCERS from './producers'; import RULE_PARSERS from './parsers'; -import $ from '../app'; +import $ from '@/core/app'; export const RuleUtils = (function () { function preprocess(raw) { diff --git a/backend/src/main.js b/backend/src/main.js index 254dedb..382ca81 100644 --- a/backend/src/main.js +++ b/backend/src/main.js @@ -18,6 +18,6 @@ console.log( `, ); -import serve from './restful'; +import serve from '@/restful'; serve(); diff --git a/backend/src/products/resource-parser.loon.js b/backend/src/products/resource-parser.loon.js index c045074..9928e44 100644 --- a/backend/src/products/resource-parser.loon.js +++ b/backend/src/products/resource-parser.loon.js @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ -import { ProxyUtils } from '../core/proxy-utils'; -import { RuleUtils } from '../core/rule-utils'; +import { ProxyUtils } from '@/core/proxy-utils'; +import { RuleUtils } from '@/core/rule-utils'; const RESOURCE_TYPE = { PROXY: 1, diff --git a/backend/src/restful/artifacts.js b/backend/src/restful/artifacts.js index 50706b4..712f9ed 100644 --- a/backend/src/restful/artifacts.js +++ b/backend/src/restful/artifacts.js @@ -1,8 +1,8 @@ -import { ProxyUtils } from '../core/proxy-utils'; -import { RuleUtils } from '../core/rule-utils'; -import download from '../utils/download'; -import Gist from '../utils/gist'; -import $ from '../core/app'; +import { ProxyUtils } from '@/core/proxy-utils'; +import { RuleUtils } from '@/core/rule-utils'; +import download from '@/utils/download'; +import Gist from '@/utils/gist'; +import $ from '@/core/app'; import { SUBS_KEY, diff --git a/backend/src/restful/collections.js b/backend/src/restful/collections.js index 1dd268d..079a3c3 100644 --- a/backend/src/restful/collections.js +++ b/backend/src/restful/collections.js @@ -1,7 +1,7 @@ import { getPlatformFromHeaders, getFlowHeaders } from './subscriptions'; import { SUBS_KEY, COLLECTIONS_KEY } from './constants'; import { produceArtifact } from './artifacts'; -import $ from '../core/app'; +import $ from '@/core/app'; export default function register($app) { if (!$.read(COLLECTIONS_KEY)) $.write({}, COLLECTIONS_KEY); diff --git a/backend/src/restful/index.js b/backend/src/restful/index.js index 44775a0..80b912e 100644 --- a/backend/src/restful/index.js +++ b/backend/src/restful/index.js @@ -3,10 +3,10 @@ import { GIST_BACKUP_KEY, GIST_BACKUP_FILE_NAME, } from './constants'; -import { ENV, HTTP } from '../vendor/open-api'; -import express from '../vendor/express'; -import Gist from '../utils/gist'; -import $ from '../core/app'; +import { ENV, HTTP } from '@/vendor/open-api'; +import express from '@/vendor/express'; +import Gist from '@/utils/gist'; +import $ from '@/core/app'; import registerSubscriptionRoutes from './subscriptions'; import registerCollectionRoutes from './collections'; diff --git a/backend/src/restful/settings.js b/backend/src/restful/settings.js index 3590d98..68a9783 100644 --- a/backend/src/restful/settings.js +++ b/backend/src/restful/settings.js @@ -1,5 +1,5 @@ import { SETTINGS_KEY } from './constants'; -import $ from '../core/app'; +import $ from '@/core/app'; export default function register($app) { if (!$.read(SETTINGS_KEY)) $.write({}, SETTINGS_KEY); diff --git a/backend/src/restful/subscriptions.js b/backend/src/restful/subscriptions.js index d1ad393..68d8227 100644 --- a/backend/src/restful/subscriptions.js +++ b/backend/src/restful/subscriptions.js @@ -1,6 +1,6 @@ import { SUBS_KEY, COLLECTIONS_KEY } from './constants'; import { produceArtifact } from './artifacts'; -import $ from '../core/app'; +import $ from '@/core/app'; export default function register($app) { if (!$.read(SUBS_KEY)) $.write({}, SUBS_KEY); diff --git a/backend/test/proxy-parsers/loon.spec.js b/backend/src/test/proxy-parsers/loon.spec.js similarity index 76% rename from backend/test/proxy-parsers/loon.spec.js rename to backend/src/test/proxy-parsers/loon.spec.js index 149b3b6..37c1ca8 100644 --- a/backend/test/proxy-parsers/loon.spec.js +++ b/backend/src/test/proxy-parsers/loon.spec.js @@ -1,128 +1,128 @@ -import { expect } from 'chai'; -import getLoonParser from '../../src/core/proxy-utils/peggy/loon'; -import testcases from './testcases'; +import getLoonParser from '@/core/proxy-utils/parsers/peggy/loon'; import { describe, it } from 'mocha'; +import testcases from './testcases'; +import { expect } from 'chai'; const parser = getLoonParser(); -describe('Loon', function() { - describe('shadowsocks', function() { - it('test shadowsocks simple', function() { +describe('Loon', function () { + describe('shadowsocks', function () { + it('test shadowsocks simple', function () { const { input, expected } = testcases.SS.SIMPLE; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected); }); - it('test shadowsocks obfs + tls', function() { + it('test shadowsocks obfs + tls', function () { const { input, expected } = testcases.SS.OBFS_TLS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected); }); - it('test shadowsocks obfs + http', function() { + it('test shadowsocks obfs + http', function () { const { input, expected } = testcases.SS.OBFS_HTTP; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected); }); }); - describe('shadowsocksr', function() { - it('test shadowsocksr simple', function() { + describe('shadowsocksr', function () { + it('test shadowsocksr simple', function () { const { input, expected } = testcases.SSR.SIMPLE; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected); }); }); - describe('trojan', function() { - it('test trojan simple', function() { + describe('trojan', function () { + it('test trojan simple', function () { const { input, expected } = testcases.TROJAN.SIMPLE; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected); }); - it('test trojan + ws', function() { + it('test trojan + ws', function () { const { input, expected } = testcases.TROJAN.WS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected); }); - it('test trojan + wss', function() { + it('test trojan + wss', function () { const { input, expected } = testcases.TROJAN.WSS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected); }); }); - describe('vmess', function() { - it('test vmess simple', function() { + describe('vmess', function () { + it('test vmess simple', function () { const { input, expected } = testcases.VMESS.SIMPLE; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); - it('test vmess + aead', function() { + it('test vmess + aead', function () { const { input, expected } = testcases.VMESS.AEAD; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); - it('test vmess + ws', function() { + it('test vmess + ws', function () { const { input, expected } = testcases.VMESS.WS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); - it('test vmess + wss', function() { + it('test vmess + wss', function () { const { input, expected } = testcases.VMESS.WSS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); - it('test vmess + http', function() { + it('test vmess + http', function () { const { input, expected } = testcases.VMESS.HTTP; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); - it('test vmess + http + tls', function() { + it('test vmess + http + tls', function () { const { input, expected } = testcases.VMESS.HTTP_TLS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); }); - describe('vless', function() { - it('test vless simple', function() { + describe('vless', function () { + it('test vless simple', function () { const { input, expected } = testcases.VLESS.SIMPLE; const proxy = parser.parse(input.Loon); - expect(proxy).eql(expected.Loon) + expect(proxy).eql(expected.Loon); }); - it('test vless + ws', function() { + it('test vless + ws', function () { const { input, expected } = testcases.VLESS.WS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); - it('test vless + wss', function() { + it('test vless + wss', function () { const { input, expected } = testcases.VLESS.WSS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); - it('test vless + http', function() { + it('test vless + http', function () { const { input, expected } = testcases.VLESS.HTTP; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); - it('test vless + http + tls', function() { + it('test vless + http + tls', function () { const { input, expected } = testcases.VLESS.HTTP_TLS; const proxy = parser.parse(input.Loon); expect(proxy).eql(expected.Loon); }); }); - describe('http(s)', function() { + describe('http(s)', function () { it('test http simple', function () { const { input, expected } = testcases.HTTP.SIMPLE; const proxy = parser.parse(input.Loon); @@ -141,4 +141,4 @@ describe('Loon', function() { expect(proxy).eql(expected); }); }); -}); \ No newline at end of file +}); diff --git a/backend/test/proxy-parsers/qx.spec.js b/backend/src/test/proxy-parsers/qx.spec.js similarity index 80% rename from backend/test/proxy-parsers/qx.spec.js rename to backend/src/test/proxy-parsers/qx.spec.js index 714d56c..34d9f56 100644 --- a/backend/test/proxy-parsers/qx.spec.js +++ b/backend/src/test/proxy-parsers/qx.spec.js @@ -1,95 +1,93 @@ -import getQXParser from '../../src/core/proxy-utils/peggy/qx'; -import { expect } from 'chai'; -import testcases from './testcases'; +import getQXParser from '@/core/proxy-utils/parsers/peggy/qx'; import { describe, it } from 'mocha'; - - +import testcases from './testcases'; +import { expect } from 'chai'; const parser = getQXParser(); -describe('QX', function() { - describe('shadowsocks', function() { - it('test shadowsocks simple', function() { +describe('QX', function () { + describe('shadowsocks', function () { + it('test shadowsocks simple', function () { const { input, expected } = testcases.SS.SIMPLE; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); - it('test shadowsocks obfs + tls', function() { + it('test shadowsocks obfs + tls', function () { const { input, expected } = testcases.SS.OBFS_TLS; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); - it('test shadowsocks obfs + http', function() { + it('test shadowsocks obfs + http', function () { const { input, expected } = testcases.SS.OBFS_HTTP; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); - it('test shadowsocks v2ray-plugin + ws', function() { + it('test shadowsocks v2ray-plugin + ws', function () { const { input, expected } = testcases.SS.V2RAY_PLUGIN_WS; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); - it('test shadowsocks v2ray-plugin + wss', function() { + it('test shadowsocks v2ray-plugin + wss', function () { const { input, expected } = testcases.SS.V2RAY_PLUGIN_WSS; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); }); - describe('shadowsocksr', function() { - it('test shadowsocksr simple', function() { + describe('shadowsocksr', function () { + it('test shadowsocksr simple', function () { const { input, expected } = testcases.SSR.SIMPLE; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); }); - describe('trojan', function() { - it('test trojan simple', function() { + describe('trojan', function () { + it('test trojan simple', function () { const { input, expected } = testcases.TROJAN.SIMPLE; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); - it('test trojan + ws', function() { + it('test trojan + ws', function () { const { input, expected } = testcases.TROJAN.WS; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); - it('test trojan + wss', function() { + it('test trojan + wss', function () { const { input, expected } = testcases.TROJAN.WSS; const proxy = parser.parse(input.QX); expect(proxy).eql(expected); }); }); - describe('vmess', function() { - it('test vmess simple', function() { + describe('vmess', function () { + it('test vmess simple', function () { const { input, expected } = testcases.VMESS.SIMPLE; const proxy = parser.parse(input.QX); expect(proxy).eql(expected.QX); }); - it('test vmess aead', function() { + it('test vmess aead', function () { const { input, expected } = testcases.VMESS.AEAD; const proxy = parser.parse(input.QX); expect(proxy).eql(expected.QX); }); - it('test vmess + ws', function() { + it('test vmess + ws', function () { const { input, expected } = testcases.VMESS.WS; const proxy = parser.parse(input.QX); expect(proxy).eql(expected.QX); }); - it('test vmess + wss', function() { + it('test vmess + wss', function () { const { input, expected } = testcases.VMESS.WSS; const proxy = parser.parse(input.QX); expect(proxy).eql(expected.QX); }); - it('test vmess + http', function() { + it('test vmess + http', function () { const { input, expected } = testcases.VMESS.HTTP; const proxy = parser.parse(input.QX); expect(proxy).eql(expected.QX); @@ -135,4 +133,4 @@ describe('QX', function() { expect(proxy).eql(expected); }); }); -}); \ No newline at end of file +}); diff --git a/backend/test/proxy-parsers/surge.spec.js b/backend/src/test/proxy-parsers/surge.spec.js similarity index 84% rename from backend/test/proxy-parsers/surge.spec.js rename to backend/src/test/proxy-parsers/surge.spec.js index 53fe7d5..0dea71a 100644 --- a/backend/test/proxy-parsers/surge.spec.js +++ b/backend/src/test/proxy-parsers/surge.spec.js @@ -1,69 +1,69 @@ -import getSurgeParser from '../../src/core/proxy-utils/peggy/surge'; -import { expect } from 'chai'; -import testcases from './testcases'; +import getSurgeParser from '@/core/proxy-utils/parsers/peggy/surge'; import { describe, it } from 'mocha'; +import testcases from './testcases'; +import { expect } from 'chai'; const parser = getSurgeParser(); -describe('Surge', function() { - describe('shadowsocks', function() { - it('test shadowsocks simple', function() { +describe('Surge', function () { + describe('shadowsocks', function () { + it('test shadowsocks simple', function () { const { input, expected } = testcases.SS.SIMPLE; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected); }); - it('test shadowsocks obfs + tls', function() { + it('test shadowsocks obfs + tls', function () { const { input, expected } = testcases.SS.OBFS_TLS; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected); }); - it('test shadowsocks obfs + http', function() { + it('test shadowsocks obfs + http', function () { const { input, expected } = testcases.SS.OBFS_HTTP; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected); }); }); - describe('trojan', function() { - it('test trojan simple', function() { + describe('trojan', function () { + it('test trojan simple', function () { const { input, expected } = testcases.TROJAN.SIMPLE; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected); }); - it('test trojan + ws', function() { + it('test trojan + ws', function () { const { input, expected } = testcases.TROJAN.WS; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected); }); - it('test trojan + wss', function() { + it('test trojan + wss', function () { const { input, expected } = testcases.TROJAN.WSS; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected); }); }); - describe('vmess', function() { - it('test vmess simple', function() { + describe('vmess', function () { + it('test vmess simple', function () { const { input, expected } = testcases.VMESS.SIMPLE; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected.Surge); }); - it('test vmess aead', function() { + it('test vmess aead', function () { const { input, expected } = testcases.VMESS.AEAD; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected.Surge); }); - it('test vmess + ws', function() { + it('test vmess + ws', function () { const { input, expected } = testcases.VMESS.WS; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected.Surge); }); - it('test vmess + wss', function() { + it('test vmess + wss', function () { const { input, expected } = testcases.VMESS.WSS; const proxy = parser.parse(input.Surge); expect(proxy).eql(expected.Surge); @@ -128,5 +128,5 @@ describe('Surge', function() { const proxy = parser.parse(input.Surge); expect(proxy).eql(expected); }); - }) -}); \ No newline at end of file + }); +}); diff --git a/backend/test/proxy-parsers/testcases.js b/backend/src/test/proxy-parsers/testcases.js similarity index 73% rename from backend/test/proxy-parsers/testcases.js rename to backend/src/test/proxy-parsers/testcases.js index 3ec0ee8..b2aa24f 100644 --- a/backend/test/proxy-parsers/testcases.js +++ b/backend/src/test/proxy-parsers/testcases.js @@ -29,7 +29,11 @@ function createTestCases() { }, expected: { type: 'ss', - name, server, port, cipher, password, + name, + server, + port, + cipher, + password, }, }, OBFS_TLS: { @@ -40,7 +44,11 @@ function createTestCases() { }, expected: { type: 'ss', - name, server, port, cipher, password, + name, + server, + port, + cipher, + password, plugin: 'obfs', 'plugin-opts': { mode: 'tls', @@ -57,7 +65,11 @@ function createTestCases() { }, expected: { type: 'ss', - name, server, port, cipher, password, + name, + server, + port, + cipher, + password, plugin: 'obfs', 'plugin-opts': { mode: 'http', @@ -72,7 +84,11 @@ function createTestCases() { }, expected: { type: 'ss', - name, server, port, cipher, password, + name, + server, + port, + cipher, + password, plugin: 'v2ray-plugin', 'plugin-opts': { mode: 'websocket', @@ -87,7 +103,11 @@ function createTestCases() { }, expected: { type: 'ss', - name, server, port, cipher, password, + name, + server, + port, + cipher, + password, plugin: 'v2ray-plugin', 'plugin-opts': { mode: 'websocket', @@ -106,7 +126,11 @@ function createTestCases() { }, expected: { type: 'ssr', - name, server, port, cipher, password, + name, + server, + port, + cipher, + password, obfs: ssr_obfs, protocol: ssr_protocol, 'obfs-param': ssr_obfs_param, @@ -123,7 +147,10 @@ function createTestCases() { }, expected: { type: 'trojan', - name, server, port, password, + name, + server, + port, + password, }, }, WS: { @@ -134,16 +161,18 @@ function createTestCases() { }, expected: { type: 'trojan', - name, server, port, password, + name, + server, + port, + password, network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, - } - , + }, }, WSS: { input: { @@ -153,13 +182,16 @@ function createTestCases() { }, expected: { type: 'trojan', - name, server, port, password, + name, + server, + port, + password, network: 'ws', tls: true, 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, 'skip-cert-verify': true, @@ -177,15 +209,26 @@ function createTestCases() { expected: { QX: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, }, Loon: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, }, Surge: { type: 'vmess', - name, server, port, uuid, // Surge lacks support for specifying cipher for vmess protocol! + name, + server, + port, + uuid, // Surge lacks support for specifying cipher for vmess protocol! }, }, }, @@ -198,15 +241,28 @@ function createTestCases() { expected: { QX: { type: 'vmess', - name, server, port, uuid, cipher, alterId: 0, + name, + server, + port, + uuid, + cipher, + alterId: 0, }, Loon: { type: 'vmess', - name, server, port, uuid, cipher, alterId: 0, + name, + server, + port, + uuid, + cipher, + alterId: 0, }, Surge: { type: 'vmess', - name, server, port, uuid, // Surge lacks support for specifying cipher for vmess protocol! + name, + server, + port, + uuid, // Surge lacks support for specifying cipher for vmess protocol! alterId: 0, }, }, @@ -220,34 +276,45 @@ function createTestCases() { expected: { QX: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, }, Loon: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, }, Surge: { type: 'vmess', - name, server, port, uuid, // Surge lacks support for specifying cipher for vmess protocol! + name, + server, + port, + uuid, // Surge lacks support for specifying cipher for vmess protocol! network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, }, @@ -262,12 +329,16 @@ function createTestCases() { expected: { QX: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, tls: true, @@ -276,12 +347,16 @@ function createTestCases() { }, Loon: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, tls: true, @@ -290,12 +365,15 @@ function createTestCases() { }, Surge: { type: 'vmess', - name, server, port, uuid, // Surge lacks support for specifying cipher for vmess protocol! + name, + server, + port, + uuid, // Surge lacks support for specifying cipher for vmess protocol! network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, tls: true, @@ -312,23 +390,31 @@ function createTestCases() { expected: { QX: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, network: 'http', 'http-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, }, Loon: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, network: 'http', 'http-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, }, @@ -341,12 +427,16 @@ function createTestCases() { expected: { Loon: { type: 'vmess', - name, server, port, uuid, cipher, + name, + server, + port, + uuid, + cipher, network: 'http', 'http-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, tls: true, @@ -364,7 +454,10 @@ function createTestCases() { expected: { Loon: { type: 'vless', - name, server, port, uuid, + name, + server, + port, + uuid, }, }, }, @@ -373,19 +466,20 @@ function createTestCases() { Loon: `${name}=vless,${server},${port},"${uuid}",transport=ws,host=${obfs_host},path=${obfs_path}`, }, expected: { - Loon: { type: 'vless', - name, server, port, uuid, + name, + server, + port, + uuid, network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, }, - }, }, WSS: { @@ -393,22 +487,23 @@ function createTestCases() { Loon: `${name}=vless,${server},${port},"${uuid}",transport=ws,host=${obfs_host},path=${obfs_path},over-tls=true,tls-name=${sni},skip-cert-verify=true`, }, expected: { - Loon: { type: 'vless', - name, server, port, uuid, + name, + server, + port, + uuid, network: 'ws', 'ws-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, tls: true, 'skip-cert-verify': true, sni, }, - }, }, HTTP: { @@ -416,15 +511,17 @@ function createTestCases() { Loon: `${name}=vless,${server},${port},"${uuid}",transport=http,host=${obfs_host},path=${obfs_path}`, }, expected: { - Loon: { type: 'vless', - name, server, port, uuid, + name, + server, + port, + uuid, network: 'http', 'http-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, }, @@ -437,12 +534,15 @@ function createTestCases() { expected: { Loon: { type: 'vless', - name, server, port, uuid, + name, + server, + port, + uuid, network: 'http', 'http-opts': { path: obfs_path, - 'headers': { - 'Host': obfs_host, + headers: { + Host: obfs_host, }, }, tls: true, @@ -461,8 +561,10 @@ function createTestCases() { }, expected: { type: 'http', - name, server, port, - } + name, + server, + port, + }, }, AUTH: { input: { @@ -472,8 +574,12 @@ function createTestCases() { }, expected: { type: 'http', - name, server, port, username, password - } + name, + server, + port, + username, + password, + }, }, TLS: { input: { @@ -483,12 +589,16 @@ function createTestCases() { }, expected: { type: 'http', - name, server, port, username, password, + name, + server, + port, + username, + password, sni, 'skip-cert-verify': true, - tls: true - } - } + tls: true, + }, + }, }; const SOCKS5 = { SIMPLE: { @@ -498,8 +608,10 @@ function createTestCases() { }, expected: { type: 'socks5', - name, server, port, - } + name, + server, + port, + }, }, AUTH: { input: { @@ -508,8 +620,12 @@ function createTestCases() { }, expected: { type: 'socks5', - name, server, port, username, password - } + name, + server, + port, + username, + password, + }, }, TLS: { input: { @@ -518,12 +634,16 @@ function createTestCases() { }, expected: { type: 'socks5', - name, server, port, username, password, + name, + server, + port, + username, + password, sni, 'skip-cert-verify': true, - tls: true - } - } + tls: true, + }, + }, }; const SNELL = { SIMPLE: { @@ -532,8 +652,12 @@ function createTestCases() { }, expected: { type: 'snell', - name, server, port, psk: password, version: 3 - } + name, + server, + port, + psk: password, + version: 3, + }, }, OBFS_HTTP: { input: { @@ -541,13 +665,17 @@ function createTestCases() { }, expected: { type: 'snell', - name, server, port, psk: password, version: 3, + name, + server, + port, + psk: password, + version: 3, 'obfs-opts': { mode: 'http', host: obfs_host, path: obfs_path, - } - } + }, + }, }, OBFS_TLS: { input: { @@ -555,18 +683,29 @@ function createTestCases() { }, expected: { type: 'snell', - name, server, port, psk: password, version: 3, + name, + server, + port, + psk: password, + version: 3, 'obfs-opts': { mode: 'tls', host: obfs_host, path: obfs_path, - } - } + }, + }, }, }; return { - SS, SSR, VMESS, VLESS, TROJAN, HTTP, SOCKS5, SNELL, + SS, + SSR, + VMESS, + VLESS, + TROJAN, + HTTP, + SOCKS5, + SNELL, }; } -export default createTestCases(); \ No newline at end of file +export default createTestCases(); diff --git a/backend/src/utils/download.js b/backend/src/utils/download.js index ec1699b..8373270 100644 --- a/backend/src/utils/download.js +++ b/backend/src/utils/download.js @@ -1,4 +1,4 @@ -import { HTTP } from '../vendor/open-api'; +import { HTTP } from '@/vendor/open-api'; const cache = new Map(); diff --git a/backend/src/utils/gist.js b/backend/src/utils/gist.js index 8726560..476e1c0 100644 --- a/backend/src/utils/gist.js +++ b/backend/src/utils/gist.js @@ -1,4 +1,4 @@ -import { HTTP } from '../vendor/open-api'; +import { HTTP } from '@/vendor/open-api'; /** * Gist backup diff --git a/backend/sub-store.min.js b/backend/sub-store.min.js index 400349a..80de904 100644 --- a/backend/sub-store.min.js +++ b/backend/sub-store.min.js @@ -6,8 +6,8 @@ * ███████║╚██████╔╝██████╔╝ ███████║ ██║ ╚██████╔╝██║ ██║███████╗ * ╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ * Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket! - * @updated: 2022/6/16 12:57:15 - * @version: 2.0 + * @updated: 2022/6/16 14:23:56 + * @version: 2.0.1 * @author: Peng-YM * @github: https://github.com/Peng-YM/Sub-Store * @documentation: https://www.notion.so/Sub-Store-6259586994d34c11a4ced5c406264b46