Skip to content

Commit

Permalink
Update RouterOS.py (#52)
Browse files Browse the repository at this point in the history
In the build function, changed the output file extension to ".src".
  • Loading branch information
kiss2u authored Mar 20, 2024
1 parent 1efaa0b commit 395bf7f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions script/RouterOS.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import json

def format_domain(domain_file):
domain = []
with open(domain_file, 'r') as file:
lines = file.readlines()
domain = []
with open(domain_file, 'r') as file:
lines = file.readlines()

for line in lines:
domain_lines = f"ip dns static add address=240.0.0.1 name={line.strip()}"
domain.append(domain_lines)
return domain
for line in lines:
domain_line = f"ip dns static add address=240.0.0.1 name={line.strip()}"
domain.append(domain_line)

return domain

def build(domain_file, regex_file):
return format_domain(domain_file)
return format_domain(domain_file)

if __name__ == '__main__':
domain_file = 'rule/domain.txt'
regex_file = 'rule/domain_regex.txt'
mikrotik_ros= build(domain_file, regex_file)

with open('mikrotik_ros.rsc', 'w') as file:
file.write('\n'.join(mikrotik_ros))

print('生成 mikrotik_ros.rsc 文件成功!')

0 comments on commit 395bf7f

Please sign in to comment.