]> git.proxmox.com Git - pmg-api.git/commitdiff
config write_transport_map: code cleanup
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 24 Mar 2020 12:29:54 +0000 (13:29 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 24 Mar 2020 12:29:54 +0000 (13:29 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/Config.pm

index 3c839448e1fb0dab86db2f11d13c182cd15d84af..4d3b0e3170ba6aaa698a4ece2cf48677306294f0 100755 (executable)
@@ -1176,23 +1176,16 @@ sub write_transport_map {
        PVE::Tools::safe_print($filename, $fh, "#$comment\n")
            if defined($comment) && $comment !~ m/^\s*$/;
 
-       my $use_mx = $data->{use_mx};
-       my $bracket_host = ! $use_mx;
+       my $bracket_host = !$data->{use_mx};
 
        if ($data->{protocol} eq 'lmtp') {
            $bracket_host = 0;
            $data->{protocol} .= ":inet";
        }
-
        $bracket_host = 1 if $data->{host} =~ m/^(?:$IPV4RE|$IPV6RE)$/i;
+       my $host = $bracket_host ? "[$data->{host}]" : $data->{host};
 
-       if ($bracket_host) {
-           PVE::Tools::safe_print(
-               $filename, $fh, "$data->{domain} $data->{protocol}:[$data->{host}]:$data->{port}\n");
-       } else {
-           PVE::Tools::safe_print(
-               $filename, $fh, "$data->{domain} $data->{protocol}:$data->{host}:$data->{port}\n");
-       }
+       PVE::Tools::safe_print($filename, $fh, "$data->{domain} $data->{protocol}:$host:$data->{port}\n");
     }
 }