forked from yeahwu/v2ray-wss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hy2.sh
100 lines (87 loc) · 2.61 KB
/
hy2.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
# forum: https://1024.day
if [[ $EUID -ne 0 ]]; then
clear
echo "Error: This script must be run as root!" 1>&2
exit 1
fi
timedatectl set-timezone Asia/Shanghai
hyPasswd=$(cat /proc/sys/kernel/random/uuid)
getPort=$(shuf -i 2000-65000 -n 1)
getIP(){
local serverIP=
serverIP=$(curl -s -4 http://www.cloudflare.com/cdn-cgi/trace | grep "ip" | awk -F "[=]" '{print $2}')
if [[ -z "${serverIP}" ]]; then
serverIP=$(curl -s -6 http://www.cloudflare.com/cdn-cgi/trace | grep "ip" | awk -F "[=]" '{print $2}')
fi
echo "${serverIP}"
}
install_hy2(){
if [ -f "/usr/bin/apt-get" ]; then
apt-get update -y && apt-get upgrade -y
apt-get install -y gawk curl
else
yum update -y && yum upgrade -y
yum install -y epel-release
yum install -y gawk curl
fi
bash <(curl -fsSL https://get.hy2.sh/)
mkdir -p /etc/hysteria/
openssl req -x509 -nodes -newkey ec:<(openssl ecparam -name prime256v1) -keyout /etc/hysteria/server.key -out /etc/hysteria/server.crt -subj "/CN=bing.com" -days 36500 && chown hysteria /etc/hysteria/server.key && chown hysteria /etc/hysteria/server.crt
cat >/etc/hysteria/config.yaml <<EOF
listen: :$getPort
tls:
cert: /etc/hysteria/server.crt
key: /etc/hysteria/server.key
auth:
type: password
password: $hyPasswd
masquerade:
type: proxy
proxy:
url: https://bing.com
rewriteHost: true
quic:
initStreamReceiveWindow: 26843545
maxStreamReceiveWindow: 26843545
initConnReceiveWindow: 67108864
maxConnReceiveWindow: 67108864
EOF
systemctl enable hysteria-server.service && systemctl restart hysteria-server.service && systemctl status --no-pager hysteria-server.service
rm -f tcp-wss.sh hy2.sh
cat >/etc/hysteria/hyclient.json<<EOF
{
===========配置参数=============
代理模式:Hysteria2
地址:$(getIP)
端口:${getPort}
密码:${hyPasswd}
SNI:bing.com
传输协议:tls
跳过证书验证:ture
====================================
hysteria2://$(echo -n "${hyPasswd}@$(getIP):${getPort}/?insecure=1&sni=bing.com#1024-Hysteria2")
}
EOF
clear
}
client_hy2(){
hylink=$(echo -n "${hyPasswd}@$(getIP):${getPort}/?insecure=1&sni=bing.com#1024-Hysteria2")
echo
echo "安装已经完成"
echo
echo "===========Hysteria2配置参数============"
echo
echo "地址:$(getIP)"
echo "端口:${getPort}"
echo "密码:${hyPasswd}"
echo "SNI:bing.com"
echo "传输协议:tls"
echo "打开跳过证书验证,true"
echo
echo "========================================="
echo "hysteria2://${hylink}"
echo
}
install_hy2
client_hy2