mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 06:16:08 +01:00
Firewall: Add Rules by IP, Bug Fixes: SSL, Error Logs, Remote Transfer
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user