-
Notifications
You must be signed in to change notification settings - Fork 24
[GT-157] Drop messages from banned dns, and add tests for messages saving to the correct queue #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 2 commits
5452084
728b8d7
87a9067
ded3121
b3ea5fe
4024cf9
60c8f37
e47b15e
7ef624b
f632de4
6b5ef75
7243862
0cabbe5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,6 +298,10 @@ def run_receiver(protocol, brokers, project, token, cp, log, dn_file): | |
dns = get_dns(dn_file, log) | ||
ssm.set_dns(dns) | ||
|
||
log.info('Fetching banned DNs.') | ||
banned_dns = get_banned_dns(log) | ||
ssm.set_banned_dns(banned_dns) | ||
|
||
except Exception as e: | ||
log.fatal('Failed to initialise SSM: %s', e) | ||
log.info(LOG_BREAK) | ||
|
@@ -379,3 +383,30 @@ def get_dns(dn_file, log): | |
|
||
log.debug('%s DNs found.', len(dns)) | ||
return dns | ||
|
||
|
||
def get_banned_dns(log): | ||
"""Retrieve the list of banned dns""" | ||
banned_dns_list = [] | ||
try: | ||
banned_dns_path = cp.get('auth', 'banned-dns') | ||
tofu-rocketry marked this conversation as resolved.
Show resolved
Hide resolved
|
||
banned_dns_file = os.path.normpath(os.path.expandvars(banned_dns_path)) | ||
except ConfigParser.NoOptionError: | ||
banned_dns_file = None | ||
f = None | ||
try: | ||
f = open(banned_dns_file, 'r') | ||
tofu-rocketry marked this conversation as resolved.
Show resolved
Hide resolved
|
||
lines = f.readlines() | ||
for line in lines: | ||
if line.isspace() or line.strip().startswith('#'): | ||
continue | ||
elif line.strip().startswith('/'): | ||
banned_dns_list.append(line.strip()) | ||
else: | ||
log.warning('DN in banned dns list is not in correct format: %s', line) | ||
finally: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now we have a context manager for the file, we can get rid of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if f is not None: | ||
f.close() | ||
|
||
return banned_dns_list | ||
|
Uh oh!
There was an error while loading. Please reload this page.