1
+ #! /bin/bash
2
+ set -e
3
+
1
4
# @license: CC BY-NC-SA 4.0 International
2
5
# @author: SMKRV
3
6
# @github: https://github.com/smkrv/mikrotik-domain-filter-script
17
20
# domains serving advertisements, integrating seamlessly with DNS Static in
18
21
# Mikrotik RouterOS, and aiding in generating DNS FWD records.
19
22
20
- #! /bin/bash
21
- set -e
22
-
23
23
# Enable debugging
24
24
# set -x
25
25
@@ -59,8 +59,6 @@ export DNS_MAX_RETRIES
59
59
60
60
# Global variables for statistics
61
61
declare -i TOTAL_DOMAINS=0
62
- declare -i PROCESSED_DOMAINS=0
63
- declare -i VALID_DOMAINS=0
64
62
65
63
# Enable debugging
66
64
# exec 2>"${WORK_DIR}/debug.log"
@@ -71,7 +69,7 @@ mkdir -p "$(dirname "$LOG_FILE")"
71
69
# Clear old log
72
70
: > " $LOG_FILE "
73
71
74
- # Check for required files
72
+ # Check for required files
75
73
check_required_files () {
76
74
local missing_files=()
77
75
@@ -87,7 +85,8 @@ check_required_files() {
87
85
88
86
# Enhanced logging
89
87
log () {
90
- local timestamp=$( date ' +%Y-%m-%d %H:%M:%S' )
88
+ local timestamp
89
+ timestamp=$( date ' +%Y-%m-%d %H:%M:%S' )
91
90
echo " [$timestamp ] $1 " | tee -a " $LOG_FILE "
92
91
}
93
92
@@ -368,7 +367,8 @@ initial_filter() {
368
367
# Function to determine domain type
369
368
get_domain_type () {
370
369
local domain=$1
371
- local parts=(${domain// ./ } )
370
+ local parts
371
+ IFS=' .' read -ra parts <<< " $domain"
372
372
local levels=${# parts[@]}
373
373
local base=" ${parts[-2]} .${parts[-1]} "
374
374
@@ -525,7 +525,7 @@ apply_whitelist() {
525
525
526
526
# Create temporary file for exclusion patterns
527
527
local whitelist_pattern=" ${TMP_DIR} /whitelist_pattern.txt"
528
- > " $whitelist_pattern "
528
+ true > " $whitelist_pattern "
529
529
530
530
# Process whitelist
531
531
while IFS= read -r domain; do
0 commit comments