Skip to content

Commit 88d12ba

Browse files
committed
cli argument to supply only-providers to be queried (ignore built-in list)
1 parent 46f70c5 commit 88d12ba

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Added new base-lists
1313
- Ability to add additional providers in CLI
1414
- Provider-based query-support-config (IPv4/IPv6/Domain)
15+
- CLI argument to supply the only providers that should be queried (ignoring the built-in list)
1516

1617
## Deprecations
1718
- Removed dead lists

src/dnsbl_check/__main__.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
sys_path.append(os_path.dirname(os_path.abspath(__file__)))
77

88
# pylint: disable=C0413
9-
from provider import Provider, BASE_PROVIDERS_IP, BASE_PROVIDERS_DOMAIN
9+
from provider import Provider
1010
from checker import CheckDomain, CheckIP
11+
from provider_config import BASE_PROVIDERS_IP, BASE_PROVIDERS_DOMAIN
1112

1213

1314
def main():
@@ -26,17 +27,26 @@ def main():
2627
'-a', '--add-providers', type=str, default='',
2728
help='Comma-separated list of additional DNS-BL provider-domains to query',
2829
)
30+
parser.add_argument(
31+
'-o', '--only-providers', type=str, default='',
32+
help='Comma-separated list of DNS-BL provider-domains to query (ignoring the built-in default providers)',
33+
)
2934
parser.add_argument(
3035
'--details', action='store_true', default=False,
3136
help='If the result details should be added to the output',
3237
)
3338
args = parser.parse_args()
3439

35-
skip_providers = args.skip_providers.split(',')
3640
add_providers = [Provider(p) for p in args.add_providers.split(',')]
41+
only_providers = [Provider(p) for p in args.only_providers.split(',')]
42+
skip_providers = args.skip_providers.split(',')
3743

3844
if args.ip is not None:
39-
providers = BASE_PROVIDERS_IP + add_providers
45+
if len(only_providers) > 0:
46+
providers = only_providers
47+
48+
else:
49+
providers = BASE_PROVIDERS_IP + add_providers
4050

4151
if not args.json:
4252
print(f'Checking IP {args.ip} ..')
@@ -45,7 +55,11 @@ def main():
4555
result = checker.check(args.ip)
4656

4757
else:
48-
providers = BASE_PROVIDERS_DOMAIN + add_providers
58+
if len(only_providers) > 0:
59+
providers = only_providers
60+
61+
else:
62+
providers = BASE_PROVIDERS_DOMAIN + add_providers
4963

5064
if not args.json:
5165
print(f'Checking Domain {args.domain} ..')

0 commit comments

Comments
 (0)