From patchwork Fri Jan 11 06:40:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 2034 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail01.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web07.i.ipfire.org (Postfix) with ESMTPS id F239187AF7F for ; Thu, 10 Jan 2019 19:40:27 +0000 (GMT) Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 7B5F721B512A; Thu, 10 Jan 2019 19:40:27 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1547149227; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id: list-unsubscribe:list-subscribe:list-post; bh=mU+c6ovDtawK725Ap5DhUPBXbTJKTzVyQG+ZL860nW4=; b=SaSKwwISBRHBBVKM5geW761hj7WYKjERkGSCOxOdF1JM7jaJstOGwpwB8C2Xk9TtH+/03u L/X1ECJzIKIcWbkLgLbrQ4VaydGtvV8C0v9xY5b2NBrwGhyzZur97jMe1tMzhhQ+Xm+Jye Sg9gz4oUalZxFLm87wPyOagmhkyKrTcETbkBnUeBf2wI6HF0F1ZpLlZedHTVCPe8gj6PP+ XMYXt2pHj9pZAr8uPdMpr4hv0WYn512q/uhWlpbcTJtWARKXVWEJzBQ4X1gA8iAFCsw9F8 7+6NGRGNPRIkLCKwWR+M3lFb2fozgXlcFqcTJ2klAvE0RkbQOLJCee1LnUED0A== Received: from tuxedo.stevee (212095005050.public.telering.at [212.95.5.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 4B94621990A2; Thu, 10 Jan 2019 19:40:22 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1547149222; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mU+c6ovDtawK725Ap5DhUPBXbTJKTzVyQG+ZL860nW4=; b=UsNi5QeP+xvrhQsDPZEdmZ3pQdAzItu3nzAC2DPgxI0ZEejb5I0oj8KiHGHmue3XI3C3Dz YcwdABkRQaJSKAj3N85XW4AKpqqKQOiqFqY1MXZikixfWh0EYWkc7mG9key2g6Ctg59RVA Vv2wKyAz1SnAgkPEpot7XJIHvBTfsucNnNvUTaNDW16lr+sqg/vi5KDIgVD2UbrSU9/ToU V8TiPSqdt+srQPOCA0/Uml1MIlMDt/1NcDLTS5u4yMolOM0TB5cPkoxQMt8ar0vNV+zKgp koroItMgX0Y67a48KBafexcfowEkeLU6S1pcHBOfz4ayV/1iDfVEO22exSxSZA== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 2/2] firewall-lib.pl: Use get_geoip_locations from geoip-functions.pl Date: Thu, 10 Jan 2019 20:40:04 +0100 Message-Id: <20190110194004.3341-2-stefan.schantl@ipfire.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190110194004.3341-1-stefan.schantl@ipfire.org> References: <20190110194004.3341-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=stevee smtp.mailfrom=stefan.schantl@ipfire.org X-Spamd-Result: default: False [-4.54 / 11.00]; ARC_NA(0.00)[]; URL_IN_SUBJECT(0.40)[geoip-functions.pl]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-2.91)[-0.970,0]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8412, ipnet:212.95.0.0/19, country:AT]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.93)[99.69%] X-Spam-Status: No, score=-4.54 X-Rspamd-Server: mail01.i.ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.15 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: Stefan Schantl --- config/firewall/firewall-lib.pl | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/config/firewall/firewall-lib.pl b/config/firewall/firewall-lib.pl index 9b7f55c9d..c14023e7b 100644 --- a/config/firewall/firewall-lib.pl +++ b/config/firewall/firewall-lib.pl @@ -39,6 +39,7 @@ my %ovpnsettings=(); my %aliases=(); require '/var/ipfire/general-functions.pl'; +require '${General::swroot}/geoip-locations.pl'; my $confignet = "${General::swroot}/fwhosts/customnetworks"; my $confighost = "${General::swroot}/fwhosts/customhosts"; @@ -591,36 +592,7 @@ sub get_internal_firewall_ip_address } sub get_geoip_locations() { - # Path to the directory which contains the binary geoip - # databases. - my $directory="/usr/share/xt_geoip/LE"; - - # Array to store the final country list. - my @country_codes = (); - - # Open location and do a directory listing. - opendir(DIR, "$directory"); - my @locations = readdir(DIR); - closedir(DIR); - - # Loop through the directory listing, and cut of the file extensions. - foreach my $location (sort @locations) { - # skip . and .. - next if($location =~ /^\.$/); - next if($location =~ /^\.\.$/); - - # Remove whitespaces. - chomp($location); - - # Cut-off file extension. - my ($country_code, $extension) = split(/\./, $location); - - # Add country code to array. - push(@country_codes, $country_code); - } - - # Return final array. - return @country_codes; + return &GeoIP::get_geoip_locations(); } return 1;