Comments (11)
AF_INET6 - looks like easy-timezones isn't IPv6 ready yet! :( :( :(
from django-easy-timezones.
Thanks for reply, will it be available? Or could you ignore ipv6 in easy-timezones?
from django-easy-timezones.
Pull requests welcome :)
On Tue, Oct 28, 2014 at 3:21 PM, Lukas Vojt [email protected]
wrote:
—
Reply to this email directly or view it on GitHub
#6 (comment)
.
from django-easy-timezones.
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.
@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.
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.
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.
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.
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.
Nice! will you push it to pip as well? Will you add IPv6 support with GEOIP file for IPv6?
from django-easy-timezones.
@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)
- Private IP matching is a bit naive HOT 1
- Problem with installation HOT 1
- AttributeError: 'AnonymousUser' object has no attribute 'timezone' HOT 1
- Local time is unaffected... HOT 3
- Online Example with detection HOT 3
- Why only process middleware? HOT 3
- ImproperlyConfigured: GEOIP_DATABASE setting is defined, but file does not exist. HOT 12
- Exception Value: Invalid database type, expected City HOT 1
- Invalid database type, expected City HOT 3
- Geolite2 HOT 5
- Syntax error, Dj1.9 Python 3.4 HOT 3
- Not working with Django 1.11.5
- UTC time doesn't work HOT 2
- Detected timezone not saved in session HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-easy-timezones.