mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-07 22:06:05 +01:00
bug fix: firewalld
This commit is contained in:
@@ -45,23 +45,20 @@ class FirewallUtilities:
|
|||||||
ruleProtocol = 'port protocol="' + proto + '"'
|
ruleProtocol = 'port protocol="' + proto + '"'
|
||||||
rulePort = 'port="' + port + '"'
|
rulePort = 'port="' + port + '"'
|
||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
if not FirewallUtilities.doCommand(command):
|
ProcessUtilities.executioner(command)
|
||||||
return 0
|
|
||||||
|
|
||||||
ruleFamily = 'rule family="ipv6"'
|
ruleFamily = 'rule family="ipv6"'
|
||||||
sourceAddress = ''
|
sourceAddress = ''
|
||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
if not FirewallUtilities.doCommand(command):
|
ProcessUtilities.executioner(command)
|
||||||
return 0
|
|
||||||
|
|
||||||
command = 'sudo firewall-cmd --reload'
|
command = 'firewall-cmd --reload'
|
||||||
|
|
||||||
if not FirewallUtilities.doCommand(command):
|
ProcessUtilities.executioner(command)
|
||||||
return 0
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -72,23 +69,20 @@ class FirewallUtilities:
|
|||||||
ruleProtocol = 'port protocol="' + proto + '"'
|
ruleProtocol = 'port protocol="' + proto + '"'
|
||||||
rulePort = 'port="' + port + '"'
|
rulePort = 'port="' + port + '"'
|
||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
if ProcessUtilities.executioner(command) == 0:
|
ProcessUtilities.executioner(command)
|
||||||
return 0
|
|
||||||
|
|
||||||
ruleFamily = 'rule family="ipv6"'
|
ruleFamily = 'rule family="ipv6"'
|
||||||
sourceAddress = ''
|
sourceAddress = ''
|
||||||
|
|
||||||
command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
|
||||||
|
|
||||||
if ProcessUtilities.executioner(command) == 0:
|
ProcessUtilities.executioner(command)
|
||||||
return 0
|
|
||||||
|
|
||||||
command = 'sudo firewall-cmd --reload'
|
command = 'firewall-cmd --reload'
|
||||||
|
|
||||||
if ProcessUtilities.executioner(command) == 0:
|
ProcessUtilities.executioner(command)
|
||||||
return 0
|
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -97,7 +91,7 @@ class FirewallUtilities:
|
|||||||
try:
|
try:
|
||||||
if type == "1":
|
if type == "1":
|
||||||
|
|
||||||
command = 'sudo semanage port -a -t ssh_port_t -p tcp ' + sshPort
|
command = 'semanage port -a -t ssh_port_t -p tcp ' + sshPort
|
||||||
ProcessUtilities.normalExecutioner(command)
|
ProcessUtilities.normalExecutioner(command)
|
||||||
|
|
||||||
FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0")
|
FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0")
|
||||||
@@ -127,7 +121,7 @@ class FirewallUtilities:
|
|||||||
writeToFile.writelines(items)
|
writeToFile.writelines(items)
|
||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
command = 'sudo systemctl restart sshd'
|
command = 'systemctl restart sshd'
|
||||||
ProcessUtilities.normalExecutioner(command)
|
ProcessUtilities.normalExecutioner(command)
|
||||||
|
|
||||||
print("1,None")
|
print("1,None")
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getRequestStatus() {
|
function getRequestStatus() {
|
||||||
$scope.cyberPanelLoading = false;
|
$scope.installDockerStatus = false;
|
||||||
|
|
||||||
url = "/serverstatus/switchTOLSWSStatus";
|
url = "/serverstatus/switchTOLSWSStatus";
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
|
|||||||
$timeout(getRequestStatus, 1000);
|
$timeout(getRequestStatus, 1000);
|
||||||
} else {
|
} else {
|
||||||
// Notifications
|
// Notifications
|
||||||
$scope.cyberPanelLoading = true;
|
$scope.installDockerStatus = true;
|
||||||
$timeout.cancel();
|
$timeout.cancel();
|
||||||
$scope.requestData = response.data.requestStatus;
|
$scope.requestData = response.data.requestStatus;
|
||||||
if (response.data.installed === 1) {
|
if (response.data.installed === 1) {
|
||||||
@@ -85,7 +85,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cantLoadInitialDatas(response) {
|
function cantLoadInitialDatas(response) {
|
||||||
$scope.cyberPanelLoading = true;
|
$scope.installDockerStatus = true;
|
||||||
new PNotify({
|
new PNotify({
|
||||||
title: 'Operation Failed!',
|
title: 'Operation Failed!',
|
||||||
text: 'Could not connect to server, please refresh this page',
|
text: 'Could not connect to server, please refresh this page',
|
||||||
|
|||||||
Reference in New Issue
Block a user