]> git.proxmox.com Git - pve-firewall.git/blobdiff - src/PVE/API2/Firewall/Host.pm
grammar fix: s/does not exists/does not exist/g
[pve-firewall.git] / src / PVE / API2 / Firewall / Host.pm
index 130ca023b6ad9022e45918534fb74c88d526b48f..d02619ad82185605d2526a41f99c443448243097 100644 (file)
@@ -2,18 +2,19 @@ package PVE::API2::Firewall::Host;
 
 use strict;
 use warnings;
+
+use PVE::Exception qw(raise_param_exc);
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::RPCEnvironment;
 
 use PVE::Firewall;
 use PVE::API2::Firewall::Rules;
 
-use Data::Dumper; # fixme: remove
 
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method ({
-    subclass => "PVE::API2::Firewall::HostRules",  
+    subclass => "PVE::API2::Firewall::HostRules",
     path => 'rules',
 });
 
@@ -49,48 +50,7 @@ __PACKAGE__->register_method({
        return $result;
     }});
 
-my $option_properties = {
-    enable => {
-       description => "Enable host firewall rules.",
-       type => 'boolean',
-       optional => 1,
-    },
-    log_level_in =>  get_standard_option('pve-fw-loglevel', {
-       description => "Log level for incoming traffic." }),
-    log_level_out =>  get_standard_option('pve-fw-loglevel', {
-       description => "Log level for outgoing traffic." }),
-    tcp_flags_log_level =>  get_standard_option('pve-fw-loglevel', {
-       description => "Log level for illegal tcp flags filter." }),
-    smurf_log_level =>  get_standard_option('pve-fw-loglevel', {
-       description => "Log level for SMURFS filter." }),
-    nosmurfs => {
-       description => "Enable SMURFS filter.",
-       type => 'boolean',
-       optional => 1,
-    },
-    tcpflags => {
-       description => "Filter illegal combinations of TCP flags.",
-       type => 'boolean',
-       optional => 1,
-    },
-    nf_conntrack_max => {
-       description => "Maximum number of tracked connections.",
-       type => 'integer',
-       optional => 1,
-       minimum => 32768,
-    },
-    nf_conntrack_tcp_timeout_established => {
-       description => "Conntrack established timeout.",
-       type => 'integer',
-       optional => 1,
-       minimum => 7875,
-    },
-    ndp => {
-       description => "Enable NDP.",
-       type => 'boolean',
-       optional => 1,
-    },
-};
+my $option_properties = $PVE::Firewall::host_option_properties;
 
 my $add_option_properties = sub {
     my ($properties) = @_;
@@ -98,7 +58,7 @@ my $add_option_properties = sub {
     foreach my $k (keys %$option_properties) {
        $properties->{$k} = $option_properties->{$k};
     }
-    
+
     return $properties;
 };
 
@@ -164,7 +124,7 @@ __PACKAGE__->register_method({
 
        if ($param->{delete}) {
            foreach my $opt (PVE::Tools::split_list($param->{delete})) {
-               raise_param_exc({ delete => "no such option '$opt'" }) 
+               raise_param_exc({ delete => "no such option '$opt'" })
                    if !$option_properties->{$opt};
                delete $hostfw_conf->{options}->{$opt};
            }
@@ -176,7 +136,7 @@ __PACKAGE__->register_method({
 
        foreach my $k (keys %$option_properties) {
            next if !defined($param->{$k});
-           $hostfw_conf->{options}->{$k} = $param->{$k}; 
+           $hostfw_conf->{options}->{$k} = $param->{$k};
        }
 
        PVE::Firewall::save_hostfw_conf($hostfw_conf);
@@ -185,8 +145,8 @@ __PACKAGE__->register_method({
     }});
 
 __PACKAGE__->register_method({
-    name => 'log', 
-    path => 'log', 
+    name => 'log',
+    path => 'log',
     method => 'GET',
     description => "Read firewall log",
     proxyto => 'node',
@@ -212,7 +172,7 @@ __PACKAGE__->register_method({
     },
     returns => {
        type => 'array',
-       items => { 
+       items => {
            type => "object",
            properties => {
                n => {
@@ -236,8 +196,8 @@ __PACKAGE__->register_method({
        my ($count, $lines) = PVE::Tools::dump_logfile("/var/log/pve-firewall.log", $param->{start}, $param->{limit});
 
        $rpcenv->set_result_attrib('total', $count);
-           
-       return $lines; 
+
+       return $lines;
     }});
 
 1;