]> git.ipfire.org Git - location/libloc.git/commitdiff
location-exporter: Do not mistake country AS for an AS number
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Jun 2020 16:31:44 +0000 (16:31 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Jun 2020 16:31:44 +0000 (16:31 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/location-exporter.in

index 894bb4408272c03aca3ab3cba5ad4387bbd6e0d0..54545619f39a3a8dddbe0981e0f85f721223030f 100644 (file)
@@ -22,6 +22,7 @@ import io
 import ipaddress
 import logging
 import os.path
+import re
 import socket
 import sys
 
@@ -258,12 +259,9 @@ class CLI(object):
                        families = [ socket.AF_INET6, socket.AF_INET ]
 
                for object in ns.objects:
-                       if object.startswith("AS"):
-                               try:
-                                       object = int(object[2:])
-                               except ValueError:
-                                       log.error("Invalid argument: %s" % object)
-                                       return 2
+                       m = re.match("^AS(\d+)$", object)
+                       if m:
+                               object = int(m.group(1))
 
                                asns.append(object)