-
Notifications
You must be signed in to change notification settings - Fork 8
/
hysteria2.sh
85 lines (56 loc) · 1.72 KB
/
hysteria2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#echo "Please enter a domain:"
#read domain
#echo "You entered: $domain"
#
# Identify the primary network interface (regardless of wg status)
PRIMARY_NETWORK_INTERFACE=$(ip route | grep default | awk '{print $5}')
# Get the authentic public IP by querying Cloudflare's DNS server 1.1.1.1
AUTHENTIC_PUBLIC_IP=$(dig @1.1.1.1 whoami.cloudflare ch txt +short -b $(ip -4 addr show $PRIMARY_NETWORK_INTERFACE | grep -oP '(?<=inet\s)\d+(\.\d+){3}') | tr -d '"')
# Read user input for domain name
echo "Please enter a domain:"
read DOMAIN_INPUT
echo "You entered:"
echo "$DOMAIN_INPUT"
# Get the IP address of the entered domain
DOMAIN_IP=$(dig @1.1.1.1 $DOMAIN_INPUT +short)
# Check if the DOMAIN_IP matches the AUTHENTIC_PUBLIC_IP
if [ "$DOMAIN_IP" = "$AUTHENTIC_PUBLIC_IP" ]; then
# echo $DOMAIN_INPUT
echo $AUTHENTIC_PUBLIC_IP
echo "The domain IP matches the authentic public IP."
else
echo "The domain IP does not match the authentic public IP."
exit 1
fi
echo "Please enter a password:"
read PW_INPUT
if [ -z "$PW_INPUT" ]; then
echo "Warning: No password entered. Exiting."
exit 1
fi
echo "The entered password is:"
echo "$PW_INPUT"
bash <(curl -fsSL https://get.hy2.sh/)
net_card=$(ip addr | awk '/<BROADCAST,MULTICAST/{gsub(/:/,""); print $2}')
cat >/etc/hysteria/config.yaml<<EOF
listen: :50001
acme:
domains:
- $DOMAIN_INPUT
email: [email protected]
bandwidth:
up: 100 mbps
down: 50 mbps
auth:
type: password
password: $PW_INPUT
masquerade:
type: proxy
proxy:
url: https://www.apple.com/
rewriteHost: true
EOF
systemctl restart hysteria-server.service
systemctl enable hysteria-server.service
systemctl --no-pager status hysteria-server.service
cat /etc/hysteria/config.yaml