Toperlock / sing-box-subscribe

https://sing-box-subscribe-doraemon.vercel.app
1.92k stars 1.99k forks source link

能做个本地分流模版么,就是把远程的srs文件下载到本地读取。 #91

Closed star8618 closed 2 months ago

star8618 commented 3 months ago

描述

"route": { "auto_detect_interface": true, "final": "Proxy", "rules": [ { "type": "logical", "mode": "or", "rules": [ { "port": 53 }, { "protocol": "dns" } ], "outbound": "dns-out" }, { "rule_set": "geosite-category-ads-all", "outbound": "AdBlock" }, { "clash_mode": "direct", "outbound": "direct" }, { "clash_mode": "global", "outbound": "Proxy" }, { "domain": [ "clash.razord.top", "yacd.metacubex.one", "yacd.haishan.me", "d.metacubex.one" ], "outbound": "direct" }, { "rule_set": "geosite-openai", "outbound": "OpenAI" }, { "rule_set": [ "geosite-youtube", "geoip-google", "geosite-google", "geosite-github" ], "outbound": "Google" }, { "rule_set": [ "geoip-telegram", "geosite-telegram" ], "outbound": "Telegram" }, { "rule_set": [ "geoip-twitter", "geosite-twitter" ], "outbound": "Twitter" }, { "rule_set": [ "geoip-facebook", "geosite-facebook" ], "outbound": "Facebook" }, { "rule_set": [ "geoip-bilibili", "geosite-bilibili" ], "outbound": "BiliBili" }, { "rule_set": "geosite-bahamut", "outbound": "Bahamut" }, { "rule_set": "geosite-spotify", "outbound": "Spotify" }, { "rule_set": "geosite-tiktok", "outbound": "TikTok" }, { "rule_set": [ "geoip-netflix", "geosite-netflix" ], "outbound": "NETFLIX" }, { "rule_set": "geosite-disney", "outbound": "Disney+" }, { "rule_set": [ "geoip-apple", "geosite-apple", "geosite-amazon" ], "outbound": "Apple" }, { "rule_set": "geosite-microsoft", "outbound": "Microsoft" }, { "rule_set": "geosite-category-games", "outbound": "Games" }, { "rule_set": [ "geosite-hbo", "geosite-primevideo" ], "outbound": "Streaming" }, { "rule_set": "geosite-geolocation-!cn", "outbound": "Global" }, { "rule_set": "geosite-private", "outbound": "direct" }, { "ip_is_private": true, "outbound": "direct" }, { "rule_set": [ "geoip-cn", "geosite-cn" ], "outbound": "China" } ], "rule_set": [ { "tag": "geoip-google", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geoip/google.srs" }, { "tag": "geoip-telegram", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geoip/telegram.srs" }, { "tag": "geoip-twitter", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geoip/twitter.srs" }, { "tag": "geoip-facebook", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geoip/facebook.srs" }, { "tag": "geoip-netflix", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geoip/netflix.srs" }, { "tag": "geoip-apple", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geoip/apple.srs" }, { "tag": "geoip-bilibili", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geoip/bilibili.srs" }, { "tag": "geoip-cn", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geoip/cn.srs" }, { "tag": "geosite-private", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/private.srs" }, { "tag": "geosite-openai", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/openai.srs" }, { "tag": "geosite-youtube", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/youtube.srs" }, { "tag": "geosite-google", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/google.srs" }, { "tag": "geosite-github", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/github.srs" }, { "tag": "geosite-telegram", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/telegram.srs" }, { "tag": "geosite-twitter", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/twitter.srs" }, { "tag": "geosite-facebook", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/facebook.srs" }, { "tag": "geosite-bilibili", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/bilibili.srs" }, { "tag": "geosite-bahamut", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/bahamut.srs" }, { "tag": "geosite-spotify", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/spotify.srs" }, { "tag": "geosite-tiktok", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/tiktok.srs" }, { "tag": "geosite-netflix", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/netflix.srs" }, { "tag": "geosite-disney", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/disney.srs" }, { "tag": "geosite-apple", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/apple.srs" }, { "tag": "geosite-amazon", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/amazon.srs" }, { "tag": "geosite-microsoft", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/microsoft.srs" }, { "tag": "geosite-category-games", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/category-games.srs" }, { "tag": "geosite-hbo", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/hbo.srs" }, { "tag": "geosite-primevideo", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/primevideo.srs" }, { "tag": "geosite-geolocation-!cn", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/geolocation-!cn.srs" }, { "tag": "geosite-category-ads-all", "type": "local", "format": "binary", "path": "/etc/sing-box/srs/category-ads-all.srs" } ]

这样操作无法启动。是哪里不对么?

up.sh

!/bin/bash

规则文件的下载链接和保存路径

declare -A RULES RULES=( ["geoip-google"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/google.srs" ["geoip-telegram"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/telegram.srs" ["geoip-twitter"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/twitter.srs" ["geoip-facebook"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/facebook.srs" ["geoip-netflix"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/netflix.srs" ["geoip-apple"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/apple.srs" ["geoip-bilibili"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/bilibili.srs" ["geoip-cn"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geoip/cn.srs" ["geosite-private"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/private.srs" ["geosite-openai"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/openai.srs" ["geosite-youtube"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/youtube.srs" ["geosite-google"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/google.srs" ["geosite-github"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/github.srs" ["geosite-telegram"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/telegram.srs" ["geosite-twitter"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/twitter.srs" ["geosite-facebook"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/facebook.srs" ["geosite-bilibili"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/bilibili.srs" ["geosite-bahamut"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/bahamut.srs" ["geosite-spotify"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/spotify.srs" ["geosite-tiktok"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/tiktok.srs" ["geosite-netflix"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/netflix.srs" ["geosite-disney"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/disney.srs" ["geosite-apple"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/apple.srs" ["geosite-amazon"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/amazon.srs" ["geosite-microsoft"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/microsoft.srs" ["geosite-category-games"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/category-games.srs" ["geosite-hbo"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/hbo.srs" ["geosite-primevideo"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/primevideo.srs" ["geosite-geolocation-!cn"]="https://testingcf.jsdelivr.net/gh/MetaCubeX/meta-rules-dat@sing/geo/geosite/geolocation-!cn.srs" )

更新目录

RULES_DIR="/etc/sing-box/srs"

确保目录存在

mkdir -p "$RULES_DIR"

下载文件

for FILE in "${!RULES[@]}"; do URL="${RULES[$FILE]}" DEST="$RULES_DIR/$FILE.srs" echo "Downloading $URL to $DEST" wget -q -O "$DEST" "$URL" done

完整性要求

Toperlock commented 3 months ago

请查看singbox日志来排查