diff --git a/i2p2www/downloads.py b/i2p2www/downloads.py index 07698cba..74e285b0 100644 --- a/i2p2www/downloads.py +++ b/i2p2www/downloads.py @@ -8,6 +8,7 @@ from random import randint from i2p2www import CURRENT_I2P_VERSION, MIRRORS_FILE DEFAULT_MIRROR = { + 'net': 'clearnet', 'protocol': 'https', 'domain': 'download.i2p2.de', 'org': 'sigterm.no', @@ -15,6 +16,7 @@ DEFAULT_MIRROR = { } DEFAULT_I2P_MIRROR = { + 'net': 'i2p', 'protocol': 'http', 'domain': 'whnxvjwjhzsske5yevyokhskllvtisv5ueokw6yvh6t7zqrpra2q.b32.i2p', 'org': 'sigterm.no', @@ -39,13 +41,16 @@ def read_mirrors(): continue if 'protocol' not in obj or 'domain' not in obj or 'path' not in obj: continue + net=obj['net'] protocol=obj['protocol'] domain=obj['domain'] path=obj['path'] obj['url']='%s://%s%s' % (protocol, domain, path) - if protocol not in ret: - ret[protocol]={} - ret[protocol][domain]=obj + if net not in ret: + ret[net]={} + if protocol not in ret[net]: + ret[net][protocol]={} + ret[net][protocol][domain]=obj return ret # List of downloads @@ -65,29 +70,40 @@ def downloads_debian(): def downloads_select(version, file): mirrors=read_mirrors() obj=[] - for protocol in mirrors.keys(): + for net in mirrors.keys(): a={} - a['name']=protocol - a['mirrors']=mirrors[protocol] + a['key']=net + a['name']=net + a['protocols']=[] + for protocol in mirrors[net].keys(): + b={} + b['key']=protocol + b['name']=protocol + b['domains']=mirrors[net][protocol] + a['protocols'].append(b) obj.append(a) return render_template('downloads/select.html', mirrors=obj, version=version, file=file) -def downloads_redirect(version, protocol, domain, file): +def downloads_redirect(version, net, protocol, domain, file): mirrors=read_mirrors() - if not protocol in mirrors: + if not net in mirrors: abort(404) - mirrors=mirrors[protocol] + mirrors=mirrors[net] data = { 'version': version, 'file': file, } - if domain: - if not domain in mirrors: - abort(404) - return render_template('downloads/redirect.html', - version=version, protocol=protocol, domain=domain, file=file, - url=mirrors[domain]['url'] % data) - randomain = mirrors.keys()[randint(0, len(mirrors) - 1)] + + if not protocol: + protocol = mirrors.leys()[randint(0, len(mirrors) - 1)] + if not protocol in mirrors: + abort(404) + mirrors=mirrors[protocol] + + if not domain: + domain = mirrors.keys()[randint(0, len(mirrors) - 1)] + if not domain in mirrors: + abort(404) return render_template('downloads/redirect.html', version=version, protocol=protocol, domain=domain, file=file, - url=mirrors[randomain]['url'] % data) + url=mirrors[domain]['url'] % data) diff --git a/i2p2www/pages/downloads/list.html b/i2p2www/pages/downloads/list.html index 2bc7c17b..4cc86e99 100644 --- a/i2p2www/pages/downloads/list.html +++ b/i2p2www/pages/downloads/list.html @@ -49,12 +49,12 @@ or type java -version at your command prompt.
{{ i2pinstall_windows_hash }}
@@ -71,12 +71,12 @@ or type java -version at your command prompt.
{{ i2pinstall_jar_hash }}
@@ -103,12 +103,12 @@ or type java -version at your command prompt.
{{ i2pinstall_jar_hash }}
@@ -195,12 +195,12 @@ or type java -version at your command prompt.
{{ i2psource_hash }}
@@ -300,12 +300,12 @@ receive the release.
{{ i2pupdate_hash }}
diff --git a/i2p2www/pages/downloads/mirrors b/i2p2www/pages/downloads/mirrors
index 64f67294..d34a6848 100644
--- a/i2p2www/pages/downloads/mirrors
+++ b/i2p2www/pages/downloads/mirrors
@@ -1,9 +1,9 @@
-{"protocol": "https", "domain": "launchpad.net", "path": "/i2p/trunk/%(version)s/+download/%(file)s", "org": "Launchpad", "org_url": "https://launchpad.net", "country": "us"}
-{"protocol": "https", "domain": "download.i2p2.de", "path": "/releases/%(version)s/%(file)s", "org": "sigterm.no", "country": "no"}
-{"protocol": "http", "domain": "whnxvjwjhzsske5yevyokhskllvtisv5ueokw6yvh6t7zqrpra2q.b32.i2p", "path": "/releases/%(version)s/%(file)s", "org": "sigterm.no", "country": "i2p"}
-{"protocol": "http", "domain": "download.i2p2.de", "path": "/releases/%(version)s/%(file)s", "org": "sigterm.no", "country": "no"}
-{"protocol": "http", "domain": "download.i2p2.no", "path": "/releases/%(version)s/%(file)s", "org": "sigterm.no", "country": "no"}
-{"protocol": "https", "domain": "dl.dropboxusercontent.com", "path": "/u/18621288/I2P/%(version)s/%(file)s", "org": "Dropbox", "country": "us"}
-{"protocol": "https", "domain": "googledrive.com", "path": "/host/0B4jHEq5G7_EPWV9UeERwdGplZXc/%(version)s/%(file)s", "org": "Google Drive", "country": "us"}
-#{"protocol": "http", "domain": "download.geti2p.com", "path": "/%(version)s/%(file)s", "org": "aargh", "country": "us"}
-#{"protocol": "http", "domain": "download2.geti2p.com", "path": "/%(version)s/%(file)s", "org": "aargh", "country": "us"}
+{"net": "clearnet", "protocol": "https", "domain": "launchpad.net", "path": "/i2p/trunk/%(version)s/+download/%(file)s", "org": "Launchpad", "org_url": "https://launchpad.net", "country": "us"}
+{"net": "clearnet", "protocol": "https", "domain": "download.i2p2.de", "path": "/releases/%(version)s/%(file)s", "org": "sigterm.no", "country": "no"}
+{"net": "i2p", "protocol": "http", "domain": "whnxvjwjhzsske5yevyokhskllvtisv5ueokw6yvh6t7zqrpra2q.b32.i2p", "path": "/releases/%(version)s/%(file)s", "org": "sigterm.no"}
+{"net": "clearnet", "protocol": "http", "domain": "download.i2p2.de", "path": "/releases/%(version)s/%(file)s", "org": "sigterm.no", "country": "no"}
+{"net": "clearnet", "protocol": "http", "domain": "download.i2p2.no", "path": "/releases/%(version)s/%(file)s", "org": "sigterm.no", "country": "no"}
+{"net": "clearnet", "protocol": "https", "domain": "dl.dropboxusercontent.com", "path": "/u/18621288/I2P/%(version)s/%(file)s", "org": "Dropbox", "country": "us"}
+{"net": "clearnet", "protocol": "https", "domain": "googledrive.com", "path": "/host/0B4jHEq5G7_EPWV9UeERwdGplZXc/%(version)s/%(file)s", "org": "Google Drive", "country": "us"}
+#{"net": "clearnet", "protocol": "http", "domain": "download.geti2p.com", "path": "/%(version)s/%(file)s", "org": "aargh", "country": "us"}
+#{"net": "clearnet", "protocol": "http", "domain": "download2.geti2p.com", "path": "/%(version)s/%(file)s", "org": "aargh", "country": "us"}
diff --git a/i2p2www/pages/downloads/select.html b/i2p2www/pages/downloads/select.html
index 9027b12c..4eb0f7a0 100644
--- a/i2p2www/pages/downloads/select.html
+++ b/i2p2www/pages/downloads/select.html
@@ -3,13 +3,18 @@
{% block content %}