Add --lttx --ltrx alias options

This commit is contained in:
Samuel Huang
2024-09-12 17:13:35 +10:00
parent bbbc27055a
commit 2881cd22f7
5 changed files with 111 additions and 82 deletions

View File

@@ -1,29 +1,29 @@
FROM golang:1.23-alpine3.20 AS builder FROM golang:1.23-alpine3.20 AS builder
ARG XRAY_VER='v1.8.23' ARG XRAY_VER='v1.8.24'
ARG QREC_VER='4.1.1' ARG QREC_VER='4.1.1'
RUN apk add --no-cache bash git build-base wget RUN apk add --no-cache bash git build-base curl
RUN cd /tmp; wget -c -t3 -T30 https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat WORKDIR /go/src/XTLS/Xray-core
RUN cd /tmp; wget -c -t3 -T30 https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat RUN git clone https://github.com/XTLS/Xray-core.git . && \
git checkout ${XRAY_VER} && \
go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main
RUN cd /tmp; wget -c -t3 -T30 https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf RUN cd /tmp; curl -O https://fukuchi.org/works/qrencode/qrencode-${QREC_VER}.tar.gz && \
RUN cd /tmp; wget -c -t3 -T30 https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf
RUN cd /tmp; wget -c -t3 -T30 https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf
RUN cd /tmp; wget -c -t3 -T30 https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf
RUN cd /tmp; wget -c -t3 -T30 https://fukuchi.org/works/qrencode/qrencode-${QREC_VER}.tar.gz && \
tar xvf qrencode-${QREC_VER}.tar.gz && \ tar xvf qrencode-${QREC_VER}.tar.gz && \
cd qrencode-${QREC_VER} && \ cd qrencode-${QREC_VER} && \
./configure --without-png && \ ./configure --without-png && \
make && \ make && \
cp -a qrencode /tmp/ cp -a qrencode /tmp/
WORKDIR /go/src/XTLS/Xray-core RUN cd /tmp; curl -O https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
RUN git clone https://github.com/XTLS/Xray-core.git . && \ RUN cd /tmp; curl -O https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
git checkout ${XRAY_VER} && \
go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main RUN cd /tmp; curl -O https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf
RUN cd /tmp; curl -O https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf
RUN cd /tmp; curl -O https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf
RUN cd /tmp; curl -O https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf
FROM alpine:3.20 FROM alpine:3.20

View File

