This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
networking:router:mikrotik_manual_blacklist [2024/04/04 09:34] gcooper |
networking:router:mikrotik_manual_blacklist [2025/02/25 16:10] (current) gcooper |
||
---|---|---|---|
Line 61: | Line 61: | ||
====== Script ====== | ====== Script ====== | ||
+ | |||
+ | FIXME Super slow and may not be 100% correct for ROS v7. | ||
:!: You should first run this script at the ROS command line to look for errors. | :!: You should first run this script at the ROS command line to look for errors. | ||
Line 77: | Line 79: | ||
\n##\r\ | \n##\r\ | ||
\n:put \" | \n:put \" | ||
- | \n:put \"This script requires the address text file to have UNIX line endi\ | + | \n:put \"This script requires the address text file to have UNIX line endings.\"; |
- | ngs.\"; | + | |
\n\ | \n\ | ||
\n:put \" | \n:put \" | ||
Line 90: | Line 91: | ||
\n:put \" | \n:put \" | ||
\n##:put \" | \n##:put \" | ||
- | \n##/ip firewall address-list remove [/ip firewall address-list find list=\ | + | \n##/ip firewall address-list remove [/ip firewall address-list find list=blacklist]; |
- | | + | |
\n:global content [/file get [/file find name=ipaddress.txt] contents] ;\r\ | \n:global content [/file get [/file find name=ipaddress.txt] contents] ;\r\ | ||
\n:global contentLen [ :len \$content ] ;\r\ | \n:global contentLen [ :len \$content ] ;\r\ | ||
Line 101: | Line 101: | ||
\n :set line [:pick \$content \$lastEnd \$lineEnd] ;\r\ | \n :set line [:pick \$content \$lastEnd \$lineEnd] ;\r\ | ||
\n :set lastEnd ( \$lineEnd + 1 ) ;\r\ | \n :set lastEnd ( \$lineEnd + 1 ) ;\r\ | ||
- | \n #If the line doesn' | + | \n #If the line doesn' |
- | \_list\r\ | + | |
\n :if ( [:pick \$line 0 1] != \"# | \n :if ( [:pick \$line 0 1] != \"# | ||
\n :local entry [:pick \$line 0 \$lineEnd ]\r\ | \n :local entry [:pick \$line 0 \$lineEnd ]\r\ | ||
\n :if ( [:len \$entry ] > 0 ) do={\r\ | \n :if ( [:len \$entry ] > 0 ) do={\r\ | ||
\n :put \" | \n :put \" | ||
- | \n /ip firewall address-list remove [find list=\" | + | \n /ip firewall address-list remove [find list=\" |
- | ss=\$entry]; | + | |
\n :put \" | \n :put \" | ||
- | \n /ip firewall address-list add list=blacklist address=\$entry | + | \n /ip firewall address-list add list=blacklist address=\$entry |
- | mment=\" | + | |
\n }\r\ | \n }\r\ | ||
\n }\r\ | \n }\r\ |