Tweaked mirror code so mirror urls can contain the current I2P version, added Launchpad as HTTPS mirror

NOTE: this enables mirrors that require a version string to download the current version
of files. Older file versions will *not* be downloadable (that would require parsing the
requested filename to try and find a version). Hey, it's better than no support at all =)
This commit is contained in:
str4d
2012-12-17 21:59:41 +00:00
parent 68ce69fdd1
commit 262040fd30
2 changed files with 17 additions and 6 deletions

View File

@@ -16,6 +16,8 @@ except ImportError:
from helpers import Pagination
CURRENT_I2P_VERSION = '0.9.4'
TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'pages')
STATIC_DIR = os.path.join(os.path.dirname(__file__), 'static')
@@ -406,13 +408,17 @@ def downloads_select(file):
if (file == 'debian'):
return render_template('downloads/debian.html')
mirrors=read_mirrors()
data = {
'version': CURRENT_I2P_VERSION,
'file': file,
}
obj=[]
for protocol in mirrors.keys():
a={}
a['name']=protocol
a['mirrors']=mirrors[protocol]
for mirror in a['mirrors']:
mirror['url']=mirror['url'] % file
mirror['url']=mirror['url'] % data
obj.append(a)
return render_template('downloads/select.html', mirrors=obj, file=file)
@@ -423,9 +429,13 @@ def downloads_redirect(protocol, file, mirror):
if not protocol in mirrors:
abort(404)
mirrors=mirrors[protocol]
data = {
'version': CURRENT_I2P_VERSION,
'file': file,
}
if mirror:
return redirect(mirrors[mirror]['url'] % file)
return redirect(mirrors[randint(0, len(mirrors) - 1)]['url'] % file)
return redirect(mirrors[mirror]['url'] % data)
return redirect(mirrors[randint(0, len(mirrors) - 1)]['url'] % data)
#####################

View File

@@ -1,3 +1,4 @@
{"url": "http://i2p.googlecode.com/files/%s", "org": "Google Code", "org_url": "http://code.google.com", "protocol": "http", "country": "us"}
{"url": "http://golden.mtveurope.org/~yang/i2p_mirror/%s", "org": "VServer.si", "org_url": "http://www.vserver.si", "protocol": "http", "country": "lu"}
{"url": "http://a.mirror.geti2p.net/releases/current/%s", "org": "welterde", "protocol": "http", "country": "de"}
{"url": "http://i2p.googlecode.com/files/%(file)s", "org": "Google Code", "org_url": "http://code.google.com", "protocol": "http", "country": "us"}
{"url": "http://golden.mtveurope.org/~yang/i2p_mirror/%(file)s", "org": "VServer.si", "org_url": "http://www.vserver.si", "protocol": "http", "country": "lu"}
{"url": "http://a.mirror.geti2p.net/releases/current/%(file)s", "org": "welterde", "protocol": "http", "country": "de"}
{"url": "https://launchpad.net/i2p/trunk/%(version)s/+download/%(file)s", "org": "Launchpad", "org_url": "https://launchpad.net", "protocol": "https", "country": "us"}