mirror of
https://github.com/EvgenyNerush/easy-xray.git
synced 2025-04-01 06:14:43 +03:00
add link command
This commit is contained in:
parent
c34cc12800
commit
19c136a860
1 changed files with 43 additions and 7 deletions
50
ex.sh
50
ex.sh
|
@ -478,6 +478,11 @@ then
|
||||||
|
|
||||||
elif [ $command = "del" ]
|
elif [ $command = "del" ]
|
||||||
then
|
then
|
||||||
|
if [ -v $2 ]
|
||||||
|
then
|
||||||
|
echo -e "${red}usernames not set${normal}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
check_command jq "needed for operations with configs"
|
check_command jq "needed for operations with configs"
|
||||||
if [ ! -f "./conf/config_server.json" ]
|
if [ ! -f "./conf/config_server.json" ]
|
||||||
then
|
then
|
||||||
|
@ -497,22 +502,50 @@ then
|
||||||
short_id=$(jq ".outbounds[0].streamSettings.realitySettings.shortId" $config)
|
short_id=$(jq ".outbounds[0].streamSettings.realitySettings.shortId" $config)
|
||||||
cp ./conf/config_server.json ./conf/tmpconfig.json
|
cp ./conf/config_server.json ./conf/tmpconfig.json
|
||||||
# update server config
|
# update server config
|
||||||
cat ./conf/tmpconfig.json | jq "del(.inbounds[1].settings.clients[] | select(.email == \"${username}@example.com\")) | del(.inbounds[1].streamSettings.realitySettings.shortIds[] | select(. == ${short_id}))" > ./conf/config_server.json
|
ok1=$(cat ./conf/tmpconfig.json | jq "del(.inbounds[1].settings.clients[] | select(.email == \"${username}@example.com\")) | del(.inbounds[1].streamSettings.realitySettings.shortIds[] | select(. == ${short_id}))" > ./conf/config_server.json)
|
||||||
rm ./conf/tmpconfig.json
|
rm ./conf/tmpconfig.json
|
||||||
# then make the user (not root) an owner of a file
|
# then make the user (not root) an owner of a file
|
||||||
[[ $SUDO_USER ]] && chown "$SUDO_USER:$SUDO_USER" ./conf/config_server.json
|
[[ $SUDO_USER ]] && chown "$SUDO_USER:$SUDO_USER" ./conf/config_server.json
|
||||||
rm config_client_${username}.json
|
ok2=$(rm ./conf/config_client_${username}.json)
|
||||||
|
if $ok1 && $ok2
|
||||||
|
then
|
||||||
echo -e "${green}config_client_${username}.json is deleted,
|
echo -e "${green}config_client_${username}.json is deleted,
|
||||||
config_server.json is updated${normal}"
|
config_server.json is updated${normal}"
|
||||||
|
else
|
||||||
|
echo -e "${red}something went wrong with username ${username}${normal}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
add
|
echo -e "Copy config to xray's dir and restart xray? (Y/n)"
|
||||||
push
|
read answer
|
||||||
|
if [ -v $answer ] || [ ${answer::1} != "n" ]
|
||||||
|
then
|
||||||
|
push
|
||||||
|
fi
|
||||||
|
|
||||||
elif [ $command = "push" ]
|
elif [ $command = "push" ]
|
||||||
then
|
then
|
||||||
push
|
push
|
||||||
|
|
||||||
|
elif [ $command = "link" ]
|
||||||
|
then
|
||||||
|
conf_file=$2
|
||||||
|
if [ -v $conf_file ]
|
||||||
|
then
|
||||||
|
echo -e "${red}no config is given${normal}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
id=$(strip_quotes $(jq ".outbounds[0].settings.vnext[0].users[0].id" $conf_file))
|
||||||
|
address=$(strip_quotes $(jq ".outbounds[0].settings.vnext[0].address" $conf_file))
|
||||||
|
port=$(jq ".outbounds[0].settings.vnext[0].port" $conf_file)
|
||||||
|
public_key=$(strip_quotes $(jq ".outbounds[0].streamSettings.realitySettings.publicKey" $conf_file))
|
||||||
|
server_name=$(strip_quotes $(jq ".outbounds[0].streamSettings.realitySettings.serverName" $conf_file))
|
||||||
|
short_id=$(strip_quotes $(jq ".outbounds[0].streamSettings.realitySettings.shortId" $conf_file))
|
||||||
|
link="vless://${id}@${address}:${port}?fragment=&security=reality&encryption=none&pbk=${public_key}&headerType=none&fp=chrome&type=tcp&flow=xtls-rprx-vision&sni=${server_name}&sid=${short_id}#easy-xray+%F0%9F%97%BD"
|
||||||
|
echo -e "${yellow}don't forget to share misc/customgeo4hiddify.txt as well
|
||||||
|
${green}here is your link:${normal}"
|
||||||
|
echo $link
|
||||||
|
|
||||||
elif [ $command = "stats" ]
|
elif [ $command = "stats" ]
|
||||||
then
|
then
|
||||||
client_stats_proxy_down=$(xray api stats -server=127.0.0.1:8080 -name "outbound>>>proxy>>>traffic>>>downlink" 2> /dev/null)
|
client_stats_proxy_down=$(xray api stats -server=127.0.0.1:8080 -name "outbound>>>proxy>>>traffic>>>downlink" 2> /dev/null)
|
||||||
|
@ -601,12 +634,15 @@ ${green}**** Hi, there! How to use: ****${normal}
|
||||||
Here is a list of all the commands available:
|
Here is a list of all the commands available:
|
||||||
|
|
||||||
${bold}help${normal} show this message (default)
|
${bold}help${normal} show this message (default)
|
||||||
${bold}install${normal} run interactive prompt, which asks to download and install
|
${bold}install${normal} run interactive prompt, which asks to download and
|
||||||
XRay and generate configs
|
install XRay, and generates configs
|
||||||
${bold}conf${normal} generate config files for server and clients
|
${bold}conf${normal} generate config files for server and clients
|
||||||
${bold}add ${underl}usernames${normal} add users with (any, fake) usernames to configs
|
${bold}add ${underl}usernames${normal} add users with given usernames to configs,
|
||||||
|
usernames should by separated by spaces
|
||||||
${bold}del ${underl}usernames${normal} delete users with given usernames from configs
|
${bold}del ${underl}usernames${normal} delete users with given usernames from configs
|
||||||
${bold}push${normal} copy config to xray's dir and restarts xray
|
${bold}push${normal} copy config to xray's dir and restarts xray
|
||||||
|
${bold}link ${underl}config${normal} convert user config to a link acceptable by
|
||||||
|
client applications such as Hiddify or V2ray
|
||||||
${bold}stats${normal} print some traffic statistics
|
${bold}stats${normal} print some traffic statistics
|
||||||
${bold}stats reset${normal} print statistics then set them to zero
|
${bold}stats reset${normal} print statistics then set them to zero
|
||||||
${bold}upgrade${normal} upgrade xray, do not touch configs
|
${bold}upgrade${normal} upgrade xray, do not touch configs
|
||||||
|
|
Loading…
Add table
Reference in a new issue