Created
November 24, 2023 19:13
-
-
Save SaeedDev94/6df60dbdd7181ae65cf45ec048f0e57d to your computer and use it in GitHub Desktop.
Refresh reality params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
XRAY="/usr/local/bin/xray" | |
SERVER="/usr/local/etc/xray/config.json" | |
BUFFER=$(mktemp) | |
UUID=$($XRAY uuid) | |
KEYS=$($XRAY x25519) | |
SHORT=$(openssl rand -hex 8) | |
PRIVATE_LABEL="Private key: " | |
PUBLIC_LABEL="Public key: " | |
readarray -t LINES <<< "$KEYS" | |
PRIVATE_TXT=${LINES[0]} | |
PUBLIC_TXT=${LINES[1]} | |
PRIVATE="${PRIVATE_TXT//$PRIVATE_LABEL/}" | |
PUBLIC="${PUBLIC_TXT//$PUBLIC_LABEL/}" | |
serverConfig() { | |
local SELECTOR="$1" | |
local VALUE="$2" | |
jq --arg VALUE "$VALUE" "$SELECTOR" "$SERVER" > "$BUFFER" && mv "$BUFFER" "$SERVER" | |
} | |
serverConfig '.inbounds[0].settings.clients[0].id = $VALUE' "$UUID" | |
serverConfig '.inbounds[0].streamSettings.realitySettings.privateKey = $VALUE' "$PRIVATE" | |
serverConfig '.inbounds[0].streamSettings.realitySettings.shortIds[0] = $VALUE' "$SHORT" | |
# Print client params | |
echo $UUID | |
echo $PUBLIC | |
echo $SHORT | |
# Restart xray service | |
service xray restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment