mirror of
https://github.com/samuelhbne/proxy-xray.git
synced 2025-12-17 04:34:37 +03:00
JSON merge support
This commit is contained in:
@@ -93,6 +93,7 @@ proxy-xray <connection-options>
|
|||||||
--tpw <TROJAN-PLN-WS option> password@host:port:/wspath
|
--tpw <TROJAN-PLN-WS option> password@host:port:/wspath
|
||||||
-d|--debug Start in debug mode with verbose output
|
-d|--debug Start in debug mode with verbose output
|
||||||
-i|--stdin Read config from stdin instead of auto generation
|
-i|--stdin Read config from stdin instead of auto generation
|
||||||
|
-j|--json '{"log":{"loglevel":"info"}' Json snippet to merge into the config
|
||||||
--dns <upstream-DNS-ip> Designated upstream DNS server IP, 1.1.1.1 will be applied by default
|
--dns <upstream-DNS-ip> Designated upstream DNS server IP, 1.1.1.1 will be applied by default
|
||||||
--dns-local-cn Enable China-accessible domains to be resolved in China
|
--dns-local-cn Enable China-accessible domains to be resolved in China
|
||||||
--domain-direct <domain-rule> Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn
|
--domain-direct <domain-rule> Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn
|
||||||
|
|||||||
19
run.sh
19
run.sh
@@ -22,6 +22,7 @@ usage() {
|
|||||||
echo " --tpw <TROJAN-PLN-WS option> password@host:port:/wspath"
|
echo " --tpw <TROJAN-PLN-WS option> password@host:port:/wspath"
|
||||||
echo " -d|--debug Start in debug mode with verbose output"
|
echo " -d|--debug Start in debug mode with verbose output"
|
||||||
echo " -i|--stdin Read config from stdin instead of auto generation"
|
echo " -i|--stdin Read config from stdin instead of auto generation"
|
||||||
|
echo " -j|--json '{"log":{"loglevel":"info"}' Json snippet to merge into the config"
|
||||||
echo " --dns <upstream-DNS-ip> Designated upstream DNS server IP, 1.1.1.1 will be applied by default"
|
echo " --dns <upstream-DNS-ip> Designated upstream DNS server IP, 1.1.1.1 will be applied by default"
|
||||||
# echo " --dns-local <local-conf-file> Enable designated domain conf file. Like apple.china.conf"
|
# echo " --dns-local <local-conf-file> Enable designated domain conf file. Like apple.china.conf"
|
||||||
echo " --dns-local-cn Enable China-accessible domains to be resolved in China"
|
echo " --dns-local-cn Enable China-accessible domains to be resolved in China"
|
||||||
@@ -38,7 +39,7 @@ usage() {
|
|||||||
|
|
||||||
Jrules='{"rules":[]}'
|
Jrules='{"rules":[]}'
|
||||||
|
|
||||||
TEMP=`getopt -o di --long lx:,ls:,ms:,ts:,lsg:,lss:,lsw:,msw:,tsw:,lpg:,lps:,lpw:,mpw:,tpw:,stdin,debug,dns:,dns-local:,dns-local-cn,domain-direct:,domain-proxy:,domain-block:,ip-direct:,ip-proxy:,ip-block:,cn-direct,rules-path: -n "$0" -- $@`
|
TEMP=`getopt -o j:di --long json:lx:,ls:,ms:,ts:,lsg:,lss:,lsw:,msw:,tsw:,lpg:,lps:,lpw:,mpw:,tpw:,stdin,debug,dns:,dns-local:,dns-local-cn,domain-direct:,domain-proxy:,domain-block:,ip-direct:,ip-proxy:,ip-block:,cn-direct,rules-path: -n "$0" -- $@`
|
||||||
if [ $? != 0 ] ; then usage; exit 1 ; fi
|
if [ $? != 0 ] ; then usage; exit 1 ; fi
|
||||||
eval set -- "$TEMP"
|
eval set -- "$TEMP"
|
||||||
while true ; do
|
while true ; do
|
||||||
@@ -116,6 +117,10 @@ while true ; do
|
|||||||
export XRAY_LOCATION_ASSET=$2
|
export XRAY_LOCATION_ASSET=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-j|--json)
|
||||||
|
INJECT+=("$2")
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
-i|--stdin)
|
-i|--stdin)
|
||||||
STDINCONF=1
|
STDINCONF=1
|
||||||
XRAYCFG=1
|
XRAYCFG=1
|
||||||
@@ -177,5 +182,17 @@ if [ "${DEBUG}" = "1" ]; then
|
|||||||
cat $XCONF
|
cat $XCONF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${INJECT}" ]; then
|
||||||
|
for JSON_IN in "${INJECT[@]}"
|
||||||
|
do
|
||||||
|
echo "${JSON_IN}"|jq -ec >/tmp/merge.json
|
||||||
|
if [[ $? -ne 0 ]]; then
|
||||||
|
echo "Invalid json ${JSON_IN}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
jq -s '.[0] * .[1]' $XCONF /tmp/merge.json |sponge $XCONF
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
exec /usr/local/bin/xray -c $XCONF
|
exec /usr/local/bin/xray -c $XCONF
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user