#!/bin/sh
SINGBOX_URL='https://www.yfjc.xyz/api/v1/client/subscribe?token=0a4261357c4f7d9cdb4610b83438ae25&flag=sing-box'
# 获取本地覆盖配置
MERGECONF=$(cat './overwrite.json')
# 获取订阅并处理
# 1. del(.inbounds) 删除入站
# 2. dns.servers、outbounds 处理
# 3. 与 MERGECONF 合并
# 4. jq --argjson 传入变量更安全
curl -s "$SINGBOX_URL" | jq -M --argjson m "$MERGECONF" '
del(.inbounds) |
.dns.servers |= map(. + { "strategy": "ipv4_only" }) |
.outbounds |= map(if .type == "hysteria2" then . + {"domain_strategy": "ipv4_only"} else . end) |
. * $m
'
{
"inbounds": [
{
"domain_strategy": "prefer_ipv4",
"listen": "0.0.0.0",
"listen_port": 2333,
"sniff": true,
"sniff_override_destination": true,
"tag": "socks-in",
"type": "socks",
"users": []
},
{
"domain_strategy": "prefer_ipv4",
"listen": "0.0.0.0",
"listen_port": 2334,
"sniff": true,
"sniff_override_destination": true,
"tag": "mixed-in",
"type": "mixed",
"users": []
}
]
}
{
"out":"json"
}