From 081034ae4b2ab3d29ab024cb05015617c59a7e90 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 14 Jun 2022 01:39:50 +0800 Subject: [PATCH] up --- class/core/config_api.py | 4 ++++ class/core/firewall_api.py | 17 ++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/class/core/config_api.py b/class/core/config_api.py index 25050001a..c9a593c02 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -139,6 +139,10 @@ class config_api: import system_api import firewall_api + if firewall_api.__isFirewalld: + mw.execShell('systemctl start firewalld') + time.sleep(1) + mw.setHostPort(port) msg = mw.getInfo('放行端口[{1}]成功', (port,)) diff --git a/class/core/firewall_api.py b/class/core/firewall_api.py index fcaf45174..d49138ed1 100755 --- a/class/core/firewall_api.py +++ b/class/core/firewall_api.py @@ -365,16 +365,15 @@ class firewall_api: def addAcceptPort(self, port): if self.__isUfw: mw.execShell('ufw allow ' + port + '/tcp') + elif self.__isFirewalld: + port = port.replace(':', '-') + cmd = 'firewall-cmd --permanent --zone=public --add-port=' + port + '/tcp' + mw.execShell(cmd) + elif self.__isMac: + pass else: - if self.__isFirewalld: - port = port.replace(':', '-') - cmd = 'firewall-cmd --permanent --zone=public --add-port=' + port + '/tcp' - mw.execShell(cmd) - elif self.__isMac: - pass - else: - cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT' - mw.execShell(cmd) + cmd = 'iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ' + port + ' -j ACCEPT' + mw.execShell(cmd) def firewallReload(self): if self.__isUfw: