]> git.proxmox.com Git - pve-firewall.git/blobdiff - src/pve-firewall
fix for test case test/test-errors1
[pve-firewall.git] / src / pve-firewall
index c8e9559fc0a568a5f8a238b0d33ed877aac56ec7..034f93354d9398ac73654ebe83137f03a04d592d 100755 (executable)
@@ -349,7 +349,7 @@ __PACKAGE__->register_method ({
 __PACKAGE__->register_method ({
     name => 'compile',
     path => 'compile',
-    method => 'POST',
+    method => 'GET',
     description => "Compile and print firewall rules. This is useful for testing.",
     parameters => {
        additionalProperties => 0,
@@ -379,11 +379,45 @@ __PACKAGE__->register_method ({
        return undef;
     }});
 
+__PACKAGE__->register_method ({
+    name => 'localnet',
+    path => 'localnet',
+    method => 'GET',
+    description => "Print information about local network.",
+    parameters => {
+       additionalProperties => 0,
+       properties => {},
+    },
+    returns => { type => 'null' },
+    code => sub {
+       my ($param) = @_;
+
+       local $SIG{'__WARN__'} = 'DEFAULT'; # do not fill up syslog
+
+       my $nodename = PVE::INotify::nodename();
+       print "local hostname: $nodename\n";
+
+       my $ip = PVE::Cluster::remote_node_ip($nodename);
+       print "local IP address: $ip\n";
+
+       my $cluster_conf = PVE::Firewall::load_clusterfw_conf();
+       
+       my $localnet = PVE::Firewall::local_network() || '127.0.0.0/8';
+       print "network auto detect: $localnet\n";
+       if ($cluster_conf->{aliases}->{local_network}) {
+           print "using user defined local_network: $cluster_conf->{aliases}->{local_network}->{cidr}\n";
+       } else {
+           print "using detected local_network: $localnet\n";
+       }
+
+       return undef;
+    }});
+
 __PACKAGE__->register_method ({
     name => 'simulate',
     path => 'simulate',
-    method => 'POST',
-    description => "Simulate firewall rules.",
+    method => 'GET',
+    description => "Simulate firewall rules. This does not simulate kernel 'routing' table. Instead, this simply assumes that routing from source zone to destination zone is possible.",
     parameters => {
        additionalProperties => 0,
        properties => {
@@ -444,6 +478,8 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
+       local $SIG{'__WARN__'} = 'DEFAULT'; # do not fill up syslog
+
        my ($ruleset, $ipset_ruleset) = PVE::Firewall::compile();
 
        PVE::FirewallSimulator::debug($param->{verbose} || 0);
@@ -495,6 +531,7 @@ my $cmddef = {
     stop => [ __PACKAGE__, 'stop', []],
     compile => [ __PACKAGE__, 'compile', []],
     simulate => [ __PACKAGE__, 'simulate', []],
+    localnet => [ __PACKAGE__, 'localnet', []],
     status => [ __PACKAGE__, 'status', [], undef, sub {
        my $res = shift;
        if ($res->{changes}) {