mirror of https://github.com/wulabing/Xray_onekey
纯IPv6 VPS支持 (#400)
* IPv6 Support * IPv6 Only VPS auto add DNS64 * IPv6 Only VPS auto add DNS64 * Optimize script * Update README.MDpull/386/head^2
parent
75df82cb8e
commit
4201762de8
|
@ -28,7 +28,7 @@ https://github.com/XTLS/Xray-core/issues/91
|
|||
- VLESS + TCP + TLS + Nginx + WebSocket
|
||||
|
||||
```
|
||||
wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontent.com/wulabing/Xray_onekey/nginx_forward/install.sh" && chmod +x install.sh && bash install.sh
|
||||
wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontents.com/wulabing/Xray_onekey/nginx_forward/install.sh" && chmod +x install.sh && bash install.sh
|
||||
```
|
||||
|
||||
### 安装/更新方式(Xray 前置)
|
||||
|
@ -40,7 +40,7 @@ wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontent.c
|
|||
- VLESS + TCP + XTLS / TLS + Nginx 及 VLESS + TCP + TLS + Nginx + WebSocket 回落并存模式
|
||||
|
||||
```
|
||||
wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontent.com/wulabing/Xray_onekey/main/install.sh" && chmod +x install.sh && bash install.sh
|
||||
wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontents.com/wulabing/Xray_onekey/main/install.sh" && chmod +x install.sh && bash install.sh
|
||||
```
|
||||
|
||||
|
||||
|
|
57
install.sh
57
install.sh
|
@ -85,11 +85,11 @@ function system_check() {
|
|||
if [[ "${ID}" == "centos" && ${VERSION_ID} -ge 7 ]]; then
|
||||
print_ok "当前系统为 Centos ${VERSION_ID} ${VERSION}"
|
||||
INS="yum install -y"
|
||||
wget -N -P /etc/yum.repos.d/ https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/basic/nginx.repo
|
||||
wget -N -P /etc/yum.repos.d/ https://raw.githubusercontents.com/wulabing/Xray_onekey/${github_branch}/basic/nginx.repo
|
||||
elif [[ "${ID}" == "ol" ]]; then
|
||||
print_ok "当前系统为 Oracle Linux ${VERSION_ID} ${VERSION}"
|
||||
INS="yum install -y"
|
||||
wget -N -P /etc/yum.repos.d/ https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/basic/nginx.repo
|
||||
wget -N -P /etc/yum.repos.d/ https://raw.githubusercontents.com/wulabing/Xray_onekey/${github_branch}/basic/nginx.repo
|
||||
elif [[ "${ID}" == "debian" && ${VERSION_ID} -ge 9 ]]; then
|
||||
print_ok "当前系统为 Debian ${VERSION_ID} ${VERSION}"
|
||||
INS="apt install -y"
|
||||
|
@ -195,7 +195,7 @@ function dependency_install() {
|
|||
${INS} jq
|
||||
|
||||
if ! command -v jq; then
|
||||
wget -P /usr/bin https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/binary/jq && chmod +x /usr/bin/jq
|
||||
wget -P /usr/bin https://raw.githubusercontents.com/wulabing/Xray_onekey/${github_branch}/binary/jq && chmod +x /usr/bin/jq
|
||||
judge "安装 jq"
|
||||
fi
|
||||
|
||||
|
@ -216,20 +216,37 @@ function basic_optimization() {
|
|||
setenforce 0
|
||||
fi
|
||||
}
|
||||
|
||||
function domain_check() {
|
||||
read -rp "请输入你的域名信息(eg: www.wulabing.com):" domain
|
||||
domain_ip=$(ping "${domain}" -c 1 | sed '1{s/[^(]*(//;s/).*//;q}')
|
||||
domain_ip=$(curl -sm8 ipget.net/?ip="${domain}")
|
||||
print_ok "正在获取 IP 地址信息,请耐心等待"
|
||||
local_ip=$(curl -4L api64.ipify.org)
|
||||
wgcfv4_status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
|
||||
wgcfv6_status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
|
||||
if [[ ${wgcfv4_status} =~ "on"|"plus" ]] || [[ ${wgcfv6_status} =~ "on"|"plus" ]]; then
|
||||
# 关闭wgcf-warp,以防误判VPS IP情况
|
||||
wg-quick down wgcf >/dev/null 2>&1
|
||||
fi
|
||||
local_ipv4=$(curl -s4m8 https://ip.gs)
|
||||
local_ipv6=$(curl -s6m8 https://ip.gs)
|
||||
if [[ -z ${local_ipv4} && -n ${local_ipv6} ]]; then
|
||||
# 纯IPv6 VPS,自动添加DNS64服务器以备acme.sh申请证书使用
|
||||
echo -e nameserver 2a01:4f8:c2c:123f::1 > /etc/resolv.conf
|
||||
judge "添加DNS64服务器"
|
||||
fi
|
||||
echo -e "域名通过 DNS 解析的 IP 地址:${domain_ip}"
|
||||
echo -e "本机公网 IP 地址: ${local_ip}"
|
||||
echo -e "本机公网 IPv4 地址: ${local_ipv4}"
|
||||
echo -e "本机公网 IPv6 地址: ${local_ipv6}"
|
||||
sleep 2
|
||||
if [[ ${domain_ip} == "${local_ip}" ]]; then
|
||||
print_ok "域名通过 DNS 解析的 IP 地址与 本机 IP 地址匹配"
|
||||
if [[ ${domain_ip} == "${local_ipv4}" ]]; then
|
||||
print_ok "域名通过 DNS 解析的 IP 地址与 本机 IPv4 地址匹配"
|
||||
sleep 2
|
||||
elif [[ ${domain_ip} == "${local_ipv6}" ]]; then
|
||||
print_ok "域名通过 DNS 解析的 IP 地址与 本机 IPv6 地址匹配"
|
||||
sleep 2
|
||||
else
|
||||
print_error "请确保域名添加了正确的 A 记录,否则将无法正常使用 xray"
|
||||
print_error "域名通过 DNS 解析的 IP 地址与 本机 IP 地址不匹配,是否继续安装?(y/n)" && read -r install
|
||||
print_error "请确保域名添加了正确的 A / AAAA 记录,否则将无法正常使用 xray"
|
||||
print_error "域名通过 DNS 解析的 IP 地址与 本机 IPv4 / IPv6 地址不匹配,是否继续安装?(y/n)" && read -r install
|
||||
case $install in
|
||||
[yY][eE][sS] | [yY])
|
||||
print_ok "继续安装"
|
||||
|
@ -258,13 +275,13 @@ function port_exist_check() {
|
|||
fi
|
||||
}
|
||||
function update_sh() {
|
||||
ol_version=$(curl -L -s https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/install.sh | grep "shell_version=" | head -1 | awk -F '=|"' '{print $3}')
|
||||
ol_version=$(curl -L -s https://raw.githubusercontents.com/wulabing/Xray_onekey/${github_branch}/install.sh | grep "shell_version=" | head -1 | awk -F '=|"' '{print $3}')
|
||||
if [[ "$shell_version" != "$(echo -e "$shell_version\n$ol_version" | sort -rV | head -1)" ]]; then
|
||||
print_ok "存在新版本,是否更新 [Y/N]?"
|
||||
read -r update_confirm
|
||||
case $update_confirm in
|
||||
[yY][eE][sS] | [yY])
|
||||
wget -N --no-check-certificate https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/install.sh
|
||||
wget -N --no-check-certificate https://raw.githubusercontents.com/wulabing/Xray_onekey/${github_branch}/install.sh
|
||||
print_ok "更新完成"
|
||||
print_ok "您可以通过 bash $0 执行本程序"
|
||||
exit 0
|
||||
|
@ -312,7 +329,7 @@ function modify_ws() {
|
|||
|
||||
function configure_nginx() {
|
||||
nginx_conf="/etc/nginx/conf.d/${domain}.conf"
|
||||
cd /etc/nginx/conf.d/ && rm -f ${domain}.conf && wget -O ${domain}.conf https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/config/web.conf
|
||||
cd /etc/nginx/conf.d/ && rm -f ${domain}.conf && wget -O ${domain}.conf https://raw.githubusercontents.com/wulabing/Xray_onekey/${github_branch}/config/web.conf
|
||||
sed -i "s/xxx/${domain}/g" ${nginx_conf}
|
||||
judge "Nginx 配置 修改"
|
||||
|
||||
|
@ -334,13 +351,13 @@ function modify_port() {
|
|||
}
|
||||
|
||||
function configure_xray() {
|
||||
cd /usr/local/etc/xray && rm -f config.json && wget -O config.json https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/config/xray_xtls-rprx-direct.json
|
||||
cd /usr/local/etc/xray && rm -f config.json && wget -O config.json https://raw.githubusercontents.com/wulabing/Xray_onekey/${github_branch}/config/xray_xtls-rprx-direct.json
|
||||
modify_UUID
|
||||
modify_port
|
||||
}
|
||||
|
||||
function configure_xray_ws() {
|
||||
cd /usr/local/etc/xray && rm -f config.json && wget -O config.json https://raw.githubusercontent.com/wulabing/Xray_onekey/${github_branch}/config/xray_tls_ws_mix-rprx-direct.json
|
||||
cd /usr/local/etc/xray && rm -f config.json && wget -O config.json https://raw.githubusercontents.com/wulabing/Xray_onekey/${github_branch}/config/xray_tls_ws_mix-rprx-direct.json
|
||||
modify_UUID
|
||||
modify_UUID_ws
|
||||
modify_port
|
||||
|
@ -384,10 +401,12 @@ function acme() {
|
|||
if "$HOME"/.acme.sh/acme.sh --installcert -d "${domain}" --fullchainpath /ssl/xray.crt --keypath /ssl/xray.key --reloadcmd "systemctl restart xray" --ecc --force; then
|
||||
print_ok "SSL 证书配置成功"
|
||||
sleep 2
|
||||
wg-quick up wgcf >/dev/null 2>&1
|
||||
fi
|
||||
else
|
||||
print_error "SSL 证书生成失败"
|
||||
rm -rf "$HOME/.acme.sh/${domain}_ecc"
|
||||
wg-quick up wgcf >/dev/null 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -434,7 +453,7 @@ function generate_certificate() {
|
|||
signedcert=$(xray tls cert -domain="$local_ip" -name="$local_ip" -org="$local_ip" -expire=87600h)
|
||||
echo $signedcert | jq '.certificate[]' | sed 's/\"//g' | tee $cert_dir/self_signed_cert.pem
|
||||
echo $signedcert | jq '.key[]' | sed 's/\"//g' >$cert_dir/self_signed_key.pem
|
||||
openssl x509 -in $cert_dir/self_signed_cert.pem -noout || 'print_error "生成自签名证书失败" && exit 1'
|
||||
openssl x509 -in $cert_dir/self_signed_cert.pem -noout || print_error "生成自签名证书失败" && exit 1
|
||||
print_ok "生成自签名证书成功"
|
||||
chown nobody.$cert_group $cert_dir/self_signed_cert.pem
|
||||
chown nobody.$cert_group $cert_dir/self_signed_key.pem
|
||||
|
@ -443,7 +462,7 @@ function generate_certificate() {
|
|||
function configure_web() {
|
||||
rm -rf /www/xray_web
|
||||
mkdir -p /www/xray_web
|
||||
wget -O web.tar.gz https://raw.githubusercontent.com/wulabing/Xray_onekey/main/basic/web.tar.gz
|
||||
wget -O web.tar.gz https://raw.githubusercontents.com/wulabing/Xray_onekey/main/basic/web.tar.gz
|
||||
tar xzf web.tar.gz -C /www/xray_web
|
||||
judge "站点伪装"
|
||||
rm -f web.tar.gz
|
||||
|
@ -590,7 +609,7 @@ function show_error_log() {
|
|||
|
||||
function bbr_boost_sh() {
|
||||
[ -f "tcp.sh" ] && rm -rf ./tcp.sh
|
||||
wget -N --no-check-certificate "https://raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
|
||||
wget -N --no-check-certificate "https://raw.githubusercontents.com/ylx2016/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
|
||||
}
|
||||
|
||||
function mtproxy_sh() {
|
||||
|
@ -742,4 +761,4 @@ menu() {
|
|||
;;
|
||||
esac
|
||||
}
|
||||
menu "$@"
|
||||
menu "$@"
|
Loading…
Reference in New Issue