public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
From: "Peter Müller" <peter.mueller@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH 1/4] location-functions.pl: add functions for fetching AS information
Date: Tue, 03 Nov 2020 15:28:53 +0100	[thread overview]
Message-ID: <8cce16a8-5a92-acbb-28e7-68df2a95d887@ipfire.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 4620 bytes --]

Signed-off-by: Peter Müller <peter.mueller(a)ipfire.org>
---
 config/cfgroot/location-functions.pl | 68 +++++++++++++++++++---------
 1 file changed, 46 insertions(+), 22 deletions(-)

diff --git a/config/cfgroot/location-functions.pl b/config/cfgroot/location-functions.pl
index 2cfe7f908..ee03a6611 100644
--- a/config/cfgroot/location-functions.pl
+++ b/config/cfgroot/location-functions.pl
@@ -1,25 +1,23 @@
 #!/usr/bin/perl -w
-############################################################################
-#                                                                          #
-# This file is part of the IPFire Firewall.                                #
-#                                                                          #
-# IPFire is free software; you can redistribute it and/or modify           #
-# it under the terms of the GNU General Public License as published by     #
-# the Free Software Foundation; either version 2 of the License, or        #
-# (at your option) any later version.                                      #
-#                                                                          #
-# IPFire is distributed in the hope that it will be useful,                #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
-# GNU General Public License for more details.                             #
-#                                                                          #
-# You should have received a copy of the GNU General Public License        #
-# along with IPFire; if not, write to the Free Software                    #
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
-#                                                                          #
-# Copyright (C) 2015 - 2020 IPFire Team <info(a)ipfire.org>.                 #
-#                                                                          #
-############################################################################
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007-2020  IPFire Team  <info(a)ipfire.org>                     #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
 
 package Location::Functions;
 
@@ -83,7 +81,7 @@ sub verify ($) {
 }
 
 #
-## Function to the the country code of a given address.
+## Function to get the country code of a given address.
 #
 sub lookup_country_code($$) {
 	my ($db_handle, $address) = @_;
@@ -221,4 +219,30 @@ sub address_has_flags($) {
 	return @flags;
 }
 
+#
+## Function to get the Autonomous System Number of a given address.
+#
+sub lookup_asn($$) {
+	my ($db_handle, $address) = @_;
+
+	# Lookup the given address.
+	my $asn = &Location::lookup_asn($db_handle, $address);
+
+	# Return the number of the Autonomous System
+	return $asn;
+}
+
+#
+## Function to get the name of an Autonomous System.
+#
+sub get_as_name($$) {
+	my ($db_handle, $asn) = @_;
+
+	# Fetch the name of this AS...
+	my $as_name = &Location::get_as_name($db_handle, $asn);
+
+	# Return the name of the Autonomous System
+	return $as_name;
+}
+
 1;
-- 
2.26.2

             reply	other threads:[~2020-11-03 14:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 14:28 Peter Müller [this message]
2020-11-03 14:29 ` [PATCH 2/4] ipinfo.cgi: display AS information as well Peter Müller
2020-11-03 14:29   ` [PATCH 3/4] langs: add changed strings to German and English translations Peter Müller
2020-11-03 14:30     ` [PATCH 4/4] langs: Hrmpf, add forgotten string Peter Müller
2020-11-06 10:56 ` [PATCH 1/4] location-functions.pl: add functions for fetching AS information Michael Tremer
2020-11-06 13:57   ` Peter Müller
2020-11-06 19:23     ` Michael Tremer
2020-11-11 13:53       ` Peter Müller
2020-11-11 14:19         ` Peter Müller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8cce16a8-5a92-acbb-28e7-68df2a95d887@ipfire.org \
    --to=peter.mueller@ipfire.org \
    --cc=development@lists.ipfire.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox