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.
49 lines
1.2 KiB
49 lines
1.2 KiB
<?php
|
|
|
|
namespace utils;
|
|
|
|
class ufw {
|
|
/**
|
|
*
|
|
* @param type $action - allow or deny
|
|
* @param type $port - Port#/tcp
|
|
* @return type
|
|
*/
|
|
public static function make_rule($action, $port) {
|
|
switch($action) {
|
|
case 'allow': case 'deny': case 'reject': case 'limit': break;
|
|
default:
|
|
return false;
|
|
}
|
|
exec(\neato::get_super_user_bin . 'ufw ' . safe_cmd($action, $port), $output, $exit_code);
|
|
check_for_error($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;
|
|
}
|
|
|
|
|
|
} |