From d04fde6cc15ffdf1437dc1f4d95e0abd0ae5e7bc Mon Sep 17 00:00:00 2001 From: Evgeny Nerush Date: Tue, 24 Oct 2023 23:13:26 +0300 Subject: [PATCH] add minimal working prototype --- .gitignore | 2 +- ex.sh | 54 ++++------------ template_config_client.json | 122 ++++++++++++++++++++++++++++++++++++ template_config_server.json | 87 +++++++++++++++++++++++++ 4 files changed, 222 insertions(+), 43 deletions(-) create mode 100644 template_config_client.json create mode 100644 template_config_server.json diff --git a/.gitignore b/.gitignore index 7cdba5e..665f454 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -*config*.json +config*.json diff --git a/ex.sh b/ex.sh index 127f982..1251b01 100755 --- a/ex.sh +++ b/ex.sh @@ -85,22 +85,7 @@ to install xray${normal}" echo -e "${red}jq not installed, can't generate configs" exit 1 else - if curl -L https://raw.githubusercontent.com/XTLS/Xray-examples/main/VLESS-gRPC-REALITY/config_server.json > tmpconfig - then - cat tmpconfig > template_config_server.json - echo -e "${green}template server config downloaded${normal}" - else - echo -e "${red}can't download template server config, trying to use that have been downloaded before${normal}" - fi - if curl -L https://raw.githubusercontent.com/XTLS/Xray-examples/main/VLESS-gRPC-REALITY/config_client.json > tmpconfig - then - cat tmpconfig > template_config_client.json - echo -e "${green}template client config downloaded${normal}" - else - echo -e "${red}can't download template client config, trying to use that have been downloaded before${normal}" - fi - rm tmpconfig - echo -e "${bold}Enter domain name, IPv4 or IPv6 address of your xray server:${normal}" + echo -e "${bold}Enter IPv4 or IPv6 address of your xray server, or its domain name:${normal}" read address id=$(xray uuid) keys=$(xray x25519) @@ -163,24 +148,25 @@ or is in the same country. Better if it is popular. fake_site="www.yahoo.com" fi echo -e "${green}mimic ${fake_site}${normal}" - port=443 + port=80 + email="love@xray.com" clients=" [ { \"id\": \"${id}\", - \"email\": \"love@xray.com\", - \"flow\": \"xtls-rprx-vision\" + \"email\": \"${email}\", + \"flow\": \"\" } ]" serverRealitySettings=" { \"show\": false, - \"dest\": \"${fake_site}:${port}\", + \"dest\": \"${fake_site}:443\", \"xver\": 0, \"serverNames\": [ \"${fake_site}\" ], \"privateKey\": \"${private_key}\", \"shortIds\": [ \"${short_id}\" ] }" # make server config - cat template_config_server.json | jq ".inbounds[].port=${port} | .settings.clients=${clients} | .inbounds[].streamSettings.realitySettings=${serverRealitySettings}" > config_server.json + cat template_config_server.json | jq ".inbounds[].settings.clients=${clients} | .inbounds[].streamSettings.realitySettings=${serverRealitySettings}" > config_server.json vnext=" [ { @@ -190,40 +176,24 @@ or is in the same country. Better if it is popular. { \"id\": \"${id}\", \"alterId\": 0, - \"email\": \"love@xray.com\", + \"email\": \"${email}\", \"security\": \"auto\", \"encryption\": \"none\", - \"flow\": \"xtls-rprx-vision\" + \"flow\": \"\" } ] } ]" clientRealitySettings=" { - \"serverName\": \"${serverName}\", + \"serverName\": \"${fake_site}\", \"fingerprint\": \"chrome\", \"show\": false, - \"publicKey\": \"${publicKey}\", + \"publicKey\": \"${public_key}\", \"shortId\": \"${short_id}\", \"spiderX\": \"\" }" - rules=" [ - { - \"type\": \"field\", - \"domain\": [ \"domain:localhost\", \"domain:ru\", \"domain:su\", \"domain:by\", \"domain:cn\", \"domain:vk.com\" ], - \"outboundTag\": \"direct\" - }, - { - \"type\": \"field\", - \"inboundTag\": [\"api\"], - \"outboundTag\": \"api\", - \"enabled\": true - } - ]" # make main client config - #cat template_config_client.json | grep -v "\/\/ Server IPv4" | jq ".outbounds[].settings.vnext=${vnext} | .outbounds[].streamSettings.realitySettings=${clientRealitySettings} | .routing.rules=${rules}" > config_client.json - #cat template_config_client.json | grep -v "\/\/ Server IPv4" | jq "if .outbounds[].settings.vnext? then .outbounds[].settings.vnext=${vnext} else . end | if .outbounds[].streamSettings.realitySettings? then .outbounds[].streamSettings.realitySettings=${clientRealitySettings} else . end" > config_client.json - #cat template_config_client.json | grep -v "\/\/ Server IPv4" | jq ".outbounds[].settings=(if .settings.vnext? then ${vnext} else .settings end)" > config_client.json - cat template_config_client.json | grep -v "\/\/ Server IPv4" | jq ".outbounds |= map(if .settings.vnext then .settings.vnext=${vnext} else . end) | .outbounds[].streamSettings.realitySettings=${clientRealitySettings} | .routing.rules=${rules}" > config_client.json + cat template_config_client.json | jq ".outbounds |= map(if .settings.vnext then .settings.vnext=${vnext} else . end) | .outbounds |= map(if .streamSettings.realitySettings then .streamSettings.realitySettings=${clientRealitySettings} else . end)" > config_client.json fi fi diff --git a/template_config_client.json b/template_config_client.json new file mode 100644 index 0000000..605b4a6 --- /dev/null +++ b/template_config_client.json @@ -0,0 +1,122 @@ +{ + "log": { + "access": "", + "error": "", + "loglevel": "info" + }, + "inbounds": [ + { + "tag": "socks", + "port": 800, + "listen": "127.0.0.1", + "protocol": "socks", + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ], + "routeOnly": false + }, + "settings": { + "auth": "noauth", + "udp": true, + "allowTransparent": false + } + }, + { + "tag": "http", + "port": 801, + "listen": "127.0.0.1", + "protocol": "http", + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ], + "routeOnly": false + }, + "settings": { + "auth": "noauth", + "udp": true, + "allowTransparent": false + } + } + ], + "outbounds": [ + { + "tag": "proxy", + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "server_address", + "port": 80, + "users": [ + { + "id": "client_id", + "alterId": 0, + "email": "client_email", + "security": "auto", + "encryption": "none", + "flow": "" + } + ] + } + ] + }, + "streamSettings": { + "network": "grpc", + "security": "reality", + "realitySettings": { + "serverName": "www.yahoo.com", + "fingerprint": "chrome", + "show": false, + "publicKey": "public_key", + "shortId": "short_id", + "spiderX": "" + }, + "grpcSettings": { + "serviceName": "", + "multiMode": false, + "idle_timeout": 60, + "health_check_timeout": 20, + "permit_without_stream": false, + "initial_windows_size": 0 + } + }, + "mux": { + "enabled": false, + "concurrency": -1 + } + }, + { + "tag": "direct", + "protocol": "freedom", + "settings": {} + }, + { + "tag": "block", + "protocol": "blackhole", + "settings": { + "response": { + "type": "http" + } + } + } + ], + "routing": { + "domainStrategy": "AsIs", + "rules": [ + { + "type": "field", + "inboundTag": [ + "api" + ], + "outboundTag": "api", + "enabled": true + } + ] + } +} diff --git a/template_config_server.json b/template_config_server.json new file mode 100644 index 0000000..f1b8cc3 --- /dev/null +++ b/template_config_server.json @@ -0,0 +1,87 @@ +{ + "log": { + "access": "/var/log/xray/access.log", + "error": "/var/log/xray/error.log", + "loglevel": "info" + }, + "routing": { + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "type": "field", + "port": "80", + "network": "udp", + "outboundTag": "block" + }, + { + "type": "field", + "ip": [ + "geoip:private" + ], + "outboundTag": "block" + } + ] + }, + "inbounds": [ + { + "listen": "0.0.0.0", + "port": 80, + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "client_id", + "email": "client_email", + "flow": "" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "grpc", + "security": "reality", + "realitySettings": { + "show": false, + "dest": "www.yahoo.com:443", + "xver": 0, + "serverNames": [ + "www.yahoo.com" + ], + "privateKey": "private_key", + "shortIds": [ + "short_id" + ] + }, + "grpcSettings": { + "serviceName": "" + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls", + "quic" + ] + } + } + ], + "outbounds": [ + { + "protocol": "freedom", + "tag": "direct" + }, + { + "protocol": "blackhole", + "tag": "block" + } + ], + "policy": { + "levels": { + "0": { + "handshake": 2, + "connIdle": 120 + } + } + } +}