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):
|
def DetectIpView(request, secret=None):
|
||||||
|
|
||||||
s = SessionStore(session_key=secret)
|
s = SessionStore(session_key=secret)
|
||||||
|
|
||||||
|
|
||||||
ipaddr = request.META['REMOTE_ADDR']
|
ipaddr = request.META['REMOTE_ADDR']
|
||||||
af = dns.inet.af_for_address(ipaddr)
|
af = dns.inet.af_for_address(ipaddr)
|
||||||
key = 'ipv4' if af == dns.inet.AF_INET else 'ipv6'
|
key = 'ipv4' if af == dns.inet.AF_INET else 'ipv6'
|
||||||
s[key] = ipaddr
|
s[key] = ipaddr
|
||||||
s.save()
|
s.save()
|
||||||
#with open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb") as f:
|
with open(os.path.join(settings.STATIC_ROOT, "1px.gif"), "rb") as f:
|
||||||
# image_data = f.read()
|
image_data = f.read()
|
||||||
#return HttpResponse(image_data, mimetype="image/png")
|
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")
|
|
||||||
|
|
||||||
|
|
||||||
def basic_challenge(realm, content='Authorization Required'):
|
def basic_challenge(realm, content='Authorization Required'):
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<h1>HeyHo!</h1>
|
||||||
{% if request.session.ipv4 and request.session.ipv6 %}
|
{% if request.session.ipv4 and request.session.ipv6 %}
|
||||||
<p>We think this are your IPs:</p>
|
<p>We think this are your IPs:</p>
|
||||||
{% elif request.session.ipv4 or request.session.ipv6 %}
|
{% elif request.session.ipv4 or request.session.ipv6 %}
|
||||||
@ -36,10 +37,9 @@
|
|||||||
|
|
||||||
{% if request.session.ipv4 %}
|
{% if request.session.ipv4 %}
|
||||||
<h1>{{request.session.ipv4}}</h1>
|
<h1>{{request.session.ipv4}}</h1>
|
||||||
{% elif request.session.ipv6 %}
|
{% endif %}
|
||||||
<h1>{{request.session.ipv4}}</h1>
|
{% if request.session.ipv6 %}
|
||||||
{% else %}
|
<h1>{{request.session.ipv6}}</h1>
|
||||||
<h1>HeyHo!</h1>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user