@@ -77,33 +77,36 @@ Xray-URL: vless://myid@mydomain.duckdns.org:443?security=xtls&type=tcp&flow=xtls
```shell ```shell
$ docker run --rm samuelhbne/proxy-xray $ docker run --rm samuelhbne/proxy-xray
proxy-xray <connection-options> proxy-xray <connection-options>
--lx <VLESS-XTLS option> id@host:port[,s=sniname.org] --lgp <VLESS-GRPC-PLN option> id@host:port:svcname
--ls <VLESS-TLS option> id@host:port[,s=sniname.org] --lgr <VLESS-GRPC-RLTY option> id@host:port:svcname,d=dest.com,pub=xxxx[,shortId=abcd]
--ms <VMESS-TLS option> id@host:port[,s=sniname.org] --lgt <VLESS-GRPC-TLS option> id@host:port:svcname[,s=sni.com]
--ts <TROJAN-TLS option> password@host:port[,s=sniname.org] --lsp <VLESS-SPLT-PLN option> id@host:port:/webpath
--lsg <VLESS-TLS-GRPC option> id@host:port:svcname[,s=sniname.org] --lst <VLESS-SPLT-TLS option> id@host:port:/webpath[,s=sni.com]
--lss <VLESS-TLS-SPLT option> id@host:port:/webpath[,s=sniname.org] --ltr <VLESS-TCP-RLTY option> id@host:port,d=dest.com,pub=xxxx[,shortId=abcd][,xtls]
--lsw <VLESS-TLS-WS option> id@host:port:/wspath[,s=sniname.org] --ltrx <VLESS-TCP-RLTY-XTLS option> id@host:port,d=dest.com,pub=xxxx[,shortId=abcd]
--msw <VMESS-TLS-WS option> id@host:port:/wspath[,s=sniname.org] --ltt <VLESS-TCP-TLS option> id@host:port[,s=sni.com][,xtls]
--tsw <TROJAN-TLS-WS option> password@host:port:/wspath[,s=sniname.org] --lttx <VLESS-TCP-TLS-XTLS option> id@host:port[,s=sni.com]
--lpg <VLESS-PLN-GRPC option> id@host:port:svcname --lwp <VLESS-WS-PLN option> id@host:port:/wspath
--lps <VLESS-PLN-SPLT option> id@host:port:/webpath --lwt <VLESS-WS-TLS option> id@host:port:/wspath[,s=sni.com]
--lpw <VLESS-PLN-WS option> id@host:port:/wspath --mtt <VMESS-TCP-TLS option> id@host:port[,s=sni.com]
--mpw <VMESS-PLN-WS option> id@host:port:/wspath --mwp <VMESS-WS-PLN option> id@host:port:/wspath
--tpw <TROJAN-PLN-WS option> password@host:port:/wspath --mwt <VMESS-WS-TLS option> id@host:port:/wspath[,s=sni.com]
-d|--debug Start in debug mode with verbose output --ttt <TROJAN-TCP-TLS option> password@host:port[,s=sni.com]
-i|--stdin Read config from stdin instead of auto generation --twp <TROJAN-WS-PLN option> password@host:port:/wspath
-j|--json '{"log":{"loglevel":"info"}' Json snippet to merge into the config --twt <TROJAN-WS-TLS option> password@host:port:/wspath[,s=sni.com]
--dns <upstream-DNS-ip> Designated upstream DNS server IP, 1.1.1.1 will be applied by default -d|--debug Start in debug mode with verbose output
--dns-local-cn Enable China-accessible domains to be resolved in China -i|--stdin Read config from stdin instead of auto generation
--domain-direct <domain-rule> Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn -j|--json Json snippet to merge into the config. Say '{log:{loglevel:info}'
--domain-proxy <domain-rule> Add a domain rule for proxy routing, like twitter.com or geosite:google-cn --dns <upstream-DNS-ip> Designated upstream DNS server IP, 1.1.1.1 will be applied by default
--domain-block <domain-rule> Add a domain rule for block routing, like geosite:category-ads-all --dns-local-cn Enable China-accessible domains to be resolved in China
--ip-direct <ip-rule> Add a ip-addr rule for direct routing, like 114.114.114.114/32 or geoip:cn --domain-direct <domain-rule> Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn
--ip-proxy <ip-rule> Add a ip-addr rule for proxy routing, like 1.1.1.1/32 or geoip:netflix --domain-proxy <domain-rule> Add a domain rule for proxy routing, like twitter.com or geosite:google-cn
--ip-block <ip-rule> Add a ip-addr rule for block routing, like geoip:private --domain-block <domain-rule> Add a domain rule for block routing, like geosite:category-ads-all
--cn-direct Add routing rules to avoid domains and IPs located in China being proxied --ip-direct <ip-rule> Add a ip-addr rule for direct routing, like 114.114.114.114/32 or geoip:cn
--rules-path <rules-dir-path> Folder path contents geoip.dat, geosite.dat and other rule files --ip-proxy <ip-rule> Add a ip-addr rule for proxy routing, like 1.1.1.1/32 or geoip:netflix
--ip-block <ip-rule> Add a ip-addr rule for block routing, like geoip:private
--cn-direct Add routing rules to avoid domains and IPs located in China being proxied
--rules-path <rules-dir-path> Folder path contents geoip.dat, geosite.dat and other rule files
``` ```
## How to stop and remove the running container ## How to stop and remove the running container
@@ -117,37 +120,37 @@ $ docker rm proxy-xray
## More complex examples ## More complex examples
### 1. Connect to Vless+TCP+XTLS server ### 1. Connect to Vless-TCP-TLS-XTLS server
The following instruction connect to mydomain.duckdns.org port 443 in Vless+TCP+XTLS mode. Connection made via IP address to avoid DNS contamination. TLS servername provided via parameter. All destination sites and IP located in China will not been proxied. The following instruction connect to mydomain.duckdns.org port 443 in Vless+TCP+XTLS mode. Connection made via IP address to avoid DNS contamination. TLS servername provided via parameter. All destination sites and IP located in China will not been proxied.
```shell ```shell
$ docker run --name proxy-xray -p 1080:1080 -p 1080:1080/udp -d samuelhbne/proxy-xray \ $ docker run --name proxy-xray -p 1080:1080 -p 1080:1080/udp -d samuelhbne/proxy-xray \
--lx myid@12.34.56.78:443,serverName=mydomain.duckdns.org --cn-direct --lttx myid@12.34.56.78:443,serverName=mydomain.duckdns.org --cn-direct
``` ```
### 2. Connect to Vless+TCP+TLS+Websocket server ### 2. Connect to Vless-Websocket-TLS server
The following instruction connect to Xray server port 443 in Vless+TCP+TLS+Websocket mode with given id. All apple-cn sites will be proxied. All sites located in China will not be proxied. The following instruction connect to Xray server port 443 in Vless+TCP+TLS+Websocket mode with given id. All apple-cn sites will be proxied. All sites located in China will not be proxied.
```shell ```shell
$ docker run --name proxy-xray -p 1080:1080 -d samuelhbne/proxy-xray \ $ docker run --name proxy-xray -p 1080:1080 -d samuelhbne/proxy-xray \
--lsw myid@mydomain.duckdns.org:443:/websocket \ --lwt myid@mydomain.duckdns.org:443:/websocket \
--domain-proxy geosite:apple-cn --domain-direct geosite:geolocation-cn --domain-proxy geosite:apple-cn --domain-direct geosite:geolocation-cn
``` ```
### 3. Connect to Vless+TCP+TLS+gRPC server ### 3. Connect to Vless-gRPC-TLS server
The following instruction connect to Xray server port 443 in Vless+TCP+TLS+gRPC mode with given password. All sites not located in China will be proxied. You need to escape '!' character in --domain-proxy parameter to be accepted by shell. The following instruction connect to Xray server port 443 in Vless-gRPC-TLS mode with given password. All sites not located in China will be proxied. You need to escape '!' character in --domain-proxy parameter to be accepted by shell.
```shell ```shell
$ docker run --name proxy-xray -p 1080:1080 samuelhbne/proxy-xray \ $ docker run --name proxy-xray -p 1080:1080 samuelhbne/proxy-xray \
--lsg myid@mydomain.duckdns.org:443:gsvc --domain-proxy geosite:geolocation-\!cn --lgt myid@mydomain.duckdns.org:443:gsvc --domain-proxy geosite:geolocation-\!cn
``` ```
### 4. Connect to TCP+TLS+Trojan server ### 4. Connect to TCP-Trojan-TLS server
The following instruction connect to Xray server port 443 in TCP+TLS+Trojan mode with given password; Update geosite and geoip rule dat files; All sites and IPs located in Iran will be connected directly. The following instruction connect to Xray server port 443 in TCP-Trojan-TLS mode with given password; Update geosite and geoip rule dat files; All sites and IPs located in Iran will be connected directly.
```shell ```shell
$ mkdir -p /tmp/rules $ mkdir -p /tmp/rules
@@ -156,7 +159,7 @@ $ wget -c -t3 -T30 https://github.com/Loyalsoldier/v2ray-rules-dat/releases/late
$ wget -c -t3 -T30 https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat $ wget -c -t3 -T30 https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
$ wget -c -t3 -T30 https://github.com/SamadiPour/iran-hosted-domains/releases/download/202108210015/iran.dat $ wget -c -t3 -T30 https://github.com/SamadiPour/iran-hosted-domains/releases/download/202108210015/iran.dat
$ docker run --name proxy-xray -p 1080:1080 -v /tmp/rules:/opt/rules -d samuelhbne/proxy-xray \ $ docker run --name proxy-xray -p 1080:1080 -v /tmp/rules:/opt/rules -d samuelhbne/proxy-xray \
--ts trojan_pass@mydomain.duckdns.org:8443 \ --ttt trojan_pass@mydomain.duckdns.org:8443 \
--rules-path /opt/rules --domain-direct ext:iran.dat:ir --ip-direct geoip:ir --rules-path /opt/rules --domain-direct ext:iran.dat:ir --ip-direct geoip:ir
``` ```
@@ -166,7 +169,7 @@ The following instruction start proxy-xray in debug mode. Output Xray config fil
```shell ```shell
$ docker run --rm -p 1080:1080 samuelhbne/proxy-xray \ $ docker run --rm -p 1080:1080 samuelhbne/proxy-xray \
--msw myid@mydomain.duckdns.org:443:/websocket --debug --mwt myid@mydomain.duckdns.org:443:/websocket --debug
``` ```
### NOTE 4 ### NOTE 4

