Skip to content
This repository was archived by the owner on Aug 22, 2021. It is now read-only.

Commit 7719ead

Browse files
committed
cert issuing; remove ipv4 check
1 parent f8d6884 commit 7719ead

File tree

1 file changed

+27
-81
lines changed

1 file changed

+27
-81
lines changed

src/v2gun.sh

Lines changed: 27 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export LANG=en_US
44
export LANGUAGE=en_US.UTF-8
55

66
branch="vless"
7-
VERSION="2.1.6"
7+
VERSION="2.1.7"
88

99
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
1010
sudoCmd="sudo"
@@ -188,22 +188,6 @@ show_links() {
188188
fi
189189
}
190190

191-
test_ipv4_conn() {
192-
local res=$(curl -L -s -w "%{http_code}" https://raw.githubusercontent.com/phlinhng/v2ray-tcp-tls-web/vless/LICENSE -o /dev/null)
193-
if [[ ${res} != "200" ]];then
194-
colorEcho ${YELLOW} "Can't access githubusercontent, try NAT64"
195-
${sudoCmd} $(which cp) /etc/resolv.conf /etc/resolv.conf.bak
196-
${sudoCmd} $(which rm) -rf /etc/resolv.conf
197-
${sudoCmd} chattr -i /etc/resolv.conf 2>/dev/null
198-
echo "nameserver 2a01:4f8:c2c:123f::1" | ${sudoCmd} tee -a /etc/resolv.conf
199-
echo "nameserver 2a01:4f9:c010:3f02::1" | ${sudoCmd} tee -a /etc/resolv.conf
200-
echo "nameserver 2a00:1098:2b::1" | ${sudoCmd} tee -a /etc/resolv.conf
201-
echo "nameserver 2a00:1098:2c::1" | ${sudoCmd} tee -a /etc/resolv.conf
202-
${sudoCmd} chattr +i /etc/resolv.conf
203-
colorEcho ${BLUE} "Nameserver successfully changed. The original settings was backuped as /etc/resolv.conf.bak"
204-
fi
205-
}
206-
207191
preinstall() {
208192
# turning off selinux
209193
${sudoCmd} setenforce 0 2>/dev/null
@@ -221,45 +205,31 @@ preinstall() {
221205

222206
${sudoCmd} ${PACKAGE_MANAGEMENT_INSTALL} jq -y
223207

224-
test_ipv4_conn
225-
226208
# install jq mannualy if the package management didn't
227209
if [[ ! "$(command -v jq)" ]]; then
228210
echo "Fetching jq failed, trying manual installation"
229211
${sudoCmd} curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -o /usr/bin/jq
230212
${sudoCmd} $(which chmod) +x /usr/bin/jq
231213
fi
232-
}
233214

234-
get_acmesh() {
235-
colorEcho ${BLUE} "Installing acme.sh"
236215
curl -fsSL https://get.acme.sh | bash
237216
}
238217

239-
get_cert() {
218+
get_cert_standalone() {
219+
# use standalone mode to issue cert
240220
colorEcho ${BLUE} "Issuing certificate"
241-
~/.acme.sh/acme.sh --issue -d "$1" -w /var/www/html --keylength ec-256
242-
243-
# install certificate
244-
colorEcho ${BLUE} "Installing certificate"
245-
${sudoCmd} ~/.acme.sh/acme.sh --install-cert --ecc --force -d "$1" \
246-
--key-file /etc/ssl/v2ray/key.pem --fullchain-file /etc/ssl/v2ray/fullchain.pem \
247-
--reloadcmd "chmod 644 /etc/ssl/v2ray/fullchain.pem; chmod 644 /etc/ssl/v2ray/key.pem; systemctl restart v2ray"
221+
${sudoCmd} /root/.acme.sh/acme.sh --issue -d "$1" --standalone --keylength ec-256
248222
}
249223

250-
get_cert_alt() {
251-
# use standalone mode to issue cert
252-
${sudoCmd} stop caddy 2>/dev/null
224+
get_cert() {
253225
colorEcho ${BLUE} "Issuing certificate"
254-
${sudoCmd} /root/.acme.sh/acme.sh --issue -d "$1" --standalone --keylength ec-256
226+
~/.acme.sh/acme.sh --issue -d "$1" -w /var/www/html --keylength ec-256
255227

256228
# install certificate
257229
colorEcho ${BLUE} "Installing certificate"
258-
${sudoCmd} /root/.acme.sh/acme.sh --install-cert --ecc -d "$1" \
230+
${sudoCmd} ~/.acme.sh/acme.sh --install-cert --ecc --force -d "$1" \
259231
--key-file /etc/ssl/v2ray/key.pem --fullchain-file /etc/ssl/v2ray/fullchain.pem \
260232
--reloadcmd "chmod 644 /etc/ssl/v2ray/fullchain.pem; chmod 644 /etc/ssl/v2ray/key.pem; systemctl restart v2ray"
261-
262-
${sudoCmd} restart caddy 2>/dev/null
263233
}
264234

265235
get_trojan() {
@@ -744,44 +714,37 @@ fix_cert() {
744714

745715
local uuid="$(read_json /usr/local/etc/v2ray/05_inbounds_vless.json '.inbounds[0].settings.clients[0].id')"
746716
local path="$(read_json /usr/local/etc/v2ray/05_inbounds_ss.json '.inbounds[0].streamSettings.wsSettings.path')"
717+
local cf_node="$(read_json /usr/local/etc/v2ray/05_inbounds_ss.json '.inbounds[0].tag')"
718+
719+
~/.acme.sh/acme.sh --remove -d $(read_json /usr/local/etc/v2ray/05_inbounds_vless.json '.inbounds[0].tag')_ecc --ecc
720+
${sudoCmd} $(which rm) -rf ~/.acme.sh/$(read_json /usr/local/etc/v2ray/05_inbounds_vless.json '.inbounds[0].tag')_ecc
747721

748-
${sudoCmd} $(which rm) -f /root/.acme.sh/$(read_json /usr/local/etc/v2ray/05_inbounds_vless.json '.inbounds[0].tag')_ecc/$(read_json /usr/local/etc/v2ray/05_inbounds_vless.json '.inbounds[0].tag').key
722+
colorEcho ${BLUE} "Re-setting v2ray"
723+
set_v2ray "${uuid}" "${path}" "${V2_DOMAIN}" "${cf_node}"
749724

750725
colorEcho ${BLUE} "Re-setting caddy"
751726
set_caddy "${V2_DOMAIN}" "${uuid}"
752-
${sudoCmd} systemctl restart caddy 2>/dev/null
753727

754728
colorEcho ${BLUE} "Re-setting trojan-go"
755729
set_trojan "${uuid}" "${path}tj" "${V2_DOMAIN}"
756-
${sudoCmd} systemctl restart trojan-go 2>/dev/null
757730

758-
colorEcho ${BLUE} "Re-setting v2ray"
759-
# temporary cert
760-
${sudoCmd} openssl req -new -newkey rsa:2048 -days 1 -nodes -x509 -subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=${V2_DOMAIN}" -keyout /etc/ssl/v2ray/key.pem -out /etc/ssl/v2ray/fullchain.pem
761-
${sudoCmd} chmod 644 /etc/ssl/v2ray/key.pem
762-
${sudoCmd} chmod 644 /etc/ssl/v2ray/fullchain.pem
731+
colorEcho ${BLUE} "Re-issuing certificates for ${V2_DOMAIN}"
732+
${sudoCmd} systemctl stop caddy
733+
get_cert_standalone "${V2_DOMAIN}"
763734

735+
${sudoCmd} systemctl restart caddy 2>/dev/null
736+
${sudoCmd} systemctl restart trojan-go 2>/dev/null
764737
${sudoCmd} systemctl restart v2ray 2>/dev/null
765-
766-
sleep 5
767-
768-
colorEcho ${BLUE} "Re-issuing certificates for ${V2_DOMAIN}"
769738
get_cert "${V2_DOMAIN}"
770739

771740
write_json /usr/local/etc/v2ray/05_inbounds_vless.json ".inbounds[0].tag" "\"${V2_DOMAIN}\""
772741

773-
if [ -f "/root/.acme.sh/${V2_DOMAIN}_ecc/fullchain.cer" ]; then
742+
if [ -f "~/.acme.sh/${V2_DOMAIN}_ecc/fullchain.cer" ]; then
774743
colorEcho ${GREEN} "证书修复成功!"
775744
show_links
776745
else
777-
get_cert_alt "${V2_DOMAIN}"
778-
if [ -f "/root/.acme.sh/${V2_DOMAIN}_ecc/fullchain.cer" ]; then
779-
colorEcho ${GREEN} "证书修复成功!"
780-
show_links
781-
else
782-
colorEcho ${RED} "证书签发失败, 请重试"
783-
exit 1
784-
fi
746+
colorEcho ${RED} "证书签发失败, 请重试"
747+
exit 1
785748
fi
786749
else
787750
colorEcho ${YELLOW} "请先安装 V2Ray"
@@ -831,14 +794,12 @@ install_v2ray() {
831794

832795
${sudoCmd} $(which mkdir) -p /etc/ssl/v2ray
833796

834-
# temporary cert
835-
${sudoCmd} openssl req -new -newkey rsa:2048 -days 1 -nodes -x509 -subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=${V2_DOMAIN}" -keyout /etc/ssl/v2ray/key.pem -out /etc/ssl/v2ray/fullchain.pem
836-
${sudoCmd} $(which chmod) 644 /etc/ssl/v2ray/key.pem
837-
${sudoCmd} $(which chmod) 644 /etc/ssl/v2ray/fullchain.pem
838-
839797
colorEcho ${BLUE} "Building dummy web site"
840798
build_web
841799

800+
${sudoCmd} systemctl stop caddy 2>/dev/null
801+
get_cert_standalone "${V2_DOMAIN}"
802+
842803
# activate services
843804
colorEcho ${BLUE} "Activating services"
844805
${sudoCmd} systemctl daemon-reload
@@ -856,28 +817,13 @@ install_v2ray() {
856817
${sudoCmd} systemctl enable naive
857818
${sudoCmd} systemctl restart naive 2>/dev/null
858819

859-
sleep 5
860-
861-
get_acmesh
862-
863-
if [ -f "/usr/local/bin/v2ray" ]; then
864-
get_cert "${V2_DOMAIN}"
865-
else
866-
colorEcho ${RED} "v2ray-core 下载失败, 可能会影响证书申请, 请先确保您的机器能访问 githubusercontent 再运行本脚本"
867-
exit 1
868-
fi
820+
get_cert "${V2_DOMAIN}"
869821

870-
if [ -f "/root/.acme.sh/${V2_DOMAIN}_ecc/fullchain.cer" ]; then
822+
if [ -f "~/.acme.sh/${V2_DOMAIN}_ecc/fullchain.cer" ]; then
871823
colorEcho ${GREEN} "安装 VLESS + VMess + Trojan + NaiveProxy 成功!"
872824
show_links
873825
else
874-
get_cert_alt "${V2_DOMAIN}"
875-
if [ -f "/root/.acme.sh/${V2_DOMAIN}_ecc/fullchain.cer" ]; then
876-
colorEcho ${GREEN} "安装 VLESS + VMess + Trojan + NaiveProxy 成功!"
877-
show_links
878-
else
879-
colorEcho ${RED} "证书签发失败, 请运行修复证书"
880-
fi
826+
colorEcho ${RED} "证书签发失败, 请运行修复证书"
881827
fi
882828
}
883829

0 commit comments

Comments
 (0)