From: Dietmar Maurer Date: Wed, 24 Jan 2018 12:30:39 +0000 (+0100) Subject: PMG/Config.pm: allow single address setups X-Git-Url: https://git.proxmox.com/?p=pmg-api.git;a=commitdiff_plain;h=1e88a52920b312a810fceb5523bccaeb1acdbf1a PMG/Config.pm: allow single address setups --- diff --git a/PMG/Config.pm b/PMG/Config.pm index c387d69..8b1c2dc 100755 --- a/PMG/Config.pm +++ b/PMG/Config.pm @@ -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; diff --git a/PMG/Utils.pm b/PMG/Utils.pm index aa0da54..412209e 100644 --- a/PMG/Utils.pm +++ b/PMG/Utils.pm @@ -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"; }