Giter Site home page Giter Site logo

Comments (11)

Miserlou avatar Miserlou commented on May 18, 2024

AF_INET6 - looks like easy-timezones isn't IPv6 ready yet! :( :( :(

from django-easy-timezones.

lucas03 avatar lucas03 commented on May 18, 2024

Thanks for reply, will it be available? Or could you ignore ipv6 in easy-timezones?

from django-easy-timezones.

Miserlou avatar Miserlou commented on May 18, 2024

Pull requests welcome :)

On Tue, Oct 28, 2014 at 3:21 PM, Lukas Vojt [email protected]
wrote:

Reopened #6 #6.


Reply to this email directly or view it on GitHub
#6 (comment)
.

from django-easy-timezones.

lucas03 avatar lucas03 commented on May 18, 2024

I created a pull request, it's my first time working with github (hope it works). Codes are similar to yours. Haven't tested it too much, take a look please.

from django-easy-timezones.

jasonm avatar jasonm commented on May 18, 2024

@vinitkumar's patch works for me. I was encountering this in the https://github.com/torchbox/wagtail CMS admin panel when previewing a page.

In case anyone is following along at home...

Wagtail's "preview this page" functionality issues a dummy request to compute the previewed content. This presumably passes a fake requestor IP address into the dummy request. The django-easy-timezones library has a piece of middleware installed which attempts to infer a time zone based on geolocating the requestor IP. So, when Wagtail issues the dummy request, the bad IP address causes django-easy-timezone to pass a malformed IP to inet_aton, which blows up.

@vinitkumar's additional well-formedness check will defensively prevent not only IPV6 addresses from causing an issue, but any malformed IP address.

from django-easy-timezones.

jasonm avatar jasonm commented on May 18, 2024

Looking more closely at easy_timezones.middleware.EazyTimezoneMiddleware.process_request, is it reasonable for it to change:

            if ip != '127.0.0.1':
                # if not local, fetch the timezone from pygeoip
                tz = db.time_zone_by_addr(ip)

to also check for a missing IP:

            if ip and ip != '127.0.0.1':
                # if not local, fetch the timezone from pygeoip
                tz = db.time_zone_by_addr(ip)

?

from django-easy-timezones.

jasonm avatar jasonm commented on May 18, 2024

There seems to be some prior Django discussion that discourages relying on REMOTE_ADDR: https://www.djangoproject.com/weblog/2009/jul/28/security/#secondary-issue so perhaps the if ip and ip != '127.0.0.1' is the way to go?

from django-easy-timezones.

Miserlou avatar Miserlou commented on May 18, 2024

I like that @jasonm.

PR's graciously accepted - if you're using the IPV6 database, please update the documentation to reflect that as well.

Thanks!

from django-easy-timezones.

Miserlou avatar Miserlou commented on May 18, 2024

The supplied code wasn't totally valid, but I've added a different solution and now it should work. I've also started adding tests.

from django-easy-timezones.

lucas03 avatar lucas03 commented on May 18, 2024

Nice! will you push it to pip as well? Will you add IPv6 support with GEOIP file for IPv6?

from django-easy-timezones.

Miserlou avatar Miserlou commented on May 18, 2024

@lucas03 - IPv6 support based on the GeoIPv6 file is available in version 0.6.0, published to pip.

Both of the GeoIP files are now included by default for convenience.

from django-easy-timezones.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.