View File

@@ -67,6 +67,12 @@ if [ -z "${port}" ]; then
port=443 port=443
fi fi
if [ -z "${publicKey}" ]; then
>&2 echo "Error: publicKey undefined."
usage
exit 1
fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
# User settings # User settings

View File

@@ -66,6 +66,12 @@ if [ -z "${port}" ]; then
port=443 port=443
fi fi
if [ -z "${publicKey}" ]; then
>&2 echo "Error: publicKey undefined."
usage
exit 1
fi
if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi if ! [ "${port}" -eq "${port}" ] 2>/dev/null; then >&2 echo "Port number must be numeric"; exit 1; fi
# User settings # User settings

74
run.sh
View File

@@ -6,41 +6,43 @@ XCONF=/tmp/proxy-xray.json
usage() { usage() {
echo "proxy-xray <connection-options>" echo "proxy-xray <connection-options>"
echo " --lgp <VLESS-GRPC-PLN option> id@host:port:svcname" echo " --lgp <VLESS-GRPC-PLN option> id@host:port:svcname"
echo " --lgr <VLESS-GRPC-RLTY option> id@host:port:svcname,d=dest.com,pub=xxxx[,shortId=abcd]" echo " --lgr <VLESS-GRPC-RLTY option> id@host:port:svcname,d=dest.com,pub=xxxx[,shortId=abcd]"
echo " --lgt <VLESS-GRPC-TLS option> id@host:port:svcname[,s=sni.com]" echo " --lgt <VLESS-GRPC-TLS option> id@host:port:svcname[,s=sni.com]"
echo " --lsp <VLESS-SPLT-PLN option> id@host:port:/webpath" echo " --lsp <VLESS-SPLT-PLN option> id@host:port:/webpath"
echo " --lst <VLESS-SPLT-TLS option> id@host:port:/webpath[,s=sni.com]" echo " --lst <VLESS-SPLT-TLS option> id@host:port:/webpath[,s=sni.com]"
echo " --ltr <VLESS-TCP-RLTY option> id@host:port,d=dest.com,pub=xxxx[,shortId=abcd][,xtls]" echo " --ltr <VLESS-TCP-RLTY option> id@host:port,d=dest.com,pub=xxxx[,shortId=abcd][,xtls]"
echo " --ltt <VLESS-TCP-TLS option> id@host:port[,s=sni.com][,xtls]" echo " --ltrx <VLESS-TCP-RLTY-XTLS option> id@host:port,d=dest.com,pub=xxxx[,shortId=abcd]"
echo " --lwp <VLESS-WS-PLN option> id@host:port:/wspath" echo " --ltt <VLESS-TCP-TLS option> id@host:port[,s=sni.com][,xtls]"
echo " --lwt <VLESS-WS-TLS option> id@host:port:/wspath[,s=sni.com]" echo " --lttx <VLESS-TCP-TLS-XTLS option> id@host:port[,s=sni.com]"
echo " --mtt <VMESS-TCP-TLS option> id@host:port[,s=sni.com]" echo " --lwp <VLESS-WS-PLN option> id@host:port:/wspath"
echo " --mwp <VMESS-WS-PLN option> id@host:port:/wspath" echo " --lwt <VLESS-WS-TLS option> id@host:port:/wspath[,s=sni.com]"
echo " --mwt <VMESS-WS-TLS option> id@host:port:/wspath[,s=sni.com]" echo " --mtt <VMESS-TCP-TLS option> id@host:port[,s=sni.com]"
echo " --ttt <TROJAN-TCP-TLS option> password@host:port[,s=sni.com]" echo " --mwp <VMESS-WS-PLN option> id@host:port:/wspath"
echo " --twp <TROJAN-WS-PLN option> password@host:port:/wspath" echo " --mwt <VMESS-WS-TLS option> id@host:port:/wspath[,s=sni.com]"
echo " --twt <TROJAN-WS-TLS option> password@host:port:/wspath[,s=sni.com]" echo " --ttt <TROJAN-TCP-TLS option> password@host:port[,s=sni.com]"
echo " -d|--debug Start in debug mode with verbose output" echo " --twp <TROJAN-WS-PLN option> password@host:port:/wspath"
echo " -i|--stdin Read config from stdin instead of auto generation" echo " --twt <TROJAN-WS-TLS option> password@host:port:/wspath[,s=sni.com]"
echo " -j|--json '{"log":{"loglevel":"info"}' Json snippet to merge into the config" echo " -d|--debug Start in debug mode with verbose output"
echo " --dns <upstream-DNS-ip> Designated upstream DNS server IP, 1.1.1.1 will be applied by default" echo " -i|--stdin Read config from stdin instead of auto generation"
# echo " --dns-local <local-conf-file> Enable designated domain conf file. Like apple.china.conf" echo " -j|--json Json snippet to merge into the config. Say '{"log":{"loglevel":"info"}'"
echo " --dns-local-cn Enable China-accessible domains to be resolved in China" echo " --dns <upstream-DNS-ip> Designated upstream DNS server IP, 1.1.1.1 will be applied by default"
echo " --domain-direct <domain-rule> Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn" # echo " --dns-local <local-conf-file> Enable designated domain conf file. Like apple.china.conf"
echo " --domain-proxy <domain-rule> Add a domain rule for proxy routing, like twitter.com or geosite:google-cn" echo " --dns-local-cn Enable China-accessible domains to be resolved in China"
echo " --domain-block <domain-rule> Add a domain rule for block routing, like geosite:category-ads-all" echo " --domain-direct <domain-rule> Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn"
echo " --ip-direct <ip-rule> Add a ip-addr rule for direct routing, like 114.114.114.114/32 or geoip:cn" echo " --domain-proxy <domain-rule> Add a domain rule for proxy routing, like twitter.com or geosite:google-cn"
echo " --ip-proxy <ip-rule> Add a ip-addr rule for proxy routing, like 1.1.1.1/32 or geoip:netflix" echo " --domain-block <domain-rule> Add a domain rule for block routing, like geosite:category-ads-all"
echo " --ip-block <ip-rule> Add a ip-addr rule for block routing, like geoip:private" echo " --ip-direct <ip-rule> Add a ip-addr rule for direct routing, like 114.114.114.114/32 or geoip:cn"
echo " --cn-direct Add routing rules to avoid domains and IPs located in China being proxied" echo " --ip-proxy <ip-rule> Add a ip-addr rule for proxy routing, like 1.1.1.1/32 or geoip:netflix"
echo " --rules-path <rules-dir-path> Folder path contents geoip.dat, geosite.dat and other rule files" echo " --ip-block <ip-rule> Add a ip-addr rule for block routing, like geoip:private"
echo " --cn-direct Add routing rules to avoid domains and IPs located in China being proxied"
echo " --rules-path <rules-dir-path> Folder path contents geoip.dat, geosite.dat and other rule files"
} }
Jrules='{"rules":[]}' Jrules='{"rules":[]}'
TEMP=`getopt -o j:di --long lgp:,lgr:,lgt:,lsp:,lst:,ltr:,ltt:,lwp:,lwt:,mtt:,mwp:,mwt:,ttt:,twp:,twt:,stdin,debug,dns:,dns-local:,dns-local-cn,domain-direct:,domain-proxy:,domain-block:,ip-direct:,ip-proxy:,ip-block:,cn-direct,rules-path:json: -n "$0" -- $@` TEMP=`getopt -o j:di --long lgp:,lgr:,lgt:,lsp:,lst:,ltr:,ltrx:,ltt:,lttx:,lwp:,lwt:,mtt:,mwp:,mwt:,ttt:,twp:,twt:,stdin,debug,dns:,dns-local:,dns-local-cn,domain-direct:,domain-proxy:,domain-block:,ip-direct:,ip-proxy:,ip-block:,cn-direct,rules-path:json: -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
@@ -56,6 +58,18 @@ while true ; do
fi fi
shift 2 shift 2
;; ;;
# Alias options
--ltrx|--lttx)
subcmd=`echo $1|tr -d '\-\-'|tr -d x`
$DIR/proxy-${subcmd}.sh $2,xtls >$XCONF
if [ $? != 0 ]; then
echo "${subcmd} Config failed: $DIR/proxy-${subcmd}.sh $2"
exit 2
else
XRAYCFG=1
fi
shift 2
;;
--dns) --dns)
DNS=$2 DNS=$2
shift 2 shift 2