From 33fb3822c7fec544b0dc42f446f7e5c917b34b7f Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Sat, 19 Feb 2022 20:51:49 +0000 Subject: [PATCH] fix iptables issue --- generate.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/generate.py b/generate.py index 131ea2c..6901047 100644 --- a/generate.py +++ b/generate.py @@ -768,17 +768,18 @@ class Parser: self.get_podman_cmd_with('podman exec {} mkdir -p /root/ssl /root/runner /root/conf'.format( self.get_container_name())) )) + + if not self.flag_container_must_host and not self.podman_user: + self.result_postup.append("PostUp=CT_IP=$({}); iptables -A FORWARD -d $CT_IP -j ACCEPT; iptables -A INPUT -s $CT_IP -j ACCEPT".format( + self.get_podman_cmd_with('/usr/bin/python3 {} {} {}'.format(path_get_ip, self.get_container_network_name(), self.get_container_name())))) + self.result_postdown.append("PostDown=CT_IP=$({}); iptables -D FORWARD -d $CT_IP -j ACCEPT; iptables -D INPUT -s $CT_IP -j ACCEPT".format( + self.get_podman_cmd_with('/usr/bin/python3 {} {} {}'.format(path_get_ip, self.get_container_network_name(), self.get_container_name())))) + self.result_postdown.append('PostDown={}'.format( self.get_podman_cmd_with('podman stop {}'.format(self.get_container_name())) )) if not self.flag_container_must_host: - if not self.podman_user: - self.result_postup.append("PostUp=CT_IP=$({}); iptables -A FORWARD -d $CT_IP -j ACCEPT; iptables -A INPUT -s $CT_IP -j ACCEPT".format( - self.get_podman_cmd_with('/usr/bin/python3 {} {} {}'.format(path_get_ip, self.get_container_network_name(), self.get_container_name())))) - self.result_postdown.append("PostUp=CT_IP=$({}); iptables -D FORWARD -d $CT_IP -j ACCEPT; iptables -D INPUT -s $CT_IP -j ACCEPT".format( - self.get_podman_cmd_with('/usr/bin/python3 {} {} {}'.format(path_get_ip, self.get_container_network_name(), self.get_container_name())))) - self.result_postdown.append('PostDown={}'.format( self.get_podman_cmd_with('podman network rm {}'.format(self.get_container_network_name())) ))