Skip to content

Commit

Permalink
feat: 增加 _subDisplayName _collectionDisplayName
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Sep 18, 2024
1 parent 6e425e5 commit 5d09fe7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.384",
"version": "2.14.385",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
4 changes: 1 addition & 3 deletions backend/src/core/proxy-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ function produce(proxies, targetPlatform, type, opts = {}) {
);

proxies = proxies.map((proxy) => {
proxy._subName = proxy.subName;
proxy._collectionName = proxy.collectionName;
proxy._resolved = proxy.resolved;

if (!isNotBlank(proxy.name)) {
Expand Down Expand Up @@ -268,7 +266,7 @@ function produce(proxies, targetPlatform, type, opts = {}) {
proxies.length > 0 &&
proxies.every((p) => p.type === 'wireguard')
) {
list = `#!name=${proxies[0]?.subName}
list = `#!name=${proxies[0]?._subName}
#!desc=${proxies[0]?._desc ?? ''}
#!category=${proxies[0]?._category ?? ''}
${list}`;
Expand Down
4 changes: 4 additions & 0 deletions backend/src/restful/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ async function compareSub(req, res) {
original.forEach((proxy, i) => {
proxy.id = i;
proxy._subName = sub.name;
proxy._subDisplayName = sub.displayName;
});

// apply processors
Expand Down Expand Up @@ -238,7 +239,9 @@ async function compareCollection(req, res) {

currentProxies.forEach((proxy) => {
proxy._subName = sub.name;
proxy._subDisplayName = sub.displayName;
proxy._collectionName = collection.name;
proxy._collectionDisplayName = collection.displayName;
});

// apply processors
Expand Down Expand Up @@ -277,6 +280,7 @@ async function compareCollection(req, res) {
original.forEach((proxy, i) => {
proxy.id = i;
proxy._collectionName = collection.name;
proxy._collectionDisplayName = collection.displayName;
});

const processed = await ProxyUtils.process(
Expand Down
5 changes: 5 additions & 0 deletions backend/src/restful/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ async function produceArtifact({

proxies.forEach((proxy) => {
proxy._subName = sub.name;
proxy._subDisplayName = sub.displayName;
});
// apply processors
proxies = await ProxyUtils.process(
Expand Down Expand Up @@ -253,7 +254,9 @@ async function produceArtifact({

currentProxies.forEach((proxy) => {
proxy._subName = sub.name;
proxy._subDisplayName = sub.displayName;
proxy._collectionName = collection.name;
proxy._collectionDisplayName = collection.displayName;
});

// apply processors
Expand Down Expand Up @@ -310,6 +313,7 @@ async function produceArtifact({

proxies.forEach((proxy) => {
proxy._collectionName = collection.name;
proxy._collectionDisplayName = collection.displayName;
});

// apply own processors
Expand Down Expand Up @@ -340,6 +344,7 @@ async function produceArtifact({
}
exist[proxy.name] = true;
}
console.log(proxies);
return ProxyUtils.produce(proxies, platform, produceType, produceOpts);
} else if (type === 'rule') {
const allRules = $.read(RULES_KEY);
Expand Down
6 changes: 3 additions & 3 deletions scripts/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function operator(proxies = [], targetPlatform, context) {
// 2. 域名解析后 会多一个 `_resolved` 字段, 表示是否解析成功
// 3. 域名解析后会有`_IPv4`, `_IPv6`, `_IP`(若有多个步骤, 只取第一次成功的 v4 或 v6 数据), `_IP4P`(若解析类型为 IPv6 且符合 IP4P 类型, 将自动转换), `_domain` 字段, `_resolved_ips` 为解析出的所有 IP
// 4. 节点字段 `exec` 为 `ssr-local` 路径, 默认 `/usr/local/bin/ssr-local`; 端口从 10000 开始递增(暂不支持配置)
// 5. `_subName` 为单条订阅名
// 6. `_collectionName` 为组合订阅名
// 5. `_subName` 为单条订阅名, `_subDisplayName` 为单条订阅显示名
// 6. `_collectionName` 为组合订阅名, `_collectionDisplayName` 为组合订阅显示名
// 7. `tls-fingerprint` 为 tls 指纹
// 8. `underlying-proxy` 为前置代理
// 9. `trojan`, `tuic`, `hysteria`, `hysteria2`, `juicity` 会在解析时设置 `tls`: true (会使用 tls 类协议的通用逻辑), 输出时删除
Expand Down Expand Up @@ -152,7 +152,7 @@ function operator(proxies = [], targetPlatform, context) {
// 1. https://t.me/zhetengsha/948

// context 为传入的上下文
// 其中 source 为 订阅和组合订阅的数据, 有三种情况, 按需判断 (若只需要取订阅/组合订阅名称 直接用 `_subName` `_collectionName` 即可)
// 其中 source 为 订阅和组合订阅的数据, 有三种情况, 按需判断 (若只需要取订阅/组合订阅名称 直接用 `_subName` `_subDisplayName` `_collectionName` `_collectionDisplayName` 即可)

// 若存在 `source._collection` 且 `source._collection.subscriptions` 中的 key 在 `source` 上也存在, 说明输出结果为组合订阅, 但是脚本设置在单条订阅上

Expand Down

0 comments on commit 5d09fe7

Please sign in to comment.