From 2d03dc5df98ab3c3146a1a4c05f8272857b51827 Mon Sep 17 00:00:00 2001 From: Samuel Huang Date: Mon, 30 Aug 2021 23:35:19 +1000 Subject: [PATCH] --rules-path support --- README.md | 37 ++++++++++++++++++++++--------------- run.sh | 31 ++++++++++++++++++------------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index bd4e79d..26aee43 100644 --- a/README.md +++ b/README.md @@ -30,18 +30,6 @@ Please replace "amd64" with the arch match the current box accordingly. Other su ```shell $ docker run --rm samuelhbne/proxy-xray proxy-xray - -i|--stdin [Optional] Read config from stdin instead of auto generation - -d|--debug [Optional] Start in debug mode with verbose output - --dns [Optional] Designated upstream DNS server IP, 1.1.1.1 will be applied by default - --dns-local [Optional] Enable designated domain conf file. Like apple.china.conf - --dns-local-cn [Optional] Enable China related domains to be resolved in China - --domain-direct [Optional] Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn - --domain-proxy [Optional] Add a domain rule for proxy routing, like twitter.com or geosite:google-cn - --domain-block [Optional] Add a domain rule for block routing, like geosite:category-ads-all - --ip-direct [Optional] Add a ip-addr rule for direct routing, like 114.114.114.114/32 or geoip:cn - --ip-proxy [Optional] Add a ip-addr rule for proxy routing, like 1.1.1.1/32 or geoip:netflix - --ip-block [Optional] Add a ip-addr rule for block routing, like geoip:private - --cn-direct [Optional] Add routing rules to avoid domains and IPs located in China being proxied --ltx id@host:port --ltt id@host:port --lttw id@host:port:/webpath @@ -50,6 +38,19 @@ proxy-xray --mttw id@host:port:/webpath --ttt password@host:port --tttw password@host:port:/webpath + -d|--debug [Optional] Start in debug mode with verbose output + -i|--stdin [Optional] Read config from stdin instead of auto generation + --dns [Optional] Designated upstream DNS server IP, 1.1.1.1 will be applied by default + --dns-local [Optional] Enable designated domain conf file. Like apple.china.conf + --dns-local-cn [Optional] Enable China-accessible domains to be resolved in China + --domain-direct [Optional] Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn + --domain-proxy [Optional] Add a domain rule for proxy routing, like twitter.com or geosite:google-cn + --domain-block [Optional] Add a domain rule for block routing, like geosite:category-ads-all + --ip-direct [Optional] Add a ip-addr rule for direct routing, like 114.114.114.114/32 or geoip:cn + --ip-proxy [Optional] Add a ip-addr rule for proxy routing, like 1.1.1.1/32 or geoip:netflix + --ip-block [Optional] Add a ip-addr rule for block routing, like geoip:private + --cn-direct [Optional] Add routing rules to avoid domains and IPs located in China being proxied + --rules-path [Optional] Folder path contents geoip.dat, geosite.dat and other rule files $ docker run --name proxy-xray -p 2080:1080 -p 2080:1080/udp -p 8223:8123 -p 65353:53/udp \ -d samuelhbne/proxy-xray --ltx myid@mydomain.duckdns.org:443 --cn-direct --dns-local-cn @@ -148,11 +149,17 @@ $ docker run --name proxy-xray -p 1080:1080 samuelhbne/proxy-xray \ ### 4. Connect to TCP+TLS+Trojan server -The following instruction connect to Xray server port 443 in TCP+TLS+Trojan mode with given password. +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 directed. ```shell -$ docker run --name proxy-xray -p 1080:1080 -d samuelhbne/proxy-xray \ ---ttt trojan_pass@mydomain.duckdns.org:8443 +$ mkdir -p /tmp/rules +$ cd /tmp/rules +$ wget -c -t3 -T30 https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.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 +$ docker run --name proxy-xray -p 1080:1080 -v /tmp/rules:/opt/rules -d samuelhbne/proxy-xray \ +--ttt trojan_pass@mydomain.duckdns.org:8443 \ +--rules-path /opt/rules --domain-direct ext:iran.dat:ir --ip-direct geoip:ir ``` ### 5. Start proxy-xray container in debug mode for for connection issue diagnosis diff --git a/run.sh b/run.sh index 41641ed..dd0da39 100755 --- a/run.sh +++ b/run.sh @@ -6,18 +6,6 @@ XCONF=/tmp/proxy-xray.json usage() { echo "proxy-xray " - echo " -i|--stdin [Optional] Read config from stdin instead of auto generation" - echo " -d|--debug [Optional] Start in debug mode with verbose output" - echo " --dns [Optional] Designated upstream DNS server IP, 1.1.1.1 will be applied by default" - echo " --dns-local [Optional] Enable designated domain conf file. Like apple.china.conf" - echo " --dns-local-cn [Optional] Enable China related domains to be resolved in China" - echo " --domain-direct [Optional] Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn" - echo " --domain-proxy [Optional] Add a domain rule for proxy routing, like twitter.com or geosite:google-cn" - echo " --domain-block [Optional] Add a domain rule for block routing, like geosite:category-ads-all" - echo " --ip-direct [Optional] Add a ip-addr rule for direct routing, like 114.114.114.114/32 or geoip:cn" - echo " --ip-proxy [Optional] Add a ip-addr rule for proxy routing, like 1.1.1.1/32 or geoip:netflix" - echo " --ip-block [Optional] Add a ip-addr rule for block routing, like geoip:private" - echo " --cn-direct [Optional] Add routing rules to avoid domains and IPs located in China being proxied" echo " --ltx id@host:port" echo " --ltt id@host:port" echo " --lttw id@host:port:/webpath" @@ -28,12 +16,25 @@ usage() { echo " --tttw password@host:port:/webpath" # echo " --ssa password:method@host:port" # echo " --sst password:method@host:port" + echo " -d|--debug [Optional] Start in debug mode with verbose output" + echo " -i|--stdin [Optional] Read config from stdin instead of auto generation" + echo " --dns [Optional] Designated upstream DNS server IP, 1.1.1.1 will be applied by default" + echo " --dns-local [Optional] Enable designated domain conf file. Like apple.china.conf" + echo " --dns-local-cn [Optional] Enable China-accessible domains to be resolved in China" + echo " --domain-direct [Optional] Add a domain rule for direct routing, likegeosite:geosite:geolocation-cn" + echo " --domain-proxy [Optional] Add a domain rule for proxy routing, like twitter.com or geosite:google-cn" + echo " --domain-block [Optional] Add a domain rule for block routing, like geosite:category-ads-all" + echo " --ip-direct [Optional] Add a ip-addr rule for direct routing, like 114.114.114.114/32 or geoip:cn" + echo " --ip-proxy [Optional] Add a ip-addr rule for proxy routing, like 1.1.1.1/32 or geoip:netflix" + echo " --ip-block [Optional] Add a ip-addr rule for block routing, like geoip:private" + echo " --cn-direct [Optional] Add routing rules to avoid domains and IPs located in China being proxied" + echo " --rules-path [Optional] Folder path contents geoip.dat, geosite.dat and other rule files" } Jrules='{"rules":[]}' -TEMP=`getopt -o di --long ltx:,ltt:,lttw:,lttg:,mtt:,mttw:,ttt:,tttw:,ssa:,sst:,dns:,dns-local:,dns-local-cn,domain-direct:,domain-proxy:,domain-block:,ip-direct:,ip-proxy:,ip-block:,cn-direct,stdin,debug -n "$0" -- $@` +TEMP=`getopt -o di --long ltx:,ltt:,lttw:,lttg:,mtt:,mttw:,ttt:,tttw:,ssa:,sst:,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 eval set -- "$TEMP" while true ; do @@ -107,6 +108,10 @@ while true ; do '.rules += [{"type":"field", "outboundTag":"block", "ip":[$blkip]}]'` shift 2 ;; + --rules-path) + export XRAY_LOCATION_ASSET=$2 + shift 2 + ;; -i|--stdin) STDINCONF=1 XRAY=1