From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D68D07071C for ; Tue, 14 Jun 2022 09:56:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C6BB21B730 for ; Tue, 14 Jun 2022 09:56:13 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 187931B727 for ; Tue, 14 Jun 2022 09:56:13 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id DE20543006 for ; Tue, 14 Jun 2022 09:56:12 +0200 (CEST) Date: Tue, 14 Jun 2022 09:56:12 +0200 From: Wolfgang Bumiller To: Dominik Csapak Cc: pmg-devel@lists.proxmox.com Message-ID: <20220614075612.rsubdorhsnu42pml@casey.proxmox.com> References: <20220531115253.3398902-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220531115253.3398902-1-d.csapak@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.314 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [config.pm] Subject: [pmg-devel] applied: [PATCH pmg-api] config: add ips/nets uniquely to the template variables X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2022 07:56:43 -0000 could have probably gone with a single hash but it's clearer this way given the function's length applied On Tue, May 31, 2022 at 01:52:53PM +0200, Dominik Csapak wrote: > otherwise a config with many entries such as: > domain1: ip1 > domain2: ip1 > domain3: ip1 > etc. > > unnecessarily adds 'ip1' multiple times to the 'mynetworks' variable > > to keep the output sorted (so it's stable) move the sort to the 'join' > > Signed-off-by: Dominik Csapak > --- > src/PMG/Config.pm | 40 +++++++++++++++++++++------------------- > 1 file changed, 21 insertions(+), 19 deletions(-) > > diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm > index 31f9c6f..9ba5c76 100755 > --- a/src/PMG/Config.pm > +++ b/src/PMG/Config.pm > @@ -1297,63 +1297,65 @@ sub get_template_vars { > my $int_ip = PMG::Cluster::remote_node_ip($dnsinfo->{hostname}); > $vars->{ipconfig}->{int_ip} = $int_ip; > > - my $transportnets = []; > + my $transportnets = {}; > + my $mynetworks = { > + '127.0.0.0/8' => 1, > + '[::1]/128', => 1, > + }; > > if (my $tmap = PVE::INotify::read_file('transport')) { > - foreach my $domain (sort keys %$tmap) { > + foreach my $domain (keys %$tmap) { > my $data = $tmap->{$domain}; > my $host = $data->{host}; > if ($host =~ m/^$IPV4RE$/) { > - push @$transportnets, "$host/32"; > + $transportnets->{"$host/32"} = 1; > + $mynetworks->{"$host/32"} = 1; (...)