mirror of
https://github.com/torproject/metrics-web.git
synced 2024-11-23 01:29:41 +00:00
Adds ant task to update fallback directories in RS
This commit is contained in:
parent
395a8204d4
commit
1bef5acf3b
@ -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.
|
||||
-->
|
||||
|
31
src/main/python/fallback_dir.py
Normal file
31
src/main/python/fallback_dir.py
Normal 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
Loading…
Reference in New Issue
Block a user