Skip to content

Commit 96fef9e

Browse files
committed
修复申请证书时未开通端口
1 parent df3a082 commit 96fef9e

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

v2ray_util/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '3.7.7.1'
1+
__version__ = '3.7.7.2'
22

33
from .util_core.trans import _

v2ray_util/util_core/utils.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def gen_cert(domain):
194194
else:
195195
os.system("curl https://get.acme.sh | sh")
196196

197-
get_ssl_cmd = "bash /root/.acme.sh/acme.sh --issue -d " + domain + " --debug --alpn --keylength ec-256"
197+
open_port(80)
198+
get_ssl_cmd = "bash /root/.acme.sh/acme.sh --issue -d " + domain + " --debug --standalone --keylength ec-256"
198199
if ":" in local_ip:
199200
get_ssl_cmd = get_ssl_cmd + " --listen-v6"
200201

@@ -239,7 +240,7 @@ def clean_iptables(port):
239240
for line in output_result:
240241
os.system(clean_cmd.format(iptable_way, "OUTPUT", str(line)))
241242

242-
def open_port():
243+
def open_port(openport=-1):
243244
import platform
244245
from .loader import Loader
245246

@@ -253,18 +254,28 @@ def open_port():
253254
group_list = profile.group_list
254255
port_set = set([group.port for group in group_list])
255256

256-
iptable_way = "iptables" if profile.network == "ipv4" else "ip6tables"
257-
for port in port_set:
258-
port_str = str(port)
259-
if len(os.popen(check_cmd.format(iptable_way, port_str)).readlines()) > 0:
260-
continue
257+
iptable_way = "iptables" if profile.network == "ipv4" else "ip6tables"
258+
if openport != -1:
259+
port_str = str(openport)
261260
if is_centos8:
262261
os.system(firewall_open_cmd.format(port_str, port_str))
263262
else:
264263
os.system(input_cmd.format(iptable_way, "tcp", port_str))
265264
os.system(input_cmd.format(iptable_way, "udp", port_str))
266265
os.system(output_cmd.format(iptable_way, "tcp", port_str))
267266
os.system(output_cmd.format(iptable_way, "udp", port_str))
267+
else:
268+
for port in port_set:
269+
port_str = str(port)
270+
if len(os.popen(check_cmd.format(iptable_way, port_str)).readlines()) > 0:
271+
continue
272+
if is_centos8:
273+
os.system(firewall_open_cmd.format(port_str, port_str))
274+
else:
275+
os.system(input_cmd.format(iptable_way, "tcp", port_str))
276+
os.system(input_cmd.format(iptable_way, "udp", port_str))
277+
os.system(output_cmd.format(iptable_way, "tcp", port_str))
278+
os.system(output_cmd.format(iptable_way, "udp", port_str))
268279
if is_centos8:
269280
os.system("firewall-cmd --reload >/dev/null 2>&1")
270281

0 commit comments

Comments
 (0)