mirror of
https://github.com/samuelhbne/proxy-xray.git
synced 2025-12-16 20:27:06 +03:00
Json compact
This commit is contained in:
14
proxy-lsp.sh
14
proxy-lsp.sh
@@ -37,21 +37,21 @@ fi
|
||||
|
||||
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
|
||||
|
||||
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid, "encryption":"none", "level":0}'`
|
||||
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'`
|
||||
|
||||
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
|
||||
'. += {"address":$host, "port":($port | tonumber), "users":[$juser]}' `
|
||||
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
|
||||
|
||||
JstreamSettings=`jq -nc --arg path "${path}" \
|
||||
'. += {"network":"splithttp", "security":"none", "splithttpSettings":{"path":$path}}' `
|
||||
'. += {"network":"splithttp","security":"none","splithttpSettings":{"path":$path}}' `
|
||||
|
||||
Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
|
||||
'. += { "tag": "proxy", "protocol":"vless", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' `
|
||||
Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}'
|
||||
Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}'
|
||||
'. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' `
|
||||
Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}'
|
||||
Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}'
|
||||
|
||||
jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \
|
||||
'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' `
|
||||
'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' `
|
||||
|
||||
echo "$jroot"
|
||||
exit 0
|
||||
|
||||
14
proxy-lwp.sh
14
proxy-lwp.sh
@@ -37,21 +37,21 @@ fi
|
||||
|
||||
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
|
||||
|
||||
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid, "encryption":"none", "level":0}'`
|
||||
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'`
|
||||
|
||||
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
|
||||
'. += {"address":$host, "port":($port | tonumber), "users":[$juser]}' `
|
||||
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
|
||||
|
||||
JstreamSettings=`jq -nc --arg path "${path}" \
|
||||
'. += {"network":"ws", "security":"none", "wsSettings":{"path":$path}}' `
|
||||
'. += {"network":"ws","security":"none","wsSettings":{"path":$path}}' `
|
||||
|
||||
Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
|
||||
'. += { "tag": "proxy", "protocol":"vless", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' `
|
||||
Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}'
|
||||
Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}'
|
||||
'. += { "tag":"proxy","protocol":"vless","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' `
|
||||
Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}'
|
||||
Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}'
|
||||
|
||||
jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \
|
||||
'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' `
|
||||
'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' `
|
||||
|
||||
echo "$jroot"
|
||||
exit 0
|
||||
|
||||
14
proxy-mwp.sh
14
proxy-mwp.sh
@@ -40,21 +40,21 @@ fi
|
||||
|
||||
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
|
||||
|
||||
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid, "encryption":"none", "level":0}'`
|
||||
Jusers=`jq -nc --arg uuid "${id}" '. += {"id":$uuid,"encryption":"none","level":0}'`
|
||||
|
||||
Jvnext=`jq -nc --arg host "${host}" --arg port "${port}" --argjson juser "${Jusers}" \
|
||||
'. += {"address":$host, "port":($port | tonumber), "users":[$juser]}' `
|
||||
'. += {"address":$host,"port":($port | tonumber),"users":[$juser]}' `
|
||||
|
||||
JstreamSettings=`jq -nc --arg path "${path}" \
|
||||
'. += {"network":"ws", "security":"none", "wsSettings":{"path":$path}}' `
|
||||
'. += {"network":"ws","security":"none","wsSettings":{"path":$path}}' `
|
||||
|
||||
Jproxy=`jq -nc --arg host "${host}" --argjson jvnext "${Jvnext}" --argjson jstreamSettings "${JstreamSettings}" \
|
||||
'. += { "tag": "proxy", "protocol":"vmess", "settings":{"vnext":[$jvnext]}, "streamSettings":$jstreamSettings }' `
|
||||
Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}'
|
||||
Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}'
|
||||
'. += { "tag": proxy","protocol":"vmess","settings":{"vnext":[$jvnext]},"streamSettings":$jstreamSettings}' `
|
||||
Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}'
|
||||
Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}'
|
||||
|
||||
jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \
|
||||
'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' `
|
||||
'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' `
|
||||
|
||||
echo "$jroot"
|
||||
exit 0
|
||||
|
||||
12
proxy-twp.sh
12
proxy-twp.sh
@@ -40,19 +40,19 @@ if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be
|
||||
|
||||
# User settings
|
||||
Jservers=`jq -nc --arg host "${host}" --arg port "${port}" --arg passwd "${passwd}" \
|
||||
'. += {"address":$host, "port":($port | tonumber), "password":$passwd}' `
|
||||
'. += {"address":$host,"port":($port | tonumber),"password":$passwd}' `
|
||||
|
||||
# Stream Settings
|
||||
JstreamSettings=`jq -nc --arg path "${path}" \
|
||||
'. += {"network":"ws", "security":"none", "wsSettings":{"path":$path}}' `
|
||||
'. += {"network":"ws","security":"none","wsSettings":{"path":$path}}' `
|
||||
|
||||
Jproxy=`jq -nc --arg host "${host}" --argjson jservers "${Jservers}" --argjson jstreamSettings "${JstreamSettings}" \
|
||||
'. += { "tag": "proxy", "protocol":"trojan", "settings":{"servers":[$jservers]}, "streamSettings":$jstreamSettings }' `
|
||||
Jdirect='{"tag": "direct", "protocol": "freedom", "settings": {}}'
|
||||
Jblocked='{"tag": "blocked", "protocol": "blackhole", "settings": {}}'
|
||||
'. += { "tag":"proxy","protocol":"trojan","settings":{"servers":[$jservers]},"streamSettings":$jstreamSettings}' `
|
||||
Jdirect='{"tag":"direct","protocol":"freedom","settings":{}}'
|
||||
Jblocked='{"tag":"blocked","protocol":"blackhole","settings":{}}'
|
||||
|
||||
jroot=`jq -n --argjson jproxy "${Jproxy}" --argjson jdirect "${Jdirect}" --argjson jblocked "${Jblocked}" \
|
||||
'. += {"log":{"loglevel":"warning"}, "outbounds":[$jproxy, $jdirect, $jblocked]}' `
|
||||
'. += {"log":{"loglevel":"warning"},"outbounds":[$jproxy,$jdirect,$jblocked]}' `
|
||||
|
||||
echo "$jroot"
|
||||
exit 0
|
||||
|
||||
32
run.sh
32
run.sh
@@ -102,45 +102,45 @@ while true ; do
|
||||
;;
|
||||
--cn-direct)
|
||||
Jrules=`echo "${Jrules}" | jq --arg igndomain "geosite:apple-cn" \
|
||||
'.rules += [{"type":"field", "outboundTag":"direct", "domain":[$igndomain]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"direct","domain":[$igndomain]}]'`
|
||||
Jrules=`echo "${Jrules}" | jq --arg igndomain "geosite:google-cn" \
|
||||
'.rules += [{"type":"field", "outboundTag":"direct", "domain":[$igndomain]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"direct","domain":[$igndomain]}]'`
|
||||
Jrules=`echo "${Jrules}" | jq --arg igndomain "geosite:geolocation-cn" \
|
||||
'.rules += [{"type":"field", "outboundTag":"direct", "domain":[$igndomain]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"direct","domain":[$igndomain]}]'`
|
||||
Jrules=`echo "${Jrules}" | jq --arg igndomain "geosite:cn" \
|
||||
'.rules += [{"type":"field", "outboundTag":"direct", "domain":[$igndomain]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"direct","domain":[$igndomain]}]'`
|
||||
Jrules=`echo "${Jrules}" | jq --arg ignip "geoip:cn" \
|
||||
'.rules += [{"type":"field", "outboundTag":"direct", "ip":[$ignip]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"direct","ip":[$ignip]}]'`
|
||||
shift 1
|
||||
;;
|
||||
--domain-direct)
|
||||
Jrules=`echo "${Jrules}" | jq --arg igndomain "$2" \
|
||||
'.rules += [{"type":"field", "outboundTag":"direct", "domain":[$igndomain]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"direct","domain":[$igndomain]}]'`
|
||||
shift 2
|
||||
;;
|
||||
--domain-proxy)
|
||||
Jrules=`echo "${Jrules}" | jq --arg pxydomain "$2" \
|
||||
'.rules += [{"type":"field", "outboundTag":"proxy", "domain":[$pxydomain]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"proxy","domain":[$pxydomain]}]'`
|
||||
shift 2
|
||||
;;
|
||||
--domain-block)
|
||||
Jrules=`echo "${Jrules}" | jq --arg blkdomain "$2" \
|
||||
'.rules += [{"type":"field", "outboundTag":"block", "domain":[$blkdomain]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"block","domain":[$blkdomain]}]'`
|
||||
shift 2
|
||||
;;
|
||||
--ip-direct)
|
||||
Jrules=`echo "${Jrules}" | jq --arg ignip "$2" \
|
||||
'.rules += [{"type":"field", "outboundTag":"direct", "ip":[$ignip]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"direct","ip":[$ignip]}]'`
|
||||
shift 2
|
||||
;;
|
||||
--ip-proxy)
|
||||
Jrules=`echo "${Jrules}" | jq --arg pxyip "$2" \
|
||||
'.rules += [{"type":"field", "outboundTag":"proxy", "ip":[$pxyip]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"proxy","ip":[$pxyip]}]'`
|
||||
shift 2
|
||||
;;
|
||||
--ip-block)
|
||||
Jrules=`echo "${Jrules}" | jq --arg blkip "$2" \
|
||||
'.rules += [{"type":"field", "outboundTag":"block", "ip":[$blkip]}]'`
|
||||
'.rules += [{"type":"field","outboundTag":"block","ip":[$blkip]}]'`
|
||||
shift 2
|
||||
;;
|
||||
--rules-path)
|
||||
@@ -191,15 +191,15 @@ if [ -z "${DNS}" ]; then
|
||||
fi
|
||||
|
||||
# Add inbounds config
|
||||
JibDKDEMO=`echo '{}' | jq --arg dns "${DNS}" \
|
||||
'. +={"tag": "dns-in", "port":5353, "listen":"0.0.0.0", "protocol":"dokodemo-door", "settings":{"address": $dns, "port":53, "network":"tcp,udp"}}' `
|
||||
JibSOCKS=`echo '{}' | jq '. +={"tag": "socks", "port":1080, "listen":"0.0.0.0", "protocol":"socks", "settings":{"udp":true}}' `
|
||||
JibHTTP=`echo '{}' | jq '. +={"tag": "http", "port":8123, "listen":"0.0.0.0", "protocol":"http"}' `
|
||||
JibDKDEMO=`jq -nc --arg dns "${DNS}" \
|
||||
'. +={"tag":"dns-in","port":5353,"listen":"0.0.0.0","protocol":"dokodemo-door","settings":{"address":$dns,"port":53,"network":"tcp,udp"}}' `
|
||||
JibSOCKS=`jq -nc '. +={"tag":"socks","port":1080,"listen":"0.0.0.0","protocol":"socks","settings":{"udp":true}}' `
|
||||
JibHTTP=`jq -nc '. +={"tag":"http","port":8123,"listen":"0.0.0.0","protocol":"http"}' `
|
||||
cat $XCONF| jq --argjson jibdkdemo "${JibDKDEMO}" --argjson jibsocks "${JibSOCKS}" --argjson jibhttp "${JibHTTP}" \
|
||||
'. += {"inbounds":[$jibdkdemo, $jibsocks, $jibhttp]}' | sponge $XCONF
|
||||
|
||||
# Add routing config
|
||||
Jrouting='{"routing": {"domainStrategy":"AsIs"}}'
|
||||
Jrouting='{"routing":{"domainStrategy":"AsIs"}}'
|
||||
Jrouting=`echo "${Jrouting}" |jq --argjson jrules "${Jrules}" '.routing += $jrules'`
|
||||
cat $XCONF| jq --argjson jrouting "${Jrouting}" '. += $jrouting' | sponge $XCONF
|
||||
|
||||
|
||||
@@ -49,9 +49,9 @@ case "${PROTOCOL}" in
|
||||
WPATH=`cat $XCONF | jq -r '.outbounds[0].streamSettings.wsSettings.path'`
|
||||
UUID=`cat $XCONF | jq -r '.outbounds[0].settings.vnext[0].users[0].id'`
|
||||
XNETWORK=`cat $XCONF | jq -r '.outbounds[0].streamSettings.network'`
|
||||
JXURL=`echo '{}' |jq --arg xhost "${XHOST}" --arg xport "${XPORT}" '. += {"v":2, "add":$xhost, "port":$xport}' `
|
||||
JXURL=`echo ${JXURL} | jq --arg uuid "${UUID}" --arg network "${XNETWORK}" '. += {"id":$uuid, "net":$network}' `
|
||||
JXURL=`echo ${JXURL} | jq '. += {"scy":"auto", "tls":"tls"}' `
|
||||
JXURL=`echo '{}' |jq --arg xhost "${XHOST}" --arg xport "${XPORT}" '. += {"v":2,"add":$xhost,"port":$xport}' `
|
||||
JXURL=`echo ${JXURL} | jq --arg uuid "${UUID}" --arg network "${XNETWORK}" '. += {"id":$uuid,"net":$network}' `
|
||||
JXURL=`echo ${JXURL} | jq '. += {"scy":"auto","tls":"tls"}' `
|
||||
if [ "${WPATH}" != "null" ]; then
|
||||
JXURL=`echo ${JXURL} | jq --arg wpath "${WPATH}" '. += {"path":$wpath}' `
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user