├── Dockerfile ├── README.md ├── conf.docker.sh ├── config.json ├── default.json ├── install.sh └── uninstall.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | LABEL maintainer="admin@samsesh.net" 4 | LABEL version="0.1" 5 | LABEL description="docker image for xray reality from https://github.com/sajjaddg/xray-reality" 6 | 7 | # Install dependencies 8 | RUN apt-get update && \ 9 | DEBIAN_FRONTEND=noninteractive apt-get install -y curl unzip jq openssl qrencode unzip tzdata && \ 10 | apt-get clean && \ 11 | rm -rf /var/lib/apt/lists/* 12 | 13 | # Set the timezone 14 | RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime && \ 15 | dpkg-reconfigure --frontend noninteractive tzdata 16 | 17 | # Install Xray-core 18 | RUN curl -L -H "Cache-Control: no-cache" -o /tmp/xray.zip https://github.com/XTLS/Xray-core/releases/download/v1.8.0/Xray-linux-64.zip && \ 19 | unzip /tmp/xray.zip -d /usr/bin/ && \ 20 | rm /tmp/xray.zip && \ 21 | chmod +x /usr/bin/xray 22 | #end 23 | 24 | #install xray-reality 25 | WORKDIR /root/ 26 | COPY ./conf.docker.sh ./install.sh 27 | RUN sh install.sh 28 | RUN qrencode -s 50 -o qr.png $(cat test.url) 29 | #end 30 | 31 | ENTRYPOINT ["tail", "-f", "/dev/null"] 32 | 33 | EXPOSE 443 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xray-reality 2 | This is a Bash script that installs Xray Beta and downloads the configuration for the repository created by [Teegrce](https://twitter.com/Teegrce) for Iran inside this repository with your own key and places it only with one command :) 3 | # 4 | ## Installation Guide 5 | just need you to run this command 6 | ``` 7 | bash -c "$(curl -L https://raw.githubusercontent.com/sajjaddg/xray-reality/master/install.sh)" 8 | ``` 9 | and it will do the rest for you. 10 | 11 | ## Uninstallation guide 12 | ``` 13 | bash -c "$(curl -L https://raw.githubusercontent.com/sajjaddg/xray-reality/master/uninstall.sh)" 14 | ``` 15 | 16 | ## Installation Guide with Docker 17 | 18 | 0. install docker 19 | ``` bash 20 | curl -fsSL https://get.docker.com | sh 21 | ``` 22 | 1. clone this project 23 | ``` bash 24 | git clone https://github.com/sajjaddg/xray-reality && cd xray-reality 25 | ``` 26 | 2. build docker image 27 | ``` bash 28 | docker build -t xrayreality . 29 | ``` 30 | 3. run 31 | ``` bash 32 | docker run -d --name xrayreality -p443:443 xrayreality 33 | ``` 34 | 4. get connection config : 35 | > get url 36 | ``` bash 37 | docker exec -it xrayreality cat /root/test.url 38 | ``` 39 | > view qrcode 40 | ``` bash 41 | docker exec -it xrayreality sh -c 'qrencode -s 120 -t ANSIUTF8 $(cat /root/test.url)' 42 | ``` 43 | ## how to manage ? 44 | > status : 45 | ``` bash 46 | docker ps -a | grep xrayreality 47 | ``` 48 | > stop : 49 | ``` bash 50 | docker stop xrayreality 51 | ``` 52 | > start : 53 | ``` bash 54 | docker stop xrayreality 55 | ``` 56 | >remove : 57 | ``` bash 58 | docker rm -f xrayreality 59 | ``` 60 | # 61 | ## Note 62 | 1. I have only tested it on Ubuntu 22 and wrote it for that system. Although I have the time and willingness to write it for other systems, I don't think I will need to do so unless I am forced to. 63 | 2. I used ChatGPT to translate my words. Please pardon any mistakes in the translation. 64 | 65 | ## ToDo 66 | - [ ] Add menu 67 | - [ ] test it on other OS and modify the script for them 68 | -------------------------------------------------------------------------------- /conf.docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | json=$(curl -s https://raw.githubusercontent.com/sajjaddg/xray-reality/master/config.json) 3 | 4 | keys=$(xray x25519) 5 | pk=$(echo "$keys" | awk '/Private key:/ {print $3}') 6 | pub=$(echo "$keys" | awk '/Public key:/ {print $3}') 7 | serverIp=$(curl -s ifconfig.me) 8 | uuid=$(xray uuid) 9 | shortId=$(openssl rand -hex 8) 10 | url="vless://$uuid@$serverIp:443?path=%2F&security=reality&encryption=none&pbk=$pub&fp=chrome&type=http&sni=yahoo.com&sid=$shortId#IRVLESS-REALITY-04" 11 | 12 | newJson=$(echo "$json" | jq \ 13 | --arg pk "$pk" \ 14 | --arg uuid "$uuid" \ 15 | '.inbounds[0].streamSettings.realitySettings.privateKey = $pk | 16 | .inbounds[0].settings.clients[0].id = $uuid | 17 | .inbounds[0].streamSettings.realitySettings.shortIds += ["'$shortId'"]') 18 | echo "$newJson" | sudo tee /usr/local/etc/xray/config.json >/dev/null 19 | 20 | sudo service xray restart 21 | 22 | 23 | echo "$url" >> /root/test.url 24 | 25 | exit 0 -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "api": { 3 | "tag": "api", 4 | "services": ["HandlerService", "LoggerService", "StatsService"] 5 | }, 6 | "stats": {}, 7 | "policy": { 8 | "levels": { 9 | "0": { 10 | "statsUserUplink": true, 11 | "statsUserDownlink": true 12 | } 13 | }, 14 | "system": { 15 | "statsInboundUplink": true, 16 | "statsInboundDownlink": true, 17 | "statsOutboundUplink": true, 18 | "statsOutboundDownlink": true 19 | } 20 | }, 21 | "dns": { 22 | "servers": [ 23 | "https+local://cloudflare-dns.com/dns-query", 24 | "1.1.1.1", 25 | "1.0.0.1", 26 | "8.8.8.8", 27 | "8.8.4.4", 28 | "localhost" 29 | ] 30 | }, 31 | "inbounds": [ 32 | { 33 | "listen": "0.0.0.0", 34 | "port": 0, 35 | "protocol": "vless", 36 | "settings": { 37 | "clients": [ 38 | { 39 | "email": "", 40 | "id": "", 41 | "flow": "" 42 | } 43 | ], 44 | "decryption": "none" 45 | }, 46 | "streamSettings": { 47 | "network": "h2", 48 | "security": "reality", 49 | "realitySettings": { 50 | "show": false, 51 | "dest": "", 52 | "xver": 0, 53 | "maxTimeDiff": 0, 54 | "minClientVer": "1.8.0", 55 | "serverNames": [], 56 | "privateKey": "", 57 | "shortIds": [] 58 | } 59 | }, 60 | "sniffing": { 61 | "enabled": true, 62 | "destOverride": ["http", "tls"] 63 | } 64 | }, 65 | { 66 | "listen": "127.0.0.1", 67 | "port": 10085, 68 | "protocol": "dokodemo-door", 69 | "settings": { 70 | "address": "127.0.0.1" 71 | }, 72 | "tag": "api" 73 | } 74 | ], 75 | 76 | "outbounds": [ 77 | { 78 | "protocol": "freedom", 79 | "tag": "direct" 80 | }, 81 | { 82 | "protocol": "blackhole", 83 | "tag": "blocked" 84 | } 85 | ], 86 | "routing": { 87 | "domainStrategy": "IPIfNonMatch", 88 | "rules": [ 89 | { 90 | "inboundTag": ["api"], 91 | "outboundTag": "api", 92 | "type": "field" 93 | }, 94 | { 95 | "domain": ["Samandehi.ir"], 96 | "type": "field", 97 | "outboundTag": "blocked" 98 | }, 99 | { 100 | "type": "field", 101 | "ip": ["geoip:ir", "geoip:private"], 102 | "outboundTag": "blocked" 103 | }, 104 | { 105 | "protocol": ["bittorrent"], 106 | "type": "field", 107 | "outboundTag": "blocked" 108 | } 109 | ] 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /default.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vless+tls+h2+reality", 3 | "email":"sajjaddg", 4 | "port": 8000, 5 | "sni": "www.openstreetmap.org", 6 | "path": "%2F" 7 | } 8 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Update package index and install dependencies 4 | sudo apt-get update 5 | sudo apt-get install -y jq openssl qrencode 6 | 7 | curl -s https://raw.githubusercontent.com/sajjaddg/xray-reality/master/default.json > config.json 8 | 9 | # Extract the desired variables using jq 10 | name=$(jq -r '.name' config.json) 11 | email=$(jq -r '.email' config.json) 12 | port=$(jq -r '.port' config.json) 13 | sni=$(jq -r '.sni' config.json) 14 | path=$(jq -r '.path' config.json) 15 | 16 | bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install --version v1.8.23 17 | 18 | json=$(curl -s https://raw.githubusercontent.com/sajjaddg/xray-reality/master/config.json) 19 | 20 | keys=$(xray x25519) 21 | pk=$(echo "$keys" | awk '/Private key:/ {print $3}') 22 | pub=$(echo "$keys" | awk '/Public key:/ {print $3}') 23 | serverIp=$(curl -s ipv4.wtfismyip.com/text) 24 | uuid=$(xray uuid) 25 | shortId=$(openssl rand -hex 8) 26 | 27 | url="vless://$uuid@$serverIp:$port?type=http&security=reality&encryption=none&pbk=$pub&fp=chrome&path=$path&sni=$sni&sid=$shortId#$name" 28 | 29 | newJson=$(echo "$json" | jq \ 30 | --arg pk "$pk" \ 31 | --arg uuid "$uuid" \ 32 | --arg port "$port" \ 33 | --arg sni "$sni" \ 34 | --arg path "$path" \ 35 | --arg email "$email" \ 36 | '.inbounds[0].port= '"$(expr "$port")"' | 37 | .inbounds[0].settings.clients[0].email = $email | 38 | .inbounds[0].settings.clients[0].id = $uuid | 39 | .inbounds[0].streamSettings.realitySettings.dest = $sni + ":443" | 40 | .inbounds[0].streamSettings.realitySettings.serverNames += ["'$sni'", "www.'$sni'"] | 41 | .inbounds[0].streamSettings.realitySettings.privateKey = $pk | 42 | .inbounds[0].streamSettings.realitySettings.shortIds += ["'$shortId'"]') 43 | 44 | echo "$newJson" | sudo tee /usr/local/etc/xray/config.json >/dev/null 45 | sudo systemctl restart xray 46 | 47 | echo "$url" 48 | 49 | qrencode -s 120 -t ANSIUTF8 "$url" 50 | qrencode -s 50 -o qr.png "$url" 51 | 52 | exit 0 53 | -------------------------------------------------------------------------------- /uninstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Stop the Xray service 4 | sudo systemctl stop xray 5 | 6 | # Remove the Xray binary 7 | sudo rm /usr/bin/xray 8 | 9 | # Remove the Xray configuration file 10 | sudo rm /etc/xray/config.json 11 | 12 | # Remove the Xray service file 13 | sudo rm /etc/systemd/system/xray.service 14 | 15 | # Reload the systemd daemon 16 | sudo systemctl daemon-reload 17 | 18 | # Remove any leftover Xray files or directories 19 | sudo rm -rf /var/log/xray /var/lib/xray 20 | --------------------------------------------------------------------------------