-
Notifications
You must be signed in to change notification settings - Fork 25
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
Specify nameservers directly #18
base: master
Are you sure you want to change the base?
Changes from all commits
7cb8258
6f700f7
57456b7
c7ad3ad
909dfdd
99dde8e
b814269
a33fda8
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
Place to define providers. | ||
Most part of _BASE_PROVIDERS was taken from https://github.com/vincecarney/dnsbl | ||
""" | ||
import os | ||
|
||
### DNSBL CATEGORIES ### | ||
# providers answers could be interpreted in one of the following categories | ||
DNSBL_CATEGORY_UNKNOWN = 'unknown' | ||
|
@@ -12,11 +14,17 @@ | |
DNSBL_CATEGORY_CNC = 'cnc' | ||
DNSBL_CATEGORY_ABUSED = 'abused' | ||
DNSBL_CATEGORY_LEGIT = 'legit' | ||
DNSBL_CATEGORY_DYNAMIC = 'dynamic' | ||
|
||
class Provider(object): | ||
|
||
def __init__(self, host): | ||
def __init__(self, host, ns=None): | ||
""" | ||
host: the hostname of provider | ||
ns: the nameserver IP to use for direct lookup | ||
""" | ||
self.host = host | ||
self.ns = ns | ||
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. As i understand there is no effect of specifying ns for Provider in the scope of this PR? 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. Yes, this was used in other code not included. 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. I still cant figure out how ns affects resolver |
||
|
||
def process_response(self, response): | ||
""" | ||
|
@@ -57,6 +65,8 @@ def process_response(self, response): | |
categories.add(DNSBL_CATEGORY_SPAM) | ||
elif result.host in ['127.0.0.4', '127.0.0.5', '127.0.0.6', '127.0.0.7']: | ||
categories.add(DNSBL_CATEGORY_EXPLOITS) | ||
elif result.host in ['127.0.0.10', '127.0.0.11']: | ||
categories.add(DNSBL_CATEGORY_DYNAMIC) | ||
else: | ||
categories.add(DNSBL_CATEGORY_UNKNOWN) | ||
return categories | ||
|
@@ -138,8 +148,8 @@ class DblSpamhaus(Provider): | |
'127.0.1.106': {DNSBL_CATEGORY_ABUSED, DNSBL_CATEGORY_LEGIT, DNSBL_CATEGORY_CNC} | ||
} | ||
|
||
def __init__(self, host='dbl.spamhaus.org'): | ||
Provider.__init__(self, host=host) | ||
def __init__(self, host='dbl.spamhaus.org', ns=None): | ||
Provider.__init__(self, host=host, ns=ns) | ||
|
||
def process_response(self, response): | ||
categories = set() | ||
|
@@ -156,5 +166,9 @@ def process_response(self, response): | |
'rhsbl.sorbs.net ' | ||
] | ||
|
||
BASE_PROVIDERS = [Provider(host) for host in _BASE_PROVIDERS] + [ZenSpamhaus()] | ||
BASE_DOMAIN_PROVIDERS = [Provider(host) for host in _DOMAIN_PROVIDERS] + [DblSpamhaus()] | ||
BASE_PROVIDERS = [Provider(host) for host in _BASE_PROVIDERS] | ||
BASE_DOMAIN_PROVIDERS = [Provider(host) for host in _DOMAIN_PROVIDERS] | ||
|
||
if os.getenv('USE_SPAMHAUS', 'false') == 'true': | ||
BASE_PROVIDERS.append(ZenSpamhaus()) | ||
BASE_DOMAIN_PROVIDERS.append(DblSpamhaus()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine, but there is questions on the other part of this PR