Message ID | 20241206164417.3840426-2-michael.tremer@ipfire.org |
---|---|
State | New |
Headers |
Return-Path: <development-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R11" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Y4cY7666Zz3x1C for <patchwork@web04.haj.ipfire.org>; Fri, 6 Dec 2024 16:44:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "E6" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Y4cY541vmz7Ph; Fri, 6 Dec 2024 16:44:25 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Y4cY53Vg5z342K; Fri, 6 Dec 2024 16:44:25 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R11" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Y4cY217tyz2xfQ for <development@lists.ipfire.org>; Fri, 6 Dec 2024 16:44:22 +0000 (UTC) Received: from michael.haj.ipfire.org (michael.haj.ipfire.org [172.28.1.242]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature ECDSA (secp384r1)) (Client CN "michael.haj.ipfire.org", Issuer "E6" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Y4cY15mVJz2Q4; Fri, 6 Dec 2024 16:44:21 +0000 (UTC) Received: by michael.haj.ipfire.org (Postfix, from userid 0) id 4Y4cY14LCTzTgKx; Fri, 6 Dec 2024 16:44:21 +0000 (UTC) From: Michael Tremer <michael.tremer@ipfire.org> To: development@lists.ipfire.org Subject: [PATCH 2/4] connections.cgi: Ignore empty interfaces Date: Fri, 6 Dec 2024 16:44:15 +0000 Message-Id: <20241206164417.3840426-2-michael.tremer@ipfire.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241206164417.3840426-1-michael.tremer@ipfire.org> References: <20241206164417.3840426-1-michael.tremer@ipfire.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: SHL3KJEN654LBFOKHMMHPJDSE7A6BDCB X-Message-ID-Hash: SHL3KJEN654LBFOKHMMHPJDSE7A6BDCB X-MailFrom: root@michael.haj.ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Michael Tremer <michael.tremer@ipfire.org> X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk <development.lists.ipfire.org> Archived-At: <https://lists.ipfire.org/hyperkitty/list/development@lists.ipfire.org/message/SHL3KJEN654LBFOKHMMHPJDSE7A6BDCB/> List-Archive: <https://lists.ipfire.org/hyperkitty/list/development@lists.ipfire.org/> List-Help: <mailto:development-request@lists.ipfire.org?subject=help> List-Owner: <mailto:development-owner@lists.ipfire.org> List-Post: <mailto:development@lists.ipfire.org> List-Subscribe: <mailto:development-join@lists.ipfire.org> List-Unsubscribe: <mailto:development-leave@lists.ipfire.org> |
Series |
[1/4] connections.cgi: Fix colour of destination country
|
|
Commit Message
Michael Tremer
Dec. 6, 2024, 4:44 p.m. UTC
Parsing any custom routes for any custom interfaces was broken so that
arbitrary routes were imported when not all interfaces were in use.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
html/cgi-bin/connections.cgi | 3 +++
1 file changed, 3 insertions(+)
Comments
If %interfaces contains defined interfaces only, this is not necessary. For blue and orange interfaces this can be done by my %interfaces = ( $settings{'GREEN_DEV'} => ${Header::colourgreen}, # IPsec "gre[0-9]+" => ${Header::colourvpn}, "vti[0-9]+" => ${Header::colourvpn}, # OpenVPN "tun[0-9]+" => ${Header::colourovpn}, ); # BLUE interface if ($settings{BLUE_DEV} ne "") { $interfaces{$settings{'BLUE_DEV'} } = ${Header::colourblue}; } #ORANGE interface if ($settings{ORANGE_DEV} ne "") { $interfaces{$settings{'ORANGE_DEV'} }= ${Header::colourorange}; } For VPN this has to be adapted. Reviewed-by-: Bernhard Bitsch <bbitsch@ipfire.org> Am 06.12.2024 um 17:44 schrieb Michael Tremer: > Parsing any custom routes for any custom interfaces was broken so that > arbitrary routes were imported when not all interfaces were in use. > > Signed-off-by: Michael Tremer <michael.tremer@ipfire.org> > --- > html/cgi-bin/connections.cgi | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi > index af375effe..705118576 100644 > --- a/html/cgi-bin/connections.cgi > +++ b/html/cgi-bin/connections.cgi > @@ -89,6 +89,9 @@ my @routes = &General::system_output("ip", "route", "show"); > > # Find all routes > foreach my $intf (keys %interfaces) { > + # Skip empty interfaces > + next if ($intf eq ""); > + > foreach my $route (grep(/dev ${intf}/, @routes)) { > if ($route =~ m/^(\d+\.\d+\.\d+\.\d+\/\d+)/) { > $networks{$1} = $interfaces{$intf};
This is also an option. I found throwing away what is empty in the loop was shorter to write. -Michael > On 7 Dec 2024, at 23:56, Bernhard Bitsch <bbitsch@ipfire.org> wrote: > > If %interfaces contains defined interfaces only, this is not necessary. > > For blue and orange interfaces this can be done by > > my %interfaces = ( > $settings{'GREEN_DEV'} => ${Header::colourgreen}, > > # IPsec > "gre[0-9]+" => ${Header::colourvpn}, > "vti[0-9]+" => ${Header::colourvpn}, > > # OpenVPN > "tun[0-9]+" => ${Header::colourovpn}, > ); > > # BLUE interface > if ($settings{BLUE_DEV} ne "") { > $interfaces{$settings{'BLUE_DEV'} } = ${Header::colourblue}; > } > > #ORANGE interface > if ($settings{ORANGE_DEV} ne "") { > $interfaces{$settings{'ORANGE_DEV'} }= ${Header::colourorange}; > } > > For VPN this has to be adapted. > > Reviewed-by-: Bernhard Bitsch <bbitsch@ipfire.org> > > Am 06.12.2024 um 17:44 schrieb Michael Tremer: >> Parsing any custom routes for any custom interfaces was broken so that >> arbitrary routes were imported when not all interfaces were in use. >> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org> >> --- >> html/cgi-bin/connections.cgi | 3 +++ >> 1 file changed, 3 insertions(+) >> diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi >> index af375effe..705118576 100644 >> --- a/html/cgi-bin/connections.cgi >> +++ b/html/cgi-bin/connections.cgi >> @@ -89,6 +89,9 @@ my @routes = &General::system_output("ip", "route", "show"); >> # Find all routes >> foreach my $intf (keys %interfaces) { >> + # Skip empty interfaces >> + next if ($intf eq ""); >> + >> foreach my $route (grep(/dev ${intf}/, @routes)) { >> if ($route =~ m/^(\d+\.\d+\.\d+\.\d+\/\d+)/) { >> $networks{$1} = $interfaces{$intf}; >
diff --git a/html/cgi-bin/connections.cgi b/html/cgi-bin/connections.cgi index af375effe..705118576 100644 --- a/html/cgi-bin/connections.cgi +++ b/html/cgi-bin/connections.cgi @@ -89,6 +89,9 @@ my @routes = &General::system_output("ip", "route", "show"); # Find all routes foreach my $intf (keys %interfaces) { + # Skip empty interfaces + next if ($intf eq ""); + foreach my $route (grep(/dev ${intf}/, @routes)) { if ($route =~ m/^(\d+\.\d+\.\d+\.\d+\/\d+)/) { $networks{$1} = $interfaces{$intf};