]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/backend/util.py
location: Redesign index page
[ipfire.org.git] / src / backend / util.py
index 18bcbe3d9240a9463badfeace991c31d752692bd..f7182c896f0378a6d4d0d14eadf24c4377400c75 100644 (file)
@@ -39,9 +39,6 @@ BLACKLISTS = (
        "zen.spamhaus.org",
 )
 
-# Open location database
-db = location.Database("/var/lib/location/database.db")
-
 class Address(Object):
        def init(self, address):
                self.address = ipaddress.ip_address(address)
@@ -58,7 +55,7 @@ class Address(Object):
 
        @lazy_property
        def network(self):
-               return db.lookup("%s" % self.address)
+               return self.backend.location.lookup("%s" % self.address)
 
        @property
        def country_code(self):
@@ -70,6 +67,11 @@ class Address(Object):
                if self.network:
                        return self.network.asn
 
+       @lazy_property
+       def autonomous_system(self):
+               if self.asn:
+                       return self.backend.location.get_as(self.asn)
+
        # Blacklist
 
        def _make_blacklist_rr(self, blacklist):