Files
proxy-xray/run.sh
Samuel Huang 5ad15c3c93 Init import
2021-08-16 00:48:32 +10:00

76 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
DIR=`dirname $0`
DIR="$(cd $DIR; pwd)"
XCONF=/tmp/proxy-xray.json
usage() {
echo "proxy-xray --<ltx|ltt|lttw|mtt|mttw|ttt|tttw|ssa|sst|stdin> [options]"
echo " --ltx <VLESS-TCP-XTLS option> uuid@xray-host:port"
echo " --ltt <VLESS-TCP-TLS option> uuid@xray-host:port"
echo " --lttw <VLESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath"
echo " --mtt <VMESS-TCP-TLS option> uuid@xray-host:port"
echo " --mttw <VMESS-TCP-TLS-WS option> uuid@xray-host:port:/webpath"
echo " --ttt <TROJAN-TCP-TLS option> password@xray-host:port"
echo " --tttw <TROJAN-TCP-TLS-WS option> password@xray-host:port:/webpath"
# echo " --ssa <Shadowsocks-AEAD option> password:method@xray-host:port"
# echo " --sst <Shadowsocks-TCP option> password:method@xray-host:port"
echo " --stdin Read XRay config from stdin instead of auto generation"
}
TEMP=`getopt -o d --long ltx:,ltt:,lttw:,mtt:,mttw:,ttt:,tttw:,ssa:,sst:stdin,debug -n "$0" -- $@`
if [ $? != 0 ] ; then usage; exit 1 ; fi
eval set -- "$TEMP"
while true ; do
case "$1" in
--ltx|--ltt|--lttw|--mtt|--mttw|--ttt|--tttw|--ssa|--sst)
subcmd=`echo "$1"|tr -d "\-\-"`
echo "$DIR/proxy-${subcmd}.sh $2 >$XCONF"
$DIR/proxy-${subcmd}.sh $2 >$XCONF
if [ $? != 0 ]; then
echo "${subcmd} Config failed: $DIR/proxy-${subcmd}.sh $2"
exit 2
else
XRAY=1
fi
shift 2
;;
--stdin)
STDINCONF=1
shift 1
;;
-d|--debug)
DEBUG=1
shift 1
;;
--)
shift
break
;;
*)
usage;
exit 1
;;
esac
done
/usr/bin/dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml &
if [ "${STDINCONF}" = "1" ]; then
exec /usr/local/bin/xray
else
if [ "${XRAY}" = "1" ]; then
if [ "${DEBUG}" = "1" ]; then
cat $XCONF |jq '.log.loglevel |="debug"' |sponge $XCONF
echo
cat $XCONF
echo
fi
exec /usr/local/bin/xray -c $XCONF
else
usage
exit 1
fi
fi