mihomo-party-org / mihomo-party

:electron: Another Mihomo GUI.
https://mihomo.party
GNU General Public License v3.0
6.62k stars 379 forks source link

[Bug] 复写逻辑优化 #82

Closed Ma-yeah closed 3 months ago

Ma-yeah commented 3 months ago

Verify steps

操作系统

Linux

系统版本

deepin v23

发生问题 mihomo-party 版本

v1.0.3

描述

我创建了一个 js 复写文件,内容如下:

function main(config){

    // 代理组
    config["proxy-groups"] = [
        {
            name: "自动",
            icon: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/Orz-3/mini/master/Color/Urltest.png",
            "include-all": true,
            "exclude-filter":
                "(?i)GB|Traffic|Expire|Premium|频道|订阅|ISP|流量|到期|重置|.com|.club|.top|.ink",
            type: "url-test",
            interval: 300,
            lazy: true,
        },
        {
            name: "兜底",
            icon: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/Orz-3/mini/master/Color/Static.png",
            type: "select",
            proxies: ["自动", "DIRECT"],
        },
        {
            name: "香港",
            icon: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/Orz-3/mini/master/Color/HK.png",
            "include-all": true,
            filter: "香港|🇭🇰|HK|(?i)Hong Kong",
            type: "url-test",
            interval: 300,
            lazy: true,
        },
        {
            name: "新加坡",
            icon: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/Orz-3/mini/master/Color/SG.png",
            "include-all": true,
            filter: "新加坡|🇸🇬|新国|SG|(?i)Singapore",
            type: "url-test",
            interval: 300,
            lazy: true,
        },
        {
            name: "日本",
            icon: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/Orz-3/mini/master/Color/JP.png",
            "include-all": true,
            filter: "日本|🇯🇵|东京|JP|(?i)Japan",
            type: "url-test",
            interval: 300,
            lazy: true,
        },
        {
            name: "美国",
            icon: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/Orz-3/mini/master/Color/US.png",
            "include-all": true,
            filter: "美国|🇺🇸|US|(?i)United states",
            type: "url-test",
            interval: 300,
            lazy: true,
        },
    ];

    if (!config['rule-providers']) {
        config['rule-providers'] = {};
    }

    config["rule-providers"] = Object.assign(config["rule-providers"], {
        private: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/private.yaml",
            path: "./ruleset/private.yaml",
            behavior: "domain",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        cn_domain: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/cn.yaml",
            path: "./ruleset/cn_domain.yaml",
            behavior: "domain",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        telegram_domain: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/telegram.yaml",
            path: "./ruleset/telegram_domain.yaml",
            behavior: "domain",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        google_domain: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/google.yaml",
            path: "./ruleset/google_domain.yaml",
            behavior: "domain",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        "geolocation-!cn": {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geosite/geolocation-!cn.yaml",
            path: "./ruleset/geolocation-!cn.yaml",
            behavior: "domain",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        cn_ip: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/cn.yaml",
            path: "./ruleset/cn_ip.yaml",
            behavior: "ipcidr",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        telegram_ip: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/telegram.yaml",
            path: "./ruleset/telegram_ip.yaml",
            behavior: "ipcidr",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        google_ip: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/MetaCubeX/meta-rules-dat/meta/geo/geoip/google.yaml",
            path: "./ruleset/google_ip.yaml",
            behavior: "ipcidr",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        bing: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Bing/Bing.yaml",
            path: "./ruleset/bing.yaml",
            behavior: "classical",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        copilot: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Copilot/Copilot.yaml",
            path: "./ruleset/copilot.yaml",
            behavior: "classical",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        claude: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Claude/Claude.yaml",
            path: "./ruleset/claude.yaml",
            behavior: "classical",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        bard: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/BardAI/BardAI.yaml",
            path: "./ruleset/bard.yaml",
            behavior: "classical",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        openai: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/OpenAI/OpenAI.yaml",
            path: "./ruleset/openai.yaml",
            behavior: "classical",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
        steam: {
            url: "https://mirror.ghproxy.com/https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/Steam/Steam.yaml",
            path: "./ruleset/steam.yaml",
            behavior: "classical",
            interval: 86400,
            format: "yaml",
            type: "http",
        },
    });

    config["rules"] = [
        "RULE-SET,private,DIRECT",
        "RULE-SET,bing,美国",
        "RULE-SET,copilot,美国",
        "RULE-SET,bard,美国",
        "RULE-SET,openai,美国",
        "RULE-SET,claude,美国",
        "RULE-SET,steam,美国",
        "RULE-SET,telegram_domain,自动",
        "RULE-SET,telegram_ip,自动",
        "RULE-SET,google_domain,自动",
        "RULE-SET,google_ip,自动",
        "RULE-SET,geolocation-!cn,自动",
        "RULE-SET,cn_domain,DIRECT",
        "RULE-SET,cn_ip,DIRECT",
        "MATCH,自动",
    ];

    // 本地规则优先
    const rules_local = [
        'DOMAIN-SUFFIX,deepin.org,DIRECT',
        'DOMAIN-SUFFIX,deepin.com,DIRECT'
    ];
    rules_local.forEach(item => config.rules.unshift(item));

    return config;
}

如上述所示,我定义了美国香港日本新加坡几个代理组。 有两个订阅链接,订阅 A 只提供了 香港、美国 节点,订阅 B 只提供了 日本节点,当把复写分别应用到 A、B 两个订阅上时,由于订阅 A 未提供 日本、新加坡 节点,则会提示 "use or proxies missing",此时删掉不存在节点的代理组就正常了。 期望是不要有这个判断,如果代理组下面不存在节点,也正常显示出这个组,只是组下无节点。

截图

重现方式

如描述所示

pompurin404 commented 3 months ago

使用预览版内核