
commit dc84ea9cf3992b16f938dfb007e153dc85a77392 Author: Damian Johnson <atagar@torproject.org> Date: Sat Feb 20 12:20:43 2016 -0800 Notify for expired tracked_relays.cfg entries Proper expiring of tracked_relays.cfg entries. When the date passes those entries are ignored and I'm notififed. --- track_relays.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/track_relays.py b/track_relays.py index e770006..a65356d 100755 --- a/track_relays.py +++ b/track_relays.py @@ -19,7 +19,7 @@ log = util.get_logger('track_relays') EMAIL_SUBJECT = 'Relays Returned' EMAIL_BODY = """\ -The following previously BadExit relays have returned to the network... +The following previously BadExited relays have returned to the network... """ @@ -79,10 +79,25 @@ def get_tracked_relays(): config = stem.util.conf.get_config('tracked_relays') config.load(util.get_path('data', 'tracked_relays.cfg')) - # TODO: check for expired entries + results, expired = [], [] - identifiers = set([key.split('.')[0] for key in config.keys()]) - return [TrackedRelay(identifier, config) for identifier in identifiers] + for identifier in set([key.split('.')[0] for key in config.keys()]): + relay = TrackedRelay(identifier, config) + + if relay.expires > datetime.datetime.now(): + results.append(relay) + else: + expired.append(relay) + + if expired: + body = 'The following entries in tracked_relays.cfg have expired...\n\n' + + for relay in expired: + body += '* %s (%s)\n' % (relay.identifier, relay.expires.strftime('%Y-%m-%d')) + + util.send('tracked_relays.cfg entries expired', body = body, to = ['atagar@torproject.org']) + + return results def main():