Opened 14 months ago

Last modified 14 months ago

#3271 new bug

Support pygeoip for ip lookups

Reported by: Cas Owned by:
Priority: minor Milestone: 2.0.4
Component: Core Version: 2.0.0
Keywords: Cc:

Description (last modified by Cas)

Alpine linux only packages the pure-python pygeoip as py3-geoip which is not the same as the MaxMind GeoIP (python3-geoip on Ubuntu).

However they packages are compatible with some minor changes:

  • deluge/core/preferencesmanager.py

    diff --git deluge/core/preferencesmanager.py deluge/core/preferencesmanager.py
    index e3c935c99..19dd3b2fb 100644
    (this hunk was shorter than expected) 
    2424from deluge._libtorrent import lt 
    2525from deluge.event import ConfigValueChangedEvent 
    2626 
     27GeoIP = None 
    2728try: 
    28     import GeoIP 
     29    from GeoIP import GeoIP 
    2930except ImportError: 
    30     GeoIP = None 
     31    try: 
     32        from pygeoip import GeoIP 
     33    except ImportError: 
     34        pass 
    3135 
    3236try: 
    3337    from urllib.parse import quote_plus 
    def _on_set_geoip_db_location(self, key, geoipdb_path): 
    464469        # Load the GeoIP DB for country look-ups if available 
    465470        if os.path.exists(geoipdb_path): 
    466471            try: 
    467                 self.core.geoip_instance = GeoIP.open( 
    468                     geoipdb_path, GeoIP.GEOIP_STANDARD 
    469                 ) 
     472                self.core.geoip_instance = GeoIP(geoipdb_path, 0) 
    470473            except AttributeError: 
    471474                log.warning('GeoIP Unavailable') 
    472475        else: 

Change History (1)

comment:1 Changed 14 months ago by Cas

  • Description modified (diff)
Note: See TracTickets for help on using tickets.