Opened 5 years ago

Closed 2 years ago

#3271 closed bug (Fixed)

Support pygeoip for ip lookups

Reported by: Cas Owned by:
Priority: minor Milestone: 2.0.6
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 (4)

comment:1 Changed 5 years ago by Cas

  • Description modified (diff)

comment:2 Changed 2 years ago by Cas

  • Milestone changed from 2.0.4 to 2.0.5

Ticket retargeted after milestone closed

comment:3 Changed 2 years ago by Cas

  • Milestone changed from 2.0.5 to 2.0.6

Ticket retargeted after milestone closed

comment:4 Changed 2 years ago by Cas

  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by: [65e5010e7fbd]

Note: See TracTickets for help on using tickets.