]> Git [git.vados.ru] :: Repos - Mikrotiks/ros.vados.ru.git/commitdiff
Autocommit in repo: ros.vados.ru, generated by owner: root, in 21:25:03 03.05.2026.
authorvados-dev <192440777+vados-dev@users.noreply.github.com>
Sun, 3 May 2026 18:25:03 +0000 (21:25 +0300)
committervados-dev <192440777+vados-dev@users.noreply.github.com>
Sun, 3 May 2026 18:25:03 +0000 (21:25 +0300)
html/AM-FwAddrLists.rsc
html/AM-GlobalFunc.rsc
html/fw-addr-lists.d/index [new file with mode: 0644]

index 4a6cb5f97886a677bb4c9c7e5c5ccbc77e9c7890..8fe59c63f8cf7e33c33578ff8c0b3c5f386f7246 100644 (file)
 
   :global GlobalScriptsUrl;
   :local FwAddrListsUrl ($GlobalScriptsUrl . "fw-addr-lists.d/");
-
-  :local FwAddrLists {
-    "allow"={
-      { url=($FwAddrListsUrl . "allow");
-        cert="ISRG Root X2"; timeout=1w };
-    };
-    "block"={
-      { url=($FwAddrListsUrl . "block");
-        cert="ISRG Root X2" };
-#      { url="https://raw.githubusercontent.com/stamparm/ipsum/refs/heads/master/levels/4.txt";
-#     # higher level (decrease the numerical value) for more addresses, and vice versa
-#      cert="ISRG Root X1" };
-#    { url="https://www.dshield.org/block.txt"; cidr="/24";
-#      cert="GTS Root R4" };
-#    { url="https://lists.blocklist.de/lists/strongips.txt";
-#      cert="GTS Root R4" };
-#    { url="https://www.spamhaus.org/drop/drop_v4.json";
-#      cert="GTS Root R4" };
-#    { url="https://www.spamhaus.org/drop/drop_v6.json";
-#      cert="GTS Root R4" };
-    };
-#    "mikrotik"={
-#      { url=($FwAddrListsUrl . "mikrotik");
-#        cert="ISRG Root X2"; timeout=1w };
-#    };
-    "FuckRKN"={
-      { url=($FwAddrListsUrl . "FuckRKN");
-        cert="ISRG Root X2"; timeout=1w };
-    };
-  };
+  :local FwAddrListsIndexUrl ($FwAddrListsUrl . "index");
   :local FwAddrListTimeOut 1d;
 
   :global CertificateAvailable;
