fixed the ip detection :3
This commit is contained in:
parent
1809737ae3
commit
6bcaf76263
@ -21,22 +21,15 @@ def MyIpView(request):
|
||||
|
||||
|
||||
def DetectIpView(request, secret=None):
|
||||
|
||||
s = SessionStore(session_key=secret)
|
||||
|
||||
|
||||
ipaddr = request.META['REMOTE_ADDR']
|
||||
af = dns.inet.af_for_address(ipaddr)
|
||||
key = 'ipv4' if af == dns.inet.AF_INET else 'ipv6'
|
||||
s[key] = ipaddr
|
||||
s.save()
|
||||
#with open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb") as f:
|
||||
# image_data = f.read()
|
||||
#return HttpResponse(image_data, mimetype="image/png")
|
||||
out = ipaddr+'\n'+str(request.session)+'\n'+str(s)+'\n'+str(request.session.session_key)+'\n'+str(s.session_key)+'\n'+key
|
||||
out += '\n'+request.session.get('ipv4','')+' | '+request.session.get('ipv6','')
|
||||
out += '\n'+s.get('ipv4','')+' | '+s.get('ipv6','')
|
||||
return HttpResponse(out, mimetype="text/plain")
|
||||
with open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb") as f:
|
||||
image_data = f.read()
|
||||
return HttpResponse(image_data, mimetype="image/png")
|
||||
|
||||
|
||||
def basic_challenge(realm, content='Authorization Required'):
|
||||
|
@ -28,6 +28,7 @@
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="container">
|
||||
<h1>HeyHo!</h1>
|
||||
{% if request.session.ipv4 and request.session.ipv6 %}
|
||||
<p>We think this are your IPs:</p>
|
||||
{% elif request.session.ipv4 or request.session.ipv6 %}
|
||||
@ -36,10 +37,9 @@
|
||||
|
||||
{% if request.session.ipv4 %}
|
||||
<h1>{{request.session.ipv4}}</h1>
|
||||
{% elif request.session.ipv6 %}
|
||||
<h1>{{request.session.ipv4}}</h1>
|
||||
{% else %}
|
||||
<h1>HeyHo!</h1>
|
||||
{% endif %}
|
||||
{% if request.session.ipv6 %}
|
||||
<h1>{{request.session.ipv6}}</h1>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user