Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问是否可以实现在 clash 格式的输出中添加 script 段? #809

Open
3 tasks done
Se7enMuting opened this issue Dec 23, 2024 · 0 comments
Open
3 tasks done

Comments

@Se7enMuting
Copy link

Se7enMuting commented Dec 23, 2024

verify

  • 我已经仔细阅读项目文档,确认现有功能无法解决我的需求
  • 我已经检索过现有issue,确认与现有issue的内容并不重复
  • 我已经尝试自行解决,确认自己没有能力解决

功能描述

我是通过配置文件的方式调用的:https://127.0.0.1:25500/getprofile?name=profiles/xxx.ini&token=passwd
所以我的所有配置在两个文件中,配置文件: xxx.ini (target=clash) 和 外部配置: (config=) yyy.ini
我想在我最终我生成的输出文件中加上类似如下的 script 段:

script:
  shortcuts:
    QTS-464C: src_port in [51413,51414,51415,23267,23277,51423,60654,33496,33396]
  code: |
    def main(ctx,metadata):
        port = int(metadata['dst_port'])
        if metadata['network'] == 'UDP' and port == 443:
            ctx.log('[Script] matched QUIC traffic use reject')
            return 'REJECT'
        port_list = [21,22,23,53,80,123,143,194,443,465,587,853,993,995,998,2052,2053,2082,2083,2086,2095,2096,3389,5222,5228,5229,5230,8080,8443,8880,8888,8889]
        if port not in port_list:
            ctx.log('[Script] not common port use direct')
            return 'DIRECT'
        if metadata['dst_ip'] == '':
            metadata['dst_ip'] = ctx.resolve_ip(metadata['host'])
        if metadata['dst_ip'] != '':
            code = ctx.geoip(metadata['dst_ip'])
            if code == 'CN':
                ctx.log('[Script] Geoip CN')
                return '🎯 大陆直连'
        ctx.log('[Script] FINAL')
        return '🐟 漏网之鱼'

有shortcuts段的话,还要加上对应的rules

rules:
- SCRIPT,QTS-464C,DIRECT

subconverter 目前有办法实现吗?还是需要自己二次修改拼接文件啊。。。。

可能的解决方案

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant