From b737fead0c1a22b9e54d79c02760b66f0957aefc Mon Sep 17 00:00:00 2001 From: vincent Date: Sun, 11 Feb 2024 15:52:13 +0800 Subject: [PATCH] update --- .github/workflows/xray_docker_reality.yml | 49 ------------ README.md | 27 +++++++ {reality => conf}/config.json | 13 ++-- conf/key.txt | 2 + docker-compose.yml | 10 +++ get_share_link.sh | 30 ++++++++ reality/Dockerfile | 42 ----------- reality/README.MD_我的版本 | 2 - reality/SERVERNAMES.MD | 6 -- reality/build.sh | 3 - reality/entrypoint.sh | 92 ----------------------- 11 files changed, 75 insertions(+), 201 deletions(-) delete mode 100644 .github/workflows/xray_docker_reality.yml create mode 100644 README.md rename {reality => conf}/config.json (90%) create mode 100644 conf/key.txt create mode 100644 docker-compose.yml create mode 100644 get_share_link.sh delete mode 100644 reality/Dockerfile delete mode 100644 reality/README.MD_我的版本 delete mode 100644 reality/SERVERNAMES.MD delete mode 100644 reality/build.sh delete mode 100644 reality/entrypoint.sh diff --git a/.github/workflows/xray_docker_reality.yml b/.github/workflows/xray_docker_reality.yml deleted file mode 100644 index 475a679..0000000 --- a/.github/workflows/xray_docker_reality.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: xray_docker_reality_docker_image_build - -on: - workflow_dispatch: - push: - paths: - - 'reality/Dockerfile' - - '.github/workflows/xray_docker_reality.yml' - - 'reality/entrypoint.sh' - pull_request: - paths: - - 'reality/Dockerfile' - - '.github/workflows/xray_docker_reality.yml' - - 'reality/entrypoint.sh' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3.4.0 - - - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v2.5.0 - - - name: Docker Login - uses: docker/login-action@v2.1.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Extract first line of commit message - shell: bash - run: | - COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.sha }}) - FIRST_LINE=$(echo "$COMMIT_MESSAGE" | head -n1) - TAG_NAME=$(echo "$FIRST_LINE" | tr -d '[:space:]') # Remove spaces if needed - echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV - - - name: Build and push Docker image - uses: docker/build-push-action@v4.0.0 - with: - context: ./reality - file: ./reality/Dockerfile - platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 - tags: | - wulabing/xray_docker_reality:${{env.TAG_NAME}} - wulabing/xray_docker_reality:latest - push: true diff --git a/README.md b/README.md new file mode 100644 index 0000000..d6f0bc8 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# 说明 + +## 前提 +提前安装好以下软件 +- docker +- docker-compose +- jq - 用于查看json文件 +- qrencode - 用于生成二维码 + +## 启动和关闭 + +启动 +``` +docker-compose up -d +``` +关闭 +``` +docker-compose down +``` + + +## 查看分享链接 + +```` +bash get_share_link.sh +```` + diff --git a/reality/config.json b/conf/config.json similarity index 90% rename from reality/config.json rename to conf/config.json index 52f2b11..293d5d3 100644 --- a/reality/config.json +++ b/conf/config.json @@ -40,30 +40,30 @@ "inbounds": [ { "listen": "0.0.0.0", - "port": 443, + "port": 8003, "protocol": "vless", "settings": { "clients": [ { - "id": "xx", + "id": "d1872fe4-9a9e-442b-87c9-74c779c56476", "flow": "xtls-rprx-vision" } ], "decryption": "none" }, "streamSettings": { - "network": "xx", + "network": "tcp", "security": "reality", "realitySettings": { "show": true, - "dest": "xx", + "dest": "www.expedia.com:443", "xver": 0, "maxTimeDiff": 0, "minClientVer": "", "serverNames": [ - "xx" + "www.expedia.com" ], - "privateKey": "xx", + "privateKey": "UArrjC-9qLXdvIHFz0SH1jSZ1CGctYxHYKrHZEH5E3A", "shortIds": [ "" ] @@ -125,4 +125,3 @@ ] } } - diff --git a/conf/key.txt b/conf/key.txt new file mode 100644 index 0000000..20bf857 --- /dev/null +++ b/conf/key.txt @@ -0,0 +1,2 @@ +Private key: UArrjC-9qLXdvIHFz0SH1jSZ1CGctYxHYKrHZEH5E3A +Public key: Z-HcL71ZNbPshcMUdNK4pC0XkbS6vjRB8fTQQUsIEV4 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fb09b4b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.9' + +services: + xray: + image: teddysun/xray + restart: always + container_name: xray + network_mode: "host" + volumes: + - './conf:/etc/xray' diff --git a/get_share_link.sh b/get_share_link.sh new file mode 100644 index 0000000..7bcf821 --- /dev/null +++ b/get_share_link.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +IPV4=$(curl -4 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null") +UUID=$(jq -r '.inbounds[0].settings.clients[0].id' ./conf/config.json) +PORT=$(jq -r '.inbounds[0].port' ./conf/config.json) +DEST=$(jq -r '.inbounds[0].streamSettings.realitySettings.dest' ./conf/config.json) +NETWORK="tcp" +PRIVATE_KEY=$(cat ./confkey.txt | grep "Private " | awk -F ': ' '{print $2}') +PUBLIC_KEY=$(cat ./conf/key.txt | grep "Public" | awk -F ': ' '{print $2}') +FIRST_SERVERNAME=$(echo $SERVERNAMES | awk '{print $1}') + +# config info with green color +echo -e "\033[32m" +echo "IPV4: $IPV4" +echo "UUID: $UUID" +echo "DEST: $DEST" +echo "PORT: $PORT" +echo "PUBLIC_KEY: $PUBLIC_KEY" +echo "NETWORK: $NETWORK" +if [ "$IPV4" != "null" ]; then + SUB_IPV4="vless://$UUID@$IPV4:$PORT?encryption=none&security=reality&type=$NETWORK&sni=$FIRST_SERVERNAME&fp=chrome&pbk=$PUBLIC_KEY&flow=xtls-rprx-vision#wulabing_docker_vless_reality_vision" + echo "IPV4 订阅连接: $SUB_IPV4" + echo -e "IPV4 订阅二维码:\n$(echo "$SUB_IPV4" | qrencode -o - -t UTF8)" +fi + +echo -e "\033[0m" + + + + diff --git a/reality/Dockerfile b/reality/Dockerfile deleted file mode 100644 index 9121a20..0000000 --- a/reality/Dockerfile +++ /dev/null @@ -1,42 +0,0 @@ -# builder -FROM golang:alpine as builder -LABEL maintainer="wulabing " - - -#ENV GOPROXY=https://goproxy.cn,direct -WORKDIR /app - -RUN apk add --no-cache git && git clone https://github.com/XTLS/Xray-core.git . && \ - go mod download && \ - go build -o xray /app/main/ - -# runner -FROM alpine:latest as runner - - -ENV UUID="" -ENV DEST="" -ENV SERVERNAMES="" -ENV PRIVATEKEY="" -ENV SHORTIDS="" -ENV NETWORK="" -ENV INTERNAL_PORT="" -ENV HOSTMODE_PORT="" -ENV TZ=Asia/Shanghai - -WORKDIR / - -COPY ./entrypoint.sh / -COPY ./config.json / - -COPY --from=builder /app/xray / - -RUN apk add --no-cache tzdata ca-certificates jq curl libqrencode && \ - mkdir -p /var/log/xray &&\ - wget -O /geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat && \ - wget -O /geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat && \ - chmod +x /entrypoint.sh - - -ENTRYPOINT ["./entrypoint.sh"] -EXPOSE 443 \ No newline at end of file diff --git a/reality/README.MD_我的版本 b/reality/README.MD_我的版本 deleted file mode 100644 index 9efd135..0000000 --- a/reality/README.MD_我的版本 +++ /dev/null @@ -1,2 +0,0 @@ -打包镜像执行build.sh -bash build.sh diff --git a/reality/SERVERNAMES.MD b/reality/SERVERNAMES.MD deleted file mode 100644 index 093fd25..0000000 --- a/reality/SERVERNAMES.MD +++ /dev/null @@ -1,6 +0,0 @@ -## 已知可用的 SERVERNAMES 及 DEST 列表 - -| DEST | SERVERMANES | 说明 | -|-------------------|--------------------------------|------------------------------------| -| www.apple.com:443 | images.apple.com www.apple.com | Apple 使用了 akamai CDN,全球各地存在节点,并且知名 | - \ No newline at end of file diff --git a/reality/build.sh b/reality/build.sh deleted file mode 100644 index 1669151..0000000 --- a/reality/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -docker pull golang:alpine -docker build -t vincent/xray_docker_reality:0.0.1 . - diff --git a/reality/entrypoint.sh b/reality/entrypoint.sh deleted file mode 100644 index b7c227f..0000000 --- a/reality/entrypoint.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -if [ -f /config_info.txt ]; then - echo "config.json exist" -else - IPV6=$(curl -6 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null") - IPV4=$(curl -4 -sSL --connect-timeout 3 --retry 2 ip.sb || echo "null") - if [ -z "$UUID" ]; then - echo "UUID is not set, generate random UUID " - UUID="$(/xray uuid)" - echo "UUID: $UUID" - fi - - if [ -z "$EXTERNAL_PORT" ]; then - echo "EXTERNAL_PORT is not set, use default value 443" - EXTERNAL_PORT=443 - fi - - if [ -n "$HOSTMODE_PORT" ];then - EXTERNAL_PORT=$HOSTMODE_PORT - jq ".inbounds[0].port=$HOSTMODE_PORT" /config.json >/config.json_tmp && mv /config.json_tmp /config.json - fi - - if [ -z "$DEST" ]; then - echo "DEST is not set. default value www.apple.com:443" - DEST="www.apple.com:443" - fi - - if [ -z "$SERVERNAMES" ]; then - echo "SERVERNAMES is not set. use default value [\"www.apple.com\",\"images.apple.com\"]" - SERVERNAMES="www.apple.com images.apple.com" - fi - - if [ -z "$PRIVATEKEY" ]; then - echo "PRIVATEKEY is not set. generate new key" - /xray x25519 >/key - PRIVATEKEY=$(cat /key | grep "Private" | awk -F ': ' '{print $2}') - PUBLICKEY=$(cat /key | grep "Public" | awk -F ': ' '{print $2}') - echo "Private key: $PRIVATEKEY" - echo "Public key: $PUBLICKEY" - fi - - if [ -z "$NETWORK" ]; then - echo "NETWORK is not set,set default value tcp" - NETWORK="tcp" - fi - - # change config - jq ".inbounds[0].settings.clients[0].id=\"$UUID\"" /config.json >/config.json_tmp && mv /config.json_tmp /config.json - jq ".inbounds[0].streamSettings.realitySettings.dest=\"$DEST\"" /config.json >/config.json_tmp && mv /config.json_tmp /config.json - - SERVERNAMES_JSON_ARRAY="$(echo "[$(echo $SERVERNAMES | awk '{for(i=1;i<=NF;i++) printf "\"%s\",", $i}' | sed 's/,$//')]")" - jq --argjson serverNames "$SERVERNAMES_JSON_ARRAY" '.inbounds[0].streamSettings.realitySettings.serverNames = $serverNames' /config.json >/config.json_tmp && mv /config.json_tmp /config.json - - jq ".inbounds[0].streamSettings.realitySettings.privateKey=\"$PRIVATEKEY\"" /config.json >/config.json_tmp && mv /config.json_tmp /config.json - jq ".inbounds[0].streamSettings.network=\"$NETWORK\"" /config.json >/config.json_tmp && mv /config.json_tmp /config.json - - - - - FIRST_SERVERNAME=$(echo $SERVERNAMES | awk '{print $1}') - # config info with green color - echo -e "\033[32m" >/config_info.txt - echo "IPV6: $IPV6" >>/config_info.txt - echo "IPV4: $IPV4" >>/config_info.txt - echo "UUID: $UUID" >>/config_info.txt - echo "DEST: $DEST" >>/config_info.txt - echo "PORT: $EXTERNAL_PORT" >>/config_info.txt - echo "SERVERNAMES: $SERVERNAMES (任选其一)" >>/config_info.txt - echo "PRIVATEKEY: $PRIVATEKEY" >>/config_info.txt - echo "PUBLICKEY: $PUBLICKEY" >>/config_info.txt - echo "NETWORK: $NETWORK" >>/config_info.txt - if [ "$IPV4" != "null" ]; then - SUB_IPV4="vless://$UUID@$IPV4:$EXTERNAL_PORT?encryption=none&security=reality&type=$NETWORK&sni=$FIRST_SERVERNAME&fp=chrome&pbk=$PUBLICKEY&flow=xtls-rprx-vision#wulabing_docker_vless_reality_vision" - echo "IPV4 订阅连接: $SUB_IPV4" >>/config_info.txt - echo -e "IPV4 订阅二维码:\n$(echo "$SUB_IPV4" | qrencode -o - -t UTF8)" >>/config_info.txt - fi - if [ "$IPV6" != "null" ];then - SUB_IPV6="vless://$UUID@$IPV6:$EXTERNAL_PORT?encryption=none&security=reality&type=$NETWORK&sni=$FIRST_SERVERNAME&fp=chrome&pbk=$PUBLICKEY&flow=xtls-rprx-vision#wulabing_docker_vless_reality_vision" - echo "IPV6 订阅连接: $SUB_IPV6" >>/config_info.txt - echo -e "IPV6 订阅二维码:\n$(echo "$SUB_IPV6" | qrencode -o - -t UTF8)" >>/config_info.txt - fi - - - echo -e "\033[0m" >>/config_info.txt - -fi - -# show config info -cat /config_info.txt - -# run xray -exec /xray -config /config.json