Skip to content

Commit

Permalink
Update SFLB to 3.0.12
Browse files Browse the repository at this point in the history
* Add support for dnsmasq conversion (normal and wildcards)
  • Loading branch information
hawkeye116477 committed Jan 28, 2024
1 parent 299170b commit 161bb42
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
include:
- dfile: "SFLB"
imname: "sflb"
version: "3.0.11"
version: "3.0.12"
- dfile: "ED"
imname: "expired_domains"
version: "1"
Expand Down Expand Up @@ -77,10 +77,10 @@ jobs:
include:
- dfile: "KAD"
imname: "kad"
version: "3.0.11"
version: "3.0.12"
- dfile: "RTM"
imname: "rtm"
version: "3.0.11"
version: "3.0.12"
needs: docker_sflb_ed
steps:
- name: Check out the repo
Expand Down
28 changes: 21 additions & 7 deletions scripts/SFLB.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
FOP = None

# Version number
SCRIPT_VERSION = "3.0.11"
SCRIPT_VERSION = "3.0.12"

# Parse arguments
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -234,7 +234,7 @@ def main(pathToFinalLists, forced, saveChangedFN):
EP_I_PAT = re.compile(r'@exclusionsPath (.*)$')
EE_I_PAT = re.compile(r'@exclusionsExt (.*)$')
VALID_INSTRUCTIONS_PAT = re.compile(
r'^@((sections|exclusions)(Path|Ext)|(HOSTS|DOMAINS|PH|B?NWL)?include)')
r'^@((sections|exclusions)(Path|Ext)|(HOSTS|DOMAINS|PH|DNSMASQ|B?NWL)?include)')
INSTRUCTIONS_START_PAT = re.compile(r'^@')
for lineT in tf:
if not VALID_INSTRUCTIONS_PAT.match(lineT) and INSTRUCTIONS_START_PAT.match(lineT):
Expand Down Expand Up @@ -454,21 +454,35 @@ def main(pathToFinalLists, forced, saveChangedFN):
external_temp.name)
section = external_temp.name

if re.match(r"(HOSTS|DOMAINS|PH|B?NWL)include", instruction):
if re.match(r"(DNSMASQ|HOSTS|DOMAINS|PH|B?NWL)include", instruction):
with open(section, "r", encoding='utf-8') as section_content, NamedTemporaryFile(dir=tempDir, delete=False, mode="w", encoding="utf-8") as external_temp_final:
unsortedLinesC = []
for lineC in section_content:
lineCwww = ""
convertItems = ""
if instruction in ("HOSTSinclude", "DOMAINSinclude"):
if instruction in ("DNSMASQinclude", "HOSTSinclude", "DOMAINSinclude"):
if not re.match(r"^(0\.0\.0\.0.*|\|\|(?!.*\/).*\^(\$all)?$)", lineC) or re.match(r"\*|\/", lineC):
lineC = ""
else:
convertItems = [
(r"\$all$", ""),
(r"[\^]", ""),
(r".*\*(.*)?", "")
(r"[\^]", "")
]
if instruction != "DNSMASQinclude":
convertItems.extend(
[
(r".*\*(.*)?", ""),
(r"\$all$", "")
]
)
if instruction == "DNSMASQinclude":
convertItems.extend(
[
(r"\$all$", "/"),
(r"^[|][|]",
"address=/"),
(r"^address=\/[0-9]?[0-9]?[0-9]\.[0-9]?[0-9]?[0-9]\.[0-9]?[0-9]?[0-9]\.[0-9]?[0-9]?[0-9](.*)?", "")
]
)
if instruction == "DOMAINSinclude":
convertItems.append(
[r"^[|][|]", ""])
Expand Down

0 comments on commit 161bb42

Please sign in to comment.