@@ -60,8 +31,8 @@
   
   :local FindDelim do={
     :local ValidChars "0123456789.:/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-";
-    :for I from=0 to=[ :len $1 ] do={
-      :if ([ :typeof [ :find $ValidChars [ :pick ($1 . " ") $I ] ] ] != "num") do={
+    :for I from=0 to=([ :len $1 ] - 1) do={
+      :if ([ :typeof [ :find $ValidChars [ :pick $1 $I ] ] ] != "num") do={
         :return $I;
       }
     }
   }
 
   :local ListComment ("managed by " . $ScriptName);
+  :local FwAddrListsIndex false;
+
+  :for I from=1 to=5 do={
+    :if ($FwAddrListsIndex = false) do={
+      :set FwAddrListsIndex [ :tolf [ $FetchHuge $ScriptName $FwAddrListsIndexUrl false ] ];
+      :if ($FwAddrListsIndex = false && $I < 5) do={
+        :log debug ($ScriptName . " Failed downloading address-list index, " . $I . ". try from: " . $FwAddrListsIndexUrl);
+        :delay (($I * $I) . "s");
+      }
+    }
+  }
+  :if ($FwAddrListsIndex = false) do={
+    :log warning ($ScriptName . " Failed downloading address-list index from: " . $FwAddrListsIndexUrl);
+    :set FwAddrListsIndex "";
+  }
+
+  :foreach FwListFile in=[ :deserialize $FwAddrListsIndex delimiter="\n" from=dsv options=dsv.plain ] do={
+    :local FwListName ($FwListFile->0);
+    :local Delim [ $FindDelim $FwListName ];
+    :if ($Delim = 0) do={ :set FwListName ""; };
+    :if ([ :len $FwListName ] = 0) do={ :error true; }
+    :set FwListName [ :pick $FwListName 0 $Delim ];
 
-  :foreach FwListName,FwList in=$FwAddrLists do={
+    :local FwListUrl ($FwAddrListsUrl . $FwListName);
     :local CntAdd 0;
     :local CntRenew 0;
     :local CntRemove 0;
     :local IPv4Addresses ({});
     :local IPv6Addresses ({});
     :local Failure false;
+    :local Data false;
+    :local TimeOut $FwAddrListTimeOut;
 
-    :foreach List in=$FwList do={
-      :local CheckCertificate false;
-      :local Data false;
-      :local TimeOut [ $EitherOr [ :totime ($List->"timeout") ] $FwAddrListTimeOut ];
-
-      :if ([ :len ($List->"cert") ] > 0) do={
-        :set CheckCertificate true;
-        :if ([ $CertificateAvailable ($List->"cert") "fetch" ] = false) do={
-          :log warning ($ScriptName . " Downloading required certificate (" . $FwListName . \
-              " / " . $List->"url" . ") failed, trying anyway.");
+    :for I from=1 to=5 do={
+      :if ($Data = false) do={
+        :set Data [ :tolf [ $FetchHuge $ScriptName $FwListUrl false ] ];
+        :if ($Data = false && $I < 5) do={
+          :log debug ($ScriptName . " Failed downloading for list '" . $FwListName . "', " . $I . ". try from: " . $FwListUrl);
+          :delay (($I * $I) . "s");
         }
       }
+    }
 
-      :for I from=1 to=5 do={
-        :if ($Data = false) do={
-          :set Data [ :tolf [ $FetchHuge $ScriptName ($List->"url") $CheckCertificate ] ];
-          :if ($Data = false) do={
-            :if ($I < 5) do={
-              :log debug ($ScriptName . " Failed downloading for list '" . $FwListName . \
-                  "', " . $I . ". try from: " . $List->"url");
-              :delay (($I * $I) . "s");
-            }
-          }
-        }
-      }
+    :if ($Data = false) do={
+      :set Data "";
+      :set Failure true;
+      :log warning ($ScriptName . " Failed downloading for list '" . $FwListName . "' from: " . $FwListUrl);
+    } else={
+      :log debug ($ScriptName . " Downloaded " . [ $HumanReadableNum [ :len $Data ] 1024 ] . "B for list '" . $FwListName . "' from: " . $FwListUrl);
+    }
 
-      :if ($Data = false) do={
-        :set Data "";
-        :set Failure true;
-        :log warning ($ScriptName . " Failed downloading for list '" . $FwListName . \
-            "' from: " . $List->"url");
+    :foreach Line in=[ :deserialize $Data delimiter="\n" from=dsv options=dsv.plain ] do={
+      :set Line ($Line->0);
+      :local Delim [ $FindDelim $Line ];
+      :if ($Delim = 0) do={ :set Line ""; };
+      :if ([ :len $Line ] = 0) do={ :error true; }
+      :local Address;
+      :if ([ :pick $Line 0 1 ] = "{" && [ :pick $Line ([ :len $Line ] - 1) ] = "}") do={
+        :do {
+          :set Address [ :tostr ([ :deserialize from=json $Line ]->"cidr") ];
+        } on-error={ }
       } else={
-        :log debug ($ScriptName . " Downloaded " . [ $HumanReadableNum [ :len $Data ] 1024 ] . \
-            "B for list '" . $FwListName . "' from: " . $List->"url");
+        :set Address [ :pick $Line 0 [ $FindDelim $Line ] ];
       }
-
-      :foreach Line in=[ :deserialize $Data delimiter="\n" from=dsv options=dsv.plain ] do={
-        :set Line ($Line->0);
-        :local Address;
-        :if ([ :pick $Line 0 1 ] = "{" && [ :pick $Line ([ :len $Line ] - 1) ] = "}") do={
-          :do {
-            :set Address [ :tostr ([ :deserialize from=json $Line ]->"cidr") ];
-          } on-error={ }
-        } else={
-          :set Address ([ :pick $Line 0 [ $FindDelim $Line ] ] . ($List->"cidr"));
-        }
-        :do {
-          :local Branch;
-          :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={
-            :local Net $Address;
-            :local CIDR 32;
-            :local Slash [ :find $Address "/" ];
-            :if ([ :typeof $Slash ] = "num") do={
-              :set Net [ :toip [ :pick $Address 0 $Slash ] ]
-              :set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ];
-              :set Address [ :tostr (([ :toip $Net ] & [ $NetMask4 $CIDR ]) . [ $IfThenElse ($CIDR < 32) ("/" . $CIDR) ]) ];
-            }
-            :set Branch [ $GetBranch $Address ];
-            :set ($IPv4Addresses->$Branch->$Address) $TimeOut;
-            :error true;
+      :do {
+        :local Branch;
+        :if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={
+          :local Net $Address;
+          :local CIDR 32;
+          :local Slash [ :find $Address "/" ];
+          :if ([ :typeof $Slash ] = "num") do={
+            :set Net [ :toip [ :pick $Address 0 $Slash ] ]
+            :set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ];
+            :set Address [ :tostr (([ :toip $Net ] & [ $NetMask4 $CIDR ]) . [ $IfThenElse ($CIDR < 32) ("/" . $CIDR) ]) ];
           }
-          :if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={
-            :local Net $Address;
-            :local CIDR 128;
-            :local Slash [ :find $Address "/" ];
-            :if ([ :typeof $Slash ] = "num") do={
-              :set Net [ :toip6 [ :pick $Address 0 $Slash ] ]
-              :set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ];
-            }
-            :set Address (([ :toip6 $Net ] & [ $NetMask6 $CIDR ]) . "/" . $CIDR);
-            :set Branch [ $GetBranch $Address ];
-            :set ($IPv6Addresses->$Branch->$Address) $TimeOut;
-            :error true;
-          }
-          :if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={
-            :set Branch [ $GetBranch $Address ];
-            :set ($IPv4Addresses->$Branch->$Address) $TimeOut;
-            :set ($IPv6Addresses->$Branch->$Address) $TimeOut;
-            :error true;
+          :set Branch [ $GetBranch $Address ];
+          :if ([ :typeof ($IPv4Addresses->$Branch) ] != "array") do={ :set ($IPv4Addresses->$Branch) ({}) };
+          :set ($IPv4Addresses->$Branch->$Address) $TimeOut;
+          :error true;
+        }
+        :if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={
+          :local Net $Address;
+          :local CIDR 128;
+          :local Slash [ :find $Address "/" ];
+          :if ([ :typeof $Slash ] = "num") do={
+            :set Net [ :toip6 [ :pick $Address 0 $Slash ] ]
+            :set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ];
           }
-        } on-error={:log error ($ScriptName . " Failed parsing address: " . $Line->0);}
-      }
+          :set Address (([ :toip6 $Net ] & [ $NetMask6 $CIDR ]) . "/" . $CIDR);
+          :set Branch [ $GetBranch $Address ];
+          :if ([ :typeof ($IPv6Addresses->$Branch) ] != "array") do={ :set ($IPv6Addresses->$Branch) ({}) };
+          :set ($IPv6Addresses->$Branch->$Address) $TimeOut;
+          :error true;
+        }
+        :if ($Address ~ "^[\\.a-zA-Z0-9-]+\\.[a-zA-Z]{2,}\$") do={
+          :set Branch [ $GetBranch $Address ];
+          :if ([ :typeof ($IPv4Addresses->$Branch) ] != "array") do={ :set ($IPv4Addresses->$Branch) ({}) };
+          :if ([ :typeof ($IPv6Addresses->$Branch) ] != "array") do={ :set ($IPv6Addresses->$Branch) ({}) };
+          :set ($IPv4Addresses->$Branch->$Address) $TimeOut;
+          :set ($IPv6Addresses->$Branch->$Address) $TimeOut;
+          :error true;
+        }
+      } on-error={:log error ($ScriptName . " Failed parsing address: " . $Line->0);}
     }
 
     :foreach Entry in=[ /ip/firewall/address-list/find where \
index 5be9b5f4bbbc0ce56e40fb805ec67ea6219d27a5..2495695463df1a50612c5c7853da92359de340a3 100644 (file)
@@ -17,9 +17,9 @@
 :global GlobalFuncReady false;
 
 # Git commit id & info, expected configuration version
-:global CommitId "main/456/18e42ec2";
+:global CommitId "main/457/33b23c0a";
 :global CommitTAG "unknown";
-:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 21:20:02 03.05.2026.";
+:global CommitInfo "Autocommit in repo: ros.vados.ru, generated by owner: root, in 21:25:03 03.05.2026.";
 
 # The variables are received right here.
 :global GlobalConfVersion 138;
diff --git a/html/fw-addr-lists.d/index b/html/fw-addr-lists.d/index
new file mode 100644 (file)
index 0000000..b3928e3
--- /dev/null
@@ -0,0 +1,4 @@
+allow
+block
+FuckRKN
+mikrotik