Firewall: Add Rules by IP, Bug Fixes: SSL, Error Logs, Remote Transfer

This commit is contained in:
usmannasir
2017-11-02 02:09:47 +05:00
parent 897a8504c2
commit e366876b9b
31 changed files with 1353 additions and 1131 deletions

View File

@@ -12,9 +12,15 @@ import socket
class FirewallUtilities:
@staticmethod
def addRule(proto,port):
def addRule(proto,port,ipAddress):
try:
command = 'firewall-cmd --add-port=' + port +'/' + proto +' --permanent'
ruleFamily = 'rule family="ipv4"'
sourceAddress = 'source address="' + ipAddress + '"'
ruleProtocol = 'port protocol="' + proto + '"'
rulePort = 'port="' + port + '"'
command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
cmd = shlex.split(command)
@@ -36,9 +42,14 @@ class FirewallUtilities:
return 1
@staticmethod
def deleteRule(proto, port):
def deleteRule(proto, port,ipAddress):
try:
command = 'firewall-cmd --remove-port=' + port + '/' + proto +' --permanent'
ruleFamily = 'rule family="ipv4"'
sourceAddress = 'source address="' + ipAddress + '"'
ruleProtocol = 'port protocol="' + proto + '"'
rulePort = 'port="' + port + '"'
command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
cmd = shlex.split(command)