]> git.proxmox.com Git - pmg-api.git/commitdiff
PMG/Config.pm: allow single address setups
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Jan 2018 12:30:39 +0000 (13:30 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Jan 2018 12:30:39 +0000 (13:30 +0100)
PMG/Config.pm
PMG/Utils.pm

index c387d691160426969741eea5e5e8051a2c2d2424..8b1c2dcfe15e8940352a448f466b0f2ec775e10e 100755 (executable)
@@ -992,9 +992,7 @@ sub get_template_vars {
 
     my $nodename = PVE::INotify::nodename();
     my $int_ip = PMG::Cluster::remote_node_ip($nodename);
-    my $int_net_cidr = PMG::Utils::find_local_network_for_ip($int_ip);
     $vars->{ipconfig}->{int_ip} = $int_ip;
-    # $vars->{ipconfig}->{int_net_cidr} = $int_net_cidr;
 
     my $transportnets = [];
 
@@ -1013,7 +1011,16 @@ sub get_template_vars {
     $vars->{postfix}->{transportnets} = join(' ', @$transportnets);
 
     my $mynetworks = [ '127.0.0.0/8', '[::1]/128' ];
-    push @$mynetworks, $int_net_cidr;
+
+    if (my $int_net_cidr = PMG::Utils::find_local_network_for_ip($int_ip, 1)) {
+       push @$mynetworks, $int_net_cidr;
+    } else {
+       if ($int_ip =~ m/^$IPV6RE$/) {
+           push @$mynetworks, "$int_ip/128";
+       } else {
+           push @$mynetworks, "$int_ip/32";
+       }
+    }
 
     my $netlist = PVE::INotify::read_file('mynetworks');
     push @$mynetworks, keys %$netlist;
index aa0da54965d7a32675621fe5f39e49271bf9f362..412209efd11439fe00d566dbb66a538f6760f495 100644 (file)
@@ -471,7 +471,7 @@ __EOD__
 }
 
 sub find_local_network_for_ip {
-    my ($ip) = @_;
+    my ($ip, $noerr) = @_;
 
     my $testip = Net::IP->new($ip);
 
@@ -499,6 +499,8 @@ sub find_local_network_for_ip {
        }
     }
 
+    return undef if $noerr;
+
     die "unable to detect local network for ip '$ip'\n";
 }