Skip to content

Commit

Permalink
Refined box.services: box run
Browse files Browse the repository at this point in the history
- adjust xray/v2fly port sync
- update example config and add format .yaml
  • Loading branch information
twnesss committed Nov 16, 2024
1 parent 61896b8 commit d3b7d6e
Show file tree
Hide file tree
Showing 3 changed files with 398 additions and 288 deletions.
33 changes: 20 additions & 13 deletions box/scripts/box.service
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,20 @@ box_run_bin() {
fi

# sync port
# sed -i "s/port = [0-9]*\.[0-9]*/port = ${tproxy_port}.0/" ${box_dir}/$bin_name/config.toml
${box_dir}/bin/yq '(.inbounds[] | select(.protocol == "dokodemo-door") | .port) = '"${tproxy_port}" -i --output-format=json "${box_dir}/${bin_name}/config.json"
${box_dir}/bin/yq '(.inbounds[] | select(.protocol == "dokodemo-door") | .port) = '"${tproxy_port}"'' -i --output-format=yaml "${box_dir}/${bin_name}/config.yaml" >/dev/null 2>&1

${box_dir}/bin/yq '(.inbounds[] | select(.protocol == "dokodemo-door") | select(.tag == "tproxy-in") | .port) = '"${tproxy_port}" -i --output-format=json "${box_dir}/${bin_name}/config.json" >/dev/null 2>&1

# check configuration file
if ! [ -f "${box_dir}/${bin_name}/config.toml" ] && ! [ -f "${box_dir}/${bin_name}/config.json" ]; then
log Error "configuration file not found: ${box_dir}/${bin_name}/config.toml or config.json"
rm -f "${box_pid}"
if [ ! -f "${box_dir}/${bin_name}/config.toml" ] && [ ! -f "${box_dir}/${bin_name}/config.json" ] && [ ! -f "${box_dir}/${bin_name}/config.yaml" ]; then
log Error "No configuration file found in ${box_dir}/${bin_name}/. Expected one of: config.toml, config.json, or config.yaml"
if [ -f "${box_pid}" ]; then
rm -f "${box_pid}"
log Info "PID file removed: ${box_pid}"
fi
exit 1
else
# Displays a configuration xray"
log Info "config ${box_dir}/${bin_name}/*.json, or *.toml"
log Info "Configuration file located in ${box_dir}/${bin_name}/ (one of: .toml, .json, or .yaml)"
fi

# run xray
Expand All @@ -453,16 +456,20 @@ box_run_bin() {
fi

# sync port
# sed -i "s/port = [0-9]*\.[0-9]*/port = ${tproxy_port}.0/" ${box_dir}/$bin_name/config.toml
${box_dir}/bin/yq '(.inbounds[] | select(.protocol == "dokodemo-door") | .port) = '"${tproxy_port}" -i --output-format=json "${box_dir}/${bin_name}/config.json"
${box_dir}/bin/yq '(.inbounds[] | select(.protocol == "dokodemo-door") | .port) = '"${tproxy_port}"'' -i --output-format=yaml "${box_dir}/${bin_name}/config.yaml" >/dev/null 2>&1

${box_dir}/bin/yq '(.inbounds[] | select(.protocol == "dokodemo-door") | select(.tag == "tproxy-in") | .port) = '"${tproxy_port}" -i --output-format=json "${box_dir}/${bin_name}/config.json" >/dev/null 2>&1

# check configuration file
if ! [ -f "${box_dir}/${bin_name}/config.toml" ] && ! [ -f "${box_dir}/${bin_name}/config.json" ]; then
log Error "configuration file not found: ${box_dir}/${bin_name}/config.toml or config.json"
if [ ! -f "${box_dir}/${bin_name}/config.toml" ] && [ ! -f "${box_dir}/${bin_name}/config.json" ] && [ ! -f "${box_dir}/${bin_name}/config.yaml" ]; then
log Error "No configuration file found in ${box_dir}/${bin_name}/. Expected one of: config.toml, config.json, or config.yaml"
if [ -f "${box_pid}" ]; then
rm -f "${box_pid}"
log Info "PID file removed: ${box_pid}"
fi
exit 1
else
# Displays a configuration v2fly"
log Info "config ${box_dir}/${bin_name}/*.json, or *.toml"
log Info "Configuration file located in ${box_dir}/${bin_name}/ (one of: .toml, .json, or .yaml)"
fi

# run v2ray
Expand Down
323 changes: 189 additions & 134 deletions box/v2fly/config.json
Original file line number Diff line number Diff line change
@@ -1,141 +1,196 @@
{
"dns": {
"queryStrategy": "UseIP",
"servers": [
"8.8.8.8"
"dns": {
"queryStrategy": "UseIP",
"servers": [
"1.1.1.1",
{
"address": "1.1.1.1",
"domains": [
"domain:googleapis.cn",
"domain:gstatic.com"
]
},
{
"address": "223.5.5.5",
"domains": [
"domain:dns.alidns.com",
"domain:doh.pub",
"domain:dot.pub",
"domain:doh.360.cn",
"domain:dot.360.cn",
"geosite:cn",
"geosite:geolocation-cn"
],
"tag": "dns",
"hosts": {}
},
"inbounds": [
{
"port": 9898,
"protocol": "dokodemo-door",
"tag": "proxy-in",
"settings": {
"followRedirect": true,
"network": "tcp,udp"
},
"sniffing": {
"destOverride": [
"http",
"tls"
],
"enabled": true,
"routeOnly": false
},
"streamSettings": {
"sockopt": {
"tproxy": "tproxy"
}
}
}
"expectIPs": [
"geoip:cn"
],
"skipFallback": true
}
],
"log": {
"access": "none",
"dnsLog": true,
"loglevel": "error"
},
"outbounds": [
{
"protocol": "vmess",
"tag": "proxy",
"mux": {
"concurrency": 8,
"enabled": false
},
"settings": {
"vnext": [
{
"address": "104.18.3.198",
"port": 443,
"users": [
{
"alterId": 0,
"encryption": "",
"id": "",
"security": "auto"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"allowInsecure": true,
"serverName": "u.taamarin.com"
},
"wsSettings": {
"path": "/vmess",
"headers": {
"Host": "u.taamarin.com"
}
}
}
},
{
"protocol": "freedom",
"tag": "direct",
"settings": {
"domainStrategy": "UseIP"
}
},
{
"protocol": "blackhole",
"tag": "block",
"settings": {
"response": {
"type": "http"
}
}
},
{
"protocol": "dns",
"tag": "dns-out"
"tag": "dns",
"hosts": {
"geosite:category-ads-all": "127.0.0.1",
"domain:googleapis.cn": "googleapis.com",
"dns.pub": [
"1.12.12.12",
"120.53.53.53"
],
"dns.alidns.com": [
"223.5.5.5",
"223.6.6.6",
"2400:3200::1",
"2400:3200:baba::1"
],
"one.one.one.one": [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::1111",
"2606:4700:4700::1001"
],
"dns.google": [
"8.8.8.8",
"8.8.4.4",
"2001:4860:4860::8888",
"2001:4860:4860::8844"
]
}
},
"inbounds": [
{
"port": 9898,
"protocol": "dokodemo-door",
"tag": "tproxy-in",
"settings": {
"followRedirect": true,
"network": "tcp,udp"
},
"sniffing": {
"destOverride": [
"http",
"tls"
],
"enabled": true,
"routeOnly": false
},
"streamSettings": {
"sockopt": {
"tproxy": "tproxy"
}
],
"routing": {
"domainMatcher": "mph",
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"inboundTag": [
"proxy-in"
],
"outboundTag": "dns-out",
"port": 53,
"type": "field"
},
{
"domain": [
"regexp:^.*googlesyndication.com$",
"regexp:^.*adtival\\.network$"
],
"outboundTag": "proxy",
"type": "field"
},
{
"domain": [
"geosite:youtube"
],
"network": "udp",
"outboundTag": "block",
"type": "field"
},
{
"domain": [
"geosite:category-ads-all"
],
"outboundTag": "block",
"type": "field"
},
{
"network": "tcp,udp",
"outboundTag": "proxy",
"type": "field"
}
}
}
],
"log": {
"access": "none",
"dnsLog": true,
"loglevel": "error"
},
"outbounds": [
{
"protocol": "vmess",
"tag": "proxy",
"mux": {
"concurrency": 8,
"enabled": false
},
"settings": {
"vnext": [
{
"address": "u.taamarin.com",
"port": 443,
"users": [
{
"alterId": 0,
"encryption": "",
"flow": "",
"id": "",
"level": 8,
"security": "auto"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"allowInsecure": true,
"fingerprint": "",
"publicKey": "",
"serverName": "u.taamarin.com",
"shortId": "",
"show": false,
"spiderX": ""
},
"wsSettings": {
"path": "/vmess",
"headers": {
"Host": "u.taamarin.com"
}
}
}
},
{
"protocol": "freedom",
"tag": "direct",
"settings": {
"domainStrategy": "UseIP"
}
},
{
"protocol": "blackhole",
"tag": "block",
"settings": {
"response": {
"type": "http"
}
}
},
{
"protocol": "dns",
"tag": "dns-out"
}
],
"routing": {
"domainMatcher": "mph",
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"inboundTag": [
"tproxy-in"
],
"outboundTag": "dns-out",
"port": 53,
"type": "field"
},
{
"domain": [
"regexp:^.*googlesyndication.com$",
"regexp:^.*adtival\\.network$"
],
"outboundTag": "proxy",
"type": "field"
},
{
"domain": [
"geosite:youtube"
],
"network": "udp",
"outboundTag": "block",
"type": "field"
},
{
"domain": [
"geosite:category-ads-all"
],
"outboundTag": "block",
"type": "field"
},
{
"network": "tcp,udp",
"outboundTag": "proxy",
"type": "field"
}
]
}
}
Loading

0 comments on commit d3b7d6e

Please sign in to comment.