Accurately check
This commit is contained in:
@ -1,17 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /etc/hysteria/core/scripts/path.sh
|
source /etc/hysteria/core/scripts/path.sh
|
||||||
|
|
||||||
function is_masquerade_enabled() {
|
function is_masquerade_enabled() {
|
||||||
if jq -e '.masquerade' $CONFIG_FILE > /dev/null; then
|
jq -e '.masquerade' $CONFIG_FILE > /dev/null 2>&1
|
||||||
echo "Masquerade is already enabled."
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Masquerade is not enabled."
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function enable_masquerade() {
|
function enable_masquerade() {
|
||||||
|
if is_masquerade_enabled; then
|
||||||
|
echo "Masquerade is already enabled."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
url="https://$1"
|
url="https://$1"
|
||||||
jq --arg url "$url" '. + {masquerade: {type: "proxy", proxy: {url: $url, rewriteHost: true}, listenHTTP: ":80", listenHTTPS: ":443", forceHTTPS: true}}' $CONFIG_FILE > tmp.json && mv tmp.json $CONFIG_FILE
|
jq --arg url "$url" '. + {masquerade: {type: "proxy", proxy: {url: $url, rewriteHost: true}, listenHTTP: ":80", listenHTTPS: ":443", forceHTTPS: true}}' $CONFIG_FILE > tmp.json && mv tmp.json $CONFIG_FILE
|
||||||
echo "Masquerade enabled with URL: $url"
|
echo "Masquerade enabled with URL: $url"
|
||||||
@ -19,16 +17,18 @@ function enable_masquerade() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function remove_masquerade() {
|
function remove_masquerade() {
|
||||||
|
if ! is_masquerade_enabled; then
|
||||||
|
echo "Masquerade is not enabled."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
jq 'del(.masquerade)' $CONFIG_FILE > tmp.json && mv tmp.json $CONFIG_FILE
|
jq 'del(.masquerade)' $CONFIG_FILE > tmp.json && mv tmp.json $CONFIG_FILE
|
||||||
echo "Masquerade removed from config.json"
|
echo "Masquerade removed from config.json"
|
||||||
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
|
python3 "$CLI_PATH" restart-hysteria2 > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$1" == "1" ]]; then
|
if [[ "$1" == "1" ]]; then
|
||||||
is_masquerade_enabled
|
|
||||||
enable_masquerade "$2"
|
enable_masquerade "$2"
|
||||||
elif [[ "$1" == "2" ]]; then
|
elif [[ "$1" == "2" ]]; then
|
||||||
is_masquerade_enabled
|
|
||||||
remove_masquerade
|
remove_masquerade
|
||||||
else
|
else
|
||||||
echo "Usage: $0 {1|2} [domain]"
|
echo "Usage: $0 {1|2} [domain]"
|
||||||
|
|||||||
Reference in New Issue
Block a user