feat: enhance kick functionality with specific user kick and integration
This commit is contained in:
31
core/scripts/hysteria2/kickuser.sh
Normal file
31
core/scripts/hysteria2/kickuser.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
USERNAME="$1"
|
||||
|
||||
if [ -z "$USERNAME" ]; then
|
||||
echo "Usage: kickuser.sh <username>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source /etc/hysteria/core/scripts/path.sh
|
||||
|
||||
SECRET=$(jq -r '.trafficStats.secret' "$CONFIG_FILE")
|
||||
KICK_ENDPOINT="http://127.0.0.1:25413/kick"
|
||||
|
||||
if [ -z "$SECRET" ]; then
|
||||
echo "Error: Could not retrieve trafficStats secret from config.json"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Kicking user: $USERNAME"
|
||||
|
||||
curl -s -H "Authorization: $SECRET" -X POST -d "[\"$USERNAME\"]" "$KICK_ENDPOINT"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "User '$USERNAME' kicked successfully."
|
||||
else
|
||||
echo "Error kicking user '$USERNAME'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@ -24,5 +24,5 @@ remove_user() {
|
||||
echo -e "${red}Error:${NC} Config file $USERS_FILE not found."
|
||||
fi
|
||||
}
|
||||
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
|
||||
# python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
|
||||
remove_user "$1"
|
||||
|
||||
Reference in New Issue
Block a user