You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
<?php
|
|
|
|
namespace utils;
|
|
|
|
class ufw {
|
|
/*
|
|
* $action (allow or deny)
|
|
* $port (Port#/tcp)
|
|
*/
|
|
public static function make_rule(string $action, string $port): int|false {
|
|
switch($action) {
|
|
case 'allow': case 'deny': case 'reject': case 'limit': break;
|
|
default:
|
|
return false;
|
|
}
|
|
exec(\neato::get_super_user_bin . 'ufw ' . safeCmd($action, $port), $output, $exit_code);
|
|
checkForError($exit_code, "UFW Unable to {$action} for port: {$port}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function status() {
|
|
exec(\neato::get_super_user_bin . 'ufw status', $output, $exit_code);
|
|
return $output;
|
|
}
|
|
|
|
public static function enable() {
|
|
exec(\neato::get_super_user_bin . 'ufw enable', $output, $exit_code);
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function disable() {
|
|
exec(\neato::get_super_user_bin . 'ufw disable', $output, $exit_code);
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function reset() {
|
|
exec(\neato::get_super_user_bin . 'ufw reset', $output, $exit_code);
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function reload() {
|
|
exec(\neato::get_super_user_bin . 'ufw reload', $output, $exit_code);
|
|
return $exit_code;
|
|
}
|
|
|
|
|
|
} |