From patchwork Tue Jan 12 18:11: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: 3796 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 RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DFdtn3QB9z3whw for ; Tue, 12 Jan 2021 18:11:29 +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 "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4DFdtm1gfwz4h0; Tue, 12 Jan 2021 18:11:28 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DFdtm0bvZz2ySQ; Tue, 12 Jan 2021 18:11:28 +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 RSA-PSS (4096 bits)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DFdtk29q7z2xl3 for ; Tue, 12 Jan 2021 18:11:26 +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 4DFdtj4SGJzmW for ; Tue, 12 Jan 2021 18:11:25 +0000 (UTC) Received: (qmail 8271 invoked from network); 12 Jan 2021 18:11:24 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 12 Jan 2021 18:11:24 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH] header.pl: Remove duplicate "IpInSubnet" function Date: Tue, 12 Jan 2021 19:11:14 +0100 Message-Id: <20210112181114.77-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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1610475085; 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=gXWqycjtIPKUgVH2Bwk/1m3nuw/2INFslGC1rI9qGR0=; b=AdZiLnrNi5znbwEoI4JNDdoruNOMMAuDGF9IzCPbsZC3WEB5WVBpKbx8MszXKG0QaL4kGv T0izKXYc6kfdjsgFRhVG/7Ptilsno/Ug0VQ8gvplqRPWFbcrdxuvIhbs/AU1WVGm40datc DGRFkcrkg/QvhqfLvHax0kYiDnM7NeZ8EUoGLSbIeP4rblYeFgKnqK2zTOD2zvsUf3jGbP KN8ND5f7w+Y9F+PRXeAJ6iQwXwDRdBl8hseaWeOpIPF6fTan3ZdSc6tYBwWcEKYuXwdMkv 30jJWx42z/CprR5RH0iwbpoqfiIy0wjqToLExyeTA3neNgIKFqgcdjK5gE+ksQ== ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1610475085; a=rsa-sha256; cv=none; b=BVZxR8OIBvL3MusUNd1M/RO1naJLvJitQ54uMXylCfYc0lvZdRE2hxImDns6p7zul9c4jA e5JCNoY83rCjMb2P12OeSFXz4I7nLfzyFENqXT840tgAqd1kHoMIG2EvwwLynuq19w3xk3 FfjDIWxAvZdSc6SeOVOJBOJ4CzCXc+/gmL6P/QpQjP+ylIPg2Cs82DL16yLtYeplrwKGQ8 MlE7J8Wu/8D87uDYLqHxOfL2Iz2pFsL8b+ez78fCJdkY6nG+35GS1ze7Tr1p7IgvOe1VD4 0VKzekUuYsiDXH8iFm4p0/pIAkKwbZbAeatrfRBDsDXrc//F5zQ5Y0SlL8wmhg== X-Rspamd-Queue-Id: 4DFdtj4SGJzmW Authentication-Results: mail01.ipfire.org; dkim=none; dmarc=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 X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-0.01 / 11.00]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; 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.71)[asn: 205766(-0.24), country: DE(-0.00), ip: 185.26.156.147(-0.61)]; MID_CONTAINS_FROM(1.00)[]; R_SPF_ALLOW(-0.20)[+mx]; 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(-3.00)[99.99%] 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" This function is deprecated. The commonly used and maintained "IpInSubnet" function can be found in general-functions.pl. Signed-off-by: Leo-Andres Hofmann --- config/cfgroot/header.pl | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index e2e6fd689..5684c01c5 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -311,22 +311,6 @@ sub getcgihash { return; } - -# Test if IP is within a subnet -# Call: IpInSubnet (Addr, Subnet, Subnet Mask) -# Subnet can be an IP of the subnet: 10.0.0.0 or 10.0.0.1 -# Everything in dottted notation -# Return: TRUE/FALSE -sub IpInSubnet -{ - $ip = unpack('N', inet_aton(shift)); - $start = unpack('N', inet_aton(shift)); - $mask = unpack('N', inet_aton(shift)); - $start &= $mask; # base of subnet... - $end = $start + ~$mask; - return (($ip >= $start) && ($ip <= $end)); -} - sub escape($) { my $s = shift; return HTML::Entities::encode_entities($s); @@ -559,13 +543,13 @@ sub colorize { return "".$string.""; } elsif ( $string =~ "lo" or $string =~ "127.0.0.0" ){ return "".$string.""; - } elsif ( $string =~ $ethsettings{'GREEN_DEV'} or &IpInSubnet($string2,$ethsettings{'GREEN_NETADDRESS'},$ethsettings{'GREEN_NETMASK'}) ){ + } elsif ( $string =~ $ethsettings{'GREEN_DEV'} or &General::IpInSubnet($string2,$ethsettings{'GREEN_NETADDRESS'},$ethsettings{'GREEN_NETMASK'}) ){ return "".$string.""; } elsif ( $string =~ "ppp0" or $string =~ $ethsettings{'RED_DEV'} or $string =~ "0.0.0.0" or $string =~ $ethsettings{'RED_ADDRESS'} ){ return "".$string.""; - } elsif ( $ethsettings{'CONFIG_TYPE'}>1 and ( $string =~ $ethsettings{'BLUE_DEV'} or &IpInSubnet($string2,$ethsettings{'BLUE_NETADDRESS'},$ethsettings{'BLUE_NETMASK'}) )){ + } elsif ( $ethsettings{'CONFIG_TYPE'}>1 and ( $string =~ $ethsettings{'BLUE_DEV'} or &General::IpInSubnet($string2,$ethsettings{'BLUE_NETADDRESS'},$ethsettings{'BLUE_NETMASK'}) )){ return "".$string.""; - } elsif ( $ethsettings{'CONFIG_TYPE'}>2 and ( $string =~ $ethsettings{'ORANGE_DEV'} or &IpInSubnet($string2,$ethsettings{'ORANGE_NETADDRESS'},$ethsettings{'ORANGE_NETMASK'}) )){ + } elsif ( $ethsettings{'CONFIG_TYPE'}>2 and ( $string =~ $ethsettings{'ORANGE_DEV'} or &General::IpInSubnet($string2,$ethsettings{'ORANGE_NETADDRESS'},$ethsettings{'ORANGE_NETMASK'}) )){ return "".$string.""; } else { return $string;