def get_deny_ip(): ports = execute("SELECT * FROM ufw_ip;") result = [] for i in ports: result.append({ "rule_id": i[0], "ip": i[1], "protocol": i[2], "description": i[3] }) return result
def get_allow_port(): ports = execute("SELECT * FROM ufw_port;") result = [] for i in ports: result.append({ "rule_id": i[0], "port": i[1], "protocol": i[2], "description": i[3] }) return result
def delete_deny_ip(self): execute("DELETE FROM ufw_ip WHERE ip = ? AND protocol = ?;", (self.ip, self.protocol)) os.system("sudo ufw delete deny from {} proto {}".format( self.ip, self.protocol))
def add_deny_ip(self, description): execute( "INSERT INTO ufw_ip (ip, protocol, description) VALUES(?, ?, ?)", (self.ip, self.protocol, description)) os.system("sudo ufw deny from {} proto {}".format( self.ip, self.protocol))
def delete_allow_port(self): execute("DELETE FROM ufw_port WHERE port = ? AND protocol = ?;", (self.port, self.protocol)) os.system("sudo ufw delete allow {}/{}".format(self.port, self.protocol)) pass
def add_allow_port(self, description): execute( "INSERT INTO ufw_port (port, protocol, description) VALUES(?, ?, ?)", (self.port, self.protocol, description)) os.system("sudo ufw allow {}/{}".format(self.port, self.protocol))