浏览代码

Add a type and version header to the fallback directory mirror file

This helps external parsers like stem and Relay Search.

Implements ticket 24725.
teor 6 年之前
父节点
当前提交
8d226a2c7b
共有 2 个文件被更改,包括 16 次插入0 次删除
  1. 4 0
      changes/ticket24725
  2. 12 0
      scripts/maint/updateFallbackDirs.py

+ 4 - 0
changes/ticket24725

@@ -0,0 +1,4 @@
+  o Minor features (fallback directory mirrors):
+    - Add a type and version header to the fallback directory mirror file.
+      This helps external parsers like stem and Relay Search.
+      Implements ticket 24725.

+ 12 - 0
scripts/maint/updateFallbackDirs.py

@@ -68,6 +68,15 @@ except ImportError:
 
 
 ## Top-Level Configuration
 ## Top-Level Configuration
 
 
+# We use semantic versioning: https://semver.org
+# In particular:
+# * major changes include removing a mandatory field, or anything else that
+#   would break an appropriately tolerant parser,
+# * minor changes include adding a field,
+# * patch changes include changing header comments or other unstructured
+#   content
+FALLBACK_FORMAT_VERSION = '2.0.0'
+
 # Output all candidate fallbacks, or only output selected fallbacks?
 # Output all candidate fallbacks, or only output selected fallbacks?
 OUTPUT_CANDIDATES = False
 OUTPUT_CANDIDATES = False
 
 
@@ -2124,6 +2133,9 @@ def list_fallbacks(whitelist, blacklist):
   """ Fetches required onionoo documents and evaluates the
   """ Fetches required onionoo documents and evaluates the
       fallback directory criteria for each of the relays """
       fallback directory criteria for each of the relays """
 
 
+  print "/* type=fallback */"
+  print ("/* version={} */"
+         .format(cleanse_c_multiline_comment(FALLBACK_FORMAT_VERSION)))
   logging.warning('Downloading and parsing Onionoo data. ' +
   logging.warning('Downloading and parsing Onionoo data. ' +
                   'This may take some time.')
                   'This may take some time.')
   # find relays that could be fallbacks
   # find relays that could be fallbacks