Create masquerade
This commit is contained in:
36
core/scripts/hysteria2/masquerade.sh
Normal file
36
core/scripts/hysteria2/masquerade.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /etc/hysteria/core/scripts/path.sh
|
||||
|
||||
function is_masquerade_enabled() {
|
||||
if jq -e '.masquerade' $CONFIG_FILE > /dev/null; then
|
||||
echo "Masquerade is already enabled."
|
||||
exit 0
|
||||
else
|
||||
echo "Masquerade is not enabled."
|
||||
fi
|
||||
}
|
||||
|
||||
function enable_masquerade() {
|
||||
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
|
||||
echo "Masquerade enabled with URL: $url"
|
||||
}
|
||||
|
||||
function remove_masquerade() {
|
||||
jq 'del(.masquerade)' $CONFIG_FILE > tmp.json && mv tmp.json $CONFIG_FILE
|
||||
echo "Masquerade removed from config.json"
|
||||
}
|
||||
|
||||
if [[ "$1" == "1" ]]; then
|
||||
is_masquerade_enabled
|
||||
enable_masquerade "$2"
|
||||
elif [[ "$1" == "2" ]]; then
|
||||
is_masquerade_enabled
|
||||
remove_masquerade
|
||||
else
|
||||
echo "Usage: $0 {1|2} [domain]"
|
||||
echo "1: Enable Masquerade [domain]"
|
||||
echo "2: Remove Masquerade"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user