Skip to content

Commit

Permalink
remove sing-box subscription support
Browse files Browse the repository at this point in the history
notes: you can use sing-box-yaott or qjebbs[may not be stable yet]
  • Loading branch information
renovate[bot] committed Aug 30, 2023
1 parent b207242 commit 92ddd8d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 70 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get tags
id: get_tags
Expand Down Expand Up @@ -52,6 +54,8 @@ jobs:
needs: [build]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get tags
id: get_tags
Expand Down
2 changes: 1 addition & 1 deletion box/scripts/box.service
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ box_run_crontab() {
echo "${interva_update} ${scripts_dir}/box.tool geosub" >> "${box_run}/root"
log Debug "Interval crontab geox and subs: ${interva_update}."
log Info "${bin_name} geox updates: ${update_geo}."
if [[ "${bin_name}" == @(clash|sing-box) ]]; then
if [ "${bin_name}" = "clash" ]; then
log Info "${bin_name} subscription update: ${update_subscription}."
fi
else
Expand Down
61 changes: 1 addition & 60 deletions box/scripts/box.tool
Original file line number Diff line number Diff line change
Expand Up @@ -186,66 +186,7 @@ update_subs() {
return 1
fi
;;
"sing-box")
if [ -n "${subscription_url_sing}" ]; then
# subscription sing-box
if [ "${update_subscription}" = "true" ]; then
log Info "daily updates subs"
log Debug "Downloading ${update_file_name}"
if update_file "${update_file_name}" "${subscription_url_sing}"; then
log Info "${update_file_name} saved"
if [ "${enhanced}" = "true" ]; then
if "${yq_cmd}" -e . "${update_file_name}" >/dev/null 2>&1; then
cp "${update_file_name}" "${sing_provide_config}"
if [ -f "${update_file_name}.bak" ]; then
rm "${update_file_name}.bak"
fi

# script to edit sing-box subscriptions
# removed the structure: inbounds/experimental/route/log and dns
"${yq_cmd}" 'del(.inbounds, .experimental, .route, .log, .dns)' -i --output-format=json "${sing_provide_config}"

# remove outbound with type: direct/block/dns/selector/urltest
"${yq_cmd}" 'del(.outbounds[] | select(.type == "direct" or .type == "block" or .type == "dns" or .type == "selector" or .type == "urltest"))' -i --output-format=json "${sing_provide_config}"

# create new outbounds with type: selector, tag: singbox in ${sing_provide_config}
"${yq_cmd}" '.outbounds += [{"tag": "b0x", "type": "selector", "outbounds": [.outbounds[].tag]}]' -i --output-format=json "${sing_provide_config}"

# create new outbounds with type: urltest, tag: b0x[urltest] in ${sing_provide_config}
"${yq_cmd}" '.outbounds += [{"tag": "b0x[urltest]", "type": "urltest", "url": "https://www.gstatic.com/generate_204", "interval": "3m", "outbounds": [.outbounds[].tag]}]' -i --output-format=json "${sing_provide_config}"

# renew outbounds with tag: singbox in main ${sing_config} dan ${sing_provide_config}
"${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "b0x"))' -i --output-format=json "${sing_provide_config}"
"${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "b0x"))' -i --output-format=json "${sing_config}"
"${yq_cmd}" '.outbounds[0].outbounds += ["b0x"]' -i --output-format=json "${sing_config}"

# renew outbounds with tag: b0x[urltest] in main ${sing_config} dan ${sing_provide_config}
"${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "b0x[urltest]"))' -i --output-format=json "${sing_provide_config}"
"${yq_cmd}" 'del(.outbounds[].outbounds[] | select(. == "b0x[urltest]"))' -i --output-format=json "${sing_config}"
"${yq_cmd}" '.outbounds[0].outbounds += ["b0x[urltest]"]' -i --output-format=json "${sing_config}"

log Info "subscription success"
log Info "Update subscription $(date +"%F %R")"
else
log Error "update subscription failed"
log Error "${update_file_name} error"
return 1
fi
fi
return 0
else
log Error "update subscription failed"
return 1
fi
else
return 1
fi
else
log Warning "${bin_name} subscription url is empty..."
return 1
fi
;;
"xray" | "v2fly")
"xray"|"v2fly"|"sing-box")
log Warning "${bin_name} does not support subscriptions.."
return 1
;;
Expand Down
11 changes: 3 additions & 8 deletions box/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ run_crontab="false"

# type "su -c /data/adb/box/scripts/box.tool geox" to update geox
update_geo="true"

# if "true" it will update config. *.yaml not subscription configuration
renew=false
# type "su -c /data/adb/box/scripts/box.tool subs" to update subscription
update_subscription="false"

renew=false # if "true" it will update config. *.yaml or *.json not subscription configuration

# ex: clash subscription url
subscription_url_clash=""
# ex: sing-box subscription url
subscription_url_sing=""

# clash configuration
name_clash_config="config.yaml"
Expand All @@ -102,9 +100,6 @@ clash_provide_rules="${box_dir}/clash/provide/${name_provide_clash_rules}"
# sing configuration
name_sing_config="config.json"
sing_config="${box_dir}/sing-box/${name_sing_config}"
# sing subscription
name_provide_sing_config="subscription.json"
sing_provide_config="${box_dir}/sing-box/${name_provide_sing_config}"

normal="\033[0m"
orange="\033[1;38;5;208m"
Expand Down
2 changes: 1 addition & 1 deletion docs/tubot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{version}
[Commit](https://github.com/shioeri/sing-box/commits/dev-next):
[Commit](https://github.com/taamarin/box_for_magisk/commits/master):
```
{cg}
```
Expand Down

0 comments on commit 92ddd8d

Please sign in to comment.