src/buildservice/database.py \
src/buildservice/decorators.py \
src/buildservice/distribution.py \
- src/buildservice/geoip.py \
src/buildservice/git.py \
src/buildservice/jobqueue.py \
src/buildservice/jobs.py \
EXTRA_DIST += \
src/crontab/pakfire-build-service
-dist_geoip_DATA = \
- src/geoip/GeoLite2-Country.mmdb
-
-geoipdir = $(datadir)/geoip
-
EXTRA_DIST += \
- src/tools/dump-database-schema.sh \
- src/tools/update-geoip-database.sh
+ src/tools/dump-database-schema.sh
# ------------------------------------------------------------------------------
-
-REQUIREMENTS
- Python modules:
- * geoip2
-
TRANSLATE
Help translating the build service!
http://pootle.ipfire.org/projects/pakfire-build-service/
-
-
-This product includes GeoLite2 data created by MaxMind, available from
- https://dev.maxmind.com/geoip/geoip2/geolite2/
from . import cache
from . import database
from . import distribution
-from . import geoip
from . import jobqueue
from . import jobs
from . import keys
self.arches = arches.Arches(self)
self.builds = builds.Builds(self)
self.cache = cache.Cache(self)
- self.geoip = geoip.GeoIP(self)
self.jobs = jobs.Jobs(self)
self.builders = builders.Builders(self)
self.distros = distribution.Distributions(self)
import tornado.httpclient
import urllib.parse
+import location
+
from . import base
from . import logs
from .decorators import lazy_property
class Mirrors(base.Object):
+ def init(self):
+ self.location = location.Database("/var/lib/location/database.db")
+
def _get_mirror(self, query, *args):
res = self.db.get(query, *args)
WHERE hostname = %s AND deleted IS FALSE", hostname)
def make_mirrorlist(self, client_address=None):
- country_code = self.backend.geoip.guess_from_address(client_address)
+ network = self.location.lookup(client_address)
# Walk through all mirrors in a random order
# and put all preferred mirrors to the front of the list
# and everything else at the end
mirrors = []
for mirror in self.random:
- if mirror.is_preferred_for_country(country_code):
+ if mirror.is_preferred_for_country(network.country_code if network else None):
mirrors.insert(0, mirror)
else:
mirrors.append(mirror)
@lazy_property
def country_code(self):
- return self.backend.geoip.guess_from_address(self.address) or "UNKNOWN"
+ network = self.location.lookup(self.address)
+
+ if network:
+ return network.country_code
+
+ return "UNKNOWN"
def get_history(self, *args, **kwargs):
kwargs["mirror"] = self