juewuy / ShellCrash

Run sing-box/mihomo as client in shell
8.89k stars 1.48k forks source link

[Feature]我不太懂,问的不合适,请别介意。 请问,如何进行用户的流量控制? #798

Closed aomidata closed 3 days ago

aomidata commented 2 weeks ago

Verify steps

Description

我想在手机端的app增加用户的流量控制,确保我的两个用户(实际上就是我2个儿子),流量是可控的,避免它们玩物丧志。请问,该怎么配置?

juewuy commented 2 weeks ago

@aomidata clash或者singbox并不是为流控而生的应用,你最多只能手动/定时切断其网络

bsdcpp commented 2 weeks ago

Verify steps

  • [x] 我已经在 Issue Tracker 中找过我要提出的问题 I have searched on the issue tracker for a related issue.
  • [x] 我已经使用公测版本测试过,问题依旧存在 I have tested using the test mod, and the issue still exists.
  • [x] 我已经仔细看过 常见问题 并无法自行解决问题

Description

我想在手机端的app增加用户的流量控制,确保我的两个用户(实际上就是我2个儿子),流量是可控的,避免它们玩物丧志。请问,该怎么配置?

我做过一些简单的尝试,在rules:指定某些ip(路由器配静态ip)走sub-rule,例如: 在自己的config里加入

proxy-groups:
 - name: "🎮 行为管控"
    type: select
    proxies:
      - DIRECT
      - REJECT
      - PASS

rules:
 - ...
 - SUB-RULE,(OR,((SRC-IP-CIDR,192.168.2.5/32),(SRC-IP-CIDR,192.168.2.6/32))),Behavior-rule
 -  ...

rule-providers:
    ChinaMedia:
    type: http
    behavior: classical
    path: ./rule_provider/ChinaMedia
    url: https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/ChinaMedia/ChinaMedia_No_Resolve.yaml
    interval: 86400
  GlobalMedia:
    type: http
    behavior: classical
    path: ./rule_provider/GlobalMedia
    url: https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/GlobalMedia/GlobalMedia_Classical_No_Resolve.yaml
    interval: 86400
  Behavior: # 自定义上网管控IP
    type: http
    behavior: classical
    path: ./rule_provider/Behavior
    url: url_to_Behavior
    interval: 86400

在sc的yamls/others.yaml里添加:

sub-rules:
  Behavior-rule:
    - RULE-SET,Behavior,🎮 行为管控 #自定义漏网之鱼
    - RULE-SET,ChinaMedia,🎮 行为管控
    - RULE-SET,GlobalMedia,🎮 行为管控
    - MATCH,PASS

在url_to_Behavior里加ip/域名,比较粗略。很多可以参考这里收集的规则集https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash 还可以添加一些比如Game规则

如果要做定时,去web页面抓包切换的api,放到crontab里执行就ok了,放入脚本,执行就是自动REJECT