[tor-commits] [fallback-scripts/master] Merge remote-tracking branch 'tor-github/pr/9'

teor at torproject.org teor at torproject.org
Mon Jan 20 05:32:02 UTC 2020


commit 77f850359ac2151c40da9dc51f40d390e83ebd09
Merge: 0a715b5 576a943
Author: teor <teor at torproject.org>
Date:   Mon Jan 20 15:11:13 2020 +1000

    Merge remote-tracking branch 'tor-github/pr/9'
    
    Merge python 3 fixes with offer-list fixes.

 .travis.yml                 |  78 ++++++++++++------
 generateFallbackDirLine.py  |  55 +++++++++----
 lookupFallbackDirContact.py |  43 +++++++---
 requirements.txt            |   1 +
 test.sh                     |  39 +++++++++
 updateFallbackDirs.py       | 189 +++++++++++++++++++++++++-------------------
 6 files changed, 272 insertions(+), 133 deletions(-)

diff --cc updateFallbackDirs.py
index 25aa4c4,86343d4..c2e63cf
--- a/updateFallbackDirs.py
+++ b/updateFallbackDirs.py
@@@ -1211,9 -1237,9 +1237,9 @@@ class Candidate(object)
                          'to %s:%d?', self._fpr, entry['ipv6'],
                          self.ipv6addr, self.ipv6orport)
          return False
 -    # if the fallback has an IPv6 address but the whitelist entry
 -    # doesn't, or vice versa, the whitelist entry doesn't match
 +    # if the fallback has an IPv6 address but the offer list entry
 +    # doesn't, or vice versa, the offer list entry doesn't match
-     elif entry.has_key('ipv6') and not self.has_ipv6():
+     elif 'ipv6' in entry and not self.has_ipv6():
        logging.warning('%s excluded: has it lost its former IPv6 address %s?',
                        self._fpr, entry['ipv6'])
        return False
@@@ -2421,22 -2446,19 +2448,22 @@@ def list_fallbacks(offer_list, exact=Fa
    """ Fetches required onionoo documents and evaluates the
        fallback directory criteria for each of the relays,
        passing exact to apply_filter_lists(). """
-   print "/* type=fallback */"
-   print ("/* version={} */"
-          .format(cleanse_c_multiline_comment(FALLBACK_FORMAT_VERSION)))
+   print("/* type=fallback */")
+   print("/* version={} */"
+         .format(cleanse_c_multiline_comment(FALLBACK_FORMAT_VERSION)))
    now = datetime.datetime.utcnow()
    timestamp = now.strftime('%Y%m%d%H%M%S')
 -  print("/* timestamp={} */"
 -        .format(cleanse_c_multiline_comment(timestamp)))
 -  if whitelist['check_existing']:
 +  print ("/* timestamp={} */"
 +         .format(cleanse_c_multiline_comment(timestamp)))
 +  if offer_list['check_existing']:
-       print "/* source=fallback */"
+       print("/* source=fallback */")
    else:
 -      print("/* source=whitelist */")
 +      # TODO: when we implement #24839, change this to descriptor,offer-list
 +      # We might want add each key based on the size of the offer list, and
 +      # the number of descriptors with offer-fallback-dir lines.
-       print "/* source=offer-list */"
++      print("/* source=offer-list */")
    # end the header with a separator, to make it easier for parsers
-   print SECTION_SEPARATOR_COMMENT
+   print(SECTION_SEPARATOR_COMMENT)
  
    logging.warning('Downloading and parsing Onionoo data. ' +
                    'This may take some time.')
@@@ -2461,15 -2483,15 +2488,15 @@@
    candidates.compute_fallbacks()
    prefilter_fallbacks = copy.copy(candidates.fallbacks)
  
 -  # filter with the whitelist
 +  # filter with the offer list
    # if a relay has changed IPv4 address or ports recently, it will be excluded
    # as ineligible before we call apply_filter_lists, and so there will be no
 -  # warning that the details have changed from those in the whitelist.
 +  # warning that the details have changed from those in the offer list.
    # instead, there will be an info-level log during the eligibility check.
    initial_count = len(candidates.fallbacks)
 -  excluded_count = candidates.apply_filter_lists(whitelist, exact=exact)
 +  excluded_count = candidates.apply_filter_lists(offer_list, exact=exact)
-   print candidates.summarise_filters(initial_count, excluded_count,
-           offer_list['check_existing'])
+   print(candidates.summarise_filters(initial_count, excluded_count,
 -                                     whitelist['check_existing']))
++                                     offer_list['check_existing']))
    eligible_count = len(candidates.fallbacks)
  
    # calculate the measured bandwidth of each relay,
@@@ -2520,12 -2542,12 +2547,12 @@@
  
    # output C comments summarising the fallback selection process
    if len(candidates.fallbacks) > 0:
-     print candidates.summarise_fallbacks(eligible_count, operator_count,
+     print(candidates.summarise_fallbacks(eligible_count, operator_count,
                                           failed_count, guard_count,
                                           target_count,
-                                          offer_list['check_existing'])
 -                                         whitelist['check_existing']))
++                                         offer_list['check_existing']))
    else:
-     print '/* No Fallbacks met criteria */'
+     print('/* No Fallbacks met criteria */')
  
    # output C comments specifying the Onionoo data used to create the list
    for s in fetch_source_list():



More information about the tor-commits mailing list