From e610038e65aa312ecfdcd71f0eef1f6388822e64 Mon Sep 17 00:00:00 2001 From: Muntashir Al-Islam Date: Tue, 20 Jul 2021 16:46:40 +0600 Subject: [PATCH 1/3] [UPDATE] Fix parsing remote files containing wildcards --- config/generate-domains-blocklist.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 config/generate-domains-blocklist.py diff --git a/config/generate-domains-blocklist.py b/config/generate-domains-blocklist.py old mode 100644 new mode 100755 index ca75d64..31fcc59 --- a/config/generate-domains-blocklist.py +++ b/config/generate-domains-blocklist.py @@ -61,13 +61,15 @@ def parse_list(content, trusted=False): rx_mdl = re.compile(r'^"[^"]+","([a-z0-9][a-z0-9.-]*[.][a-z]{2,})",') rx_b = re.compile(r"^([a-z0-9][a-z0-9.-]*[.][a-z]{2,}),.+,[0-9: /-]+,") rx_dq = re.compile(r"^address=/([a-z0-9][a-z0-9.-]*[.][a-z]{2,})/.") + rx_trusted = re.compile(r"^([*a-z0-9.-]+)\s*(@\S+)?$") + if trusted: return parse_trusted_list(content) names = set() time_restrictions = {} - rx_set = [rx_u, rx_l, rx_h, rx_mdl, rx_b, rx_dq] + rx_set = [rx_u, rx_l, rx_h, rx_mdl, rx_b, rx_dq, rx_trusted] for line in content.splitlines(): line = str.lower(str.strip(line)) if rx_comment.match(line): From f9abbd2e44df0be4219eef638e258b2dfadbe123 Mon Sep 17 00:00:00 2001 From: Muntashir Al-Islam Date: Tue, 20 Jul 2021 17:18:31 +0600 Subject: [PATCH 2/3] [UPDATE] List time restrictions for remote files --- config/generate-domains-blocklist.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/generate-domains-blocklist.py b/config/generate-domains-blocklist.py index 31fcc59..6bdbe95 100755 --- a/config/generate-domains-blocklist.py +++ b/config/generate-domains-blocklist.py @@ -81,6 +81,12 @@ def parse_list(content, trusted=False): continue name = matches.group(1) names.add(name) + try: + time_restriction = matches.group(2) + if time_restriction: + time_restrictions[name] = time_restriction + except IndexError as e: + pass return names, time_restrictions From 23f4f6c5bbeeb1ef9a27315bec14f33e9e5dcf8f Mon Sep 17 00:00:00 2001 From: Muntashir Al-Islam Date: Tue, 20 Jul 2021 17:19:35 +0600 Subject: [PATCH 3/3] [UPDATE] Parse all supported filter patterns For both remote and local files, parse all the filter patterns supported by DNSCrypt. A list of supported patterns are given here: https://github.com/DNSCrypt/dnscrypt-proxy/wiki/Filters#filter-patterns --- config/generate-domains-blocklist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/generate-domains-blocklist.py b/config/generate-domains-blocklist.py index 6bdbe95..e64f297 100755 --- a/config/generate-domains-blocklist.py +++ b/config/generate-domains-blocklist.py @@ -20,7 +20,7 @@ except (ImportError, ModuleNotFoundError): def parse_time_restricted_list(content): rx_comment = re.compile(r"^(#|$)") rx_inline_comment = re.compile(r"\s*#\s*[a-z0-9-].*$") - rx_trusted = re.compile(r"^([*a-z0-9.-]+)\s*(@\S+)?$") + rx_trusted = re.compile(r"^(=?[*a-z0-9.\-\[\]\?\:]+)\s*(@\S+)?$") rx_timed = re.compile(r".+\s*(@\S+)?$") names = set() @@ -61,7 +61,7 @@ def parse_list(content, trusted=False): rx_mdl = re.compile(r'^"[^"]+","([a-z0-9][a-z0-9.-]*[.][a-z]{2,})",') rx_b = re.compile(r"^([a-z0-9][a-z0-9.-]*[.][a-z]{2,}),.+,[0-9: /-]+,") rx_dq = re.compile(r"^address=/([a-z0-9][a-z0-9.-]*[.][a-z]{2,})/.") - rx_trusted = re.compile(r"^([*a-z0-9.-]+)\s*(@\S+)?$") + rx_trusted = re.compile(r"^(=?[*a-z0-9.\-\[\]\?\:]+)\s*(@\S+)?$") if trusted: