Adds ant task to update fallback directories in RS

This commit is contained in:
Iain R. Learmonth 2020-02-27 11:27:11 +00:00 committed by Karsten Loesing
parent 395a8204d4
commit 1bef5acf3b
3 changed files with 41 additions and 2 deletions

View File

@ -322,6 +322,14 @@
</untar>
</target>
<target name="update-fallback-dir-list"
description="Update the fallback directory list used by Relay Search">
<exec executable="bash">
<arg value="-c"/>
<arg value="python3 src/main/python/fallback_dir.py | tee src/main/resources/web/js/rs/fallback_dir.js"/>
</exec>
</target>
<!-- The following line adds the common targets and properties
for Metrics' Java Projects.
-->

View File

@ -0,0 +1,31 @@
import json
import re
import urllib.request
response = urllib.request.urlopen("https://gitweb.torproject.org/tor.git/plain/src/app/config/fallback_dirs.inc")
lines = [x.decode("ascii") for x in response.readlines()]
fingerprints = []
for line in lines:
if line.startswith("\""):
m = re.search('(?<=id=)\w+', line)
if m:
fingerprints.append(m.group(0))
print("""
/*
This file is generated by src/main/python/fallback_dir.py.
To update run:
ant update-fallback-dir-list
*/
var fallbackDirs = %s;
function IsFallbackDir(fingerprint) {
return $.inArray(fingerprint, fallbackDirs) > -1;
}
""" % (json.dumps(fingerprints)))

File diff suppressed because one or more lines are too long