|
|
|
@ -1,9 +1,7 @@
@@ -1,9 +1,7 @@
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
from django.shortcuts import redirect |
|
|
|
|
from django.shortcuts import render_to_response |
|
|
|
|
from django.core.exceptions import ValidationError |
|
|
|
|
from django.http import HttpResponse |
|
|
|
|
|
|
|
|
|
from web.postkey.models import i2phost |
|
|
|
|
from web.lib.validation import validate_hostname |
|
|
|
@ -14,11 +12,16 @@ def jumper(request, host):
@@ -14,11 +12,16 @@ def jumper(request, host):
|
|
|
|
|
try: |
|
|
|
|
hostname = validate_hostname(host) |
|
|
|
|
except ValidationError, e: |
|
|
|
|
return redirect('/jump/error/') |
|
|
|
|
return render_to_response('jump-error.html', { |
|
|
|
|
'title': settings.SITE_NAME, |
|
|
|
|
'error': e, |
|
|
|
|
}) |
|
|
|
|
try: |
|
|
|
|
key = i2phost.objects.get(name=hostname, activated=True).b64hash |
|
|
|
|
except i2phost.DoesNotExist: |
|
|
|
|
return redirect('/jump/unknown/') |
|
|
|
|
return render_to_response('jump-unknown.html', { |
|
|
|
|
'title': settings.SITE_NAME, |
|
|
|
|
}) |
|
|
|
|
url = 'http://' + hostname + '/?i2paddresshelper=' + key |
|
|
|
|
# get params from requst string, e.g. from 'example.i2p/smth/1?a=b&c=d' get 'smth/1?a=b&c=d' |
|
|
|
|
pattern = host + r'/(.+)' |
|
|
|
@ -30,9 +33,3 @@ def jumper(request, host):
@@ -30,9 +33,3 @@ def jumper(request, host):
|
|
|
|
|
'title': settings.SITE_NAME, |
|
|
|
|
'url': url, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
def error(request): |
|
|
|
|
return HttpResponse('You are trying to access an invalid hostname.') |
|
|
|
|
|
|
|
|
|
def unknown(request): |
|
|
|
|
return HttpResponse('You are trying to access an unknown hostname.') |
|
|
|
|