From patchwork Thu Feb 18 14:30:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3895 Return-Path: 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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DhHDp6C4Kz3wps for ; Thu, 18 Feb 2021 14:30:34 +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 ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHDn3tvlz27r; Thu, 18 Feb 2021 14:30:33 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DhHDn1n90z2xqV; Thu, 18 Feb 2021 14:30:33 +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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DhHDm1Ypnz2xXd for ; Thu, 18 Feb 2021 14:30:32 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHDl34cgz11 for ; Thu, 18 Feb 2021 14:30:31 +0000 (UTC) Received: (qmail 28635 invoked from network); 18 Feb 2021 14:30:25 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 18 Feb 2021 14:30:25 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH v2 1/6] zoneconf.cgi: Change NIC display order, improve code Date: Thu, 18 Feb 2021 15:30:11 +0100 Message-Id: <20210218143016.972-1-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1613658631; a=rsa-sha256; cv=none; b=Qt3orUYbNSOtlBamOISAc9UsTSKgmEQbubWSwp0XAoBRmmCX3Ln+NGD4wz7OeSWG951Kpj WM6Vce2gV3bMyrA/R6Yn/Sz6P7xm1Ba6oQJRSDGOGvplIdNa0CuIEyCxsc3yenyHSE9PJU 56VklUfhE/FLvDj2erQOFUodOVSUQaXwEEJfhszrgQiYuYCAR9qkD5TfG74AYHM6e4zY9H RB6fm1A0iu8LTEpp9FEhgMH8jYts7aX3dIoO3EOdy0ftybQXruRK4RE89VOXjZSFI+1JM6 7RWWSzB95I++Z8rb+LUdHuyrcbcZNP5GcCNk+15wr26l2UNwj1g7tBBHCJAbsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1613658631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xSn2RSepe1SXE705yeN/+ziu1UMuvTGjr8Hx3TU7Irg=; b=amnPoMeUrLsvqi7o+uF/fNADN0wtx0B/tV5rVi9zfxMgHp5bT6HRYT3YhejNowKmNL1JmO CkU9XmFIWWLH4B0wrZJeGl8DmBxCyv0uOK/UF50kyZvhFl+nFkMbCu2I8EEQkH3Z2Gr7IC o1AfGOLt8anpnF8gOjQDFRhNqLRfvV8z68lNQWk/F1bo5HxqO5v9gLhpn/W9mpk6/8D5Iz wFtvxch0Z72X+k3OD2DhazlwPRhhhF7VFUPpso9eJq04TYJAokXBM8Njcyqoc+CKc74nWL a/ADyzrLO/GGtC3ZIcfoFSE4Ndk+eIKdW0D9Z0IET8ie5Gnle/n+2nmZ+95PMA== Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [2.71 / 11.00]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; IP_REPUTATION_HAM(-1.98)[asn: 205766(-0.28), country: DE(-0.01), ip: 185.26.156.147(-0.70)]; MID_CONTAINS_FROM(1.00)[]; MIME_HTML_ONLY(0.20)[]; DMARC_NA(0.00)[leo-andres.de]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:~]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-0.31)[75.19%] X-Rspamd-Queue-Id: 4DhHDl34cgz11 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Refactor duplicate perl code and add comments Signed-off-by: Leo-Andres Hofmann --- html/cgi-bin/zoneconf.cgi | 53 +++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index 0914ceb78..bf46ab0c7 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -26,6 +26,7 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +###--- HTML HEAD ---### my $extraHead = < table#zoneconf { @@ -105,7 +106,9 @@ my $extraHead = < END ; +###--- END HTML HEAD ---### +### Read configuration ### my %ethsettings = (); my %vlansettings = (); my %cgiparams = (); @@ -119,7 +122,7 @@ my $restart_notice = ""; &Header::showhttpheaders(); # Define all zones we will check for NIC assignment -my @zones = ("green", "red", "orange", "blue"); +my @zones = ("red", "green", "orange", "blue"); # Get all physical NICs present opendir(my $dh, "/sys/class/net/"); @@ -153,6 +156,21 @@ foreach (@nics) { } } +### Functions ### + +# Check if a zone is in IP mode or in PPP, PPPoE, VDSL, ... mode +sub is_zonetype_ip { + my $zone_type = shift; + return ($zone_type eq "STATIC" || $zone_type eq "DHCP"); +} + +# Check if a zone is activated (device assigned) +sub is_zone_activated { + my $zone = uc shift; + return ($ethsettings{"${zone}_DEV"} ne ""); +} + +### START PAGE ### &Header::openpage($Lang::tr{"zoneconf title"}, 1, $extraHead); &Header::openbigbox('100%', 'center'); @@ -195,6 +213,7 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) { } } + # skip NIC/VLAN assignment and additional zone options for RED in PPP mode next; } @@ -278,6 +297,7 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) { } } + # validation failed, show error message and exit if ($VALIDATE_error) { &Header::openbox('100%', 'left', $Lang::tr{"error"}); @@ -290,16 +310,17 @@ if ($cgiparams{"ACTION"} eq $Lang::tr{"save"}) { exit 0; } + # new settings are valid, write configuration files &General::writehash("${General::swroot}/ethernet/settings",\%ethsettings); &General::writehash("${General::swroot}/ethernet/vlans",\%vlansettings); $restart_notice = $Lang::tr{'zoneconf notice reboot'}; } -&Header::openbox('100%', 'left', $Lang::tr{"zoneconf nic assignment"}); - ### START OF TABLE ### +&Header::openbox('100%', 'left', $Lang::tr{"zoneconf nic assignment"}); + print < @@ -311,19 +332,16 @@ END # Fill the table header with all activated zones foreach (@zones) { my $uc = uc $_; - my $dev_name = $ethsettings{"${uc}_DEV"}; - if ($dev_name eq "") { # If the zone is not activated, don't show it - next; - } + # If the zone is not activated, don't show it + next unless is_zone_activated($_); - # If the zone is in PPP mode, don't show a mode dropdown + # If the red zone is in PPP mode, don't show a mode dropdown if ($uc eq "RED") { my $red_type = $ethsettings{"RED_TYPE"}; - my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP")); - if ($red_restricted) { - print "\t\t\n"; + unless (is_zonetype_ip($red_type)) { + print "\t\t\n"; next; # We're done here } @@ -354,6 +372,7 @@ END print "\t\n"; +# NIC assignment matrix foreach (@nics) { my $mac = $_->[0]; my $nic = $_->[1]; @@ -365,19 +384,14 @@ foreach (@nics) { # Iterate through all zones and check if the current NIC is assigned to it foreach (@zones) { my $uc = uc $_; - my $dev_name = $ethsettings{"${uc}_DEV"}; my $highlight = ""; - if ($dev_name eq "") { # Again, skip the zone if it is not activated - next; - } + # If the zone is not activated, don't show it + next unless is_zone_activated($_); if ($uc eq "RED") { - my $red_type = $ethsettings{"RED_TYPE"}; - my $red_restricted = ($uc eq "RED" && ! ($red_type eq "STATIC" || $red_type eq "DHCP")); - # VLANs/Bridging is not possible if the RED interface is set to PPP, PPPoE, VDSL, ... - if ($red_restricted) { + unless (is_zonetype_ip($ethsettings{"RED_TYPE"})) { my $checked = ""; if ($mac eq $ethsettings{"${uc}_MACADDR"}) { @@ -449,6 +463,7 @@ END print "\t\n"; } +# footer and submit button print < From patchwork Thu Feb 18 14:30:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3896 Return-Path: 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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DhHDs1663z3wps for ; Thu, 18 Feb 2021 14:30:37 +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 ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHDr3T4Lz295; Thu, 18 Feb 2021 14:30:36 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DhHDr2s87z2xjs; Thu, 18 Feb 2021 14:30:36 +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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DhHDq1NYXz2xXd for ; Thu, 18 Feb 2021 14:30:35 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHDp5Lqpz294 for ; Thu, 18 Feb 2021 14:30:34 +0000 (UTC) Received: (qmail 28648 invoked from network); 18 Feb 2021 14:30:27 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 18 Feb 2021 14:30:27 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH v2 2/6] zoneconf.cgi: Modify CSS to allow additional rows Date: Thu, 18 Feb 2021 15:30:12 +0100 Message-Id: <20210218143016.972-2-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20210218143016.972-1-hofmann@leo-andres.de> References: <20210218143016.972-1-hofmann@leo-andres.de> MIME-Version: 1.0 ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1613658634; a=rsa-sha256; cv=none; b=CyrPLZ0E/Zv1E5UYcCfszerxDhLkEx56psb/KO8kL2cLo1ES1oaMKjbLYDmx1jq1+br4eY 0sAAw1wH7JChrtDJWNz+8mz0S8cJaK/ZqjaCbAGz2tRWRVxNbzUxlf6fH4Amm7+Cy5cfSx 3hBPlUJmVYJtJCfYeqsoFPHA5b2D6Hulj3HjwJR5otmqykaLVR0fiDvKjDICpG/opb2yfn FMeL8G0Zti9OFW337LCxDdnactxkdy+E/QkLr9CnfueAfP+fyL+lmo0GBB5rO4774NjUJC GYOGiPZYNfIhDgw/yCZJ2o0BC8EEWgFgBVF17TkdVvgRE7ogU93pW0DlTsuPjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1613658634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZBaN2O2bu+YmHjikxQ5y+qt7xYwh8IBYx+TKkUDCZMk=; b=ad9N6HLJtV2L1DPUv6hpg6UsHk8A0DF4J4wOUVeYUj3dGRcIcZtIS69eqHgh6k3Zaj9Zly THmIBweK/hs55f7shsW1kQWd8hm7ceCVuEdy6L/ULfAUXgeOFVYq0Ya+ZNBgt3E2vh1fVA 2+o5FfX7SKgfmpyqRpmhrgb6+k15X9T7OcH/ud+p65L606qZqRszj/B+piSRZO9Zb6jt6h 69f4WWJUQM6UusfFr2ih1QAad7q59uixGukE5tChfn/j+YUVR5j0Gu1Wk/d7LRKRO9IhRt OwaXTJtcy4JwKn8rrakd1AQmGTDUQEq6qMFm3OygMRzOf6mCR5ED2qbgjL2WPw== Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [0.01 / 11.00]; ARC_NA(0.00)[]; BAYES_HAM(-2.98)[99.91%]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx:c]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_CONTAINS_FROM(1.00)[]; IP_REPUTATION_HAM(-1.71)[asn: 205766(-0.24), country: DE(-0.01), ip: 185.26.156.147(-0.61)]; DMARC_NA(0.00)[leo-andres.de]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_COUNT_TWO(0.00)[2]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1] X-Rspamd-Queue-Id: 4DhHDp5Lqpz294 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Simplify borders, load more colors from header and add dividers Signed-off-by: Leo-Andres Hofmann --- html/cgi-bin/zoneconf.cgi | 42 ++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index bf46ab0c7..13543d244 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -32,39 +32,59 @@ my $extraHead = < td:first-child { width: 11em; } + #zoneconf tr.nic-row > td:first-child { + background-color: darkgray; + } + #zoneconf tr.nic-row { + border-bottom: 0.5px solid $Header::bordercolour; + } /* alternating row background color */ + #zoneconf tr { + background-color: $Header::table2colour; + } #zoneconf tr:nth-child(2n+3) { - background-color: #F0F0F0; + background-color: $Header::table1colour; } + /* special cell colors */ #zoneconf td.green { background-color: $Header::colourgreen; } @@ -83,8 +103,6 @@ my $extraHead = <
$uc ($red_type)$uc ($red_type)
- + END ; @@ -359,7 +377,7 @@ foreach (@zones) { } print <$uc
+
\n"; - print "\t\t\n"; + print "\t\n"; + print "\t\t\n"; # Iterate through all zones and check if the current NIC is assigned to it foreach (@zones) { From patchwork Thu Feb 18 14:30:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3897 Return-Path: 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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DhHF71C83z3wps for ; Thu, 18 Feb 2021 14:30:51 +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 ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHF64ML0z26N; Thu, 18 Feb 2021 14:30:50 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DhHF63kvbz2xqV; Thu, 18 Feb 2021 14:30:50 +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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DhHF53pPRz2xjs for ; Thu, 18 Feb 2021 14:30:49 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHF50C4nznm for ; Thu, 18 Feb 2021 14:30:49 +0000 (UTC) Received: (qmail 28674 invoked from network); 18 Feb 2021 14:30:30 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 18 Feb 2021 14:30:30 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH v2 3/6] zoneconf.cgi: Add STP options to GUI Date: Thu, 18 Feb 2021 15:30:13 +0100 Message-Id: <20210218143016.972-3-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20210218143016.972-1-hofmann@leo-andres.de> References: <20210218143016.972-1-hofmann@leo-andres.de> MIME-Version: 1.0 ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1613658649; a=rsa-sha256; cv=none; b=npPb5u+yE3MqNtz1yDPTYk74x8vWWNBwYnmNuDG15HBFWScaTCKehRZybXkxEeObIazLD2 N7/3R5dijeRIjhtW3ZKfUCgOZFkqAQljWCrQ1eHUE6ImdXEuz2dg+tHu0Fy7UClKBcP2yG q+2U/FY1gTRwapqpbbPtouO3KoVvzj8yMjW6a83FDqs8nuFGMkivb/sz4OdwgUhlUz2ksc BK0I0mFsCtsDmGiorlWNYGC92t/g1nxBq2Ql53FarvhoxJtH7jd16TEXOdGEIwiQUOM/+K 3AaoTDxuwHwGythiYRZyGeFW+KyLDcbChzUu+EiswDpL9JKJ/lAjzBAh69X+sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1613658649; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KSmByo1VMTgp2Kii/vWVLb6gfTzfBeEOiC+Htfwe6Yc=; b=TxIWReXhVNOKXiRpyAb4Lv2XysECZUV7QWuQUWlZjh64PVH3mtZ0+s1moOZiOaIv6lcw1r cH4pM3i1rr+I7gja4jSbBvZBbhv+h7K41VGfF9AlKDHUHsCVdQGi8IlPfy+FmIGqbWTzNY zzBSBSFEiuaanadlZasjRtbSAvBlpPs7zW+/jsX87kjMOzDhpxS2r42k0HvnaHlSQGC8JL HddHkEsCFdyWBQawMCideusWWat08fnLpzGaCpsqIOyJ4hRJhbuxc79Wmb+6gqtIilVVT5 wKO1C6koJ4ICqF0W60rzErIw87vHtE5CMf5XCJOgIXWoELoyRIhCF0fpibHJDQ== Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-4.01 / 11.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[leo-andres.de]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; IP_REPUTATION_HAM(-1.71)[asn: 205766(-0.24), country: DE(-0.01), ip: 185.26.156.147(-0.61)]; MID_CONTAINS_FROM(1.00)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[99.99%] X-Rspamd-Queue-Id: 4DhHF50C4nznm X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Changes & new features: - Add CSS for STP options, add texts to language files - Read STP settings from ethernet configuration and display inputs - Validate and save STP settings Signed-off-by: Leo-Andres Hofmann --- html/cgi-bin/zoneconf.cgi | 100 ++++++++++++++++++++++++++++++++++++++ langs/de/cgi-bin/de.pl | 4 ++ langs/en/cgi-bin/en.pl | 4 ++ 3 files changed, 108 insertions(+) diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index 13543d244..1d30450ed 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -40,6 +40,13 @@ my $extraHead = < td { + padding: 2px 10px; + } + /* section separators */ #zoneconf tr.divider-top { border-top: 2px solid $Header::bordercolour; @@ -75,6 +82,9 @@ my $extraHead = < td:first-child { + background-color: gray; + } /* alternating row background color */ #zoneconf tr { @@ -108,6 +118,9 @@ my $extraHead = <= 1) && ($stp_priority <= 65535)) { # STP bridge priority range: 1..65535 + $VALIDATE_error = $Lang::tr{"zoneconf val stp priority range error"}; + last; + } + $ethsettings{"${uc}_STP"} = "on"; # network-hotplug-bridges expects "on" + $ethsettings{"${uc}_STP_PRIORITY"} = $stp_priority; + } } # validation failed, show error message and exit @@ -481,6 +513,74 @@ END print "\t\n"; } +# STP options +my @stp_html = (); # form fields buffer (two rows) + +foreach (@zones) { # load settings and prepare form elements for each zone + my $uc = uc $_; + + # skip if zone is not activated + next unless is_zone_activated($_); + + # STP is not available if the RED interface is set to PPP, PPPoE, VDSL, ... + if ($uc eq "RED") { + unless (is_zonetype_ip($ethsettings{"RED_TYPE"})) { + push(@stp_html, ["\t\t\n", "\t\t\n"]); # print empty cell + next; + } + } + + # load configuration + my $stp_available = $ethsettings{"${uc}_MODE"} eq "bridge"; # STP is only available in bridge mode + my $stp_enabled = $ethsettings{"${uc}_STP"} eq "on"; + my $stp_priority = $ethsettings{"${uc}_STP_PRIORITY"}; + + # form element modifiers + my $checked = ""; + my $disabled = ""; + $checked = "checked" if ($stp_available && $stp_enabled); + $disabled = "disabled" unless $stp_available; + + # enable checkbox HTML + my $row_1 = < + + +END +; + $disabled = "disabled" unless $stp_enabled; # STP priority can't be entered if STP is disabled + + # priority input box HTML + my $row_2 = < + + +END +; + # add fields to buffer + push(@stp_html, [$row_1, $row_2]); +} + +# print two rows of prepared form elements +print < + +END +; +foreach (@stp_html) { + print $_->[0]; # row 1 +} +print < + + +END +; +foreach (@stp_html) { + print $_->[1]; # row 2 +} +print "\t\n"; + # footer and submit button print < diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 307b8a97c..b3c2a69da 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -2979,9 +2979,13 @@ 'zoneconf nicmode default' => 'Normal', 'zoneconf nicmode macvtap' => 'MacVTap', 'zoneconf notice reboot' => 'Bitte einen Neustart durchführen, um die Änderungen zu übernehmen.', +'zoneconf stp enable' => 'STP aktivieren', +'zoneconf stp priority' => 'Brücke Priorität', 'zoneconf title' => 'Zonen einrichten', 'zoneconf val native assignment error' => 'Eine Netzwerkkarte kann nicht von mehreren Zonen nativ verwendet werden.', 'zoneconf val ppp assignment error' => 'Die Netzwerkkarte, die von RED im PPP-Modus verwendet wird, kann keiner anderen Zone zugeordnet werden.', +'zoneconf val stp priority range error' => 'STP Brücke Priorität muss im Bereich 1-65535 liegen', +'zoneconf val stp zone mode error' => 'STP kann nur aktiviert werden, wenn sich die Zone im Brückenmodus befindet', 'zoneconf val vlan amount assignment error' => 'Pro Zone kann nur ein VLAN verwendet werden.', 'zoneconf val vlan tag assignment error' => 'Pro Netzwerkkarte kann derselbe VLAN-Tag nur einmal verwendet werden.', 'zoneconf val zoneslave amount error' => 'Wenn eine Zone nicht im Brückenmodus ist, kann ihr nur eine Netzwerkkarte zugewiesen werden.', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 22e8a4cc6..10167f872 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -3027,9 +3027,13 @@ 'zoneconf nicmode default' => 'Default', 'zoneconf nicmode macvtap' => 'MacVTap', 'zoneconf notice reboot' => 'Please reboot to apply your changes.', +'zoneconf stp enable' => 'STP enable', +'zoneconf stp priority' => 'Bridge Priority', 'zoneconf title' => 'Zone Configuration', 'zoneconf val native assignment error' => 'A NIC cannot be accessed natively by more than one zone.', 'zoneconf val ppp assignment error' => 'The NIC used for RED in PPP mode cannot be accessed by any other zone.', +'zoneconf val stp priority range error' => 'STP bridge priority must be in the range of 1-65535', +'zoneconf val stp zone mode error' => 'STP can only be enabled if the zone is in bridge mode', 'zoneconf val vlan amount assignment error' => 'A zone cannot have more than one VLAN assigned.', 'zoneconf val vlan tag assignment error' => 'You cannot use the same VLAN tag more than once per NIC.', 'zoneconf val zoneslave amount error' => 'A zone that is not in bridge mode can\'t have more than one NIC assigned', From patchwork Thu Feb 18 14:30:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3898 Return-Path: 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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DhHFD2B43z3wps for ; Thu, 18 Feb 2021 14:30:56 +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 ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHFC59vGzsY; Thu, 18 Feb 2021 14:30:55 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DhHFC4WZpz2xn3; Thu, 18 Feb 2021 14:30:55 +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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DhHFB0gdbz2xX7 for ; Thu, 18 Feb 2021 14:30:54 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHF81RH4z11 for ; Thu, 18 Feb 2021 14:30:52 +0000 (UTC) Received: (qmail 28734 invoked from network); 18 Feb 2021 14:30:36 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 18 Feb 2021 14:30:36 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH v2 4/6] zoneconf.cgi: Add Javascript for new GUI elements Date: Thu, 18 Feb 2021 15:30:14 +0100 Message-Id: <20210218143016.972-4-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20210218143016.972-1-hofmann@leo-andres.de> References: <20210218143016.972-1-hofmann@leo-andres.de> MIME-Version: 1.0 ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1613658652; a=rsa-sha256; cv=none; b=mbanNl2Wp57V/rHJH65Q3C50tHg2AhEdn5rkeizRpzBimDS1GpXFY7pXt9SQmgava1auA9 3BPKozrwA8mRnT0K2GONHwEIFLlDp2NWoiFI7E7uHXm9pv+vTW2+MI10k/Gu777/Fk3koX X0iEGjrw/K/+UWL6x7RAJjlQqI9P52Fj1WLQ+G6bhmcs6Ff8+qwwI85Hf1ho3+/+UdQ0tH Te8Af8jDDNrEnmbzvNxxw1ti9JklhAl/CEXkTz4iJY1K3UDJiIlu4orpBgtJr2L9yEjUzs 3F81hFG1TOnGLkt2IHn9oAd0xnwh7CuHhocofTtCOOqz3sZ6xnx/lMrZqBnNBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1613658652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4PJUOc3W0+2qra0kHnBLCSPbxR0umMn/yyA4Wg3JOm8=; b=iYV0iKqGYFV6fvLDkyCydh+gNcoJBBi/baR9pVx9Y4z1StjgYOiQbL7SUcUBVYjSEf+mRw HykBGq9boJIrSXTUcotHbGvTv6sI4H+BGSqhyOGzy/qztXiv1dO1+ckeHlRdhnIpECpkhh FGSd9lzxitCDUyxkaUlZWyrS6oBRFi7+cbwPMDy8blY/xVqtdhUU6urgpkrETCqzWxq4F7 soeKVoZ27sPv+ILuFXMyBeMsqaMX/4v8Or/ciYcX7q3ihUgjugeRCepyisz/+1yUgJg9aa 05Hq4oZL+p+dOD5Lp0Ynl2PC/7qJOtzJYi8xWuNUQtPzA/P4rQZhNc4JQ4aztQ== Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-0.01 / 11.00]; ARC_NA(0.00)[]; BAYES_HAM(-3.00)[99.99%]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx:c]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_CONTAINS_FROM(1.00)[]; IP_REPUTATION_HAM(-1.71)[asn: 205766(-0.24), country: DE(-0.01), ip: 185.26.156.147(-0.61)]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_COUNT_TWO(0.00)[2]; DMARC_NA(0.00)[leo-andres.de] X-Rspamd-Queue-Id: 4DhHF81RH4z11 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Leo-Andres Hofmann --- html/cgi-bin/zoneconf.cgi | 6 +++--- html/html/include/zoneconf.js | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index 1d30450ed..eb6cd0e66 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -410,7 +410,7 @@ foreach (@zones) { print <$uc
- @@ -544,7 +544,7 @@ foreach (@zones) { # load settings and prepare form elements for each zone # enable checkbox HTML my $row_1 = < - + END ; @@ -553,7 +553,7 @@ END # priority input box HTML my $row_2 = < - + END ; diff --git a/html/html/include/zoneconf.js b/html/html/include/zoneconf.js index d76f0ab68..d27a79bc8 100644 --- a/html/html/include/zoneconf.js +++ b/html/html/include/zoneconf.js @@ -54,3 +54,30 @@ function highlightAccess(selectObj) { //if interface is assigned, highlight table cell in zone color colorParentCell(selectObj, zoneColor, (selectObj.value !== 'NONE')); } + +//update zone mode +function changeZoneMode(selectObj) { + if(!(selectObj && ('zone' in selectObj.dataset))) { + return; //required parameters are missing + } + + // STP enable checkbox + let stpEnable = document.getElementById('STP-' + selectObj.dataset.zone); + if(stpEnable) { + stpEnable.disabled = (selectObj.value !== 'BRIDGE'); //STP is available if zone is in bridge mode + stpEnable.checked = stpEnable.checked && (! stpEnable.disabled); //un-check if disabled + stpEnable.dispatchEvent(new Event('change')); + } +} + +//STP enable checkbox change toggles priority input +function changeEnableSTP(inputObj) { + if(!(inputObj && ('zone' in inputObj.dataset))) { + return; //required parameters are missing + } + + let priority = document.getElementById('STP-PRIORITY-' + inputObj.dataset.zone); + if(priority) { + priority.disabled = inputObj.disabled || (! inputObj.checked); + } +} From patchwork Thu Feb 18 14:30:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3899 Return-Path: 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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DhHFL1MBmz3wps for ; Thu, 18 Feb 2021 14:31:02 +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 ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHFK5skmz299; Thu, 18 Feb 2021 14:31:01 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DhHFK5Fnjz2xqV; Thu, 18 Feb 2021 14:31:01 +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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DhHFJ0FQ8z2xX7 for ; Thu, 18 Feb 2021 14:31:00 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHFH3HcPz11 for ; Thu, 18 Feb 2021 14:30:59 +0000 (UTC) Received: (qmail 28797 invoked from network); 18 Feb 2021 14:30:46 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 18 Feb 2021 14:30:46 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH v2 5/6] zoneconf.cgi: Import network-functions.pl Date: Thu, 18 Feb 2021 15:30:15 +0100 Message-Id: <20210218143016.972-5-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20210218143016.972-1-hofmann@leo-andres.de> References: <20210218143016.972-1-hofmann@leo-andres.de> MIME-Version: 1.0 ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1613658659; a=rsa-sha256; cv=none; b=nmQ2/b/viFZRuhaJw8LzdxNfckkZ00PPvuWHaO+OtJNJOHsr20KNHe3jiLtmnlI/da6XBu Q9nO5lOjdQ80cbLPKlq6fOq5DEVw7DJBzjRG4ECtAIHpWexyJlYx9Wu0e8CjQg4+vzCyUt 1EVqDYW/dBJhkg4IIQYPipwqXDtssxGDXYwphuYiEwFH0swKBGiS/79nJrfCSvJHpW8Q74 bFu+9/rM8US3yonuA0Nyd2gZwIPlpnsNFwlqubkaAVoAM6GoIJm/LKuKSGU33zBfvPD/Jg taWp+rksbswB+wpSYmIdl1lus7W1PBbImhQiqsJgGYUCIR+0n9YUYs+1hU1ITA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1613658659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=atgqWCqDUrFs2M8mw8/htpqTc1zvPJ1+MRecEdREpDc=; b=pUTm8S3T3irFRXtZApR2YAhfOyIad9ovd46dsLyd2AUoEpF35SVphN42XmElvVeAo7n1Al H00QT8t7vEsv8ETI5mQ9EMr/5S8Q+DD7KnMMnLDHpy11IcKn4ssre2iejqqUztLlMTrHvx p1Hj0XXU4MJGC+dst7l+YSptDUUKbK7Y11+KTSM4r6xwiXyoeOIrLAXEjUU/Hk2RqMyl6C TWreBj0jaWCtFOdpi5Ax4pPWvi0WM2yWpIvX9vtkgNLUf8TPWQz9z/vbEwQIg0dGZZyDxR bHtZYFl9HrqCr0gv6tZBqnABMAt7xW/dPTa3U+FmaW4MOT1X8CD1Pt15ezOnxw== Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-0.01 / 11.00]; ARC_NA(0.00)[]; BAYES_HAM(-3.00)[99.99%]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx:c]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_CONTAINS_FROM(1.00)[]; IP_REPUTATION_HAM(-1.71)[asn: 205766(-0.24), country: DE(-0.01), ip: 185.26.156.147(-0.61)]; DMARC_NA(0.00)[leo-andres.de]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_COUNT_TWO(0.00)[2]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1] X-Rspamd-Queue-Id: 4DhHFH3HcPz11 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Remove custom functions and use network-functions.pl instead to detect the available zones correctly. This also removes the requirement that a device must be assigned for a zone to become visible/configurable. Fixes: #12568 Signed-off-by: Leo-Andres Hofmann --- html/cgi-bin/zoneconf.cgi | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index eb6cd0e66..9d01d06ce 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -25,6 +25,7 @@ use Scalar::Util qw(looks_like_number); require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +require "${General::swroot}/network-functions.pl"; ###--- HTML HEAD ---### my $extraHead = <$uc ($red_type)\n"; next; # We're done here @@ -436,12 +421,9 @@ foreach (@nics) { my $uc = uc $_; my $highlight = ""; - # If the zone is not activated, don't show it - next unless is_zone_activated($_); - if ($uc eq "RED") { # VLANs/Bridging is not possible if the RED interface is set to PPP, PPPoE, VDSL, ... - unless (is_zonetype_ip($ethsettings{"RED_TYPE"})) { + unless (Network::is_red_mode_ip()) { my $checked = ""; if ($mac eq $ethsettings{"${uc}_MACADDR"}) { @@ -519,12 +501,9 @@ my @stp_html = (); # form fields buffer (two rows) foreach (@zones) { # load settings and prepare form elements for each zone my $uc = uc $_; - # skip if zone is not activated - next unless is_zone_activated($_); - # STP is not available if the RED interface is set to PPP, PPPoE, VDSL, ... if ($uc eq "RED") { - unless (is_zonetype_ip($ethsettings{"RED_TYPE"})) { + unless (Network::is_red_mode_ip()) { push(@stp_html, ["\t\t
\n", "\t\t\n"]); # print empty cell next; } From patchwork Thu Feb 18 14:30:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3900 Return-Path: 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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DhHFP2xKCz3wps for ; Thu, 18 Feb 2021 14:31:05 +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 ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHFN70kPz295; Thu, 18 Feb 2021 14:31:04 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DhHFN6PTgz2xkD; Thu, 18 Feb 2021 14:31:04 +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 (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DhHFM1yc0z2xX7 for ; Thu, 18 Feb 2021 14:31:03 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4DhHFM0zjNz295 for ; Thu, 18 Feb 2021 14:31:03 +0000 (UTC) Received: (qmail 28825 invoked from network); 18 Feb 2021 14:30:49 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 18 Feb 2021 14:30:49 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH v2 6/6] zoneconf.cgi: Improve VLAN & STP inputs Date: Thu, 18 Feb 2021 15:30:16 +0100 Message-Id: <20210218143016.972-6-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 In-Reply-To: <20210218143016.972-1-hofmann@leo-andres.de> References: <20210218143016.972-1-hofmann@leo-andres.de> MIME-Version: 1.0 ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1613658663; a=rsa-sha256; cv=none; b=Uul+xUP6qPzPt2ZLFHaldKAJ+d8epPvDJpW9OGn1YU/HfQc4VhRAWBTfvqCSWDkDF7vgeV tzSZJ6LqlzF+jJPmFbVe2gL9JXJQiZAi3mC6S9PpdLC0aNDLLWp1npAfZ53uYdjL/QMs68 VSt0ISbsyCxBupZHkoHjVP1Qgx8M7dE0m6u/NinexxRNYs7TNxjIoTdAp/RG27/S6DgsOO lqJEZ6of+jaN1V2MFaTkzMRdJedz+ki3y1Dv+GM16bghxzGca8k1JnhT8X+tjcB0mt7UzE ezy9hmI2jKlOyJNiVxcZul86NRadfz7N+tdlW6Tlt64ndQJBI4t9DfykWA+22g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1613658663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P3Zn1Q4M9HZsluCwVQ6injHrYHMxu6BF6CNgl3k1uu4=; b=Fb4pY8lrxqPWEYavzl7qRt8lk/BIXU0oSFmKfd5q3HmDqIJvBgY+kgfAjXAva+YG/Uek9v gFjncNUOiIfJiCHQpEHWOZ1Lf3V+05KVxyFcf8saqTYVhApMPRuMrT96cGT1qZtmYa2tBt M+QbBHrxu2+LiL6VH9x18+YEMhiXPANm6SVtvbK5z4wSgmXgS3XWCqwhhAtWXeQuYuUhDB kMpCH+gvmWqC+omNBbuEFeoCA0BDh2vY2mBa43wZQfqENTfR7Uw4UHX2EK3ClW3JlK+Eg8 BPJA9VXORDZhDyONbePUb3xgbdj22aWfRO0QDu+comF2rWWuE+bIBn1ojmbM7A== Authentication-Results: mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de; dmarc=none X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-0.01 / 11.00]; ARC_NA(0.00)[]; BAYES_HAM(-3.00)[99.99%]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx:c]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_CONTAINS_FROM(1.00)[]; IP_REPUTATION_HAM(-1.71)[asn: 205766(-0.24), country: DE(-0.01), ip: 185.26.156.147(-0.61)]; DMARC_NA(0.00)[leo-andres.de]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_COUNT_TWO(0.00)[2]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1] X-Rspamd-Queue-Id: 4DhHFM0zjNz295 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Add default values and mark fields as required. Signed-off-by: Leo-Andres Hofmann --- html/cgi-bin/zoneconf.cgi | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/html/cgi-bin/zoneconf.cgi b/html/cgi-bin/zoneconf.cgi index 9d01d06ce..bbd042ffc 100644 --- a/html/cgi-bin/zoneconf.cgi +++ b/html/cgi-bin/zoneconf.cgi @@ -478,6 +478,9 @@ END if ($access_selected{"NONE"} eq "") { $highlight = $_; } + + # default VLAN tag if not configured + $zone_vlan_id = 1 unless looks_like_number($zone_vlan_id); print < @@ -486,7 +489,7 @@ END - + END ; @@ -513,6 +516,9 @@ foreach (@zones) { # load settings and prepare form elements for each zone my $stp_available = $ethsettings{"${uc}_MODE"} eq "bridge"; # STP is only available in bridge mode my $stp_enabled = $ethsettings{"${uc}_STP"} eq "on"; my $stp_priority = $ethsettings{"${uc}_STP_PRIORITY"}; + + # set priority to default value if no numerical value is configured + $stp_priority = 32768 unless looks_like_number($stp_priority); # form element modifiers my $checked = ""; @@ -532,7 +538,7 @@ END # priority input box HTML my $row_2 = < - + END ;
$uc
$nic
$mac
$nic
$mac
$Lang::tr{"zoneconf stp enable"}
$Lang::tr{"zoneconf stp priority"}