|
|
|
@ -1,3 +1,5 @@
@@ -1,3 +1,5 @@
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
from django.shortcuts import redirect |
|
|
|
|
from django.core.exceptions import ValidationError |
|
|
|
|
from django.http import HttpResponse |
|
|
|
@ -5,10 +7,10 @@ from django.http import HttpResponse
@@ -5,10 +7,10 @@ from django.http import HttpResponse
|
|
|
|
|
from web.postkey.models import i2phost |
|
|
|
|
from web.lib.validation import validate_hostname |
|
|
|
|
|
|
|
|
|
def jumper(request, data): |
|
|
|
|
def jumper(request, host): |
|
|
|
|
"""Actually do jumps.""" |
|
|
|
|
try: |
|
|
|
|
hostname = validate_hostname(data) |
|
|
|
|
hostname = validate_hostname(host) |
|
|
|
|
except ValidationError, e: |
|
|
|
|
return redirect('/jump/error/') |
|
|
|
|
try: |
|
|
|
@ -16,6 +18,12 @@ def jumper(request, data):
@@ -16,6 +18,12 @@ def jumper(request, data):
|
|
|
|
|
except i2phost.DoesNotExist: |
|
|
|
|
return redirect('/jump/unknown/') |
|
|
|
|
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'/(.+)' |
|
|
|
|
m = re.search(pattern, request.get_full_path()) |
|
|
|
|
if m: |
|
|
|
|
params = m.group(1) |
|
|
|
|
url += '/' + params |
|
|
|
|
return redirect(url, permanent=True) |
|
|
|
|
|
|
|
|
|
def error(request): |
|
|
|
|