Opened 5 years ago

Closed 3 years ago

#3271 closed bug (Fixed)

Support pygeoip for ip lookups

Reported by: Calum Owned by:
Priority: minor Milestone: 2.0.6
Component: Core Version: 2.0.0
Keywords: Cc:

Description (last modified by Calum)

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 by Calum, 5 years ago

Description: modified (diff)

comment:2 by Calum, 3 years ago

Milestone: 2.0.42.0.5

Ticket retargeted after milestone closed

comment:3 by Calum, 3 years ago

Milestone: 2.0.52.0.6

Ticket retargeted after milestone closed

comment:4 by Calum, 3 years ago

Resolution: Fixed
Status: newclosed

Fixed by: [65e5010e7fbd]

Note: See TracTickets for help on using tickets.