V0.0.4
[fix] 更正 README.MD 错误 [update] Dockerfile alpine 版本调整 [fix] entrypoint.sh 逻辑修正
This commit is contained in:
parent
1812cba147
commit
a4602771cb
@ -11,7 +11,7 @@ RUN apk add --no-cache git && git clone https://github.com/XTLS/Xray-core.git .
|
|||||||
go build -o xray /app/main/
|
go build -o xray /app/main/
|
||||||
|
|
||||||
# runner
|
# runner
|
||||||
FROM alpine:3.17 as runner
|
FROM alpine:latest as runner
|
||||||
|
|
||||||
|
|
||||||
ENV UUID=""
|
ENV UUID=""
|
||||||
|
|||||||
@ -12,7 +12,7 @@ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
|
|||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
ocker run -d --name xray_reality -p 443:443 wulabing/xray_docker_reality:0.0.1
|
docker run -d --name xray_reality --restart=always -p 443:443 wulabing/xray_docker_reality:0.0.1
|
||||||
```
|
```
|
||||||
|
|
||||||
查看日志获取配置信息
|
查看日志获取配置信息
|
||||||
|
|||||||
1
reality/SERVERNAMES.MD
Normal file
1
reality/SERVERNAMES.MD
Normal file
@ -0,0 +1 @@
|
|||||||
|
## 已知可用的 SERVERNAMES 及 DEST 列表
|
||||||
@ -1,55 +1,58 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
if [ -f /config_info.txt ]; then
|
||||||
if [ -z "$UUID" ]; then
|
echo "config.json exist"
|
||||||
|
cat /config_info.txt
|
||||||
|
else
|
||||||
|
if [ -z "$UUID" ]; then
|
||||||
echo "UUID is not set, generate random UUID "
|
echo "UUID is not set, generate random UUID "
|
||||||
UUID="$(uuidgen)"
|
UUID="$(uuidgen)"
|
||||||
echo "UUID: $UUID"
|
echo "UUID: $UUID"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$DEST" ]; then
|
if [ -z "$DEST" ]; then
|
||||||
echo "DEST is not set. default value www.apple.com:443"
|
echo "DEST is not set. default value www.apple.com:443"
|
||||||
DEST="www.apple.com:443"
|
DEST="www.apple.com:443"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$SERVERNAMES" ]; then
|
if [ -z "$SERVERNAMES" ]; then
|
||||||
echo "SERVERNAMES is not set. use default value [\"www.apple.com\",\"images.apple.com\"]"
|
echo "SERVERNAMES is not set. use default value [\"www.apple.com\",\"images.apple.com\"]"
|
||||||
SERVERNAMES="www.apple.com images.apple.com"
|
SERVERNAMES="www.apple.com images.apple.com"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$PRIVATEKEY" ]; then
|
if [ -z "$PRIVATEKEY" ]; then
|
||||||
echo "PRIVATEKEY is not set. generate new key"
|
echo "PRIVATEKEY is not set. generate new key"
|
||||||
/xray x25519 > /key
|
/xray x25519 >/key
|
||||||
PRIVATEKEY=$(cat /key | grep "Private" | awk -F ': ' '{print $2}')
|
PRIVATEKEY=$(cat /key | grep "Private" | awk -F ': ' '{print $2}')
|
||||||
PUBLICKEY=$(cat /key | grep "Public" | awk -F ': ' '{print $2}')
|
PUBLICKEY=$(cat /key | grep "Public" | awk -F ': ' '{print $2}')
|
||||||
echo "Private key: $PRIVATEKEY"
|
echo "Private key: $PRIVATEKEY"
|
||||||
echo "Public key: $PUBLICKEY"
|
echo "Public key: $PUBLICKEY"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$NETWORK" ]; then
|
if [ -z "$NETWORK" ]; then
|
||||||
echo "NETWORK is not set,set default value tcp"
|
echo "NETWORK is not set,set default value tcp"
|
||||||
NETWORK="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
|
||||||
fi
|
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
|
|
||||||
|
|
||||||
# config info with green color
|
# config info with green color
|
||||||
echo -e "\033[32m"
|
echo -e "\033[32m" >/config_info.txt
|
||||||
echo "UUID: $UUID"
|
echo "UUID: $UUID" >>/config_info.txt
|
||||||
echo "DEST: $DEST"
|
echo "DEST: $DEST" >>/config_info.txt
|
||||||
echo "SERVERNAMES: $SERVERNAMES (任选其一)"
|
echo "SERVERNAMES: $SERVERNAMES (任选其一)" >>/config_info.txt
|
||||||
echo "PRIVATEKEY: $PRIVATEKEY"
|
echo "PRIVATEKEY: $PRIVATEKEY" >>/config_info.txt
|
||||||
echo "PUBLICKEY: $PUBLICKEY"
|
echo "PUBLICKEY: $PUBLICKEY" >>/config_info.txt
|
||||||
echo "NETWORK: $NETWORK"
|
echo "NETWORK: $NETWORK" >>/config_info.txt
|
||||||
echo -e "\033[0m"
|
echo -e "\033[0m" >>/config_info.txt
|
||||||
|
|
||||||
# run xray
|
# run xray
|
||||||
/xray -config /config.json
|
exec /xray -config /config.json
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user