mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 16:26:12 +01:00
Firewall rules (intermediate version)
This commit is contained in:
@@ -14,19 +14,21 @@ class FirewallUtilities:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def addRule(proto,port):
|
def addRule(proto,port):
|
||||||
try:
|
try:
|
||||||
if port == "21":
|
command = 'sudo firewall-cmd --permanent --zone-public --add-port=' + port + '/' + proto
|
||||||
command = "sudo firewall-cmd --add-service=ftp --permanent"
|
|
||||||
cmd = shlex.split(command)
|
|
||||||
res = subprocess.call(cmd)
|
|
||||||
|
|
||||||
ipAddress = "0.0.0.0/0"
|
#if port == "21":
|
||||||
|
# command = "sudo firewall-cmd --add-service=ftp --permanent"
|
||||||
|
# cmd = shlex.split(command)
|
||||||
|
# res = subprocess.call(cmd)
|
||||||
|
|
||||||
ruleFamily = 'rule family="ipv4"'
|
#ipAddress = "0.0.0.0/0"
|
||||||
sourceAddress = 'source address="' + ipAddress + '"'
|
|
||||||
ruleProtocol = 'port protocol="' + proto + '"'
|
|
||||||
rulePort = 'port="' + port + '"'
|
|
||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
#ruleFamily = 'rule family="ipv4"'
|
||||||
|
#sourceAddress = 'source address="' + ipAddress + '"'
|
||||||
|
#ruleProtocol = 'port protocol="' + proto + '"'
|
||||||
|
#rulePort = 'port="' + port + '"'
|
||||||
|
|
||||||
|
#command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
cmd = shlex.split(command)
|
cmd = shlex.split(command)
|
||||||
|
|
||||||
@@ -50,19 +52,21 @@ class FirewallUtilities:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def deleteRule(proto, port):
|
def deleteRule(proto, port):
|
||||||
try:
|
try:
|
||||||
if port=="21":
|
command = 'sudo firewall-cmd --permanent --zone-public --remove-port=' + port + '/' + proto
|
||||||
command = "sudo firewall-cmd --remove-service=ftp --permanent"
|
|
||||||
cmd = shlex.split(command)
|
|
||||||
res = subprocess.call(cmd)
|
|
||||||
|
|
||||||
ipAddress = "0.0.0.0/0"
|
#if port=="21":
|
||||||
|
# command = "sudo firewall-cmd --remove-service=ftp --permanent"
|
||||||
|
# cmd = shlex.split(command)
|
||||||
|
# res = subprocess.call(cmd)
|
||||||
|
|
||||||
ruleFamily = 'rule family="ipv4"'
|
#ipAddress = "0.0.0.0/0"
|
||||||
sourceAddress = 'source address="' + ipAddress + '"'
|
|
||||||
ruleProtocol = 'port protocol="' + proto + '"'
|
|
||||||
rulePort = 'port="' + port + '"'
|
|
||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
#ruleFamily = 'rule family="ipv4"'
|
||||||
|
#sourceAddress = 'source address="' + ipAddress + '"'
|
||||||
|
#ruleProtocol = 'port protocol="' + proto + '"'
|
||||||
|
#rulePort = 'port="' + port + '"'
|
||||||
|
|
||||||
|
#command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
cmd = shlex.split(command)
|
cmd = shlex.split(command)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user