]> Git [git.vados.ru] :: Repos - Mikrotiks/backups.git/commitdiff
Backup for MikroMaster created successfully at May 12 10:00:18.
authorvados-dev <vados@vados.ru>
Tue, 12 May 2026 07:00:18 +0000 (10:00 +0300)
committervados-dev <vados@vados.ru>
Tue, 12 May 2026 07:00:18 +0000 (10:00 +0300)
MikroMaster/20260512/20260512100002-Binary.backup [new file with mode: 0644]
MikroMaster/20260512/20260512100002-Config.rsc [new file with mode: 0644]
MikroMaster/history/20260512/20260512100002-Diff-Config.rsc [new file with mode: 0644]

diff --git a/MikroMaster/20260512/20260512100002-Binary.backup b/MikroMaster/20260512/20260512100002-Binary.backup
new file mode 100644 (file)
index 0000000..022d75c
Binary files /dev/null and b/MikroMaster/20260512/20260512100002-Binary.backup differ
diff --git a/MikroMaster/20260512/20260512100002-Config.rsc b/MikroMaster/20260512/20260512100002-Config.rsc
new file mode 100644 (file)
index 0000000..8ded78a
--- /dev/null
@@ -0,0 +1,4653 @@
+# 2026-05-12 10:00:02 by RouterOS 7.23beta5\r
+# software id = A8L5-07YF\r
+#\r
+# model = RB952Ui-5ac2nD\r
+# serial number = D3D50CEDCD38\r
+/caps-man configuration\r
+add channel.band=2ghz-b/g/n .control-channel-width=20mhz .extension-channel=\\r
+    XX country=belarus datapath.client-to-client-forwarding=yes \\r
+    .local-forwarding=yes name=cfg-2ghz ssid=vados\r
+add channel.band=5ghz-a/n/ac .control-channel-width=20mhz .extension-channel=\\r
+    XXXX country=belarus datapath.client-to-client-forwarding=yes \\r
+    .local-forwarding=yes name=cfg-5ghz-ac ssid=vados5g\r
+add channel.band=5ghz-a/n .control-channel-width=20mhz .extension-channel=XX \\r
+    country=belarus datapath.client-to-client-forwarding=yes \\r
+    .local-forwarding=yes name=cfg-5ghz-an ssid=vados5g\r
+/interface ethernet\r
+# same mac-address as wlan1\r
+set [ find default-name=ether1 ] comment="WAN - Unet" mac-address=\\r
+    48:8F:5A:8E:1A:C2 name="ether1 - Unet"\r
+set [ find default-name=ether3 ] comment=LEN\r
+set [ find default-name=ether4 ] comment=NUC\r
+set [ find default-name=ether5 ] poe-out=off\r
+/interface l2tp-server\r
+add comment=Server disabled=yes name=l2tp-in1 user=vados\r
+/interface l2tp-client\r
+add comment="Starless 2 MikroSPb" connect-to=176.53.203.171 name=l2tp-EoIP \\r
+    user=vados\r
+add allow=mschap2 allow-fast-path=yes comment=Starless connect-to=\\r
+    vpn.starless.ru max-mru=1280 name=l2tp-vpn use-ipsec=yes use-peer-dns=yes \\r
+    user=vados\r
+/interface wireguard\r
+add listen-port=13231 mtu=1280 name=WG\r
+/disk\r
+add slot=tmpfs tmpfs-max-size=22369621 type=tmpfs\r
+/interface list\r
+add name=WAN\r
+add name=LAN\r
+/interface lte apn\r
+set [ find default=yes ] ip-type=ipv4 use-network-apn=no\r
+/interface wifi channel\r
+add band=5ghz-ax disabled=no frequency=5180,5200,5220,5240 name=5G-AX\r
+add band=5ghz-ac disabled=no frequency=5180,5200,5220,5240 name=5G-AC\r
+add band=2ghz-n disabled=no frequency=2422,2442,2462 name=2G-N\r
+add band=2ghz-ax disabled=no frequency=2422,2442,2462 name=2G-AX\r
+add band=2ghz-g disabled=no frequency=2422,2442,2462 name=2G-G\r
+add band=5ghz-n disabled=no frequency=5180,5200,5220,5240 name=5G-AN\r
+/interface wifi security\r
+add authentication-types=wpa2-psk,wpa3-psk disabled=no group-encryption=ccmp \\r
+    group-key-update=1h management-protection=allowed name=sec2g\r
+add authentication-types=wpa3-psk disable-pmkid=yes disabled=no \\r
+    group-encryption=ccmp group-key-update=5m management-encryption=cmac \\r
+    management-protection=required name=sec5G\r
+/interface wifi configuration\r
+add channel=5G-AX disabled=no mode=ap name=5G-AX security=sec5G security.ft=\\r
+    yes .ft-over-ds=yes ssid=vados\r
+add channel=5G-AN disabled=no mode=ap name=5G-AN security=sec5G ssid=vados\r
+/interface wireless security-profiles\r
+set [ find default=yes ] supplicant-identity=MikroTik\r
+/ip dhcp-server option\r
+add code=12 name=HostName\r
+add code=119 force=yes name=domain-search-list value="0x03'WORKGROUP'0x00"\r
+/ip dhcp-server option sets\r
+add name=HP1505n options=HostName\r
+add name=StartLife1 options=HostName\r
+add name=amsterDev options=HostName\r
+add name=MiTV options=HostName\r
+add name=miller options=HostName\r
+add name=amster options=HostName\r
+add name=garage options=HostName\r
+add name=domain-search-set options=domain-search-list\r
+add name=VADOS-LEN options=HostName\r
+add name=VADOS-NUC options=HostName\r
+add name=MikroNUC options=HostName\r
+add name=master options=HostName\r
+add name=MikroYellow options=HostName\r
+add name="=\"Client ID\"" options=HostName\r
+/ip dns forwarders\r
+add dns-servers=1.1.1.1,1.0.0.1 name=blsp.at verify-doh-cert=no\r
+add comment=Kra dns-servers=1.0.0.1,1.1.1.1 name=slon2.to verify-doh-cert=no\r
+add dns-servers=1.1.1.1,1.0.0.1 name=slon3.at verify-doh-cert=no\r
+add dns-servers=1.0.0.1,1.1.1.1 name=slon3.cc verify-doh-cert=no\r
+add dns-servers=1.1.1.1,1.0.0.1 name=bs2web.at verify-doh-cert=no\r
+add dns-servers=1.1.1.1,1.0.0.1 name=bs2best.at verify-doh-cert=no\r
+add dns-servers=1.0.0.1,1.1.1.1 name=psrms.is verify-doh-cert=no\r
+/ip ipsec proposal\r
+set [ find default=yes ] disabled=yes\r
+/ip pool\r
+add name=dhcp ranges=10.30.30.83-10.30.30.254\r
+/ip smb users\r
+set [ find default=yes ] disabled=yes\r
+add disabled=yes name=vados\r
+/ppp profile\r
+set *FFFFFFFE use-upnp=no\r
+/routing bgp template\r
+set default disabled=no output.network=bgp-networks\r
+/routing table\r
+add disabled=no fib name=To-VPN\r
+/system logging action\r
+add email-start-tls=yes email-to=vados@vados.ru name=email target=email\r
+/system script\r
+add dont-require-permissions=no name=fetchCustom owner=vados policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    /tool/fetch mode=https url=(\$GlobalScriptsUrl . #\".bak/mikro_bak_rsa@10.\\r
+    30.30.86.pub\") dst-path=\"/mikro_bak_rsa@10.30.30.86.pub\";\\r
+    \n#:local Script AM-setup\\r
+    \n#/system/script/add name=\$Script owner=\$Script source=([ /tool/fetch c\\r
+    heck-certificate=yes-without-crl url=(\$GlobalScriptsUrl . \$Script . \".r\\r
+    sc\")  output=user as-value ]->\"data\");\\r
+    \n#/usb1/mikro_bak_rsa.pub\\r
+    \n\\r
+    \n#\\r
+    \n#/tool/fetch mode=https url=(\$GlobalScriptsUrl . \".bak/mikro_bak_rsa@1\\r
+    0.30.30.10.pub\") dst-path=\"/mikro_bak_rsa@10.30.30.10.pub\";\\r
+    \n#\\r
+    \n#root.mnuc.backuper\\r
+    \n\\r
+    \n#/tool/fetch mode=https url=(\$GlobalScriptsUrl . \".bak/mikro_bak_rsa@1\\r
+    0.30.30.81.pub\") dst-path=\"/mikro_bak_rsa@10.30.30.81.pub\";\\r
+    \n#:local Script AM-GlobalConfig;\\r
+    \n#/system/script/add name=\$Script owner=\$Script source=([ /tool/fetch c\\r
+    heck-certificate=yes-without-crl url=(\$GlobalScriptsUrl . \$Script . \".r\\r
+    sc\")  output=user as-value ]->\"data\");\\r
+    \n#/usb1/mikro_bak_rsa.pub\\r
+    \n#:local FetchFile AM-DOHCert.rsc\\r
+    \n\\r
+    \n:global GlobalScriptsUrl \"https://ros.vados.ru/tmp/\";\\r
+    \n:global MkDir;\\r
+    \n\\r
+    \n:local FetchFile Binary.backup\\r
+    \n:local localDir \"\";\\r
+    \n\\r
+    \n#\$MkDir \$localDir;\\r
+    \n\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \$FetchFile) dst-path=(\\r
+    \$localDir . \$FetchFile);"\r
+add comment="Example add WU servers to AddrList" dont-require-permissions=no \\r
+    name=WU-add-to-list owner=vados policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    \_Script to add target web sites DNS IP addresses into address list\r\\r
+    \n# Tested with Mikrotik 6.4x\r\\r
+    \n# Syed Jahanzaib / aacable@hotmail.com\r\\r
+    \n# List name\r\\r
+    \n:local LISTNAME \"windowsupdateslist\"\r\\r
+    \n# Web site names which will be added in address list\r\\r
+    \n:local TARGET1 \"update.microsoft.com\"\r\\r
+    \n:local TARGET2 \"download.windowsupdate.com\"\r\\r
+    \n:local TARGET3 \"download.microsoft.com\"\r\\r
+    \n:local TARGET4 \"windowsupdate.com\"\r\\r
+    \n:local TARGET5 \"ntservicepack.microsoft.com\"\r\\r
+    \n:local TARGET6 \"wustat.windows.com\"\r\\r
+    \n:local TARGET7 \"stats.microsoft.com\"\r\\r
+    \n:local TARGET8 \"mp.microsoft.com\"\r\\r
+    \n:local TARGET9 \"ws.microsoft.com\"\r\\r
+    \n:local TARGET10 \"sls.update.microsoft.com.akadns.net\"\r\\r
+    \n:local TARGET11 \"vortex.data.microsoft.com\"\r\\r
+    \n:local TARGET12 \"vortex-win.data.microsoft.com\"\r\\r
+    \n:local TARGET13 \"fe2.update.microsoft.com.akadns.net\"\r\\r
+    \n:local TARGET14 \"statsfe2.update.microsoft.com.akadns.net\"\r\\r
+    \n \r\\r
+    \n# 1st time runner, check if address list is not created previously and a\\r
+    dd entries in it for 1st time usage\r\\r
+    \n:if ( [/ip firewall address-list find where list=\$LISTNAME] = \"\") do=\\r
+    {\r\\r
+    \n:log warning \"No address list for \$TARGET1 found ! creating and adding\\r
+    \_resolved entry for 1st time usage ... zaib\"\r\\r
+    \n \r\\r
+    \n:local FirstAddr [resolve \$TARGET1];\r\\r
+    \n\r\\r
+    \n/ip firewall address-list add address=\$FirstAddr list=\$LISTNAME commen\\r
+    t=\$TARGET1;\r\\r
+    \n} else={\r\\r
+    \n:log warning \"Previous List for \$LISTNAME found ! moving forward and c\\r
+    hecking if DNS entries can be added in it ...\"\r\\r
+    \n}\r\\r
+    \n \r\\r
+    \n# Check DNS entries and collect matching names\r\\r
+    \n:foreach i in=[/ip dns cache find name~\"(\$TARGET1|\$TARGET2|\$TARGET3|\\r
+    \$TARGET4|\$TARGET5|\$TARGET6|\$TARGET7|\$TARGET8|\$TARGET9|\$TARGET10|\$T\\r
+    ARGET11|\$TARGET12|\$TARGET13|\$TARGET14)\" && \$type ~ \"^(A|CNAME)\\\$\"\\r
+    \_] do={\r\\r
+    \n \r\\r
+    \n# Get IP Address from the names and hold it in temporary buffer\r\\r
+    \n:local Buffer [/ip dns cache get \$i data];\r\\r
+    \ndelay delay-time=10ms\r\\r
+    \n \r\\r
+    \n# Check if entry is already not exists, then OK, otherwise ignore duplic\\r
+    ation\r\\r
+    \n:if ( [/ip firewall address-list find where address=\$Buffer] = \"\") do\\r
+    ={\r\\r
+    \n \r\\r
+    \n# Fetch DNS names for the entries\r\\r
+    \n:local sitednsname [/ip dns cache get \$i name] ;\r\\r
+    \n \r\\r
+    \n# Print name in LOG window\r\\r
+    \n:log info (\"added entry: \$sitednsname \$Buffer\");\r\\r
+    \n \r\\r
+    \n# Add IP addresses and there names to the address list\r\\r
+    \n/ip firewall address-list add address=\$Buffer list=\$LISTNAME comment=\\r
+    \$sitednsname;\r\\r
+    \n}\r\\r
+    \n}"\r
+add comment="Add Hosts DNS names to NoWG addres list" \\r
+    dont-require-permissions=no name=Add2vdsina owner=vados policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    \_Script to add target web sites DNS IP addresses into address list\r\\r
+    \n# Tested with Mikrotik 6.4x\r\\r
+    \n# \r\\r
+    \n# List name\r\\r
+    \n:local LISTNAME \"NoWG\"\r\\r
+    \n#\r\\r
+    \n# Web site names which will be added in address list\r\\r
+    \n:local TARGET1 \"comp-lenta.ru\"\r\\r
+    \n:local TARGET2 \"ok.ru\"\r\\r
+    \n:local TARGET3 \"vk.com\"\r\\r
+    \n#:local TARGET4 \"smtp.mail.me.com\"\r\\r
+    \n#:local TARGET4 \"windowsupdate.com\"\r\\r
+    \n#:local TARGET5 \"ntservicepack.microsoft.com\"\r\\r
+    \n#:local TARGET6 \"wustat.windows.com\"\r\\r
+    \n#:local TARGET7 \"stats.microsoft.com\"\r\\r
+    \n#:local TARGET8 \"mp.microsoft.com\"\r\\r
+    \n#:local TARGET9 \"ws.microsoft.com\"\r\\r
+    \n#:local TARGET10 \"sls.update.microsoft.com.akadns.net\"\r\\r
+    \n#:local TARGET11 \"vortex.data.microsoft.com\"\r\\r
+    \n#:local TARGET12 \"vortex-win.data.microsoft.com\"\r\\r
+    \n#:local TARGET13 \"fe2.update.microsoft.com.akadns.net\"\r\\r
+    \n#:local TARGET14 \"statsfe2.update.microsoft.com.akadns.net\"\r\\r
+    \n \r\\r
+    \n# 1st time runner, check if address list is not created previously and a\\r
+    dd entries in it for 1st time usage\r\\r
+    \n:if ( [/ip firewall address-list find where list=\$LISTNAME] = \"\") do=\\r
+    {\r\\r
+    \n:log warning \"No address list for \$TARGET1 found ! creating and adding\\r
+    \_resolved entry for 1st time usage ... zaib\"\r\\r
+    \n\r\\r
+    \n:local FirstAddr [resolve \$TARGET1];\r\\r
+    \n\r\\r
+    \n/ip firewall address-list add address=\$FirstAddr list=\$LISTNAME commen\\r
+    t=\$TARGET1;\r\\r
+    \n\r\\r
+    \n} else={\r\\r
+    \n:log warning \"Previous List for \$LISTNAME found ! moving forward and c\\r
+    hecking if DNS entries can be added in it ...\"\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n# Check DNS entries and collect matching names\r\\r
+    \n:foreach i in=[/ip dns cache find name~\"(\$TARGET1|\$TARGET2|\$TARGET3|\\r
+    \$TARGET4)\" && \$type ~ \"^(A|CNAME)\\\$\" ] do={\r\\r
+    \n\r\\r
+    \n:log info (\"start entry: \$c \$sitednsname \$Buffer\");\r\\r
+    \n\r\\r
+    \n# Get IP Address from the names and hold it in temporary buffer\r\\r
+    \n:local Buffer [/ip dns cache get \$i data];\r\\r
+    \ndelay delay-time=10ms\r\\r
+    \n:log info (\"1: \$Buffer\"); \r\\r
+    \n\r\\r
+    \n# Check if entry is already not exists, then OK, otherwise ignore duplic\\r
+    ation\r\\r
+    \n:if ( [/ip firewall address-list find where address=\$Buffer] = \"\") do\\r
+    ={\r\\r
+    \n\r\\r
+    \n:log info (\"2: \$Buffer\"); \r\\r
+    \n \r\\r
+    \n# Fetch DNS names for the entries\r\\r
+    \n:local sitednsname [/ip dns cache get \$i name] ;\r\\r
+    \n \r\\r
+    \n# Print name in LOG window\r\\r
+    \n:log info (\"added entry: \$i \$sitednsname \$Buffer\");\r\\r
+    \n \r\\r
+    \n# Add IP addresses and there names to the address list\r\\r
+    \n/ip firewall address-list add address=\$Buffer list=\$LISTNAME comment=\\r
+    \$sitednsname;\r\\r
+    \n}\r\\r
+    \n}"\r
+add comment="Flush DNS Cache" dont-require-permissions=no name=\\r
+    DNS_Flush_Cache owner=vados policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\\r
+    "/ip dns cache flush"\r
+add comment="Certificates CloudFlare, Quad9 " dont-require-permissions=no \\r
+    name=Update-Certificates owner=vados policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    \_CloudFlare\r\\r
+    \n#/tool/fetch mode=https url=https://cacerts.digicert.com/DigiCertGlobalR\\r
+    ootCA.crt.pem;\r\\r
+    \n#/certificate/import file-name=DigiCertGlobalRootCA.crt.pem passphrase=\\r
+    \"\";\r\\r
+    \n#/tool/ fetch mode=https url=https://cacerts.digicert.com/DigiCertGlobal\\r
+    G2TLSRSASHA2562020CA1-1.crt.pem;\r\\r
+    \n#/certificate/import file-name=DigiCertGlobalG2TLSRSASHA2562020CA1-1.crt\\r
+    .pem passphrase=\"\";\r\\r
+    \n# Quad9\r\\r
+    \n#/tool/fetch mode=https url=\"https://cacerts.digicert.com/DigiCertGloba\\r
+    lG3TLSECCSHA3842020CA1-1.crt.pem\"\r\\r
+    \n#/certificate/import file-name=DigiCertGlobalG3TLSECCSHA3842020CA1-1.crt\\r
+    .pem  passphrase=\"\";\r\\r
+    \n\r\\r
+    \n:global GlobalScriptsUrl;\r\\r
+    \n#google\r\\r
+    \n:local CertName \"DigiCert-Global-Root-CA.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Global-Root-CA\" [ find where common-na\\r
+    me=\"DigiCert Global Root CA\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-Assured-ID-Root-CA.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Assured-ID-Root-CA\" [ find where commo\\r
+    n-name=\"DigiCert Assured ID Root CA\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-Assured-ID-Root-G2.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Assured-ID-Root-G2\" [ find where commo\\r
+    n-name=\"DigiCert Assured ID Root G3\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-Assured-ID-Root-G3.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Assured-ID-Root-G3\" [ find where commo\\r
+    n-name=\"DigiCert Assured ID Root G3\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-Global-G2-TLS-RSA-SHA256-2020-CA1.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Global-G2-TLS-RSA-SHA256-2020-CA1\" [ f\\r
+    ind where common-name=\"DigiCert Global G2 TLS RSA SHA256 2020 CA1\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-Global-G3-TLS-ECC-SHA384-2020-CA1.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Global-G3-TLS-ECC-SHA384-2020-CA1\" [ f\\r
+    ind where common-name=\"DigiCert Global G3 TLS ECC SHA384 2020 CA1\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-Global-Root-G2.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Global-Root-G2\" [ find where common-na\\r
+    me=\"DigiCert Global Root G2\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-Global-Root-G3.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Global-Root-G3\" [ find where common-na\\r
+    me=\"DigiCert Global Root G3\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-TLS-ECC-P384-Root-G5.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-TLS-ECC-P384-Root-G5\" [ find where com\\r
+    mon-name=\"DigiCert TLS ECC P384 Root G5\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-TLS-RSA4096-Root-G5.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-TLS-RSA4096-Root-G5\" [ find where comm\\r
+    on-name=\"DigiCert TLS RSA4096 Root G5\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"DigiCert-Trusted-Root-G4.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"DigiCert-Trusted-Root-G4\" [ find where common-n\\r
+    ame=\"DigiCert Trusted Root G4\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"GTS-Root-R4.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"GTS-Root-R4\" [ find where common-name=\"GTS Roo\\r
+    t R4\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"Go-Daddy-Root-Certificate-Authority-G2.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"Go-Daddy-Root-Certificate-Authority-G2\" [ find \\r
+    where common-name=\"Go Daddy Root Certificate Authority - G2\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"ISRG-Root-X1.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"ISRG-Root-X1\" [ find where common-name=\"ISRG R\\r
+    oot X1\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"Root-YE.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"Root-YE\" [ find where common-name=\"Root YE\" ]\\r
+    ;\r\\r
+    \n\r\\r
+    \n:set CertName \"Starfield-Root-Certificate-Authority-G2.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"Starfield-Root-Certificate-Authority-G2\" [ find\\r
+    \_where common-name=\"Starfield Root Certificate Authority - G2\" ];\r\\r
+    \n\r\\r
+    \n:set CertName \"USERTrust-RSA-Certification-Authority.pem\";\r\\r
+    \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \"certs/Master/\" . \$C\\r
+    ertName);\r\\r
+    \n/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n/certificate/set name=\"USERTrust-RSA-Certification-Authority\" [ find w\\r
+    here common-name=\"USERTrust RSA Certification Authority\" ];\r\\r
+    \n\r\\r
+    \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n#:set CertName \"GTS-Root-RX.pem\";\r\\r
+    \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\\r
+    \r\\r
+    \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n#internet\r\\r
+    \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n#:set CertName \"ISRG-Root-X2.pem\";\r\\r
+    \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\\r
+    \r\\r
+    \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\\r
+    \n\r\\r
+    \n\r\\r
+    \n#/ip/dns/set allow-remote-requests=yes doh-max-concurrent-queries=100 do\\r
+    h-max-server-connections=20 use-doh-server=https://security.cloudflare-dns\\r
+    .com/dns-query verify-doh-cert=yes;\r\\r
+    \n#/ip/dns/static remove [find where address=1.1.1.1];\r\\r
+    \n#/ip/dns/static add address=1.1.1.1 name=security.cloudflare-dns.com com\\r
+    ment=\"cloudflare-dns IPv4 1\";\r\\r
+    \n#/ip/dns/ static remove  [find where address=1.0.0.1];\r\\r
+    \n#/ip/dns/static add address=1.0.0.1 name=security.cloudflare-dns.com com\\r
+    ment=\"cloudflare-dns IPv4 2\"\r\\r
+    \n#/ip dns static add address=2606:4700:4700::1111 name=security.cloudflar\\r
+    e-dns.com type=AAAA\r\\r
+    \n#/ip dns static add address=2606:4700:4700::1001 name=security.cloudflar\\r
+    e-dns.com type=AAAA\r\\r
+    \n#/ip/dns set servers=\"1.0.0.1, 8.8.4.4\";\r\\r
+    \n#/ip/dns set servers=\"\";"\r
+add dont-require-permissions=no name=script1 owner=vados policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/\\r
+    tool/netwatch/add comment=\"doh-fallback, doh-url=https://security.cloudfl\\r
+    are-dns.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=Clou\\r
+    dFlare-doh IPv4 1\" host=1.1.1.1;\r\\r
+    \n/tool/netwatch/add comment=\"doh, doh-url=https://security.cloudflare-dn\\r
+    s.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=CloudFlare\\r
+    -doh IPv4 2\" host=1.0.0.1;\r\\r
+    \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\\r
+    /dns.google/dns-query, doh-cert=DigiCert Global Root G2, notify, name=Goog\\r
+    le-doh IPv4 1\" host=8.8.8.8;\r\\r
+    \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\\r
+    /dns.google/dns-query, doh-cert=DigiCert Global Root G2, notify, name=Goog\\r
+    le-doh IPv4 2\" host=8.8.4.4;\r\\r
+    \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\\r
+    /dns.quad9.net/dns-query, doh-cert=DigiCert Global Root G3, notify, name=C\\r
+    uad9-doh IPv4 1\" host=9.9.9.9;\r\\r
+    \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\\r
+    /dns.quad9.net/dns-query, doh-cert=DigiCert Global Root G3, notify, name=C\\r
+    uad9-doh IPv4 2\" host=149.112.112.112;\r\\r
+    \n\r\\r
+    \n/tool/netwatch/add comment=\"dns, notify, name=ns1.unet.ws\" host=91.192\\r
+    .189.2;"\r
+add dont-require-permissions=no name=script2 owner=vados policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    \r\\r
+    \n\r\\r
+    \n:global InspectVar;\r\\r
+    \n#:global RouterBoard;\r\\r
+    \n#:do {:set RouterBoard [[ :parse \"/system/routerboard/get\" ]]} on-erro\\r
+    r={}\r\\r
+    \n#:global Resources;\r\\r
+    \n#:do {:set Resources [[ :parse \"/system/resource/get\" ]]} on-error={}\\r
+    \r\\r
+    \n\r\\r
+    \n#:global Updates;\r\\r
+    \n#:do {:set Updates [[ :parse \"/system/package/update/get\" ]]} on-error\\r
+    ={}\r\\r
+    \n\r\\r
+    \n#:global PkgUpdStatus \"undefined\";\r\\r
+    \n#:local Update [/system/package/update/get];\r\\r
+    \n#:retry command={:set PkgUpdStatus (\$Update->\"status\")} delay=200ms m\\r
+    ax=5 on-error={};\r\\r
+    \n\r\\r
+    \n#:log warning [\$InspectVar \$RouterBoard];\r\\r
+    \n#:put [\$InspectVar \$RouterBoard];\r\\r
+    \n\r\\r
+    \n#:retry command={/system/package/update check-for-updates without-paging\\r
+    \_as-value} delay=300ms max=5 on-error={};\r\\r
+    \n\r\\r
+    \n#:global arrDeviceInfo ({});\r\\r
+    \n#:local arrDeviceInfo ({\"section\":{\"key\":\"\"; \"value\":\"\";};});\\r
+    \r\\r
+    \n#:set (\$arrDeviceInfo->\"RouterBoard\") [[ :parse \"/system/routerboard\\r
+    /get\" ]];\r\\r
+    \n#:retry command={:set (\$arrDeviceInfo->\"Updates\") [[ :parse \"/system\\r
+    /package/update/get\" ]]} delay=500ms max=5 on-error={:log error (\"Error\\r
+    \")};\r\\r
+    \n# [:toarray {\"section\"={\"key\"=\"\"; \"value\"=\"\";} }];\r\\r
+    \n# [:toarray \"\"];\r\\r
+    \n:local arrDeviceInfo ({});\r\\r
+    \n\r\\r
+    \n:set (\$arrDeviceInfo->\"devUpdates\") {\"channel\"; \"stable\";};\r\\r
+    \n#:do {:set (arrDeviceInfo->\"Updates\") [[ :parse \"/system/package/upda\\r
+    te/get\" ]]} on-error={:log error (\$error)}\r\\r
+    \n\$InspectVar \$arrDeviceInfo;\r\\r
+    \n"\r
+add comment="Script for setup routeros script system" \\r
+    dont-require-permissions=no name=AM-setup owner=AM-setup policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    !rsc by Vados\r\\r
+    \n# RouterOS script: AM-setup\r\\r
+    \n# Script comment: Script for setup routeros script system\r\\r
+    \n# Copyright (c) 2005-2026 Vados <vados@vados.ru>\r\\r
+    \n#\r\\r
+    \n#\r\\r
+    \n# requires RouterOS, version=7.19\r\\r
+    \n# requires device-mode, fetch\r\\r
+    \n#\r\\r
+    \n# :local ScriptName [ :jobname ];\r\\r
+    \n# Additional commands:\r\\r
+    \n#\r\\r
+    \n# For scripts:\r\\r
+    \n#:global NewScript \"script_name\"; \r\\r
+    \n#:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\\r
+    \n#/system/script/add name=\$NewScript owner=\$NewScript source=([/tool/fe\\r
+    tch check-certificate=yes-without-crl (\$GlobalScriptsUrl . \$ScriptAdd . \\r
+    \".rsc\") output=user as-value ]->\"data\");\r\\r
+    \n#:global NewScript (a);\r\\r
+    \n#:global ScriptInstallUpdate; \$ScriptInstallUpdate;\r\\r
+    \n#\r\\r
+    \n# For run from terminal:\r\\r
+    \n#/system/script/add name=AM-setup owner=AM-Setup source=([/tool/fetch ch\\r
+    eck-certificate=yes-without-crl \"https://ros.vados.ru/AM-setup.rsc\" outp\\r
+    ut=user as-value ]->\"data\");\r\\r
+    \n#\r\\r
+    \n\r\\r
+    \n:global ScriptUpdatesCRLF \"LF\";\r\\r
+    \n#:if (\$ScriptUpdatesCRLF != false) do={\r\\r
+    \n#  :foreach Script in=[ /system/script/find where source~\"^#!rsc by Vad\\r
+    os\" ] do={\r\\r
+    \n#    if (\$ScriptUpdatesCRLF = true) do={\r\\r
+    \n#      /system/script/set source=[ :tocrlf [ get \$Script source ] ] \$S\\r
+    cript;\r\\r
+    \n#    } else={\r\\r
+    \n#      /system/script/set source=[ :tolf [ get \$Script source ] ] \$Scr\\r
+    ipt;\r\\r
+    \n#    }\r\\r
+    \n#  }\r\\r
+    \n#}\r\\r
+    \n\r\\r
+    \n# /import verbose=no \$ScriptName\r\\r
+    \n:global Identity [/system/identity/get name];\r\\r
+    \n:global SetupScript [ :jobname ];\r\\r
+    \n:global RemoveMe true;\r\\r
+    \n:global RunOnce (a);\r\\r
+    \n:global InitSetup true;\r\\r
+    \n:global tmpfs false;\r\\r
+    \n\r\\r
+    \n{\r\\r
+    \n  :local RmMe [:tobool \$1];\r\\r
+    \n\r\\r
+    \n  :global GlobalScriptsUrl;\r\\r
+    \n  :global SetupScript;\r\\r
+    \n  :global RemoveMe;\r\\r
+    \n  :global InitSetup;\r\\r
+    \n  :global tmpfs;\r\\r
+    \n\r\\r
+    \n  :local UrlSuffix \$Identity;\r\\r
+    \n  :local UrlDir \"certs/\";\r\\r
+    \n  :local CertUrl (\$GlobalScriptsUrl . \$UrlDir . \$UrlSuffix .\"/\"); \\r
+    \r\\r
+    \n  :local CertCommonName \"Root YE\";\r\\r
+    \n  :local CertFileName \"Root-YE.pem\";\r\\r
+    \n  :local CertFingerprint \"e14ffcad5b0025731006caa43a121a22d8e9700f4fb9c\\r
+    f852f02a708aa5d5666\";\r\\r
+    \n\r\\r
+    \n  :if (\$SetupScript = false) do={\r\\r
+    \n    :global SetupScript \"AM-setup\";\r\\r
+    \n  }\r\\r
+    \n  :if (\$RemoveMe != false) do={\r\\r
+    \n    :set RemoveMe true;\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :log warning (\"\\n\\\$GlobalScriptsUrl = \" . \$GlobalScriptsUrl);\r\\r
+    \n \r\\r
+    \n\r\\r
+    \n    :if (!(((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" ||\\r
+    \_\\\r\\r
+    \n          (\$CertSettings->\"builtin-trust-store\") ~ \"fetch\" || \\\r\\r
+    \n          (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\r\\r
+    \n         [ :len [ /certificate/builtin/find where common-name=\$CertComm\\r
+    onName ] ] > 0)) do={\r\\r
+    \n        :put \"Importing certificate...\";\r\\r
+    \n        /tool/fetch (\$CertUrl . \$CertFileName) dst-path=\$CertFileName\\r
+    \_as-value;\r\\r
+    \n        :delay 1s;\r\\r
+    \n        /certificate/import file-name=\$CertFileName passphrase=\"\";\r\\r
+    \n        /certificate/set name=\"Root-YE\" [ find where common-name=\"Roo\\r
+    t YE\" ];\r\\r
+    \n        :delay 1s;\r\\r
+    \n      };\r\\r
+    \n  :local CertSettings [ /certificate/settings/get ];\r\\r
+    \n  :if ([ :len [ /certificate/find where fingerprint=\$CertFingerprint ] \\r
+    ] != 1) do={\r\\r
+    \n      :error \"Something is wrong with your certificates!\";\r\\r
+    \n  };\r\\r
+    \n\r\\r
+    \n:local MkTmpfs do={\r\\r
+    \n  :local TmpFs [ /disk/find where slot=tmpfs type=tmpfs ];\r\\r
+    \n  :if ([ :len \$TmpFs ] = 1) do={\r\\r
+    \n    :if ([ /disk/get \$TmpFs disabled ] = true) do={\r\\r
+    \n      :log info (\"The tmpfs is disabled, enabling.\");\r\\r
+    \n      /disk/enable \$TmpFs;\r\\r
+    \n    }\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  :log info (\"Try to removing directory 'tmpfs'.\");\r\\r
+    \n  :do {\r\\r
+    \n    :retry {\r\\r
+    \n      /file/remove tmpfs;\r\\r
+    \n      :return true;\r\\r
+    \n    } delay=100ms max=10;\r\\r
+    \n  } on-error={ }\r\\r
+    \n#  \$RmDir \"tmpfs\";\r\\r
+    \n  :onerror Err {\r\\r
+    \n    /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource/g\\r
+    et total-memory ] / 3);\r\\r
+    \n    :do {\r\\r
+    \n      :retry {\r\\r
+    \n        /file/get tmpfs;\r\\r
+    \n        :return true;\r\\r
+    \n      } delay=222ms max=10;\r\\r
+    \n      } on-error={ }\r\\r
+    \n    } do={\r\\r
+    \n      :log warning (\"Creating disk of type tmpfs failed: \" . \$Err);\r\\r
+    \n      :return false;\r\\r
+    \n    }\r\\r
+    \n#    :return true;\r\\r
+    \n}\r\\r
+    \n:if (\$tmpfs = true) do={\r\\r
+    \n  :put \"Tmpfs variable is true. Checking for tmpfs/scripts directory...\\r
+    \";\r\\r
+    \n  :if ([/file find name=\"tmpfs/scripts\"] != \"\") do={\r\\r
+    \n    :log info (\$0 . \"Directory tmpfs/scripts exsist.\");\r\\r
+    \n    :return \$true;\r\\r
+    \n  } else={\r\\r
+    \n    :log warning (\$0 . \"Directory tmpfs/scripts does't exsist.\");\r\\r
+    \n    :if ([ \$MkTmpfs ] = false) do={\r\\r
+    \n      :log error (\$0 . \"Directory tmpfs is not created!\");\r\\r
+    \n      :return false;\r\\r
+    \n    } else={\r\\r
+    \n      :onerror Err {\r\\r
+    \n        /file/add type=\"directory\" name=/tmpfs/scripts;\r\\r
+    \n        :do {\r\\r
+    \n          :retry {\r\\r
+    \n            /file/get /tmpfs/scripts;\r\\r
+    \n            :return true;\r\\r
+    \n          } delay=100ms max=10;\r\\r
+    \n      } on-error={ }\r\\r
+    \n      } do={\r\\r
+    \n        :log warning (\$0 . \"Making directory 'scripts' failed: \" . \$\\r
+    Err);\r\\r
+    \n        :return false;\r\\r
+    \n      }\r\\r
+    \n#      :return true;\r\\r
+    \n#      [ /file/get \$FileName ]\r\\r
+    \n    }\r\\r
+    \n#    :log error (\$0 . \"Directory tmpfs/scripts does not exsist. Remove\\r
+    \_global variable tmpfs!\");\r\\r
+    \n#    :global tmpfs (a);\r\\r
+    \n#    return false;\r\\r
+    \n  }\r\\r
+    \n}\r\\r
+    \n  :put \"Renaming AM-GlobalConfig, if exists...\";\r\\r
+    \n  :local ConfOldName (\"AM-GlobalConfig-\" . [ /system/clock/get date ] \\r
+    . [ /system/clock/get time ] . \".rsc\");\r\\r
+    \n  /system/script/set name=\$ConfOldName [ find where name=\"AM-GlobalCon\\r
+    fig\" ];\r\\r
+    \n  :foreach Script in={ \"AM-GlobalConfig\"; \"AM-GlobalFunc\"; \"mod/AM-\\r
+    Certs-By-Ident\" } do={\r\\r
+    \n    :put \"Installing \$Script...\";\r\\r
+    \n    /system/script/remove [ find where name=\$Script ];\r\\r
+    \n    /system/script/add name=\$Script owner=\$Script source=([ /tool/fetc\\r
+    h check-certificate=yes-without-crl url=(\$GlobalScriptsUrl . \$Script . \\r
+    \".rsc\")  output=user as-value ]->\"data\");\r\\r
+    \n    \r\\r
+    \n    /system/script run \$Script;\r\\r
+    \n    :delay 2s;\r\\r
+    \n  };\r\\r
+    \n\r\\r
+    \n  :if ([ :len [ /certificate/find where fingerprint=\$CertFingerprint ] \\r
+    ] > 0) do={\r\\r
+    \n    :put \"Renaming certificate by its common-name...\";\r\\r
+    \n    :global CertificateNameByCN;\r\\r
+    \n    \$CertificateNameByCN \$CertFingerprint;\r\\r
+    \n  };\r\\r
+    \n\r\\r
+    \n  :if (\$RemoveMe = true) do={\r\\r
+    \n    :put \"Add Scheduler for remove this script...\";\r\\r
+    \n    :local OnEvent (\":delay 30s;\\n\" . \"/system/script/remove [ find \\r
+    where name=\\\"\$SetupScript\\\" ];\\n\" . \\\r\\r
+    \n    \":delay 2s;\\n\" . \"/system/scheduler/remove [ find where name=\\\\r
+    \"_RemoveSetup\\\" ];\\n\" . \\\r\\r
+    \n    \":delay 2s;\\n\" . \":global RemoveMe (a);\\n\");\r\\r
+    \n    :local Comment \"_RemoveSetup tmp scheduler for remove setup script.\\r
+    \";\r\\r
+    \n    /system/scheduler/add name=\"_RemoveSetup\" comment=\$Comment start-\\r
+    time=startup interval=30s on-event=\$OnEvent;\r\\r
+    \n      :log warning (\$0 . \"\\nI've done everything, and now I'm tired..\\r
+    . I'm leaving.\\nThere will be an error below, this is normal.\");\r\\r
+    \n    }\r\\r
+    \n    :delay 1;\r\\r
+    \n    :put \"Loading configuration and functions...\";\r\\r
+    \n    :do {      \r\\r
+    \n      :global ScriptInstallUpdate; \$ScriptInstallUpdate;\r\\r
+    \n      :put \"Normal removing temporary global environment variables.\";\\r
+    \r\\r
+    \n      :global SetupScript (a);\r\\r
+    \n      :global InitSetup (a);\r\\r
+    \n      :global RemoveMe (a);\r\\r
+    \n    } on-error={\r\\r
+    \n      :local ErrorMsg \"Loading configuration and functions error!\";\r\\r
+    \n      :log error (\$0 . \$ErrorMsg . :error);\r\\r
+    \n      :error \$ErrorMsg;\r\\r
+    \n    }\r\\r
+    \n}\r\\r
+    \n"\r
+add comment="Global Config Script" dont-require-permissions=no name=\\r
+    AM-GlobalConfig owner=AM-GlobalConfig policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    !rsc by Vados\r\\r
+    \n# RouterOS script: AM-GlobalConfig\r\\r
+    \n# Script comment: Global Config Script\r\\r
+    \n# Copyright (c) 2007-2026 Vados <vados@vados.ru>\r\\r
+    \n#\r\\r
+    \n#\r\\r
+    \n# Warning: Dont touch this line!\r\\r
+    \n:global Identity [/system/identity/get name];\r\\r
+    \n:global GlobalConfReady false;\r\\r
+    \n#\r\\r
+    \n#\r\\r
+    \n# Global Url For Amster scripts to fetch\r\\r
+    \n# most be defined in AM-Init-Script or AM-setup scripts\r\\r
+    \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\\r
+    \n:global ScriptsUrlSuffix (a);\r\\r
+    \n:global CheckSumsVerify true;\r\\r
+    \n\r\\r
+    \n:global ScriptUpdatesCRLF true;\r\\r
+    \n:global CommentsInScripts true;\r\\r
+    \n\r\\r
+    \n# Debug output:\r\\r
+    \n:global PrintDebug true; #false;\r\\r
+    \n\r\\r
+    \n# Debug output for specific script:\r\\r
+    \n#:set (\$PrintDebugOverride->\"AM-GlobalFunc\") true;\r\\r
+    \n\r\\r
+    \n# Debug logs\r\\r
+    \n# Other actions (disk, email, remote or support) can be used as well.\r\\r
+    \n# I do not recommend using echo - use debug output instead (https://rsc.\\r
+    eworm.de/main/DEBUG.html#debug-output).\r\\r
+    \n#/system/logging/add topics=script,debug action=memory;\r\\r
+    \n\r\\r
+    \n:global MikrotikUpgradeUrl \"https://upgrade.mikrotik.com/routeros\";\r\\r
+    \n:global Domain \"WORKGROUP\";\r\\r
+    \n\r\\r
+    \n:global EmailGeneralTo \"vados@vados.ru\";\r\\r
+    \n#:global EmailGeneralCc \"\";\r\\r
+    \n\r\\r
+    \n# \$ScriptInstallUpdate mod/notification-telegram\r\\r
+    \n:global TelegramTokenId \"8390868324:AAG3_d1hfVR2M6pGAgDK6ZvhOe4J97nyopw\\r
+    \";\r\\r
+    \n:global TelegramChatId \"-1003631309063\"; #\"454403445\";\r\\r
+    \n# Use this to send notifications to a specific topic in group.\r\\r
+    \n#:global TelegramThreadId \"30\";\r\\r
+    \n# Using telegram-chat you have to define trusted chat ids (not group ids\\r
+    !)\r\\r
+    \n# or user names. Groups allow to chat with devices simultaneously.\r\\r
+    \n:global TelegramChatIdsTrusted {\r\\r
+    \n  \"454403445\"\r\\r
+    \n  \"-1003631309063\"\r\\r
+    \n  \"-5124482807\"\r\\r
+    \n  \"1087968824\";\r\\r
+    \n};\r\\r
+    \n#  \"-5294757340\";\r\\r
+    \n\r\\r
+    \n:global TelegramChatGroups \"(all)\";\r\\r
+    \n#:global TelegramChatGroups \"(all|home|office)\";\r\\r
+    \n\r\\r
+    \n:global NotificationFunctions {\r\\r
+    \n  \"email\"\r\\r
+    \n  \"telegram\";\r\\r
+    \n};\r\\r
+    \n# Toggle this to disable symbols in notifications.\r\\r
+    \n:global NotificationsWithSymbols true;\r\\r
+    \n:global TerminalColorOutput true;\r\\r
+    \n\r\\r
+    \n:global DetectIpAddrDefault \"https://ipv4.mikrotik.ovh/\";\r\\r
+    \n:global DetectIpAddrFallback \"https://api.ipify.org/\";\r\\r
+    \n\r\\r
+    \n## Update channel. Possible values: stable, long-term, testing, developm\\r
+    ent\r\\r
+    \n:global updateChannel \"stable\";\r\\r
+    \n\r\\r
+    \n:global CertRenewUrl (\$GlobalScriptsUrl . \"certs/\" . \$Identity . \"/\\r
+    \");\r\\r
+    \n:global CertRenewTime 2w;\r\\r
+    \n:global CertRenewPass (a); #{\r\\r
+    \n#  \"\";\r\\r
+    \n#  \"v3ry-s3cr3t\";\r\\r
+    \n#  \"4n0th3r-s3cr3t\";\r\\r
+    \n#};\r\\r
+    \n:global CertWarnTime 1w;\r\\r
+    \n:global CertIssuedExportPass (a); # {\r\\r
+    \n#  \"\";\r\\r
+    \n#  \"cert1-cn\"=\"v3ry-s3cr3t\";\r\\r
+    \n#  \"cert2-cn\"=\"4n0th3r-s3cr3t\";\r\\r
+    \n#};\r\\r
+    \n\r\\r
+    \n# Script BackupAndUpdate mode, possible values: backup,\r\\r
+    \n# updateOnce - Update once as \"osnotify\" and back \"osnotify\" mode (i\\r
+    n terminal run :set OSUpdateMode updateOnce; \$OSUpdateMode;).  \r\\r
+    \n# osupdate - Update if available and creates backups before/after update\\r
+    \_(ignores `forceBackup`)\r\\r
+    \n#               Set `forceBackup` to true to always create backups, even\\r
+    \_without updates\r\\r
+    \n# osnotify - Set `forceBackup` to always create backups on every run\r\\r
+    \n:global DevInfoIncludeIP true;\r\\r
+    \n:global BackupAndUpdateMode \"osnotify\"\r\\r
+    \n\r\\r
+    \n:global forceBackup true;\r\\r
+    \n:global BackupPassword \"Peskar55\";\r\\r
+    \n\r\\r
+    \n# SFTP Backup Variables\r\\r
+    \n:global BackupRandomDelay 0;\r\\r
+    \n:global BackupUploadUrl \"sftp://amster.vados.ru/upload/\";\r\\r
+    \n:global BackupUploadUser \$Identity;\r\\r
+    \n:global BackupUploadPass \"root.mnuc.backuper\";\r\\r
+    \n\r\\r
+    \n:global BackupSendBinary true;\r\\r
+    \n:global BackupSendExport true;\r\\r
+    \n:global BackupSendGlobalConfig true;\r\\r
+    \n:global BackupSendScripts true;\r\\r
+    \n\r\\r
+    \n# Remove local file after uploading if no errors\r\\r
+    \n:global BackupRmLocal true;\r\\r
+    \n\r\\r
+    \n# Local Backups Root Directory \r\\r
+    \n:global BackupLocalRoot \"tmpfs\";\r\\r
+    \n\r\\r
+    \n# Encrypt Backup\r\\r
+    \n:global BackupEncrypt true;\r\\r
+    \n\r\\r
+    \n# Sensitive information in Backups\r\\r
+    \n:global BackupSens true;\r\\r
+    \n\r\\r
+    \n# User Export\r\\r
+    \n:global BackupUser true;\r\\r
+    \n\r\\r
+    \n# License Export (not for CHR, will silently skip)\r\\r
+    \n:global BackupLicense false;\r\\r
+    \n\r\\r
+    \n# SSH Keys\r\\r
+    \n:global BackupSshKeys true;\r\\r
+    \n\r\\r
+    \n# Certificate Export\r\\r
+    \n:global BackupCerts true;\r\\r
+    \n\r\\r
+    \n# Certificate Password\r\\r
+    \n:global BackupCertsPasswd \"\";\r\\r
+    \n\r\\r
+    \n# User-Manager Export\r\\r
+    \n:global BackupUserMan false;\r\\r
+    \n\r\\r
+    \n# The Dude Export\r\\r
+    \n:global BackupDude false;\r\\r
+    \n\r\\r
+    \n# User Files to export, comma-separated string or array of strings\r\\r
+    \n# User Files are not removed on backup\r\\r
+    \n# Any directory paths will be removed (/ -> _) on remote file\r\\r
+    \n# Nonpresent files are silently skipped\r\\r
+    \n:global BackupUserList \"autosupout.rif,autosupout.old.rif\";\r\\r
+    \n\r\\r
+    \n# load functions and any custom scripts\r\\r
+    \n#                    [ /system/script/find where name=\"global-config-ov\\r
+    erlay\" ], \\\r\\r
+    \n#                    [ /system/script/find where name~\"^global-config-o\\r
+    verlay\\\\.d/.\" ]\r\\r
+    \n#\r\\r
+    \n#:foreach Script in=([ /system/script/find where name=\"Amster-TGglobalV\\r
+    ars\" ], [ /system/script/find where name=\"Amster-TGglobalFunc\" ]) do={\\r
+    \r\\r
+    \n#  :onerror Err {\r\\r
+    \n#     /system/script/run \$Script;\r\\r
+    \n#     } do={\r\\r
+    \n#       :log error (\"Loading configuration from configs and functions\"\\r
+    \_. [ /system/script/get \$Script name ] . \" failed: \" . \$Err);\r\\r
+    \n#  }\r\\r
+    \n#}\r\\r
+    \n#:log info \"\\ndevMode = \$devMode\";\r\\r
+    \n#:log info \"\\ndevRunning = \$devRunning\";\r\\r
+    \n:foreach Script in=[ /system/script/find where source~\"^#!rsc by Vados \\r
+    GlobalRUN\\r\?\\n\" ] do={\r\\r
+    \n  :onerror Err {\r\\r
+    \n    /system/script/run \$Script;\r\\r
+    \n       } do={\r\\r
+    \n       :log error (\"Run script \" . [ /system/script/get \$Script name \\r
+    ] . \" width marker \\\" GlobalRUN\\\" failed: \" . \$Err);\r\\r
+    \n  }\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n# signal we are ready\r\\r
+    \n:set GlobalConfReady true;\r\\r
+    \n:while (\$GlobalConfReady != true) do={:delay 500ms};\r\\r
+    \n"\r
+add comment="Global functions" dont-require-permissions=no name=AM-GlobalFunc \\r
+    owner=AM-GlobalFunc policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    !rsc by Vados\r\\r
+    \n# RouterOS script: AM-GglobalFunc\r\\r
+    \n# Script comment: Global functions\r\\r
+    \n# Copyright (c) 2005-2026 Vados <vados@vados.ru>\r\\r
+    \n#\r\\r
+    \n#\r\\r
+    \n# requires RouterOS, version=7.19\r\\r
+    \n# requires device-mode, fetch, scheduler\r\\r
+    \n:local ExitOK false;\r\\r
+    \n:local ScriptName [ :jobname ];\r\\r
+    \n#:global checkRunJob \$SriptName;\r\\r
+    \n#:global fixCRLF;\r\\r
+    \n#:if (\$fixCRLF !=  false) do={\r\\r
+    \n#:foreach fixScript in=([ /system/script/find where name~\"*\" ]) do={/s\\r
+    ystem/script/set source=[ :tocrlf [ get \$fixScript source ] ] \$fixScript\\r
+    }\r\\r
+    \n#:if (\$fixCRLF !=  \"LF\") do={ /system/script/set source=[ :tocrlf [ g\\r
+    et \$fixScript source ] ] \$fixScript};};\r\\r
+    \n#}\r\\r
+    \n:global GlobalFuncReady false;\r\\r
+    \n\r\\r
+    \n# Git commit id & info, expected configuration version\r\\r
+    \n:global CommitId \"main/635/33f8040a\";\r\\r
+    \n:global CommitTAG \"unknown\";\r\\r
+    \n:global CommitInfo \"Autocommit in repo: ros.vados.ru, generated by owne\\r
+    r: root, in 13:30:03 11.05.2026.\";\r\\r
+    \n\r\\r
+    \n# The variables are received right here.\r\\r
+    \n:global GlobalConfVersion 140;\r\\r
+    \n\r\\r
+    \n:global SumsDirAndFileName \"tmp/checksums.json\";\r\\r
+    \n\r\\r
+    \n:global Identity [/system/identity/get name];\r\\r
+    \n:global IdentityShort [:pick \$Identity 0 18];\r\\r
+    \n\r\\r
+    \n:global devBoardName [/system/resource/get board-name];\r\\r
+    \n:global devMode [/system/device-mode/get mode];\r\\r
+    \n:global devCurArch [/system/resource/get architecture-name];\r\\r
+    \n:global devCurVersion [/system/resource/get version];\r\\r
+    \n\r\\r
+    \n# Variables defined in AM-GlobalConfig.rsc\r\\r
+    \n:global TerminalColorOutput;\r\\r
+    \n:global CommentsInScripts;\r\\r
+    \n:global DetectIpAddrDefault;\r\\r
+    \n:global DetectIpAddrFallback;\r\\r
+    \n:global updateChannel;\r\\r
+    \n:global Domain;\r\\r
+    \n:global EmailGeneralTo;\r\\r
+    \n:global BackupAndUpdateMode;\r\\r
+    \n\r\\r
+    \n# Single functions, without nested functions.\r\\r
+    \n:global MiniDateTimeStamp;\r\\r
+    \n:global MicroDateTimeStamp;\r\\r
+    \n\r\\r
+    \n# Include globals \$PrintDebug and \$PrintDebugOverride\r\\r
+    \n:global LogPrint;\r\\r
+    \n\r\\r
+    \n# DeviceInfo and Updates\r\\r
+    \n:global IsCheckUpdates;\r\\r
+    \n:global WaitCheckUpdates;\r\\r
+    \n:global GetPubIp;\r\\r
+    \n\r\\r
+    \n:global GetArrDeviceInfo;\r\\r
+    \n:global WaitArrDeviceInfo;\r\\r
+    \n\r\\r
+    \n:global devModel;\r\\r
+    \n:global devRunningMode;\r\\r
+    \n\r\\r
+    \n:global devRbRevision;\r\\r
+    \n:global devRbSerialNumber;\r\\r
+    \n:global devRbVerAvail;\r\\r
+    \n\r\\r
+    \n:global runningChannelVersion;\r\\r
+    \n:global runningChannel;\r\\r
+    \n:global runningVersion;\r\\r
+    \n\r\\r
+    \n:global devBuildTime;\r\\r
+    \n:global ROsVerAvail;\r\\r
+    \n:global PkgUpdStatus;\r\\r
+    \n:global currentUpdateChannel;\r\\r
+    \n\r\\r
+    \n:global ScriptInstallUpdate;\r\\r
+    \n\r\\r
+    \n:global DeviceInfo;\r\\r
+    \n\r\\r
+    \n:global OldMode;\r\\r
+    \n\r\\r
+    \n:global ParseKeyValueStore;\r\\r
+    \n:global RandomDelay;\r\\r
+    \n:global GetRandomNumber;\r\\r
+    \n:global EscapeForRegEx;\r\\r
+    \n:global CharacterMultiply;\r\\r
+    \n:global CharacterReplace;\r\\r
+    \n:global CleanFilePath;\r\\r
+    \n:global CleanName;\r\\r
+    \n\r\\r
+    \n:global CommitBrief;\r\\r
+    \n\r\\r
+    \n:global EitherOr;\r\\r
+    \n:global FormatLine;\r\\r
+    \n:global GetRandom20CharAlNum;\r\\r
+    \n:global GetRandom20CharHex;\r\\r
+    \n:global GetRandomNumber;\r\\r
+    \n:global Grep;\r\\r
+    \n:global IfThenElse;\r\\r
+    \n:global MAX;\r\\r
+    \n:global MIN;\r\\r
+    \n:global HumanReadableNum;\r\\r
+    \n\r\\r
+    \n:global IsFullyConnected;\r\\r
+    \n:global IsDNSResolving;\r\\r
+    \n:global IsTimeSync;\r\\r
+    \n:global IsTimeSyncCached;\r\\r
+    \n:global IsTimeSyncResetNtp;\r\\r
+    \n\r\\r
+    \n:global WaitDNSResolving;\r\\r
+    \n:global WaitFullyConnected;\r\\r
+    \n:global WaitTimeSync;\r\\r
+    \n:global MkDir;\r\\r
+    \n:global RmDir;\r\\r
+    \n:global RmFile;\r\\r
+    \n:global FileGet;\r\\r
+    \n:global Unix2Dos;\r\\r
+    \n:global UrlEncode;\r\\r
+    \n:global WaitForFile;\r\\r
+    \n:global ScriptLock;\r\\r
+    \n:global SendTelegram;\r\\r
+    \n:global NotificationFunctions;\r\\r
+    \n:global SendNotification;\r\\r
+    \n:global SendNotification2;\r\\r
+    \n:global SymbolForNotification;\r\\r
+    \n:global SymbolByUnicodeName;\r\\r
+    \n:global ValidateSyntax;\r\\r
+    \n:global CheckSumsVerify;\r\\r
+    \n:global GlobalConfChanges;\r\\r
+    \n:global GlobalConfMigration;\r\\r
+    \n:global VersionToNum;\r\\r
+    \n:global RequiredRouterOS;\r\\r
+    \n:global ExitError;\r\\r
+    \n:global ExitOnError;\r\\r
+    \n\r\\r
+    \n:global FetchHugeFiles;\r\\r
+    \n:global FetchUserAgentStr;\r\\r
+    \n:global FileExists;\r\\r
+    \n:global CertificateAvailable;\r\\r
+    \n:global CertificateDownload;\r\\r
+    \n:global CertificateNameByCN;\r\\r
+    \n:global CharacterMultiply;\r\\r
+    \n\r\\r
+    \n:global InspectVar;\r\\r
+    \n:global InspectVarRet;\r\\r
+    \n:global ParseCustom;\r\\r
+    \n\r\\r
+    \n:set IsCheckUpdates do={\r\\r
+    \n  :local isInfo [:tobool \$1];\r\\r
+    \n  :global updateChannel;\r\\r
+    \n  :global PkgUpdStatus;\r\\r
+    \n  :global currentUpdateChannel;\r\\r
+    \n  :global ROsVerAvail;\r\\r
+    \n  :global arrDeviceInfo;\r\\r
+    \n  :log info (\$0 . \" \\\$isInfo = \" . \$isInfo); \r\\r
+    \n  :local CurrentChannel [ /system/package/update/get channel ];\r\\r
+    \n  :if ([ :len \$updateChannel ] > 0 && \$CurrentChannel != \$updateChann\\r
+    el) do={\r\\r
+    \n    :retry command={/system/package/update set channel=\$updateChannel} \\r
+    \_delay=300ms max=5 on-error={};\r\\r
+    \n    :log info (\$0 . \" Set updates channel to: \$updateChannel\");\r\\r
+    \n  }\r\\r
+    \n  :local Update [ /system/package/update/get ];\r\\r
+    \n  :local Channel [ :tostr (\$Update->\"channel\") ];\r\\r
+    \n  :set currentUpdateChannel \$Channel;\r\\r
+    \n  :log info (\$0 . \" Update Channel: \" . \$Channel . \".\");\r\\r
+    \n  :local StatusPkg \"undefined\";\r\\r
+    \n  :log info (\$0 . \" Checking for updates...\");\r\\r
+    \n  :retry command={:set \$StatusPkg ([/system/package/update/check-for-up\\r
+    dates without-paging as-value]->\"status\")} \\\r\\r
+    \n   delay=300ms max=5 on-error={};\r\\r
+    \n  :log info (\$0 . \" \\\$StatusPkg = \" . \$StatusPkg);\r\\r
+    \n  :if (\$StatusPkg = \"New version is available\") do={ :set PkgUpdStatu\\r
+    s true; } else={ :set PkgUpdStatus false; }\r\\r
+    \n  :set ROsVerAvail [ :tostr [ /system/package/update/get latest-version \\r
+    ] ];\r\\r
+    \n  :log info (\$0 . \" \\\$PkgUpdStatus = \" . \$PkgUpdStatus);\r\\r
+    \n  :if (\$isInfo != false || \$PkgUpdStatus = true) do={\r\\r
+    \n    :log info (\$0 . \" \\\$PkgUpdStatus = \" . \$PkgUpdStatus);\r\\r
+    \n    :if ([ :typeof \$arrDeviceInfo ] != \"array\") do={\r\\r
+    \n      :set arrDeviceInfo [:toarray \$arrDeviceInfo];\r\\r
+    \n    }\r\\r
+    \n    :retry command={:set (\$arrDeviceInfo->\"devUpdates\") [ /system/pac\\r
+    kage/update/get ]} delay=500ms max=5 on-error={:log error (\"Error\")};\r\\r
+    \n    :return true;\r\\r
+    \n  } else={\r\\r
+    \n    :return \$PkgUpdStatus;\r\\r
+    \n  }\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set WaitCheckUpdates do={\r\\r
+    \n  :global IsCheckUpdates;\r\\r
+    \n  :global PkgUpdStatus;\r\\r
+    \n  :global currentUpdateChannel;\r\\r
+    \n  :global ROsVerAvail;\r\\r
+    \n  :global arrDeviceInfo;\r\\r
+    \n  :local Status \"\";\r\\r
+    \n  :local Update;\r\\r
+    \n  :local WaitCount 0;\r\\r
+    \n  :if ([ \$IsCheckUpdates true ] = false) do={\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :set Status [ :tostr [ /system/package/update/get status ] ];\r\\r
+    \n  :while ((\$Status = \"\" || \$Status = \"finding out latest version...\\r
+    \") && \$WaitCount < 60) do={\r\\r
+    \n    :delay 1s;\r\\r
+    \n    :set WaitCount (\$WaitCount + 1);\r\\r
+    \n    :set Status [ :tostr [ /system/package/update/get status ] ];\r\\r
+    \n   }\r\\r
+    \n  :set Update [ /system/package/update/get ];\r\\r
+    \n  :set currentUpdateChannel [ :tostr (\$Update->\"channel\") ];\r\\r
+    \n  :set ROsVerAvail [ :tostr (\$Update->\"latest-version\") ];\r\\r
+    \n  :if ((\$Update->\"status\") = \"New version is available\") do={\r\\r
+    \n    :set PkgUpdStatus true;\r\\r
+    \n  } else={\r\\r
+    \n    :set PkgUpdStatus false;\r\\r
+    \n  }\r\\r
+    \n  :if ([ :typeof \$arrDeviceInfo ] != \"array\") do={\r\\r
+    \n    :set arrDeviceInfo [:toarray \$arrDeviceInfo];\r\\r
+    \n  }\r\\r
+    \n  :set (\$arrDeviceInfo->\"devUpdates\") \$Update;\r\\r
+    \n  :if (\$Status = \"\" || \$Status = \"finding out latest version...\") \\r
+    do={\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set WaitArrDeviceInfo do={\r\\r
+    \n   :global GetArrDeviceInfo;\r\\r
+    \n   :while ([ \$GetArrDeviceInfo ] = false) do={\r\\r
+    \n    :delay 1s;\r\\r
+    \n   }\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set GetArrDeviceInfo do={\r\\r
+    \n   :global LogPrint;\r\\r
+    \n   :global arrDeviceInfo;\r\\r
+    \n   :global devBoardName;\r\\r
+    \n   :global devModel;\r\\r
+    \n   :global devRunning;\r\\r
+    \n   :global devCurArch;\r\\r
+    \n   :global devRbRevision;\r\\r
+    \n   :global devRbSerialNumber;\r\\r
+    \n   :global devBuildTime;\r\\r
+    \n   :global runningChannelVersion;\r\\r
+    \n   :global runningChannel;\r\\r
+    \n   :global runningVersion;\r\\r
+    \n   :global currentUpdateChannel;\r\\r
+    \n   :global ROsVerAvail;\r\\r
+    \n\r\\r
+    \n   :local DeviceInfo;\r\\r
+    \n   :local Resource [/system/resource/get];\r\\r
+    \n   :local Update [ /system/package/update/get ];\r\\r
+    \n   :local VersionString [ :tostr (\$Resource->\"version\") ];\r\\r
+    \n   :local ChannelStart [ :find \$VersionString \" (\" ];\r\\r
+    \n   :local RouterBoard;\r\\r
+    \n   :local IsRouterBoard false;\r\\r
+    \n   :local RunningMode \"\";\r\\r
+    \n\r\\r
+    \n   :set devCurArch [ :tostr (\$Resource->\"architecture-name\") ];\r\\r
+    \n   :set devBuildTime [ :tostr (\$Resource->\"build-time\") ];\r\\r
+    \n   :set runningChannelVersion \$VersionString;\r\\r
+    \n   :set runningVersion \$VersionString;\r\\r
+    \n   :set runningChannel \"\";\r\\r
+    \n\r\\r
+    \n   :if ([ :typeof \$ChannelStart ] = \"num\" && \$ChannelStart >= 0) do=\\r
+    {\r\\r
+    \n     :set runningVersion [ :pick \$VersionString 0 \$ChannelStart ];\r\\r
+    \n     :local ChannelRest [ :pick \$VersionString (\$ChannelStart + 2) [ :\\r
+    len \$VersionString ] ];\r\\r
+    \n     :local ChannelEnd [ :find \$ChannelRest \")\" ];\r\\r
+    \n     :if ([ :typeof \$ChannelEnd ] = \"num\" && \$ChannelEnd >= 0) do={\\r
+    \r\\r
+    \n       :set runningChannel [ :pick \$ChannelRest 0 \$ChannelEnd ];\r\\r
+    \n     }\r\\r
+    \n   }\r\\r
+    \n\r\\r
+    \n   :if ([:pick \$devBoardName 0 3] != \"CHR\" or [:pick \$devBoardName 0\\r
+    \_3] != \"x86\") do={\r\\r
+    \n   :do {\r\\r
+    \n      :set RouterBoard [[ :parse \"/system/routerboard/get\" ]];\r\\r
+    \n#     :set RouterBoard [ /system/routerboard/get ];\r\\r
+    \n      :if ((\$RouterBoard->\"routerboard\") = true) do={\r\\r
+    \n        :set IsRouterBoard true;\r\\r
+    \n     }\r\\r
+    \n   } on-error={}\r\\r
+    \n    }\r\\r
+    \n\r\\r
+    \n   :do {\r\\r
+    \n     :set RunningMode [ /system/device-mode/get mode ];\r\\r
+    \n   } on-error={\r\\r
+    \n     :do {\r\\r
+    \n       :set RunningMode [ /system/device-mode/get running ];\r\\r
+    \n     } on-error={\r\\r
+    \n       :set RunningMode \"\";\r\\r
+    \n     }\r\\r
+    \n   }\r\\r
+    \n   :set devRunning \$RunningMode;\r\\r
+    \n\r\\r
+    \n   :if (\$IsRouterBoard = true) do={\r\\r
+    \n     :set devModel [ :tostr (\$RouterBoard->\"model\") ];\r\\r
+    \n     :set devRbRevision [ :tostr (\$RouterBoard->\"revision\") ];\r\\r
+    \n     :set devRbSerialNumber [ :tostr (\$RouterBoard->\"serial-number\") \\r
+    ];\r\\r
+    \n   } else={\r\\r
+    \n     :set devModel \$devBoardName;\r\\r
+    \n     :set devRbRevision \"\";\r\\r
+    \n     :set devRbSerialNumber \"\";\r\\r
+    \n   }\r\\r
+    \n\r\\r
+    \n   :set currentUpdateChannel [ :tostr (\$Update->\"channel\") ];\r\\r
+    \n   :set ROsVerAvail [ :tostr (\$Update->\"latest-version\") ];\r\\r
+    \n\r\\r
+    \n   :set (\$DeviceInfo->\"board-name\") \$devBoardName;\r\\r
+    \n   :set (\$DeviceInfo->\"architecture-name\") \$devCurArch;\r\\r
+    \n   :set (\$DeviceInfo->\"model\") \$devModel;\r\\r
+    \n   :set (\$DeviceInfo->\"revision\") \$devRbRevision;\r\\r
+    \n   :set (\$DeviceInfo->\"serial-number\") \$devRbSerialNumber;\r\\r
+    \n   :set (\$DeviceInfo->\"running-mode\") \$devRunning;\r\\r
+    \n   :set (\$DeviceInfo->\"build-time\") \$devBuildTime;\r\\r
+    \n   :set (\$DeviceInfo->\"running-channel-version\") \$runningChannelVers\\r
+    ion;\r\\r
+    \n   :set (\$DeviceInfo->\"running-version\") \$runningVersion;\r\\r
+    \n   :set (\$DeviceInfo->\"running-channel\") \$runningChannel;\r\\r
+    \n   :set (\$DeviceInfo->\"routerboard\") \$IsRouterBoard;\r\\r
+    \n   :set (\$DeviceInfo->\"current-firmware\") [ :tostr (\$RouterBoard->\"\\r
+    current-firmware\") ];\r\\r
+    \n   :set (\$DeviceInfo->\"upgrade-firmware\") [ :tostr (\$RouterBoard->\"\\r
+    upgrade-firmware\") ];\r\\r
+    \n   :set (\$DeviceInfo->\"package-channel\") \$currentUpdateChannel;\r\\r
+    \n   :set (\$DeviceInfo->\"installed-version\") [ :tostr (\$Update->\"inst\\r
+    alled-version\") ];\r\\r
+    \n   :set (\$DeviceInfo->\"latest-version\") \$ROsVerAvail;\r\\r
+    \n   :set (\$DeviceInfo->\"update-status\") [ :tostr (\$Update->\"status\"\\r
+    ) ];\r\\r
+    \n\r\\r
+    \n   :set arrDeviceInfo \$DeviceInfo;\r\\r
+    \n   :return \$DeviceInfo;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set DeviceInfo do={\r\\r
+    \n  :global GetArrDeviceInfo;\r\\r
+    \n  :global GlobalConfVersion;\r\\r
+    \n  :global Identity;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :global FormatLine;\r\\r
+    \n  :global CommitBrief;\r\\r
+    \n\r\\r
+    \n  :local License [/system/license/get];\r\\r
+    \n  :local Snmp [ /snmp/get ];\r\\r
+    \n  :local Info [ \$GetArrDeviceInfo ];\r\\r
+    \n\r\\r
+    \n  :if ([ :typeof \$Info ] != \"array\") do={\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :return ( \\\r\\r
+    \n    [ \$FormatLine \"Hostname\" \$Identity ] . \"\\n\" . \\\r\\r
+    \n    [ \$IfThenElse ([ :len (\$Snmp->\"location\") ] > 0) \\\r\\r
+    \n      ([ \$FormatLine \"Location\" (\$Snmp->\"location\") ] . \"\\n\") ]\\r
+    \_. \\\r\\r
+    \n    [ \$IfThenElse ([ :len (\$Snmp->\"contact\") ] > 0) \\\r\\r
+    \n      ([ \$FormatLine \"Contact\" (\$Snmp->\"contact\") ] . \"\\n\") ] .\\r
+    \_\\\r\\r
+    \n    \"Hardware:\\n\" . \\\r\\r
+    \n    [ \$FormatLine \"    Board\" (\$Info->\"board-name\") ] . \"\\n\" . \\r
+    \\\r\\r
+    \n    [ \$FormatLine \"    Arch\" (\$Info->\"architecture-name\") ] . \"\\\\r
+    n\" . \\\r\\r
+    \n    [ \$FormatLine \"    Model\" (\$Info->\"model\") ] . \\\r\\r
+    \n    [ \$IfThenElse ([ :len (\$Info->\"revision\") ] > 0) \\\r\\r
+    \n      (\" \" . (\$Info->\"revision\")) ] . \"\\n\" . \\\r\\r
+    \n    [ \$IfThenElse ([ :len (\$Info->\"serial-number\") ] > 0) \\\r\\r
+    \n      ([ \$FormatLine \"    Serial\" (\$Info->\"serial-number\") ] . \"\\r
+    \\n\") ] . \\\r\\r
+    \n    [ \$IfThenElse ([ :len (\$License->\"nlevel\") ] > 0) \\\r\\r
+    \n      ([ \$FormatLine \"    License\" (\"level \" . (\$License->\"nlevel\\r
+    \")) ] . \"\\n\") ] . \\\r\\r
+    \n    \"RouterOS:\\n\" . \\\r\\r
+    \n    [ \$IfThenElse ([ :len (\$License->\"level\") ] > 0) \\\r\\r
+    \n      ([ \$FormatLine \"    License\" (\"level \" . (\$License->\"level\\r
+    \")) ] . \"\\n\") ] . \\\r\\r
+    \n    [ \$FormatLine \"    Channel\" (\$Info->\"package-channel\") ] . \"\\r
+    \\n\" . \\\r\\r
+    \n    [ \$FormatLine \"    Installed\" (\$Info->\"installed-version\") ] .\\r
+    \_\"\\n\" . \\\r\\r
+    \n    [ \$IfThenElse ([ :len (\$Info->\"running-channel\") ] > 0) \\\r\\r
+    \n      ([ \$FormatLine \"    Running\" ((\$Info->\"running-version\") . \\r
+    \" (\" . (\$Info->\"running-channel\") . \")\") ] . \"\\n\") \\\r\\r
+    \n      ([ \$FormatLine \"    Running\" (\$Info->\"running-version\") ] . \\r
+    \"\\n\") ] . \\\r\\r
+    \n    [ \$IfThenElse ([ :len (\$Info->\"latest-version\") ] > 0 && \\\r\\r
+    \n        (\$Info->\"installed-version\") != (\$Info->\"latest-version\"))\\r
+    \_\\\r\\r
+    \n      ([ \$FormatLine \"    Available\" (\$Info->\"latest-version\") ] .\\r
+    \_\"\\n\") ] . \\\r\\r
+    \n    [ \$IfThenElse ((\$Info->\"routerboard\") = true && \\\r\\r
+    \n        (\$Info->\"current-firmware\") != (\$Info->\"upgrade-firmware\")\\r
+    ) \\\r\\r
+    \n      ([ \$FormatLine \"    Firmware\" ((\$Info->\"current-firmware\") .\\r
+    \_\" -> \" . (\$Info->\"upgrade-firmware\")) ] . \"\\n\") ] . \\\r\\r
+    \n    \"RouterOS-Scripts:\\n\" . \\\r\\r
+    \n    [ \$FormatLine \"    Commit\" [ \$CommitBrief ] ] . \"\\n\" . \\\r\\r
+    \n    [ \$FormatLine \"    Version\" \$GlobalConfVersion ]);\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:if ([ :typeof \$NotificationFunctions ] != \"array\") do={:set Notifica\\r
+    tionFunctions ({})}\r\\r
+    \n\r\\r
+    \n:set GetRandom20CharAlNum do={\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :return [ :rndstr length=[ \$EitherOr [ :tonum \$1 ] 20 ] from=\"ABCDE\\r
+    FGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\" ];\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set GetRandom20CharHex do={:global EitherOr; :return [ :rndstr length=[\\r
+    \_\$EitherOr [ :tonum \$1 ] 20 ] from=\"0123456789abcdef\" ]; }\r\\r
+    \n:set GetRandomNumber do={:global EitherOr; :return [ :rndnum from=0 to=[\\r
+    \_\$EitherOr [ :tonum \$1 ] 4294967295 ] ]; }\r\\r
+    \n\r\\r
+    \n:global checkRunJob;\r\\r
+    \n:set checkRunJob do={\r\\r
+    \n  :local Script [ :tostr \$1 ];\r\\r
+    \n  :global ScriptLock; \r\\r
+    \n  :if ([ \$ScriptLock \$Script ] = false) do={:return false}\r\\r
+    \n  :foreach Job in=[ /system/script/job/find where script=\$Script ] do={\\r
+    :set Job [ /system/script/job/get \$Job ];\r\\r
+    \n    :while ([ :typeof (\$Job->\"parent\") ] = \"id\") do={:set Job [ /sy\\r
+    stem/script/job/get [ find where .id=(\$Job->\"parent\") ] ]}\r\\r
+    \n     :if ((\$Job->\"type\") = \"login\") do={:return true};}; :return fa\\r
+    lse; \r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set InspectVar do={\r\\r
+    \n  :global InspectVarRet;\r\\r
+    \n  :put [ :tocrlf [ \$InspectVarRet \$1 ] ];\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CommitBrief do={\r\\r
+    \n  :global CommitId;\r\\r
+    \n  :global CommitInfo;\r\\r
+    \n  :if (\$CommitId = \"unknown\") do={\r\\r
+    \n    :return \"unknown\";\r\\r
+    \n    }\r\\r
+    \n  :return (\$CommitInfo . \"/\" . [ :pick \$CommitId 0 8 ]);\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set InspectVarRet do={\r\\r
+    \n  :local Input \$1;\r\\r
+    \n  :local Level (0 + [ :tonum \$2 ]);\r\\r
+    \n  :global CharacterReplace;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :global InspectVarRet;\r\\r
+    \n  :local IndentReturn do={\r\\r
+    \n    :local Prefix [ :tostr \$1 ];\r\\r
+    \n    :local Value  [ :tostr \$2 ];\r\\r
+    \n    :local Level  [ :tonum \$3 ];\r\\r
+    \n    :global CharacterMultiply;\r\\r
+    \n    :return ([ \$CharacterMultiply \" \" (\$Level * 2) ] . \"-\" . \$Pre\\r
+    fix . \"-> \" . \$Value);\r\\r
+    \n  }\r\\r
+    \n  :local TypeOf [ :typeof \$Input ];\r\\r
+    \n  :local Len    [ :len \$Input ];\r\\r
+    \n  :local Return [ \$IndentReturn \"type\" \$TypeOf \$Level ];\r\\r
+    \n  :if (\$TypeOf = \"array\") do={\r\\r
+    \n    :foreach Key,Value in=\$Input do={\r\\r
+    \n      :set \$Return (\$Return . \"\\n\" . \\\r\\r
+    \n        [ \$IndentReturn \"key\" \$Key (\$Level + 1) ] . \"\\n\" . \\\r\\r
+    \n        [ \$InspectVarRet \$Value (\$Level + 2) ]);\r\\r
+    \n    }\r\\r
+    \n  } else={\r\\r
+    \n    :if (\$TypeOf = \"str\") do={\r\\r
+    \n      :set \$Return (\$Return . \"\\n\" . \\\r\\r
+    \n         [ \$IndentReturn \"len\" \$Len \$Level ]);\r\\r
+    \n      :if ([ :typeof [ :find \$Input (\"\\r\") ] ] = \"num\") do={\r\\r
+    \n        :set Input [ \$CharacterReplace \$Input (\"\\r\") \"\" ];\r\\r
+    \n      }\r\\r
+    \n      :if ([ :typeof [ :find \$Input (\"\\n\") ] ] = \"num\") do={\r\\r
+    \n        :set Input [ \$CharacterReplace \$Input (\"\\n\") \" \" ];\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n    :if (\$TypeOf != \"nothing\") do={\r\\r
+    \n      :set \$Return (\$Return . \"\\n\" . \\\r\\r
+    \n       [ \$IndentReturn \"value\" [ \$IfThenElse ([ :len \$Input ] > 80)\\r
+    \_\\\r\\r
+    \n        ([ :pick \$Input 0 77 ] . \"...\") \$Input ] \$Level ]);\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set GetPubIp do={\r\\r
+    \n    :global DetectIpAddrDefault;\r\\r
+    \n    :global DetectIpAddrFallback;\r\\r
+    \n\r\\r
+    \n    :local PubIpAddr false;\r\\r
+    \n    :local Url \$DetectIpAddrDefault;\r\\r
+    \n    :local JobName [ :jobname ];\r\\r
+    \n\r\\r
+    \n    :do {\r\\r
+    \n      :log debug (\$0 . \" Trying to detect public IP using default serv\\r
+    ice: \" . \$Url . \"...\");\r\\r
+    \n       :retry command={:set PubIpAddr ([ /tool/fetch http-method=\"get\"\\r
+    \_check-certificate=yes-without-crl \$Url output=user as-value ]->\"data\"\\r
+    )} \\\r\\r
+    \n        delay=50ms max=5 on-error={:log error (\$JobName . \" Failed to \\r
+    detect public IP using default service: \" . \$Url . \".\")}\r\\r
+    \n     } on-error={\r\\r
+    \n      :log error (\$0 . \" Failed to detect public IP using default serv\\r
+    ice: \" . \$Url . \".\");\r\\r
+    \n      :set Url \$DetectIpAddrFallBack;\r\\r
+    \n      :log debug (\$0 . \" Trying to detect public IP using fallback ser\\r
+    vice: \" . \$Url . \"...\");\r\\r
+    \n       :retry command={:set PubIpAddr ([ /tool/fetch http-method=\"get\"\\r
+    \_check-certificate=yes-without-crl \$Url output=user as-value ]->\"data\"\\r
+    )} \\\r\\r
+    \n        delay=200ms max=5 on-error={:log error (\$JobName . \" Failed to\\r
+    \_detect public IP using fallback service: \" . \$Url . \".\")}\r\\r
+    \n    };\r\\r
+    \n    :local IpLen ([ :len \$PubIpAddr ] -1);\r\\r
+    \n    :if (\$PubIpAddr = false) do={:set PubIpAddr \"not-detected\"} else=\\r
+    {:set PubIpAddr [:pick \$PubIpAddr 0 \$IpLen]}\r\\r
+    \n    :return \$PubIpAddr;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set FormatLine do={\r\\r
+    \n  :local Key    [ :tostr \$1 ];\r\\r
+    \n  :local Value  [ :tostr \$2 ];\r\\r
+    \n  :local Indent [ :tonum \$3 ];\r\\r
+    \n  :local Spaces;\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :global CharacterMultiply;\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :set Indent [ \$EitherOr \$Indent 16 ];\r\\r
+    \n  :local Spaces [ \$CharacterMultiply \" \" \$Indent ];\r\\r
+    \n  :if ([ :len \$Key ] > 0) do={ :set Return (\$Key . \":\")}\r\\r
+    \n  :if ([ :len \$Key ] > (\$Indent - 2)) do={:set Return (\$Return . \"\\\\r
+    n\" . [ :pick \$Spaces 0 \$Indent ] . \$Value);\r\\r
+    \n  } else={:set Return (\$Return . [ :pick \$Spaces 0 (\$Indent - [ :len \\r
+    \$Return ]) ] . \$Value)}\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set ParseCustom do={\r\\r
+    \n  :local Str [ :tostr \$1 ];\r\\r
+    \n  :local Start [:find [ \$Str ] [:tostr \$2]];\r\\r
+    \n  :local End [ :tostr \$3 ];\r\\r
+    \n  :local Num [ :tonum \$4 ];\r\\r
+    \n  :local Return;\r\\r
+    \n  :if ([:len \$Num] = 0) do={:set Num \"0\"}\r\\r
+    \n  :local rest [:pick \$Str (\$Start+\$Num) [:len \$Str]]; \r\\r
+    \n  :if ([:len \$End ] = 0) do={:set Return [:pick \$Str \$Num \$Start]} e\\r
+    lse={\r\\r
+    \n  :set End [:find \$rest \$End];\r\\r
+    \n  :set Return [:pick \$rest 0 \$End];\r\\r
+    \n  }\r\\r
+    \n:return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set LogPrint do={\r\\r
+    \n  :local Severity [ :tostr \$1 ];\r\\r
+    \n  :local Name     [ :tostr \$2 ];\r\\r
+    \n  :local Message  [ :tostr \$3 ];\r\\r
+    \n  :global PrintDebug;\r\\r
+    \n  :global PrintDebugOverride;\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :local Debug [ \$EitherOr (\$PrintDebugOverride->\$Name) \$PrintDebug \\r
+    ];\r\\r
+    \n  :local PrintSeverity do={\r\\r
+    \n  :global TerminalColorOutput;\r\\r
+    \n   :if (\$TerminalColorOutput != true) do={:return \$1}\r\\r
+    \n   :local Color { debug=96; info=97; warning=93; error=91 };\r\\r
+    \n   :return (\"\\1B[\" . \$Color->\$1 . \"m\" . \$1 . \"\\1B[0m\");\r\\r
+    \n}\r\\r
+    \n  :local Log ([ \$EitherOr \$Name \"<unknown>\" ] . \": \" . \$Message);\\r
+    \r\\r
+    \n  :if (\$Severity ~ (\"^(custom|debug|error|info)\\\$\")) do={\r\\r
+    \n    :if (\$Severity = \"debug\") do={:log debug \$Log}\r\\r
+    \n    :if (\$Severity = \"error\") do={:log error \$Log}\r\\r
+    \n    :if (\$Severity = \"info\" ) do={:log info  \$Log}\r\\r
+    \n  } else={:log warning \$Log; :set Severity \"warning\"}\r\\r
+    \n  :if (\$Severity != \"debug\" || \$Debug = true) do={:put ([ \$PrintSev\\r
+    erity \$Severity ] . \": \" . \$Message)}\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CertificateAvailable do={\r\\r
+    \n  :local CommonName [ :tostr \$1 ];\r\\r
+    \n  :local UseFor     [ :tostr \$2 ];\r\\r
+    \n\r\\r
+    \n  :global CertificateDownload;\r\\r
+    \n  :global ParseKeyValueStore;\r\\r
+    \n\r\\r
+    \n  :if ([ :len \$UseFor ] = 0) do={\r\\r
+    \n    :log warning (\$0 . \"The intended use is undefined!\");\r\\r
+    \n    :set UseFor \"undefined\";\r\\r
+    \n  }\r\\r
+    \n  :if ([ /system/resource/get free-hdd-space ] < 8388608 && \\\r\\r
+    \n       [ /certificate/settings/get crl-download ] = true && \\\r\\r
+    \n       [ /certificate/settings/get crl-store ] = \"system\") do={\r\\r
+    \n    :log warning (\$0 . \"This system has low free flash space but \" . \\r
+    \\\r\\r
+    \n      \"is configured to download certificate CRLs to system!\");\r\\r
+    \n  }\r\\r
+    \n  :if ([ :len \$CommonName ] = 0) do={\r\\r
+    \n    :log warning (\$0 . \"No CommonName given!\");\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :local CertSettings [ /certificate/settings/get ];\r\\r
+    \n  :if (((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" || \\\\r
+    \r\\r
+    \n        (\$CertSettings->\"builtin-trust-store\") ~ \$UseFor || \\\r\\r
+    \n        (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\r\\r
+    \n       [ :len [ /certificate/builtin/find where common-name=\$CommonName\\r
+    \_] ] > 0) do={\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] = 0\\r
+    ) do={\r\\r
+    \n    :log info (\$0 . \"Certificate with CommonName '\" . \$CommonName . \\r
+    \"' not available.\");\r\\r
+    \n    :if ([ \$CertificateDownload \$CommonName ] = false) do={\r\\r
+    \n      :return false;\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n  :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] > 1\\r
+    ) do={\r\\r
+    \n    :log info (\$0 . \"There are \" . \$CertCount . \" Certificates with\\r
+    \_CommonName '\" . \$CommonName . \"'. Should be ok.\");\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  :local CertVal [ /certificate/get [ find where common-name=\$CommonNam\\r
+    e ] ];\r\\r
+    \n  :while ((\$CertVal->\"akid\") != \"\" && (\$CertVal->\"akid\") != (\$C\\r
+    ertVal->\"skid\")) do={\r\\r
+    \n    :if ([ :len [ /certificate/find where skid=(\$CertVal->\"akid\") ] ]\\r
+    \_= 0) do={\r\\r
+    \n      :local IssuerCN ([ \$ParseKeyValueStore (\$CertVal->\"issuer\") ]-\\r
+    >\"CN\");\r\\r
+    \n      :log info (\$0 . \"Certificate chain for '\" . \$CommonName . \"' \\r
+    is incomplete, missing '\" . \$IssuerCN . \"'.\");\r\\r
+    \n      :if ([ \$CertificateDownload \$IssuerCN ] = false) do={\r\\r
+    \n        :return false;\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n    :set CertVal [ /certificate/get [ find where skid=(\$CertVal->\"akid\\r
+    \") ] ];\r\\r
+    \n  }\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CertificateDownload do={\r\\r
+    \n  :local CommonName [ :tostr \$1 ];\r\\r
+    \n  :global ScriptUpdatesBaseUrl;\r\\r
+    \n  :global ScriptUpdatesUrlSuffix;\r\\r
+    \n  :global CertificateNameByCN;\r\\r
+    \n  :global CleanName;\r\\r
+    \n  :global FetchUserAgentStr;\r\\r
+    \n  :global RmFile;\r\\r
+    \n  :global WaitForFile;\r\\r
+    \n\r\\r
+    \n  :log info (\$0 . \"Downloading and importing certificate with \" . \\\\r
+    \r\\r
+    \n      \"CommonName '\" . \$CommonName . \"'.\");\r\\r
+    \n  :local FileName ([ \$CleanName \$CommonName ] . \".pem\");\r\\r
+    \n  :do {\r\\r
+    \n    /tool/fetch check-certificate=yes-without-crl mode=https http-header\\r
+    -field=({ [ \$FetchUserAgentStr \$0 ] }) \\\r\\r
+    \n      (\$ScriptUpdatesBaseUrl . \"certs/\" . \$FileName . \$ScriptUpdate\\r
+    sUrlSuffix) \\\r\\r
+    \n      dst-path=\$FileName as-value;\r\\r
+    \n    \$WaitForFile \$FileName;\r\\r
+    \n  } on-error={\r\\r
+    \n    :log warning (\$0 . \" Failed downloading certificate with CommonNam\\r
+    e '\" . \$CommonName . \\\r\\r
+    \n      \"' from repository! Trying fallback to mkcert.org...\");\r\\r
+    \n    :do {\r\\r
+    \n      :local CertSettings [ /certificate/settings/get ];\r\\r
+    \n      :if ([ :len [ /certificate/find where common-name=\"ISRG Root X1\"\\r
+    \_] ] = 0 && \\\r\\r
+    \n           !(((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" \\r
+    || \\\r\\r
+    \n              (\$CertSettings->\"builtin-trust-store\") ~ \"fetch\" || \\r
+    \\\r\\r
+    \n              (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\\r
+    \r\\r
+    \n             [ :len [ /certificate/builtin/find where common-name=\"ISRG\\r
+    \_Root X1\" ] ] > 0)) do={\r\\r
+    \n        :log error (\$0 . \" Required certificate is not available.\");\\r
+    \r\\r
+    \n        :return false;\r\\r
+    \n      }\r\\r
+    \n      /tool/fetch check-certificate=yes-without-crl mode=https http-head\\r
+    er-field=({ [ \$FetchUserAgentStr \$0 ] }) \\\r\\r
+    \n      url=\"https://mkcert.org/generate/\" http-data=[ :serialize to=jso\\r
+    n ({ \$CommonName }) ] \\\r\\r
+    \n      dst-path=\$FileName as-value;\r\\r
+    \n      \$WaitForFile \$FileName;\r\\r
+    \n      :if ([ /file/get \$FileName size ] = 0) do={\r\\r
+    \n        \$RmFile \$FileName;\r\\r
+    \n        :error false;\r\\r
+    \n      }\r\\r
+    \n    } on-error={\r\\r
+    \n      :log error (\$0 . \" Failed downloading certificate with CommonNam\\r
+    e '\" . \$CommonName . \"'!\");\r\\r
+    \n      :return false;\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n  /certificate/import file-name=\$FileName passphrase=\"\" as-value;\r\\r
+    \n  :delay 1s;\r\\r
+    \n  \$RmFile \$FileName;\r\\r
+    \n  :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] = 0\\r
+    ) do={\r\\r
+    \n    /certificate/remove [ find where name~(\"^\" . \$FileName . \"_[0-9]\\r
+    +\\\$\") ];\r\\r
+    \n    :log warning (\$0 . \" Certificate with CommonName '\" . \$CommonNam\\r
+    e . \"' still unavailable!\");\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :foreach Cert in=[ /certificate/find where name~(\"^\" . \$FileName . \\r
+    \"_[0-9]+\\\$\") ] do={\r\\r
+    \n    \$CertificateNameByCN [ /certificate/get \$Cert common-name ];\r\\r
+    \n  }\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CertificateNameByCN do={\r\\r
+    \n  :local Match [ :tostr \$1 ];\r\\r
+    \n  :global CleanName;\r\\r
+    \n  :local Cert ([ /certificate/find where (common-name=\$Match or fingerp\\r
+    rint=\$Match or name=\$Match) ]->0);\r\\r
+    \n  :if ([ :len \$Cert ] = 0) do={\r\\r
+    \n    :log warning (\$0 .\" No matching certificate found.\");\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :local CommonName [ /certificate/get \$Cert common-name ];\r\\r
+    \n  /certificate/set \$Cert name=[ \$CleanName \$CommonName ];\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CharacterMultiply do={\r\\r
+    \n  :local Str [ :tostr \$1 ];\r\\r
+    \n  :local Num [ :tonum \$2 ];\r\\r
+    \n  :if (\$Num = 0) do={:return \"\"}\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :for I from=1 to=\$Num do={:set Return (\$Return . \$Str)}\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set FileExists do={\r\\r
+    \n  :local FileName [ :tostr \$1 ];\r\\r
+    \n  :local Type     [ :tostr \$2 ];\r\\r
+    \n  :global FileGet;\r\\r
+    \n  :local FileVal [ \$FileGet \$FileName ];\r\\r
+    \n  :if (\$FileVal = false) do={ :return false; }\r\\r
+    \n  :if ([ :len (\$FileVal->\"size\") ] = 0) do={ :return false; }\r\\r
+    \n  :if ([ :len \$Type ] = 0 || \$FileVal->\"type\" = \$Type) do={ :return\\r
+    \_true; }\r\\r
+    \n  :return false;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set Grep do={\r\\r
+    \n  :local Input  ([ :tostr \$1 ] . \"\\n\");\r\\r
+    \n  :local Pattern [ :tostr \$2 ];\r\\r
+    \n  :if ([ :typeof [ :find \$Input \$Pattern ] ] = \"nil\") do={:return []\\r
+    }\r\\r
+    \n  :do {\r\\r
+    \n    :local Line [ :pick \$Input 0 [ :find \$Input \"\\n\" ] ];\r\\r
+    \n    :if ([ :typeof [ :find \$Line \$Pattern ] ] = \"num\") do={:return \\r
+    \$Line}\r\\r
+    \n    :set Input [ :pick \$Input ([ :find \$Input \"\\n\" ] + 1) [ :len \$\\r
+    Input ] ];\r\\r
+    \n  } while=([ :len \$Input ] > 0);\r\\r
+    \n  :return [];\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set HumanReadableNum do={\r\\r
+    \n  :local Input [ :tonum \$1 ];\r\\r
+    \n  :local Base  [ :tonum \$2 ];\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :local Prefix \"kMGTPE\";\r\\r
+    \n  :local Pow 1;\r\\r
+    \n  :set Base [ \$EitherOr \$Base 1024 ];\r\\r
+    \n  :local Bin [ \$IfThenElse (\$Base = 1024) \"i\" \"\" ];\r\\r
+    \n  :if (\$Input < \$Base) do={:return \$Input}\r\\r
+    \n  :for I from=0 to=[ :len \$Prefix ] do={\r\\r
+    \n    :set Pow (\$Pow * \$Base);\r\\r
+    \n    :if (\$Input / \$Base < \$Pow) do={\r\\r
+    \n      :set Prefix [ :pick \$Prefix \$I ];\r\\r
+    \n      :local Tmp1 (\$Input * 100 / \$Pow);\r\\r
+    \n      :local Tmp2 (\$Tmp1 / 100);\r\\r
+    \n      :if (\$Tmp2 >= 100) do={:return (\$Tmp2 . \$Prefix . \$Bin)}\r\\r
+    \n      :return (\$Tmp2 . \".\" . \\\r\\r
+    \n          [ :pick \$Tmp1 [ :len \$Tmp2 ] ([ :len \$Tmp1 ] - [ :len \$Tmp\\r
+    2 ] + 1) ] . \\\r\\r
+    \n          \$Prefix . \$Bin);\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CleanFilePath do={\r\\r
+    \n  :local Path [ :tostr \$1 ];\r\\r
+    \n  :global CharacterReplace;\r\\r
+    \n  :while (\$Path ~ \"//\") do={ :set \$Path [ \$CharacterReplace \$Path \\r
+    \"//\" \"/\" ]; }\r\\r
+    \n  :if ([ :pick \$Path 0 ] = \"/\") do={ :set Path [ :pick \$Path 1 [ :le\\r
+    n \$Path ] ]; }\r\\r
+    \n  :if ([ :pick \$Path ([ :len \$Path ] - 1) ] = \"/\") do={ :set Path [ \\r
+    :pick \$Path 0 ([ :len \$Path ] - 1) ]; }\r\\r
+    \n  :return \$Path;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CleanName do={\r\\r
+    \n  :local Input [ :tostr \$1 ];\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :for I from=0 to=([ :len \$Input ] - 1) do={\r\\r
+    \n    :local Char [ :pick \$Input \$I ];\r\\r
+    \n    :if ([ :typeof [ find \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr\\r
+    stuvwxyz0123456789\" \$Char ] ] = \"nil\") do={\r\\r
+    \n      :do {:if ([ :len \$Return ] = 0) do={:error true};\r\\r
+    \n        :if ([ :pick \$Return ([ :len \$Return ] - 1) ] = \"-\") do={:er\\r
+    ror true}; :set Char \"-\"} on-error={:set Char \"\"}; \r\\r
+    \n    };\r\\r
+    \n    :set Return (\$Return . \$Char)};\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set RandomDelay do={\r\\r
+    \n  :local Time [ :tonum \$1 ];\r\\r
+    \n  :local Unit [ :tostr \$2 ];\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :global GetRandomNumber;\r\\r
+    \n  :global MAX;\r\\r
+    \n  :if (\$Time = 0) do={:return false}\r\\r
+    \n  :delay ([ \$MAX 10 [ \$GetRandomNumber ([ :tonsec [ :totime (\$Time . \\r
+    [ \$EitherOr \$Unit \"s\" ]) ] ] / 1000000) ] ] . \"ms\");\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set EscapeForRegEx do={\r\\r
+    \n  :local Input [ :tostr \$1 ];\r\\r
+    \n  :if ([ :len \$Input ] = 0) do={:return \"\"}\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :local Chars (\"^.[]\\\$()|*+\?{}\\\\\");\r\\r
+    \n  :for I from=0 to=([ :len \$Input ] - 1) do={\r\\r
+    \n    :local Char [ :pick \$Input \$I ];\r\\r
+    \n    :if ([ :find \$Chars \$Char ]) do={:set Char (\"\\\\\" . \$Char)}\r\\r
+    \n    :set Return (\$Return . \$Char);\r\\r
+    \n  }\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set ExitError do={\r\\r
+    \n  :local ExitOK [ :tostr \$1 ];\r\\r
+    \n  :local Name   [ :tostr \$2 ];\r\\r
+    \n  :local Error  [ :tostr \$3 ];\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :if (\$ExitOK = \"false\") do={\r\\r
+    \n    :log error (\$Name [ \$IfThenElse ([ :pick \$Name 0 1 ] = \"\\\$\") \\r
+    \\\r\\r
+    \n        \"Function\" \"Script\" ] . \" '\" . \$Name . \"' exited with er\\r
+    ror\" . \\\r\\r
+    \n        [ \$IfThenElse (!(\$Error ~ \"^(|true|false)\\\$\")) (\": \" . \\r
+    \$Error) \".\" ]);\r\\r
+    \n  }\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set ExitOnError do={\r\\r
+    \n  :local Name   [ :tostr \$1 ];\r\\r
+    \n  :local Error  [ :tostr \$2 ];\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :log error (\$Name . \" \" . [ \$IfThenElse ([ :pick \$Name 0 1 ] = \"\\r
+    \\\$\") \\\r\\r
+    \n      \"Function\" \"Script\" ] . \" '\" . \$Name . \"' exited with erro\\r
+    r\" . \\\r\\r
+    \n      [ \$IfThenElse (!(\$Error ~ \"^(|true|false)\\\$\")) (\": \" . \$E\\r
+    rror) \".\" ]);\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set MiniDateTimeStamp do={\r\\r
+    \n    :local mikro [ :tobool \$1 ];\r\\r
+    \n    /system/clock;\r\\r
+    \n    :local vdate [get date];\r\\r
+    \n    :local vtime [get time];\r\\r
+    \n    :local vdoff [:toarray \"0,4,5,7,8,10\"];\r\\r
+    \n    :local MM    [:pick \$vdate (\$vdoff->2) (\$vdoff->3)];\r\\r
+    \n    :local M     [:tonum \$MM];\r\\r
+    \n    :if (\$vdate ~ \".../../....\") do={\r\\r
+    \n        :set vdoff [:toarray \"7,11,1,3,4,6\"];\r\\r
+    \n        :set M     ([:find \"xxanebarprayunulugepctovecANEBARPRAYUNULUGE\\r
+    PCTOVEC\" [:pick \$vdate (\$vdoff->2) (\$vdoff->3)] -1] / 2);\r\\r
+    \n        :if (\$M>12) do={:set M (\$M - 12)}\r\\r
+    \n        :set MM    [:pick (100 + \$M) 1 3];\r\\r
+    \n    }\r\\r
+    \n    :local yyyy [:pick \$vdate (\$vdoff->0) (\$vdoff->1)];\r\\r
+    \n    :local dd   [:pick \$vdate (\$vdoff->4) (\$vdoff->5)];\r\\r
+    \n    :local HH   [:pick \$vtime 0  2];\r\\r
+    \n    :local mm   [:pick \$vtime 3  5];\r\\r
+    \n    :local ss   [:pick \$vtime 6  8];\r\\r
+    \n    :local Return;\r\\r
+    \n    :if (\$mikro = true) do={\r\\r
+    \n      :set Return ([:pick \$yyyy 2 4] . [:pick \$dd 0 1] . [:pick \$HH 0\\r
+    \_1] . [:pick \$mm 3 4] . [:pick \$ss 6 7]);\r\\r
+    \n    } else={\r\\r
+    \n    :set Return ([\$yyyy] . [\$MM] . [\$dd] . [\$HH] . [\$mm] . [\$ss]);\\r
+    \r\\r
+    \n   }\r\\r
+    \n   :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set WaitForFile do={\r\\r
+    \n  :local FileName [ :tostr  \$1 ];\r\\r
+    \n  :local WaitTime [ :totime \$2 ];\r\\r
+    \n  :global CleanFilePath;\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :global MAX;\r\\r
+    \n  :set FileName [ \$CleanFilePath \$FileName ];\r\\r
+    \n  :local Delay ([ \$MAX [ \$EitherOr \$WaitTime 2s ] 100ms ] / 9);\r\\r
+    \n  :do {\r\\r
+    \n    :retry {\r\\r
+    \n      /file/get \$FileName;\r\\r
+    \n      :return true;\r\\r
+    \n    } delay=\$Delay max=10;\r\\r
+    \n  } on-error={ }\r\\r
+    \n  :while ([ :len [ /file/find where name=\$FileName ] ] > 0) do={\r\\r
+    \n    :do {\r\\r
+    \n      /file/get \$FileName;\r\\r
+    \n      :return true;\r\\r
+    \n    } on-error={ }\r\\r
+    \n    :delay \$Delay;\r\\r
+    \n    :set Delay (\$Delay * 3 / 2);\r\\r
+    \n  }\r\\r
+    \n  :return false;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set FileGet do={\r\\r
+    \n  :local FileName [ :tostr \$1 ];\r\\r
+    \n  :global WaitForFile;\r\\r
+    \n  :if ([ \$WaitForFile \$FileName 0s ] = false) do={\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :local FileVal false;\r\\r
+    \n  :do {\r\\r
+    \n    :set FileVal [ /file/get \$FileName ];\r\\r
+    \n   } on-error={ }\r\\r
+    \n  :return \$FileVal;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set RmDir do={\r\\r
+    \n  :local DirName [ :tostr \$1 ];\r\\r
+    \n  :global FileGet;\r\\r
+    \n  :log debug (\$0 . \" Removing directory: \". \$DirName);\r\\r
+    \n  :local DirVal [ \$FileGet \$DirName ];\r\\r
+    \n  :if (\$DirVal = false) do={\r\\r
+    \n    :log debug (\$0 . \" ... which does not exist.\");\r\\r
+    \n    :return true;\r\\r
+    \n  };\r\\r
+    \n  :if (\$DirVal->\"type\" != \"directory\") do={\r\\r
+    \n    :log error (\$0 . \" Directory '\" . \$DirName . \"' is not a direct\\r
+    ory.\");\r\\r
+    \n    :return false;\r\\r
+    \n  };\r\\r
+    \n  :onerror Err {\r\\r
+    \n    /file/remove \$DirName;\r\\r
+    \n  } do={\r\\r
+    \n    :log error (\$0 . \" Removing directory '\" . \$DirName . \"' failed\\r
+    : \" . \$Err);\r\\r
+    \n    :return false;\r\\r
+    \n  };\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set RmFile do={\r\\r
+    \n  :local FileName [ :tostr \$1 ];\r\\r
+    \n  :global FileGet;\r\\r
+    \n  :log debug (\$0 . \" Removing file: \". \$FileName);\r\\r
+    \n  :local FileVal [ \$FileGet \$FileName ];\r\\r
+    \n  :if (\$FileVal = false) do={\r\\r
+    \n    :log debug (\$0 . \" ... which does not exist.\");\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  :if (\$FileVal->\"type\" = \"directory\" || \$FileVal->\"type\" = \"di\\r
+    sk\") do={\r\\r
+    \n    :log error (\$0 . \" File '\" . \$FileName . \"' is not a file.\");\\r
+    \r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :onerror Err {\r\\r
+    \n    /file/remove \$FileName;\r\\r
+    \n  } do={\r\\r
+    \n    :log error (\$0 . \" Removing file '\" . \$FileName . \"' failed: \"\\r
+    \_. \$Err); :return false;\r\\r
+    \n  }\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set MkDir do={\r\\r
+    \n  :local Path [ :tostr \$1 ];\r\\r
+    \n  :global CleanFilePath;\r\\r
+    \n  :global FileGet;\r\\r
+    \n  :global RmDir;\r\\r
+    \n  :global WaitForFile;\r\\r
+    \n\r\\r
+    \n  :local MkTmpfs do={\r\\r
+    \n   :global WaitForFile;\r\\r
+    \n   :local TmpFs [ /disk/find where slot=tmpfs type=tmpfs ];\r\\r
+    \n   :if ([ :len \$TmpFs ] = 1) do={\r\\r
+    \n     :if ([ /disk/get \$TmpFs disabled ] = true) do={\r\\r
+    \n       :log info (\$0 . \" The tmpfs is disabled, enabling.\");\r\\r
+    \n       /disk/enable \$TmpFs;\r\\r
+    \n      }\r\\r
+    \n      :return true;\r\\r
+    \n    }\r\\r
+    \n    :log info (\$0 . \" Creating disk of type tmpfs.\");\r\\r
+    \n    \$RmDir \"tmpfs\";\r\\r
+    \n    :onerror Err {\r\\r
+    \n      /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource\\r
+    /get total-memory ] / 3);\r\\r
+    \n      \$WaitForFile \"tmpfs\";\r\\r
+    \n    } do={\r\\r
+    \n      :log warning (\$0 . \" Creating disk of type tmpfs failed: \" . \$\\r
+    Err);\r\\r
+    \n      :return false;\r\\r
+    \n    }\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  :set Path [ \$CleanFilePath \$Path ];\r\\r
+    \n  :if (\$Path = \"\") do={\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  :log debug (\$0 . \" Making directory: \" . \$Path);\r\\r
+    \n  :local PathVal [ \$FileGet \$Path ];\r\\r
+    \n  :if (\$PathVal->\"type\" = \"directory\") do={\r\\r
+    \n    :log debug (\$0 . \" ... which already exists.\");\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  :if ([ :pick \$Path 0 5 ] = \"tmpfs\") do={\r\\r
+    \n    :if ([ \$MkTmpfs ] = false) do={\r\\r
+    \n      :return false;\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n  :onerror Err {\r\\r
+    \n    /file/add type=\"directory\" name=\$Path;\r\\r
+    \n    \$WaitForFile \$Path;\r\\r
+    \n  } do={\r\\r
+    \n    :log warning (\$0 . \" Making directory '\" . \$Path . \"' failed: \\r
+    \" . \$Err);\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set MAX do={:if (\$1 > \$2) do={:return \$1}\r\\r
+    \n :return \$2;\r\\r
+    \n}\r\\r
+    \n:set MIN do={:if (\$1 < \$2) do={:return \$1}\r\\r
+    \n :return \$2;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CharacterMultiply do={\r\\r
+    \n  :local Str [ :tostr \$1 ];\r\\r
+    \n  :local Num [ :tonum \$2 ];\r\\r
+    \n  :if (\$Num = 0) do={:return \"\"}\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :for I from=1 to=\$Num do={:set Return (\$Return . \$Str)}\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set CharacterReplace do={\r\\r
+    \n  :local String [ :tostr \$1 ];\r\\r
+    \n  :local ReplaceFrom [ :tostr \$2 ];\r\\r
+    \n  :local ReplaceWith [ :tostr \$3 ];\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :if (\$ReplaceFrom = \"\") do={:return \$String}\r\\r
+    \n  :while ([ :typeof [ :find \$String \$ReplaceFrom ] ] != \"nil\") do={\\r
+    \r\\r
+    \n    :local Pos [ :find \$String \$ReplaceFrom ];\r\\r
+    \n    :set Return (\$Return . [ :pick \$String 0 \$Pos ] . \$ReplaceWith);\\r
+    \r\\r
+    \n    :set String [ :pick \$String (\$Pos + [ :len \$ReplaceFrom ]) [ :len\\r
+    \_\$String ] ];\r\\r
+    \n  }\r\\r
+    \n  :return (\$Return . \$String);\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set IfThenElse do={\r\\r
+    \n  :if ([ :tostr \$1 ] = \"true\" || [ :tobool \$1 ] = true) do={:return \\r
+    \$2};\r\\r
+    \n  :return \$3;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set EitherOr do={\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :if ([ :typeof \$1 ] = \"num\") do={:return [ \$IfThenElse (\$1 != 0) \\r
+    \$1 \$2 ]}\r\\r
+    \n  :if ([ :typeof \$1 ] = \"time\") do={:return [ \$IfThenElse (\$1 > 0s)\\r
+    \_\$1 \$2 ]}\r\\r
+    \n# this works for boolean values, literal ones with parentheses\r\\r
+    \n  :return [ \$IfThenElse ([ :len [ :tostr \$1 ] ] > 0) \$1 \$2 ];\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set ParseKeyValueStore do={\r\\r
+    \n  :local Source \$1;\r\\r
+    \n  :if ([ :pick \$Source 0 1 ] = \"{\") do={\r\\r
+    \n    :do {\r\\r
+    \n      :return [ :deserialize from=json \$Source ];\r\\r
+    \n    } on-error={ }\r\\r
+    \n  }   \r\\r
+    \n  :if ([ :typeof \$Source ] != \"array\") do={:set Source [ :tostr \$1 ]\\r
+    }\r\\r
+    \n  :local Result ({});\r\\r
+    \n  :foreach KeyValue in=[ :toarray \$Source ] do={\r\\r
+    \n    :if ([ :find \$KeyValue \"=\" ]) do={\r\\r
+    \n      :local Key [ :pick \$KeyValue 0 [ :find \$KeyValue \"=\" ] ];\r\\r
+    \n      :local Value [ :pick \$KeyValue ([ :find \$KeyValue \"=\" ] + 1) [\\r
+    \_:len \$KeyValue ] ];\r\\r
+    \n      :if (\$Value=\"true\") do={:set Value true}\r\\r
+    \n      :if (\$Value=\"false\") do={:set Value false}\r\\r
+    \n      :set (\$Result->\$Key) \$Value;\r\\r
+    \n      } else={:set (\$Result->\$KeyValue) true}\r\\r
+    \n  }\r\\r
+    \n  :return \$Result;\r\\r
+    \n}\r\\r
+    \n:set RequiredRouterOS do={\r\\r
+    \n  :local Caller   [ :tostr \$1 ];\r\\r
+    \n  :local Required [ :tostr \$2 ];\r\\r
+    \n  :local Warn     [ :tostr \$3 ];\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :global VersionToNum;\r\\r
+    \n  :if (!(\$Required ~ \"^\\\\d+\\\\.\\\\d+((alpha|beta|rc|\\\\.)\\\\d+|)\\r
+    \\\$\")) do={\r\\r
+    \n    :log error (\$0 . \" No valid RouterOS version: \" . \$Required);\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :if ([ \$VersionToNum \$Required ] > [ \$VersionToNum [ /system/packag\\r
+    e/update/get installed-version ] ]) do={\r\\r
+    \n    :if (\$Warn = \"true\") do={\r\\r
+    \n      :log warning (\$0 . \" This \" . [ \$IfThenElse ([ :pick \$Caller \\r
+    0 ] = (\"\\\$\")) \"function\" \"script\" ] . \\\r\\r
+    \n        \" '\" . \$Caller . \"' (at least specific functionality) requir\\r
+    es RouterOS \" . \$Required . \". Please update!\");\r\\r
+    \n    }\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set ValidateSyntax do={\r\\r
+    \n  :local Code [ :tostr \$1 ];\r\\r
+    \n  :global LogPrint;\r\\r
+    \n  :onerror Err {\r\\r
+    \n    [ :parse (\":local Validate do={\\n\" . \$Code . \"\\n}\") ];\r\\r
+    \n  } do={\r\\r
+    \n    \$LogPrint debug \$0 (\"Valdation failed: \" . \$Err);\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set VersionToNum do={\r\\r
+    \n  :local Input [ :tostr \$1 ];\r\\r
+    \n  :local Multi 0x1000000;\r\\r
+    \n  :local Return 0;\r\\r
+    \n  :global CharacterReplace;\r\\r
+    \n  :set Input [ \$CharacterReplace \$Input \".\" \",\" ];\r\\r
+    \n  :foreach I in={ \"zero\"; \"alpha\"; \"beta\"; \"rc\" } do={\r\\r
+    \n    :set Input [ \$CharacterReplace \$Input \$I (\",\" . \$I . \",\") ];\\r
+    \r\\r
+    \n  }\r\\r
+    \n  :foreach Value in=([ :toarray \$Input ], 0) do={\r\\r
+    \n    :local Num [ :tonum \$Value ];\r\\r
+    \n    :if (\$Multi = 0x100) do={\r\\r
+    \n      :if ([ :typeof \$Num ] = \"num\") do={\r\\r
+    \n        :set Return (\$Return + 0xff00);\r\\r
+    \n        :set Multi (\$Multi / 0x100);\r\\r
+    \n      } else={\r\\r
+    \n        :if (\$Value = \"zero\") do={ }\r\\r
+    \n        :if (\$Value = \"alpha\") do={ :set Return (\$Return + 0x3f00); \\r
+    }\r\\r
+    \n        :if (\$Value = \"beta\") do={ :set Return (\$Return + 0x5f00); }\\r
+    \r\\r
+    \n        :if (\$Value = \"rc\") do={ :set Return (\$Return + 0x7f00); }\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n    :if ([ :typeof \$Num ] = \"num\") do={ :set Return (\$Return + (\$Va\\r
+    lue * \$Multi)); }\r\\r
+    \n    :set Multi (\$Multi / 0x100);\r\\r
+    \n  }\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set ScriptLock do={\r\\r
+    \n  :local Script  [ :tostr  \$1 ];\r\\r
+    \n  :local WaitMax [ :totime \$2 ];\r\\r
+    \n  :global GetRandom20CharAlNum;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :global ScriptLockOrder;\r\\r
+    \n  :if ([ :typeof \$ScriptLockOrder ] = \"nothing\") do={\r\\r
+    \n    :set ScriptLockOrder ({});\r\\r
+    \n  }\r\\r
+    \n  :if ([ :typeof (\$ScriptLockOrder->\$Script) ] = \"nothing\") do={\r\\r
+    \n    :set (\$ScriptLockOrder->\$Script) ({});\r\\r
+    \n  }\r\\r
+    \n  :local JobCount do={\r\\r
+    \n    :local Script [ :tostr \$1 ];\r\\r
+    \n    :return [ :len [ /system/script/job/find where script=\$Script ] ];\\r
+    \r\\r
+    \n  }\r\\r
+    \n  :local TicketCount do={\r\\r
+    \n    :local Script [ :tostr \$1 ];\r\\r
+    \n    :global ScriptLockOrder;\r\\r
+    \n    :local Count 0;\r\\r
+    \n    :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\\r
+    \n      :if ([ :typeof \$Ticket ] != \"nothing\") do={:set Count (\$Count \\r
+    + 1)}\r\\r
+    \n    }\r\\r
+    \n    :return \$Count;\r\\r
+    \n  }\r\\r
+    \n  :local IsFirstTicket do={\r\\r
+    \n    :local Script [ :tostr \$1 ];\r\\r
+    \n    :local Check  [ :tostr \$2 ];\r\\r
+    \n    :global ScriptLockOrder;\r\\r
+    \n    :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\\r
+    \n      :if (\$Ticket = \$Check) do={:return true}\r\\r
+    \n      :if ([ :typeof \$Ticket ] != \"nothing\" && \$Ticket != \$Check) d\\r
+    o={:return false}\r\\r
+    \n    }\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :local AddTicket do={\r\\r
+    \n    :local Script [ :tostr \$1 ];\r\\r
+    \n    :local Add    [ :tostr \$2 ];\r\\r
+    \n    :global ScriptLockOrder;\r\\r
+    \n    :while (true) do={\r\\r
+    \n      :local Pos [ :len (\$ScriptLockOrder->\$Script) ];\r\\r
+    \n      :set (\$ScriptLockOrder->\$Script->\$Pos) \$Add;\r\\r
+    \n      :delay 10ms;\r\\r
+    \n      :if ((\$ScriptLockOrder->\$Script->\$Pos) = \$Add) do={:return tru\\r
+    e}\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n  :local RemoveTicket do={\r\\r
+    \n    :local Script [ :tostr \$1 ];\r\\r
+    \n    :local Remove [ :tostr \$2 ];\r\\r
+    \n    :global ScriptLockOrder;\r\\r
+    \n    :foreach Id,Ticket in=(\$ScriptLockOrder->\$Script) do={\r\\r
+    \n      :while ((\$ScriptLockOrder->\$Script->\$Id) = \$Remove) do={\r\\r
+    \n        :set (\$ScriptLockOrder->\$Script->\$Id);\r\\r
+    \n        :delay 10ms;\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n  :local CleanupTickets do={\r\\r
+    \n    :local Script [ :tostr \$1 ];\r\\r
+    \n    :global ScriptLockOrder;\r\\r
+    \n    :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\\r
+    \n      :if ([ :typeof \$Ticket ] != \"nothing\") do={:return false}\r\\r
+    \n    }\r\\r
+    \n    :set (\$ScriptLockOrder->\$Script) ({});\r\\r
+    \n  }\r\\r
+    \n  :if ([ :typeof \$WaitMax ] = \"nil\" ) do={:set WaitMax 0s}\r\\r
+    \n  :if ([ :len [ /system/script/find where name=\$Script ] ] = 0) do={\r\\r
+    \n    :log error (\$0 . \" A script named '\" . \$Script . \"' does not ex\\r
+    ist!\");\r\\r
+    \n    :error false;\r\\r
+    \n  }\r\\r
+    \n  :if ([ \$JobCount \$Script ] = 0) do={\r\\r
+    \n    \$LogPrint error \$0 (\"No script '\" . \$Script . \"' is running!\"\\r
+    );\r\\r
+    \n    :error false;\r\\r
+    \n  }\r\\r
+    \n  :if ([ \$TicketCount \$Script ] >= [ \$JobCount \$Script ]) do={\r\\r
+    \n    :log error (\$0 . \" More tickets than running scripts '\" . \$Scrip\\r
+    t . \"', resetting!\");\r\\r
+    \n    :set (\$ScriptLockOrder->\$Script) ({});\r\\r
+    \n    /system/script/job/remove [ find where script=\$Script ];\r\\r
+    \n  }\r\\r
+    \n  :local MyTicket [ \$GetRandom20CharAlNum 6 ];\r\\r
+    \n  \$AddTicket \$Script \$MyTicket;\r\\r
+    \n  :local WaitInterval (\$WaitMax / 20);\r\\r
+    \n  :local WaitTime \$WaitMax;\r\\r
+    \n  :while (\$WaitTime > 0 && \\\r\\r
+    \n      ([ \$IsFirstTicket \$Script \$MyTicket ] = false || \\\r\\r
+    \n      [ \$TicketCount \$Script ] < [ \$JobCount \$Script ])) do={\r\\r
+    \n    :set WaitTime (\$WaitTime - \$WaitInterval);\r\\r
+    \n    :delay \$WaitInterval;\r\\r
+    \n  }\r\\r
+    \n  :if ([ \$IsFirstTicket \$Script \$MyTicket ] = true && \\\r\\r
+    \n      [ \$TicketCount \$Script ] = [ \$JobCount \$Script ]) do={\r\\r
+    \n    \$RemoveTicket \$Script \$MyTicket;\r\\r
+    \n    \$CleanupTickets \$Script;\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  \$RemoveTicket \$Script \$MyTicket;\r\\r
+    \n  \$LogPrint debug \$0 (\"Script '\" . \$Script . \"' started more than \\r
+    once\" . \\\r\\r
+    \n    [ \$IfThenElse (\$WaitTime < \$WaitMax) \" and timed out waiting for\\r
+    \_lock\" \"\" ] . \"...\");\r\\r
+    \n  :return false;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set SendNotification do={ :onerror Err {\r\\r
+    \n  :global SendNotification2;\r\\r
+    \n  \$SendNotification2 ({ origin=\$0; subject=\$1; message=\$2; link=\$3;\\r
+    \_silent=\$4 });\r\\r
+    \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err}\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set SendNotification2 do={\r\\r
+    \n  :local Notification \$1;\r\\r
+    \n  :global NotificationFunctions;\r\\r
+    \n  :foreach FunctionName,Discard in=\$NotificationFunctions do={\r\\r
+    \n    (\$NotificationFunctions->\$FunctionName) (\"\\\$NotificationFunctio\\r
+    ns->\\\"\" . \$FunctionName . \"\\\"\") \$Notification;\r\\r
+    \n  }\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set SymbolByUnicodeName do={\r\\r
+    \n  :local Name [ :tostr \$1 ];\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :global SymbolsExtra;\r\\r
+    \n  :local Symbols ({\r\\r
+    \n    \"abacus\"=\"\\F0\\9F\\A7\\AE\";\r\\r
+    \n    \"alarm-clock\"=\"\\E2\\8F\\B0\";\r\\r
+    \n    \"arrow-down\"=\"\\E2\\AC\\87\";\r\\r
+    \n    \"arrow-up\"=\"\\E2\\AC\\86\";\r\\r
+    \n    \"calendar\"=\"\\F0\\9F\\93\\85\";\r\\r
+    \n    \"card-file-box\"=\"\\F0\\9F\\97\\83\";\r\\r
+    \n    \"chart-decreasing\"=\"\\F0\\9F\\93\\89\";\r\\r
+    \n    \"chart-increasing\"=\"\\F0\\9F\\93\\88\";\r\\r
+    \n    \"cloud\"=\"\\E2\\98\\81\";\r\\r
+    \n    \"cross-mark\"=\"\\E2\\9D\\8C\";\r\\r
+    \n    \"earth\"=\"\\F0\\9F\\8C\\8D\";\r\\r
+    \n    \"fire\"=\"\\F0\\9F\\94\\A5\";\r\\r
+    \n    \"floppy-disk\"=\"\\F0\\9F\\92\\BE\";\r\\r
+    \n    \"gear\"=\"\\E2\\9A\\99\";\r\\r
+    \n    \"heart\"=\"\\E2\\99\\A5\";\r\\r
+    \n    \"high-voltage-sign\"=\"\\E2\\9A\\A1\";\r\\r
+    \n    \"incoming-envelope\"=\"\\F0\\9F\\93\\A8\";\r\\r
+    \n    \"information\"=\"\\E2\\84\\B9\";\r\\r
+    \n    \"large-orange-circle\"=\"\\F0\\9F\\9F\\A0\";\r\\r
+    \n    \"large-red-circle\"=\"\\F0\\9F\\94\\B4\";\r\\r
+    \n    \"link\"=\"\\F0\\9F\\94\\97\";\r\\r
+    \n    \"lock-with-ink-pen\"=\"\\F0\\9F\\94\\8F\";\r\\r
+    \n    \"memo\"=\"\\F0\\9F\\93\\9D\";\r\\r
+    \n    \"mobile-phone\"=\"\\F0\\9F\\93\\B1\";\r\\r
+    \n    \"pushpin\"=\"\\F0\\9F\\93\\8C\";\r\\r
+    \n    \"scissors\"=\"\\E2\\9C\\82\";\r\\r
+    \n    \"scroll\"=\"\\F0\\9F\\93\\9C\";\r\\r
+    \n    \"smiley-partying-face\"=\"\\F0\\9F\\A5\\B3\";\r\\r
+    \n    \"smiley-smiling-face\"=\"\\E2\\98\\BA\";\r\\r
+    \n    \"smiley-winking-face-with-tongue\"=\"\\F0\\9F\\98\\9C\";\r\\r
+    \n    \"sparkles\"=\"\\E2\\9C\\A8\";\r\\r
+    \n    \"speech-balloon\"=\"\\F0\\9F\\92\\AC\";\r\\r
+    \n    \"star\"=\"\\E2\\AD\\90\";\r\\r
+    \n    \"warning-sign\"=\"\\E2\\9A\\A0\";\r\\r
+    \n    \"white-heavy-check-mark\"=\"\\E2\\9C\\85\"\r\\r
+    \n  }, \$SymbolsExtra);\r\\r
+    \n  :local Magic [ :pick [ /system/clock/get date ] 4 10 ];\r\\r
+    \n  :local Special {\r\\r
+    \n    \"information-04-01\"=\"\\F0\\9F\\9A\\BB\";\r\\r
+    \n    \"large-orange-circle-04-01\"=\"\\F0\\9F\\8D\\8A\";\r\\r
+    \n    \"large-orange-circle-10-31\"=\"\\F0\\9F\\8E\\83\";\r\\r
+    \n    \"large-red-circle-04-01\"=\"\\F0\\9F\\8D\\92\" };\r\\r
+    \n  :if ([ :len (\$Symbols->\$Name) ] = 0) do={\r\\r
+    \n    :log warning (\$0 . \"No symbol available for name '\" . \$Name . \"\\r
+    '!\");\r\\r
+    \n    :return \"\";\r\\r
+    \n  }\r\\r
+    \n  :return ([ \$EitherOr (\$Special->(\$Name . \$Magic)) (\$Symbols->\$Na\\r
+    me) ] . \"\\EF\\B8\\8F\");\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set SymbolForNotification do={\r\\r
+    \n  :global NotificationsWithSymbols;\r\\r
+    \n  :global SymbolByUnicodeName;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :if (\$NotificationsWithSymbols != true) do={:return [ \$IfThenElse ([\\r
+    \_:len \$2 ] > 0) ([ :tostr \$2 ] . \" \") \"\" ]}\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :foreach Symbol in=[ :toarray \$1 ] do={:set Return (\$Return . [ \$Sy\\r
+    mbolByUnicodeName \$Symbol ])}\r\\r
+    \n  :return (\$Return . \" \");\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set Unix2Dos do={:return [ :tocrlf [ :tostr \$1 ] ]}\r\\r
+    \n:set UrlEncode do={\r\\r
+    \n  :local Input [ :tostr \$1 ];\r\\r
+    \n  :if ([ :len \$Input ] = 0) do={:return \"\"}\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :local Chars (\"\\n\\r !\\\"#\\\$%&'()*+,:;<=>\?@[\\\\]^`{|}~\");\r\\r
+    \n  :local Subs { \"%0A\"; \"%0D\"; \"%20\"; \"%21\"; \"%22\"; \"%23\"; \"\\r
+    %24\"; \"%25\"; \"%26\"; \"%27\";\r\\r
+    \n         \"%28\"; \"%29\"; \"%2A\"; \"%2B\"; \"%2C\"; \"%3A\"; \"%3B\"; \\r
+    \"%3C\"; \"%3D\"; \"%3E\"; \"%3F\";\r\\r
+    \n         \"%40\"; \"%5B\"; \"%5C\"; \"%5D\"; \"%5E\"; \"%60\"; \"%7B\"; \\r
+    \"%7C\"; \"%7D\"; \"%7E\" };\r\\r
+    \n  :for I from=0 to=([ :len \$Input ] - 1) do={\r\\r
+    \n    :local Char [ :pick \$Input \$I ];\r\\r
+    \n    :local Replace [ :find \$Chars \$Char ];\r\\r
+    \n    :if ([ :typeof \$Replace ] = \"num\") do={:set Char (\$Subs->\$Repla\\r
+    ce)}\r\\r
+    \n    :set Return (\$Return . \$Char);\r\\r
+    \n  }\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set IsDNSResolving do={\r\\r
+    \n  :do {:resolve \"api.telegram.org\"} on-error={:return false}\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set IsFullyConnected do={\r\\r
+    \n  :global IsDNSResolving;\r\\r
+    \n  :global IsTimeSync;\r\\r
+    \n  :if ([ \$IsDNSResolving ] = false) do={:return false};\r\\r
+    \n  :if ([ \$IsTimeSync ] = false) do={:return false};\r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set IsTimeSync do={\r\\r
+    \n  :global IsTimeSyncCached;\r\\r
+    \n  :global IsTimeSyncResetNtp;\r\\r
+    \n  :if (\$IsTimeSyncCached = true) do={:return true}\r\\r
+    \n  :if ([ /system/ntp/client/get enabled ] = true) do={\r\\r
+    \n    :if ([ /system/ntp/client/get status ] = \"synchronized\") do={\r\\r
+    \n      :set IsTimeSyncCached true;\r\\r
+    \n      :return true;\r\\r
+    \n    }\r\\r
+    \n    :local Uptime [ /system/resource/get uptime ];\r\\r
+    \n    :if ([ :typeof \$IsTimeSyncResetNtp ] = \"nothing\") do={\r\\r
+    \n      :set IsTimeSyncResetNtp \$Uptime;\r\\r
+    \n    }\r\\r
+    \n    :if (\$Uptime - \$IsTimeSyncResetNtp < 3m) do={:return false}\r\\r
+    \n    :log warning \"\$0 The ntp client is configured, but did not sync.\"\\r
+    ;\r\\r
+    \n    :set IsTimeSyncResetNtp \$Uptime;\r\\r
+    \n    /system/ntp/client/set enabled=no;\r\\r
+    \n    :delay 20ms;\r\\r
+    \n    /system/ntp/client/set enabled=yes;\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :if ([ /system/license/get ]->\"level\" = \"free\" || \\\r\\r
+    \n       [ /system/resource/get ]->\"board-name\" = \"x86\") do={\r\\r
+    \n    :log debug \"\$0 No ntp client configured, relying on RTC for CHR fr\\r
+    ee license and x86.\";\r\\r
+    \n    :return true;\r\\r
+    \n  }\r\\r
+    \n  :if ([ /ip/cloud/get update-time ] = true) do={\r\\r
+    \n    :if ([ :typeof [ /ip/cloud/get public-address ] ] = \"ip\") do={\r\\r
+    \n      :set IsTimeSyncCached true;\r\\r
+    \n      :return true;\r\\r
+    \n    }\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n  :log debug \"\$0 No time source configured! Returning gracefully...\";\\r
+    \r\\r
+    \n  :return true;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set FetchHugeFiles do={\r\\r
+    \n  :local ScriptName [ :tostr \$1 ];\r\\r
+    \n  :local Url        [ :tostr \$2 ];\r\\r
+    \n  :local CheckCert  [ :tostr \$3 ];\r\\r
+    \n\r\\r
+    \n  :global CleanName;\r\\r
+    \n  :global FetchUserAgentStr;\r\\r
+    \n  :global GetRandom20CharAlNum;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :global LogPrint;\r\\r
+    \n  :global MkDir;\r\\r
+    \n  :global RmDir;\r\\r
+    \n  :global RmFile;\r\\r
+    \n  :global WaitForFile;\r\\r
+    \n\r\\r
+    \n  :set CheckCert [ \$IfThenElse (\$CheckCert = \"false\") \"no\" \"yes-w\\r
+    ithout-crl\" ];\r\\r
+    \n\r\\r
+    \n  :local DirName (\"tmpfs/\" . [ \$CleanName \$ScriptName ]);\r\\r
+    \n  :if ([ \$MkDir \$DirName ] = false) do={\r\\r
+    \n    \$LogPrint error \$0 (\"Failed creating directory!\");\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :local FileName (\$DirName . \"/\" . [ \$CleanName \$0 ] . \"-\" . [ \\r
+    \$GetRandom20CharAlNum ]);\r\\r
+    \n  :onerror Err {\r\\r
+    \n    /tool/fetch check-certificate=\$CheckCert \$Url dst-path=\$FileName \\r
+    \\\r\\r
+    \n      http-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] }) as-va\\r
+    lue;\r\\r
+    \n  } do={\r\\r
+    \n    :if ([ \$WaitForFile \$FileName 500ms ] = true) do={\r\\r
+    \n      \$RmFile \$FileName;\r\\r
+    \n    }\r\\r
+    \n    \$LogPrint debug \$0 (\"Failed downloading from \" . \$Url . \" - \"\\r
+    \_. \$Err);\r\\r
+    \n    \$RmDir \$DirName;\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :if ([ \$WaitForFile \$FileName 5s ] = false) do={\r\\r
+    \n    \$LogPrint debug \$0 (\"The file downloaded from \" . \$Url . \" did\\r
+    \_not show up.\");\r\\r
+    \n    :return false;\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :local FileSize [ /file/get \$FileName size ];\r\\r
+    \n  :local Return \"\";\r\\r
+    \n  :local VarSize 0;\r\\r
+    \n  :while (\$VarSize != \$FileSize) do={\r\\r
+    \n    :set Return (\$Return . ([ /file/read offset=\$VarSize chunk-size=32\\r
+    768 file=\$FileName as-value ]->\"data\"));\r\\r
+    \n    :set FileSize [ /file/get \$FileName size ];\r\\r
+    \n    :set VarSize [ :len \$Return ];\r\\r
+    \n    :if (\$VarSize > \$FileSize) do={\r\\r
+    \n      :delay 100ms;\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n  \$RmDir \$DirName;\r\\r
+    \n  :return \$Return;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set FetchUserAgentStr do={\r\\r
+    \n  :local Caller [ :tostr \$1 ];\r\\r
+    \n  :global GlobalScriptsUrl;\r\\r
+    \n  :global CommitBrief;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :local Resource [ /system/resource/get ];\r\\r
+    \n  :return (\"User-Agent: Mikrotik/\" . \$Resource->\"version\" . \" \" .\\r
+    \_\$Resource->\"architecture-name\" . \\\r\\r
+    \n    \" \" . \$Caller . \"/Fetch (\" . \$GlobalScriptsUrl . \"; \" . [ \$\\r
+    CommitBrief ] . \")\");\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:set ScriptInstallUpdate do={ :onerror Err {\r\\r
+    \n  :local Scripts    [ :toarray \$1 ];\r\\r
+    \n  :local NewComment [ :tostr   \$2 ];\r\\r
+    \n  :global InitSetup;\r\\r
+    \n\r\\r
+    \n  :global CommitId;\r\\r
+    \n  :global ScriptUpdatesCRLF;\r\\r
+    \n  :global GlobalConfVersion;\r\\r
+    \n  :global Identity;\r\\r
+    \n  :global CertificateAvailable;\r\\r
+    \n  :global CheckSumsVerify;\r\\r
+    \n  :global GlobalScriptsUrl;\r\\r
+    \n  :global SumsDirAndFileName;\r\\r
+    \n  :global GlobalScriptsUrlSuffix;\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :global FetchUserAgentStr;\r\\r
+    \n  :global Grep;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :global LogPrint;\r\\r
+    \n  :global ParseKeyValueStore;\r\\r
+    \n  :global RequiredRouterOS;\r\\r
+    \n  :global SendNotification2;\r\\r
+    \n  :global SymbolForNotification;\r\\r
+    \n  :global ValidateSyntax;\r\\r
+    \n  :global CommentsInScripts;\r\\r
+    \n\r\\r
+    \n  :if ([ \$CertificateAvailable \"Root YE\" \"fetch\" ] = false) do={\r\\r
+    \n    \$LogPrint warning \$0 (\"Downloading certificate failed, trying wit\\r
+    hout.\");\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :foreach Script in=\$Scripts do={\r\\r
+    \n    :if ([ :len [ /system/script/find where name=\$Script ] ] = 0) do={\\r
+    \r\\r
+    \n      \$LogPrint info \$0 (\"Adding new script: \" . \$Script);\r\\r
+    \n      /system/script/add name=\$Script owner=\$Script source=\"#!rsc by \\r
+    Vados\\n\" comment=\$NewComment;\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :local CommitIdBefore \$CommitId;\r\\r
+    \n  :local GlobalConfVersionBefore \$GlobalConfVersion;\r\\r
+    \n  :local ReloadGlobal false;\r\\r
+    \n  :local DeviceMode [ /system/device-mode/get ];\r\\r
+    \n\r\\r
+    \n  :if (\$CheckSumsVerify = true) do={\r\\r
+    \n    :local CheckSums ({});\r\\r
+    \n     :do {\r\\r
+    \n     :local Url (\$GlobalScriptsUrl . \$SumsDirAndFileName . \$GlobalScr\\r
+    iptsUrlSuffix);\r\\r
+    \n      \$LogPrint debug \$0 (\"Fetching checksums from url: \" . \$Url);\\r
+    \r\\r
+    \n      :set CheckSums [ :deserialize from=json ([ /tool/fetch check-certi\\r
+    ficate=yes-without-crl \\\r\\r
+    \n        http-header-field=({ [ \$FetchUserAgentStr \$0 ] }) \$Url output\\r
+    =user as-value ]->\"data\") ];\r\\r
+    \n    } on-error={ \$LogPrint warning \$0 (\"Err = \" . \$Err); }\r\\r
+    \n    }\r\\r
+    \n\r\\r
+    \n  :foreach Script in=[ /system/script/find where source~\"^#!rsc by Vado\\r
+    s\" ] do={\r\\r
+    \n    :local ScriptVal [ /system/script/get \$Script ];\r\\r
+    \n    :local ScriptInfo [ \$ParseKeyValueStore (\$ScriptVal->\"comment\") \\r
+    ];\r\\r
+    \n    :local SourceNew;\r\\r
+    \n\r\\r
+    \n    :foreach Scheduler in=[ /system/scheduler/find where on-event~(\"\\\\r
+    \\b\" . \$ScriptVal->\"name\" . \"\\\\b\") ] do={\r\\r
+    \n      :local SchedulerVal [ /system/scheduler/get \$Scheduler ];\r\\r
+    \n      :if (\$ScriptVal->\"policy\" != \$SchedulerVal->\"policy\") do={\r\\r
+    \n        \$LogPrint warning \$0 (\"Policies differ for script '\" . \$Scr\\r
+    iptVal->\"name\" . \"' and its scheduler '\" . \$SchedulerVal->\"name\" . \\r
+    \"'!\");\r\\r
+    \n        }\r\\r
+    \n    }\r\\r
+    \n    :do {\r\\r
+    \n      :if (\$ScriptInfo->\"ignore\" = true) do={\r\\r
+    \n        \$LogPrint debug \$0 (\"Ignoring script '\" . \$ScriptVal->\"nam\\r
+    e\" . \"', as requested.\");\r\\r
+    \n        :error true;\r\\r
+    \n      }\r\\r
+    \n      :if (\$CheckSumsVerify = true) do={\r\\r
+    \n        :local CheckSum (\$CheckSums->(\$ScriptVal->\"name\"));\r\\r
+    \n        :if ([ :len (\$ScriptInfo->\"base-url\") ] = 0 && [ :len (\$Scri\\r
+    ptInfo->\"url-suffix\") ] = 0 && \\\r\\r
+    \n             [ :convert transform=md5 to=hex [ :tolf (\$ScriptVal->\"sou\\r
+    rce\") ] ] = \$CheckSum) do={\r\\r
+    \n          \$LogPrint debug \$0 (\"Checksum for script '\" . \$ScriptVal-\\r
+    >\"name\" . \"' matches, ignoring.\");\r\\r
+    \n          :error true;\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n      :if ([ :len (\$ScriptInfo->\"certificate\") ] > 0) do={\r\\r
+    \n        :if ([ \$CertificateAvailable (\$ScriptInfo->\"certificate\") \"\\r
+    fetch\" ] = false) do={\r\\r
+    \n          \$LogPrint warning \$0 (\"Downloading certificate failed, tryi\\r
+    ng without.\");\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n      :onerror Err {\r\\r
+    \n        :local BaseUrl [ \$EitherOr (\$ScriptInfo->\"base-url\") \$Globa\\r
+    lScriptsUrl ];\r\\r
+    \n        :local UrlSuffix [ \$EitherOr (\$ScriptInfo->\"url-suffix\") \$G\\r
+    lobalScriptsUrlSuffix ];\r\\r
+    \n        :local Url (\$BaseUrl . \$ScriptVal->\"name\" . \".rsc\" . \$Url\\r
+    Suffix);\r\\r
+    \n        \$LogPrint warning \$0 (\"Fetching script '\" . (\$ScriptVal->\"\\r
+    name\") . \"' from url: \" . \$Url);\r\\r
+    \n        :local Result [ /tool/fetch check-certificate=yes-without-crl \\\\r
+    \r\\r
+    \n          http-header-field=({ [ \$FetchUserAgentStr \$0 ] }) \$Url outp\\r
+    ut=user as-value ];\r\\r
+    \n        :if (\$Result->\"status\" = \"finished\") do={\r\\r
+    \n          :set SourceNew [ :tolf (\$Result->\"data\") ];\r\\r
+    \n        } \r\\r
+    \n      } do={\r\\r
+    \n        \$LogPrint warning \$0 (\"Failed fetching script '\" . \$ScriptV\\r
+    al->\"name\" . \"': \" . \$Err);\r\\r
+    \n        :if (\$Err != \"Fetch failed with status 404\") do={\r\\r
+    \n          :error false;\r\\r
+    \n        }\r\\r
+    \n        :if (\$ScriptVal->\"source\" = \"#!rsc by Vados\") do={\r\\r
+    \n          \$LogPrint warning \$0 (\"Removing dummy. Typo on installation\\r
+    \?\");\r\\r
+    \n          /system/script/remove \$Script;\r\\r
+    \n          :error false;\r\\r
+    \n        }\r\\r
+    \n        :if (\$CheckSumsVerify = true) do={\r\\r
+    \n          :if ([ :len (\$ScriptInfo->\"base-url\") ] = 0 && [ :len (\$Sc\\r
+    riptInfo->\"url-suffix\") ] = 0 && \\\r\\r
+    \n               [ :len \$CheckSum ] = 0) do={\r\\r
+    \n            \$LogPrint warning \$0 (\"Added the script manually\? Skip u\\r
+    pdates with 'ignore=true' in comment.\");\r\\r
+    \n          }\r\\r
+    \n        }\r\\r
+    \n        :error false;\r\\r
+    \n      }\r\\r
+    \n\r\\r
+    \n      :if ([ :len \$SourceNew ] = 0) do={\r\\r
+    \n        \$LogPrint debug \$0 (\"No update for script '\" . (\$ScriptVal-\\r
+    >\"name\") . \"'.\");\r\\r
+    \n        :error false;\r\\r
+    \n      }\r\\r
+    \n\r\\r
+    \n      :local SourceCRLF [ :tocrlf \$SourceNew ];\r\\r
+    \n      :if (\$InitSetup != true && ((\$ScriptVal->\"name\") != \"AM-Globa\\r
+    lConfig\" || (\$ScriptVal->\"name\") != \"AM-GlobalFunc\")) do={\r\\r
+    \n        :if (\$SourceNew = (\$ScriptVal->\"source\") || \$SourceCRLF = (\\r
+    \$ScriptVal->\"source\")) do={\r\\r
+    \n          \$LogPrint debug \$0 (\"Script '\" .  (\$ScriptVal->\"name\") \\r
+    . \"' source did not change. End of lines set to CRLF.\");\r\\r
+    \n          if (\$ScriptUpdatesCRLF = false) do={\r\\r
+    \n            :put [ :tolf \$SourceNew ];\r\\r
+    \n            \$LogPrint debug \$0 (\"Script '\" .  (\$ScriptVal->\"name\"\\r
+    ) . \"' source update end of lines to LF.\");\r\\r
+    \n          }\r\\r
+    \n        :error false;\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n\r\\r
+    \n      :if ([ :pick \$SourceNew 0 14 ] != \"#!rsc by Vados\") do={\r\\r
+    \n        \$LogPrint warning \$0 (\"Looks like new script '\" . \$ScriptVa\\r
+    l->\"name\" . \"' is not valid (missing shebang = '\$shebang') Ignoring!\"\\r
+    );\r\\r
+    \n        :error false;\r\\r
+    \n      }\r\\r
+    \n\r\\r
+    \n      :if (\$CommentsInScripts = true) do={\r\\r
+    \n         :local CommentLine [ \$Grep \$SourceNew (\"\\23 Script comment:\\r
+    \_\") ];\r\\r
+    \n         :if ([ :len \$CommentLine ] = 0) do={\r\\r
+    \n           \$LogPrint debug \$0 (\"The search in new script '\" . (\$Scr\\r
+    iptVal->\"name\") . \"' for comment in script body, is not found result Ig\\r
+    noring!\");\r\\r
+    \n           :error false;\r\\r
+    \n         } else={\r\\r
+    \n           :if ([ :len (\$ScriptVal->\"comment\")] = 0 || [ :len (\$Scri\\r
+    ptVal->\"comment\")] != [ :pick \$CommentLine ([ :find \$CommentLine \":\"\\r
+    ] + 2) [ :len \$CommentLine] ]) do={\r\\r
+    \n             \$LogPrint debug \$0 (\"Exsiting comment for script '\" . (\\r
+    \$ScriptVal->\"name\") . \"' is '\" . (\$ScriptVal->\"comment\") . \"'.\")\\r
+    ;\r\\r
+    \n             :set (\$ScriptVal->\"comment\") [ :pick \$CommentLine ([ :f\\r
+    ind \$CommentLine \":\"] + 2) [ :len \$CommentLine] ];\r\\r
+    \n             \$LogPrint debug \$0 (\"New comment (\" . (\$ScriptVal->\"c\\r
+    omment\") . \") for script '\" . (\$ScriptVal->\"name\") . \"' has been ad\\r
+    ded!\");\r\\r
+    \n           } else={\r\\r
+    \n             \$LogPrint debug \$0 (\"Comment for script '\" . (\$ScriptV\\r
+    al->\"name\") . \"' did not change.\");\r\\r
+    \n             :error false;\r\\r
+    \n           }\r\\r
+    \n         }   \r\\r
+    \n      }\r\\r
+    \n\r\\r
+    \n      :local RequiredROS ([ \$ParseKeyValueStore [ \$Grep \$SourceNew (\\r
+    \"\\23 requires RouterOS, \") ] ]->version);\r\\r
+    \n      :if ([ \$RequiredRouterOS \$0 [ \$EitherOr \$RequiredROS \"0.0\" ]\\r
+    \_false ] = false) do={\r\\r
+    \n        \$LogPrint warning \$0 (\"The script '\" . (\$ScriptVal->\"name\\r
+    \") . \"' requires RouterOS \" . \\\r\\r
+    \n            \$RequiredROS . \", which is not met by your installation. I\\r
+    gnoring!\");\r\\r
+    \n        :error false;\r\\r
+    \n      }\r\\r
+    \n      :local RequiredDM [ \$ParseKeyValueStore [ \$Grep \$SourceNew (\"\\r
+    \\23 requires device-mode, \") ] ];\r\\r
+    \n      :local MissingDM ({});\r\\r
+    \n      :foreach Feature,Value in=\$RequiredDM do={\r\\r
+    \n        :if ([ :typeof (\$DeviceMode->\$Feature) ] = \"bool\" && (\$Devi\\r
+    ceMode->\$Feature) = false) do={\r\\r
+    \n          :set MissingDM (\$MissingDM, \$Feature);\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n      :if ([ :len \$MissingDM ] > 0) do={\r\\r
+    \n        \$LogPrint warning \$0 (\"The script '\" . (\$ScriptVal->\"name\\r
+    \") . \"' requires disabled \" . \\\r\\r
+    \n            \"device-mode features (\" . [ :tostr \$MissingDM ] . \"). I\\r
+    gnoring!\");\r\\r
+    \n        :error false;\r\\r
+    \n      }\r\\r
+    \n\r\\r
+    \n      :if ([ \$ValidateSyntax \$SourceNew ] = false) do={\r\\r
+    \n        \$LogPrint warning \$0 (\"Syntax validation for script '\" . (\$\\r
+    ScriptVal->\"name\") . \"' failed! Ignoring!\");\r\\r
+    \n        :error false;\r\\r
+    \n      }\r\\r
+    \n      \r\\r
+    \n      :log info (\"Updating script: \" . (\$ScriptVal->\"name\") . \" Sc\\r
+    ript comment: \" . (\$ScriptVal->\"comment\"));\r\\r
+    \n\r\\r
+    \n      /system/script/set owner=(\$ScriptVal->\"name\") comment=(\$Script\\r
+    Val->\"comment\") \\\r\\r
+    \n          source=[ \$IfThenElse (\$ScriptUpdatesCRLF = true) \$SourceCRL\\r
+    F \$SourceNew ] \$Script;\r\\r
+    \n      :if (\$ScriptVal->\"name\" = \"AM-GlobalConfig\" || \\\r\\r
+    \n           \$ScriptVal->\"name\" = \"AM-GlobalFunc\" || \\\r\\r
+    \n           \$ScriptVal->\"name\" ~ (\"^(AM-GlobalFunc\\\\.d|mod)/.\")) d\\r
+    o={\r\\r
+    \n        :set ReloadGlobal true;\r\\r
+    \n      }\r\\r
+    \n    } on-error={ }\r\\r
+    \n  }\r\\r
+    \n  :if (\$ReloadGlobal = true) do={\r\\r
+    \n    \$LogPrint info \$0 (\"Reloading global configuration and functions.\\r
+    \");\r\\r
+    \n    :onerror Err {\r\\r
+    \n      :global InitSetup (a);\r\\r
+    \n      /system/script {run AM-GlobalConfig; run AM-GlobalFunc;};\r\\r
+    \n    } do={\$LogPrint error \$0 (\"Reloading global configuration and fun\\r
+    ctions failed! \" . \$Err)}\r\\r
+    \n  }\r\\r
+    \n  :if (\$GlobalConfVersionBefore > \$GlobalConfVersion) do={\r\\r
+    \n    \$LogPrint warning \$0 (\"The configuration version decreased from \\r
+    \" . \\\r\\r
+    \n      \$GlobalConfVersionBefore . \" to \" . \$GlobalConfVersion . \\\r\\r
+    \n      \". Installed an older version\?\");\r\\r
+    \n  }\r\\r
+    \n    :if (\$GlobalConfVersionBefore < \$GlobalConfVersion) do={\r\\r
+    \n    :global GlobalConfChanges;\r\\r
+    \n    :global GlobalConfMigration;\r\\r
+    \n    :local ChangeLogCode;\r\\r
+    \n    :if ([ :len \$ChangeLogCode ] > 0) do={\r\\r
+    \n      :if ([ \$ValidateSyntax \$ChangeLogCode ] = true) do={\r\\r
+    \n        :onerror Err {\r\\r
+    \n          [ :parse \$ChangeLogCode ];\r\\r
+    \n        } do={\$LogPrint warning \$0 (\"The changelog failed to run: \" \\r
+    . \$Err)}\r\\r
+    \n      } else={\$LogPrint warning \$0 (\"The changelog failed syntax vali\\r
+    dation!\")}\r\\r
+    \n    }\r\\r
+    \n    :if ([ :len \$GlobalConfMigration ] > 0) do={\r\\r
+    \n      :for I from=(\$GlobalConfVersionBefore + 1) to=\$GlobalConfVersion\\r
+    \_do={\r\\r
+    \n        :local Migration (\$GlobalConfMigration->[ :tostr \$I ]);\r\\r
+    \n        :do {\r\\r
+    \n          :if ([ :typeof \$Migration ] != \"str\") do={\r\\r
+    \n            \$LogPrint debug \$0 (\"Migration code for change \" . \$I .\\r
+    \_\" is not available.\");\r\\r
+    \n            :error false;\r\\r
+    \n          }\r\\r
+    \n          :if ([ \$ValidateSyntax \$Migration ] = false) do={\r\\r
+    \n            \$LogPrint warning \$0 (\"Migration code for change \" . \$I\\r
+    \_. \" failed syntax validation!\");\r\\r
+    \n            :error false}\r\\r
+    \n          \$LogPrint info \$0 (\"Applying migration for change \" . \$I \\r
+    . \": \" . \$Migration);\r\\r
+    \n          :onerror Err {\r\\r
+    \n            [ :parse \$Migration ];\r\\r
+    \n          } do={\$LogPrint warning \$0 (\"Migration code for change \" .\\r
+    \_\$I . \" failed to run: \" . \$Err)}\r\\r
+    \n        } on-error={ }\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n    :local NotificationMessage (\"The configuration version on \" . \$Id\\r
+    entity . \" increased \" . \\\r\\r
+    \n       \"to \" . \$GlobalConfVersion . \", current configuration may nee\\r
+    d modification. \" . \\\r\\r
+    \n       \"Please review and update global-config-overlay, then re-run glo\\r
+    bal-config.\");\r\\r
+    \n    \$LogPrint info \$0 (\$NotificationMessage);\r\\r
+    \n    :if ([ :len \$GlobalConfChanges ] > 0) do={\r\\r
+    \n      :set NotificationMessage (\$NotificationMessage . \"\\n\\nChanges:\\r
+    \");\r\\r
+    \n      :for I from=(\$GlobalConfVersionBefore + 1) to=\$GlobalConfVersion\\r
+    \_do={\r\\r
+    \n        :local Change (\$GlobalConfChanges->[ :tostr \$I ]);\r\\r
+    \n        :set NotificationMessage (\$NotificationMessage . \"\\n \" . \\\\r
+    \r\\r
+    \n            [ \$SymbolForNotification \"pushpin\" \"*\" ] . \$Change);\r\\r
+    \n        \$LogPrint info \$0 (\"Change \" . \$I . \": \" . \$Change);\r\\r
+    \n      }\r\\r
+    \n    } else={\r\\r
+    \n      :set NotificationMessage (\$NotificationMessage . \"\\n\\nNews and\\r
+    \_changes are not available.\");\r\\r
+    \n\r\\r
+    \n      }\r\\r
+    \n\r\\r
+    \n    :if ([ :len \$GlobalConfChanges ] > 0) do={ :set GlobalConfChanges; \\r
+    } else={ :global GlobalConfChanges (a); }\r\\r
+    \n    :if ([ :len \$GlobalConfMigration ] > 0) do={ :set GlobalConfMigrati\\r
+    on; } else={ :global GlobalConfMigration (a); }\r\\r
+    \n  }\r\\r
+    \n} do={\r\\r
+    \n  :global ExitOnError; \$ExitOnError \$0 \$Err;\r\\r
+    \n} }\r\\r
+    \n\r\\r
+    \n# load modules\r\\r
+    \n:foreach Script in=[ /system/script/find where name ~ \"^(global-functio\\r
+    ns\\\\.d|mod)/.\" ] do={\r\\r
+    \n  :local ScriptVal [ /system/script/get \$Script ];\r\\r
+    \n  :if ([ \$ValidateSyntax (\$ScriptVal->\"source\") ] = true) do={\r\\r
+    \n    :onerror Err {\r\\r
+    \n      /system/script/run \$Script;\r\\r
+    \n    } do={\r\\r
+    \n      \$LogPrint error \$0 (\"Module '\" . \$ScriptVal->\"name\" . \"' f\\r
+    ailed to run: \" . \$Err);\r\\r
+    \n    }\r\\r
+    \n  } else={\r\\r
+    \n    \$LogPrint error \$0 (\"Module '\" . \$ScriptVal->\"name\" . \"' fai\\r
+    led syntax validation, skipping.\");\r\\r
+    \n  }\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n# Add and fix global scheduler\r\\r
+    \n:put \"Add or/and fix Global scheduler...\";\r\\r
+    \n:local OnEvent \"/system/script { run AM-GlobalConfig; run AM-GlobalFunc\\r
+    ; }\";\r\\r
+    \n:local Comment \"Every Day Set Global Environment Variables\";\r\\r
+    \n:if ([ :len [ /system/scheduler/find where name=\"AM-SetGlobalEnv\" ] ] \\r
+    = 0) do={\r\\r
+    \n  /system/scheduler/add name=\"AM-SetGlobalEnv\" comment=\$Comment on-ev\\r
+    ent=\$OnEvent start-time=startup;\r\\r
+    \n}\r\\r
+    \n:if ([ /system/scheduler/get \"AM-SetGlobalEnv\" comment ] != \$Comment)\\r
+    \_do={\r\\r
+    \n  /system/scheduler/set \"AM-SetGlobalEnv\" comment=\$Comment;\r\\r
+    \n}\r\\r
+    \n:if ([ /system/scheduler/get \"AM-SetGlobalEnv\" on-event ] != \$OnEvent\\r
+    ) do={\r\\r
+    \n  /system/scheduler/set \"AM-SetGlobalEnv\" on-event=\$OnEvent;\r\\r
+    \n}\r\\r
+    \n# Add Update Script scheduler\r\\r
+    \n:put \"Add or/and fix Update Script scheduler\";\r\\r
+    \n:set OnEvent \":global ScriptInstallUpdate; \\\$ScriptInstallUpdate;\";\\r
+    \r\\r
+    \n:set Comment \"Every Day Check For Update Scripts\";\r\\r
+    \n:if ([ :len [ /system/scheduler/find where name=\"AM-ScriptInstallUpdate\\r
+    \" ] ] = 0) do={\r\\r
+    \n/system/scheduler/add name=\"AM-ScriptInstallUpdate\" comment=\$Comment \\r
+    start-time=startup interval=1d on-event=\$OnEvent;\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:onerror Err {\r\\r
+    \n  :global GlobalConfReady;\r\\r
+    \n  :retry { :if (\$GlobalConfReady != true) do={ :error (\"Global configs\\r
+    \_not ready.\"); }; } delay=100ms max=5;\r\\r
+    \n\r\\r
+    \n:log warning (\"This script \$ScriptName Loaded \" . \\\r\\r
+    \n    [ \$IfThenElse (\$CommitId != \"unknown\") ([ \$CommitBrief ] . \" \\r
+    \") ] . \\\r\\r
+    \n    \"on \" . \$devBoardName . \"\\nRouterOS: \" . \$devCurVersion . \"\\r
+    \\nArchitecture: \" . \$devCurArch . \"\\nIdentity: \" . \$Identity);\r\\r
+    \n    # signal we are ready\r\\r
+    \n:set GlobalFuncReady true;\r\\r
+    \n:set ExitOK true;\r\\r
+    \n\r\\r
+    \n:log info (\$0 . \"Global configs ready!\");\r\\r
+    \n} do={\r\\r
+    \n  :global ExitOnError; \$ExitOnError \$0 \$Err;\r\\r
+    \n}\r\\r
+    \n"\r
+add comment="download, import and update firewall address-lists" \\r
+    dont-require-permissions=no name=AM-FwAddrLists owner=AM-FwAddrLists \\r
+    policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \\r
+    source="#!rsc by Vados\r\\r
+    \n# RouterOS script: AM-FwAddrLists\r\\r
+    \n# Script comment: download, import and update firewall address-lists\r\\r
+    \n# Copyright (c) 2007-2026 Vados <vados@vados.ru>\r\\r
+    \n#\r\\r
+    \n#\r\\r
+    \n# requires RouterOS, version=7.19\r\\r
+    \n# https://ros.vados.ru/doc/fw-addr-lists.md\r\\r
+    \n:local ExitOK false;\r\\r
+    \n:onerror Err {\r\\r
+    \n  :global GlobalConfReady; :global GlobalFuncReady;\r\\r
+    \n  :retry { :if (\$GlobalConfReady != true || \$GlobalFuncReady != true) \\r
+    \\\r\\r
+    \n      do={ :error (\"Global config and/or functions not ready.\"); }; } \\r
+    delay=500ms max=50;\r\\r
+    \n  :local ScriptName [ :jobname ];\r\\r
+    \n\r\\r
+    \n  :global GlobalScriptsUrl;\r\\r
+    \n  :local ListsDirName (\"fw-addr-lists.d/\" . [ /system identity get nam\\r
+    e ] . \"/\");\r\\r
+    \n  :local ListsUrl (\$GlobalScriptsUrl . \$ListsDirName);\r\\r
+    \n  :local ListsIndex \"index.lst\";\r\\r
+    \n  :local AddrListsTimeOut 1d;\r\\r
+    \n  :local CheckCerts false;\r\\r
+    \n\r\\r
+    \n  :global CertificateAvailable;\r\\r
+    \n  :global EitherOr;\r\\r
+    \n  :global FetchHugeFiles;\r\\r
+    \n  :global HumanReadableNum;\r\\r
+    \n  :global IfThenElse;\r\\r
+    \n  :global LogPrint;\r\\r
+    \n  :global NetMask4;\r\\r
+    \n  :global NetMask6;\r\\r
+    \n  :global ScriptLock;\r\\r
+    \n  \r\\r
+    \n  :local FindDelim do={\r\\r
+    \n    :local ValidChars \"0123456789.:/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi\\r
+    jklmnopqrstuvwxyz-\";\r\\r
+    \n    :for I from=0 to=[ :len \$1 ] do={\r\\r
+    \n      :if ([ :typeof [ :find \$ValidChars [ :pick (\$1 . \" \") \$I ] ] \\r
+    ] != \"num\") do={\r\\r
+    \n        :return \$I;\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :local GetBranch do={\r\\r
+    \n    :global EitherOr;\r\\r
+    \n    :return [ :pick [ :convert transform=md5 to=hex [ :pick \$1 0 [ \$Ei\\r
+    therOr [ :find \$1 \"/\" ] [ :len \$1 ] ] ] ] 0 2 ];\r\\r
+    \n  }\r\\r
+    \n    \r\\r
+    \n  :if ([ \$ScriptLock \$ScriptName ] = false) do={\r\\r
+    \n    :set ExitOK true;\r\\r
+    \n    :error false;\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :local ListComment (\"managed by \" . \$ScriptName);\r\\r
+    \n  :local Url (\$ListsUrl . \$ListsIndex);\r\\r
+    \n  :local tmpIndex false;\r\\r
+    \n\r\\r
+    \n  :for I from=1 to=5 do={\r\\r
+    \n    :if (\$tmpIndex = false) do={\r\\r
+    \n      :set tmpIndex [ :tolf [ \$FetchHugeFiles \$ScriptName \$Url \$Chec\\r
+    kCerts ] ];\r\\r
+    \n      :if (\$tmpIndex = false && \$I < 5) do={\r\\r
+    \n        :log warning (\$ScriptName . \" Failed downloading address-list \\r
+    index, \" . \$I . \". try from: \" . \$Url);\r\\r
+    \n        :delay ((\$I * \$I) . \"s\");\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n  }\r\\r
+    \n  :if (\$tmpIndex = false) do={\r\\r
+    \n    :log warning (\$ScriptName . \" Failed downloading address-list inde\\r
+    x from: \" . \$Url);\r\\r
+    \n    :set tmpIndex \"\";\r\\r
+    \n  }\r\\r
+    \n\r\\r
+    \n  :foreach List in=[ :deserialize \$tmpIndex delimiter=\"\\n\" from=dsv \\r
+    options=dsv.plain ] do={\r\\r
+    \n#    :set List (\$List->0);\r\\r
+    \n    :local ListName;\r\\r
+    \n    :local Delim [ \$FindDelim \$List ];\r\\r
+    \n    :if (\$Delim = 0) do={ :set List \"\"; };\r\\r
+    \n    :log warning (\$ScriptName . \" Parsing address-list index entry: \"\\r
+    \_. \$List);\r\\r
+    \n    :if ([ :len \$List ] = 0) do={\r\\r
+    \n      :log error (\$ScriptName . \" Failed parsing address-list index en\\r
+    try: \" . \$List);\r\\r
+    \n      } else={\r\\r
+    \n        :set ListName [ :pick \$List 0 \$Delim ];\r\\r
+    \n      }\r\\r
+    \n    :log warning (\$ScriptName . \" Parsing address-list index entry: \"\\r
+    \_. \$ListName . \" - Ok.\");\r\\r
+    \n    :local ListUrl (\$ListsUrl . \$ListName);\r\\r
+    \n    :local CntAdd 0;\r\\r
+    \n    :local CntRenew 0;\r\\r
+    \n    :local CntRemove 0;\r\\r
+    \n    :local IPv4Addresses ({});\r\\r
+    \n    :local IPv6Addresses ({});\r\\r
+    \n    :local Failure false;\r\\r
+    \n    :local Data false;\r\\r
+    \n    :local TimeOut \$AddrListTimeOut;\r\\r
+    \n\r\\r
+    \n    :for I from=1 to=5 do={\r\\r
+    \n      :if (\$Data = false) do={\r\\r
+    \n        :set Data [ :tolf [ \$FetchHugeFiles \$ScriptName \$ListUrl \$Ch\\r
+    eckCerts ] ];\r\\r
+    \n        :if (\$Data = false && \$I < 5) do={\r\\r
+    \n          :log warning (\$ScriptName . \" Failed downloading for list '\\r
+    \" . \$ListName . \"', \" . \$I . \". try from: \" . \$ListUrl);\r\\r
+    \n          :delay ((\$I * \$I) . \"s\");\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n\r\\r
+    \n    :if (\$Data = false) do={\r\\r
+    \n      :set Data \"\";\r\\r
+    \n      :set Failure true;\r\\r
+    \n      :log warning (\$ScriptName . \" Failed downloading for list '\" . \\r
+    \$ListName . \"' from: \" . \$ListUrl);\r\\r
+    \n    } else={\r\\r
+    \n      :log warning (\$ScriptName . \" Downloaded \" . [ \$HumanReadableN\\r
+    um [ :len \$Data ] 1024 ] . \"B for list '\" . \$ListName . \"' from: \" .\\r
+    \_\$ListUrl);\r\\r
+    \n    }\r\\r
+    \n\r\\r
+    \n    :foreach Line in=[ :deserialize \$Data delimiter=\"\\n\" from=dsv op\\r
+    tions=dsv.plain ] do={\r\\r
+    \n      :set Line (\$Line->0);\r\\r
+    \n      :local Address;\r\\r
+    \n      :if ([ :pick \$Line 0 1 ] = \"{\" && [ :pick \$Line ([ :len \$Line\\r
+    \_] - 1) ] = \"}\") do={\r\\r
+    \n        :do {\r\\r
+    \n          :set Address [ :tostr ([ :deserialize from=json \$Line ]->\"ci\\r
+    dr\") ];\r\\r
+    \n        } on-error={ }\r\\r
+    \n      } else={\r\\r
+    \n          :set Address ([ :pick \$Line 0 [ \$FindDelim \$Line ] ] . (\$L\\r
+    ist->\"cidr\"));\r\\r
+    \n      }\r\\r
+    \n      :do {\r\\r
+    \n        :local Branch;\r\\r
+    \n        :if (\$Address ~ \"^[0-9]{1,3}\\\\.[0-9]{1,3}\\\\.[0-9]{1,3}\\\\\\r
+    .[0-9]{1,3}(/[0-9]{1,2})\?\\\$\") do={\r\\r
+    \n          :local Net \$Address;\r\\r
+    \n          :local CIDR 32;\r\\r
+    \n          :local Slash [ :find \$Address \"/\" ];\r\\r
+    \n          :if ([ :typeof \$Slash ] = \"num\") do={\r\\r
+    \n            :set Net [ :toip [ :pick \$Address 0 \$Slash ] ]\r\\r
+    \n            :set CIDR [ :pick \$Address (\$Slash + 1) [ :len \$Address ]\\r
+    \_];\r\\r
+    \n            :set Address [ :tostr (([ :toip \$Net ] & [ \$NetMask4 \$CID\\r
+    R ]) . [ \$IfThenElse (\$CIDR < 32) (\"/\" . \$CIDR) ]) ];\r\\r
+    \n          }\r\\r
+    \n          :set Branch [ \$GetBranch \$Address ];\r\\r
+    \n          :set (\$IPv4Addresses->\$Branch->\$Address) \$TimeOut;\r\\r
+    \n        }\r\\r
+    \n        :if (\$Address ~ \"^[0-9a-zA-Z]*:[0-9a-zA-Z:\\\\.]+(/[0-9]{1,3})\\r
+    \?\\\$\") do={\r\\r
+    \n          :local Net \$Address;\r\\r
+    \n          :local CIDR 128;\r\\r
+    \n          :local Slash [ :find \$Address \"/\" ];\r\\r
+    \n          :if ([ :typeof \$Slash ] = \"num\") do={\r\\r
+    \n            :set Net [ :toip6 [ :pick \$Address 0 \$Slash ] ]\r\\r
+    \n            :set CIDR [ :pick \$Address (\$Slash + 1) [ :len \$Address ]\\r
+    \_];\r\\r
+    \n          }\r\\r
+    \n          :set Address (([ :toip6 \$Net ] & [ \$NetMask6 \$CIDR ]) . \"/\\r
+    \" . \$CIDR);\r\\r
+    \n          :set Branch [ \$GetBranch \$Address ];\r\\r
+    \n          :set (\$IPv6Addresses->\$Branch->\$Address) \$TimeOut;\r\\r
+    \n        }\r\\r
+    \n        :if (\$Address ~ \"^[\\\\.a-zA-Z0-9-]+\\\\.[a-zA-Z]{2,}\\\$\") d\\r
+    o={\r\\r
+    \n          :set Branch [ \$GetBranch \$Address ];\r\\r
+    \n          :set (\$IPv4Addresses->\$Branch->\$Address) \$TimeOut;\r\\r
+    \n          :set (\$IPv6Addresses->\$Branch->\$Address) \$TimeOut;\r\\r
+    \n        }\r\\r
+    \n      } on-error={ }\r\\r
+    \n    }\r\\r
+    \n  \r\\r
+    \n\r\\r
+    \n    :foreach Entry in=[ /ip/firewall/address-list/find where \\\r\\r
+    \n        list=\$ListName comment=\$ListComment ] do={\r\\r
+    \n      :local Address [ /ip/firewall/address-list/get \$Entry address ];\\r
+    \r\\r
+    \n      :local Branch [ \$GetBranch \$Address ];\r\\r
+    \n      :local TimeOut (\$IPv4Addresses->\$Branch->\$Address);\r\\r
+    \n      :if ([ :typeof \$TimeOut ] = \"time\") do={\r\\r
+    \n        :log warning (\$ScriptName . \" Renewing IPv4 address \" . \$Add\\r
+    ress . \\\r\\r
+    \n            \" in list '\" . \$ListName . \"' with \" . \$TimeOut . \".\\r
+    \");\r\\r
+    \n        /ip/firewall/address-list/set \$Entry timeout=\$TimeOut;\r\\r
+    \n        :set (\$IPv4Addresses->\$Branch->\$Address);\r\\r
+    \n        :set CntRenew (\$CntRenew + 1);\r\\r
+    \n      } else={\r\\r
+    \n        :if (\$Failure = false) do={\r\\r
+    \n          :log warning (\$ScriptName . \" Removing IPv4 address \" . \$A\\r
+    ddress . \\\r\\r
+    \n              \" from list '\" . \$ListName . \".\");\r\\r
+    \n          /ip/firewall/address-list/remove \$Entry;\r\\r
+    \n          :set CntRemove (\$CntRemove + 1);\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n\r\\r
+    \n    :foreach Entry in=[ /ipv6/firewall/address-list/find where \\\r\\r
+    \n        list=\$ListName comment=\$ListComment ] do={\r\\r
+    \n      :local Address [ /ipv6/firewall/address-list/get \$Entry address ]\\r
+    ;\r\\r
+    \n      :local Branch [ \$GetBranch \$Address ];\r\\r
+    \n      :local TimeOut (\$IPv6Addresses->\$Branch->\$Address);\r\\r
+    \n      :if ([ :typeof \$TimeOut ] = \"time\") do={\r\\r
+    \n        :log warning (\$ScriptName . \" Renewing IPv6 address \" . \$Add\\r
+    ress . \\\r\\r
+    \n            \" in list '\" . \$ListName . \"' with \" . \$TimeOut . \".\\r
+    \");\r\\r
+    \n        /ipv6/firewall/address-list/set \$Entry timeout=\$TimeOut;\r\\r
+    \n        :set (\$IPv6Addresses->\$Branch->\$Address);\r\\r
+    \n        :set CntRenew (\$CntRenew + 1);\r\\r
+    \n      } else={\r\\r
+    \n        :if (\$Failure = false) do={\r\\r
+    \n          :log warning (\$ScriptName . \" Removing IPv6 address \" . \$A\\r
+    ddress . \\\r\\r
+    \n              \" from list '\" . \$ListName . \".\");\r\\r
+    \n          /ipv6/firewall/address-list/remove \$Entry;\r\\r
+    \n          :set CntRemove (\$CntRemove + 1);\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n\r\\r
+    \n    :foreach BranchName,Branch in=\$IPv4Addresses do={\r\\r
+    \n      :log warning (\$ScriptName . \" Handling branch: \" . \$BranchName\\r
+    );\r\\r
+    \n      :foreach Address,Timeout in=\$Branch do={\r\\r
+    \n        :log warning (\$ScriptName . \" Adding IPv4 address \" . \$Addre\\r
+    ss . \\\r\\r
+    \n            \" to list '\" . \$ListName . \"' with \" . \$Timeout . \".\\r
+    \");\r\\r
+    \n        :onerror Err {\r\\r
+    \n          /ip/firewall/address-list/add list=\$ListName comment=\$ListCo\\r
+    mment \\\r\\r
+    \n              address=\$Address timeout=\$Timeout;\r\\r
+    \n          :set CntAdd (\$CntAdd + 1);\r\\r
+    \n        } do={\r\\r
+    \n          :log warning (\$ScriptName . \" Failed to add IPv4 address \" \\r
+    . \$Address . \\\r\\r
+    \n              \" to list '\" . \$ListName . \"': \" . \$Err);\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n\r\\r
+    \n    :foreach BranchName,Branch in=\$IPv6Addresses do={\r\\r
+    \n      :log warning (\$ScriptName . \" Handling branch: \" . \$BranchName\\r
+    );\r\\r
+    \n      :foreach Address,Timeout in=\$Branch do={\r\\r
+    \n        :log warning (\$ScriptName . \" Adding IPv6 address \" . \$Addre\\r
+    ss . \\\r\\r
+    \n            \" to list '\" . \$ListName . \"' with \" . \$Timeout . \".\\r
+    \");\r\\r
+    \n        :onerror Err {\r\\r
+    \n          /ipv6/firewall/address-list/add list=\$ListName comment=\$List\\r
+    Comment \\\r\\r
+    \n              address=\$Address timeout=\$Timeout;\r\\r
+    \n          :set CntAdd (\$CntAdd + 1);\r\\r
+    \n        } do={\r\\r
+    \n          :log warning (\$ScriptName . \" Failed to add IPv6 address \" \\r
+    . \$Address . \\\r\\r
+    \n              \" to list '\" . \$ListName . \"': \" . \$Err);\r\\r
+    \n        }\r\\r
+    \n      }\r\\r
+    \n    }\r\\r
+    \n\r\\r
+    \n    :log info (\$ScriptName . \" list: \" . \$ListName . \\\r\\r
+    \n        \" (\" . [ \$HumanReadableNum (\$CntAdd + \$CntRenew) 1000 ] . \\r
+    \")\" . \\\r\\r
+    \n        \" -- added: \" . [ \$HumanReadableNum \$CntAdd 1000 ] . \\\r\\r
+    \n        \" - renewed: \" . [ \$HumanReadableNum \$CntRenew 1000 ] . \\\r\\r
+    \n        \" - removed: \" . [ \$HumanReadableNum \$CntRemove 1000 ]);\r\\r
+    \n  }\r\\r
+    \n} do={\r\\r
+    \n  :global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err;\r\\r
+    \n}\r\\r
+    \n"\r
+add comment=\\r
+    "Lookup IP addresses for RKN list and add them to firewall address-list" \\r
+    dont-require-permissions=no name=AM-RKN-dnsLookup owner=AM-RKN-dnsLookup \\r
+    policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \\r
+    source="#!rsc by Vados\r\\r
+    \n# RouterOS script: AM-RKN-dnsLookup\r\\r
+    \n# Script comment: Lookup IP addresses for RKN list and add them to firew\\r
+    all address-list\r\\r
+    \n# Copyright (c) 2007-2026 Vados <vados@vados.ru>\r\\r
+    \n#\r\\r
+    \n#\r\\r
+    \n# requires RouterOS, version=7.19\r\\r
+    \n# requires device-mode, fetch\r\\r
+    \n#\r\\r
+    \n# Script description: This script is intended to be run periodically, e.\\r
+    g. once a day, to update the IP addresses in the firewall address-list bas\\r
+    ed on the RKN list.\r\\r
+    \n#                     It resolves the domain names in the RKN list and a\\r
+    dds the corresponding IP addresses to the specified firewall address-list.\\r
+    \r\\r
+    \n#                     The script also handles CNAME records by following\\r
+    \_them until it finds A records.\r\\r
+    \n# Usage:\r\\r
+    \n# /system/script { run AM-RKN-dnsLookup; }\r\\r
+    \n:local ScriptName [ :jobname ];\r\\r
+    \n\r\\r
+    \n:global dnsLookupReady false;\r\\r
+    \n:if ([:typeof \$dnsLookupReady] != \"boolean\") do={ :set dnsLookupReady\\r
+    \_true; }\r\\r
+    \nwhile (!\$dnsLookupReady) do={ :nothing; }\r\\r
+    \n:set dnsLookupReady false;\r\\r
+    \n\r\\r
+    \n:local arrRKN {\r\\r
+    \n  \"telegra.ph\"\r\\r
+    \n  \"grani.ru\"\r\\r
+    \n  \"xhamster.com\"\r\\r
+    \n  \"kasparov.ru\"\r\\r
+    \n  \"lostfilm.tv\"\r\\r
+    \n  \"rutracker.org\"\r\\r
+    \n  \"lurkmore.to\"\r\\r
+    \n  \"dou.ua\"\r\\r
+    \n  \"youporn.com\"\r\\r
+    \n  \"pornolab.net\"\r\\r
+    \n  \"crimerussia.com\"\r\\r
+    \n  \"telegram.org\"\r\\r
+    \n  \"api.telegram.org\"\r\\r
+    \n  \"telegram.me\"\r\\r
+    \n  \"t.me\";}\r\\r
+    \n\r\\r
+    \n:local ListRKN \"FuckRKN\";\r\\r
+    \n:local ListComment (\"ListRKN managed by \" . \$ScriptName);\r\\r
+    \n:foreach aListItem in=[/ip/firewall/address-list find list=\$ListRKN] do\\r
+    ={\r\\r
+    \n    /ip firewall address-list remove \$aListItem;\r\\r
+    \n}\r\\r
+    \n:foreach aItem in=\$arrRKN do={\r\\r
+    \n    :do {\r\\r
+    \n        :resolve \$aItem;\r\\r
+    \n    } on-error={\r\\r
+    \n        :log error \"dns resolve failure [ ip - resolve ip ]\";\r\\r
+    \n    }\r\\r
+    \n    :foreach dnsRecord in=[/ip dns cache all find where (name=\$aItem)] \\r
+    do={\r\\r
+    \n        :if ([/ip dns cache all get \$dnsRecord type]=\"A\") do={\r\\r
+    \n            :local newAddress [/ip dns cache all get \$dnsRecord data];\\r
+    \r\\r
+    \n            :do {\r\\r
+    \n                /ip firewall address-list add list=\$ListRKN address=\$n\\r
+    ewAddress comment=\$aItem;\r\\r
+    \n            } on-error={\r\\r
+    \n                :log error \"error when adding ip to list: \$newAddress\\r
+    \";\r\\r
+    \n            }\r\\r
+    \n        }\r\\r
+    \n        :if ([/ip dns cache all get \$dnsRecord type]=\"CNAME\") do={\r\\r
+    \n            :local cname;\r\\r
+    \n            :local nextCname;\r\\r
+    \n            :set cname [/ip dns cache all find where (name=\$aItem && ty\\r
+    pe=\"CNAME\")];\r\\r
+    \n            :set nextCname [/ip dns cache all find where (name=[/ip dns \\r
+    cache all get \$cname data] && type=\"CNAME\")];\r\\r
+    \n            :while (\$nextCname != \"\") do={\r\\r
+    \n                :set cname \$nextCname;\r\\r
+    \n                :set nextCname [/ip dns cache all find where (name=[/ip \\r
+    dns cache all get \$cname data] && type=\"CNAME\")];\r\\r
+    \n            }\r\\r
+    \n            :foreach aRecord in=[/ip dns cache all find where (name=[/ip\\r
+    \_dns cache all get \$cname data] && type=\"A\")] do={\r\\r
+    \n                :do {\r\\r
+    \n                    /ip firewall address-list add list=\$ListRKN address\\r
+    =[/ip dns cache all get \$aRecord data] comment=\$aItem;\r\\r
+    \n                } on-error={\r\\r
+    \n                    :log error \"error when adding ip to list: \$newAddr\\r
+    ess\";\r\\r
+    \n                }\r\\r
+    \n            }\r\\r
+    \n        }\r\\r
+    \n    }\r\\r
+    \n}\r\\r
+    \n\r\\r
+    \n:if ([ :len [ /system/scheduler/find where name=\$ScriptName ] ] = 0) do\\r
+    ={\r\\r
+    \n   :log error (\$ScriptName . \"System Scheduler for script: \" . \$Scri\\r
+    ptName . \" is NOT SET! Fix It Now!\");\r\\r
+    \n    /system/scheduler/add name=\$ScriptName on-event=\"/system/script { \\r
+    run \$ScriptName; }\" comment=\"Update RKN DNS Looup\" interval=00:20:00 p\\r
+    olicy=\"ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon\"\\r
+    \_start-time=startup;\r\\r
+    \n  }\r\\r
+    \n:set dnsLookupReady true;\r\\r
+    \ndelay 5s;  \r\\r
+    \n:global dnsLookupReady (a);\r\\r
+    \n"\r
+add dont-require-permissions=no name=dnsForwarders owner=vados policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\\r
+    !rsc by Vados\r\\r
+    \n# RouterOS script: AM-dnsForwarders\r\\r
+    \n# Script comment: DNS Forwarders and DOH Servers | by @xmrdenb43\r\\r
+    \n# Copyright (c) 2005-2026 Vados <vados@vados.ru>\r\\r
+    \n#\r\\r
+    \n#\r\\r
+    \n# requires RouterOS, version=7.19\r\\r
+    \n# requires device-mode, fetch, scheduler\r\\r
+    \n# \r\\r
+    \n# tested on hap ac lite tc/hap ax3, RoS 7.18.2+\r\\r
+    \n\r\\r
+    \n\r\\r
+    \n/ip/dns/set allow-remote-requests=yes doh-max-concurrent-queries=100 doh\\r
+    -max-server-connections=20 use-doh-server=https://security.cloudflare-dns.\\r
+    com/dns-query verify-doh-cert=no;\r\\r
+    \n\r\\r
+    \n/ip dns static\r\\r
+    \n:do {\r\\r
+    \nadd address=8.8.8.8 comment=\"DNS Google\" name=dns.google type=A\r\\r
+    \nadd address=8.8.4.4 comment=\"DNS Google\" name=dns.google type=A\r\\r
+    \nadd address=9.9.9.9 comment=\"DNS Quad9\" name=dns.quad9.net type=A\r\\r
+    \nadd address=149.112.112.112 comment=\"DNS Quad9\" name=dns.quad9.net typ\\r
+    e=A\r\\r
+    \nadd address=195.133.25.16 comment=\"DNS Comss\" name=dns.comss.one type=\\r
+    A\r\\r
+    \n\r\\r
+    \n/ip dns forwarders\r\\r
+    \nadd doh-servers=https://cloudflare-dns.com/dns-query name=\"CloudFlare D\\r
+    oH\"\r\\r
+    \nadd doh-servers=https://secure.cloudflare-dns.com/dns-query name=\"Cloud\\r
+    Flare Secure DoH\"\r\\r
+    \nadd disabled=yes doh-servers=https://dns.quad9.net/dns-query name=\"Quad\\r
+    9 Default\" verify-doh-cert=no\r\\r
+    \nadd doh-servers=https://dns.google/dns-query name=\"Google DoH\"\r\\r
+    \nadd dns-servers=dns.comss.one doh-servers=https://dns.comss.one/mikrotik\\r
+    \_name=\"Comss DoH\" verify-doh-cert=no\r\\r
+    \nadd doh-servers=https://cloudflare-dns.com/dns-query,https://dns.google/\\r
+    dns-query name=\"CF & Google DoH\"\r\\r
+    \nadd dns-servers=1.0.0.1,8.8.4.4,1.1.1.1,8.8.8.8,77.88.8.1,77.88.8.8 name\\r
+    =\"CF & G & Ya IPv4\" verify-doh-cert=no\r\\r
+    \n} on-error={ }\r\\r
+    \n\r\\r
+    \n"\r
+add dont-require-permissions=no name=AM-ADguardHome-container owner=vados \\r
+    policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \\r
+    source="#!rsc by Vados\r\\r
+    \n# RouterOS script: AM-ADguardHome-container\r\\r
+    \n# Script comment: ADguardHome-container to container | by @xdenb43\r\\r
+    \n# Copyright (c) 2005-2026 Vados <vados@vados.ru>\r\\r
+    \n#\r\\r
+    \n#\r\\r
+    \n# requires RouterOS, version=7.19\r\\r
+    \n# requires device-mode, fetch, scheduler\r\\r
+    \n# \r\\r
+    \n# tested on hap ac lite tc/hap ax3, RoS 7.18.2+\r\\r
+    \n# tested on hap ax3/RoS 7.17.2+\r\\r
+    \n\r\\r
+    \n# enable containers, follow https://help.mikrotik.com/docs/spaces/ROS/pa\\r
+    ges/84901929/Container\r\\r
+    \n#/system/device-mode/update container=yes\r\\r
+    \n\r\\r
+    \n# MAIN PART STARTS HERE\r\\r
+    \n/interface veth\r\\r
+    \nadd address=192.168.254.5/24 gateway=192.168.254.1 name=ADGUARD-HOME\r\\r
+    \n\r\\r
+    \n/interface bridge\r\\r
+    \nadd name=Bridge-Docker port-cost-mode=short\r\\r
+    \n/interface bridge port\r\\r
+    \nadd bridge=Bridge-Docker interface=ADGUARD-HOME\r\\r
+    \n/ip address\r\\r
+    \nadd address=192.168.254.1/24 interface=Bridge-Docker network=192.168.254\\r
+    .0\r\\r
+    \n\r\\r
+    \n/ip firewall nat\r\\r
+    \nadd action=masquerade chain=srcnat comment=AdGuardHome src-address=192.1\\r
+    68.254.5\r\\r
+    \n\r\\r
+    \n# USB flash drive, FS ext4\r\\r
+    \n/container config\r\\r
+    \nset ram-high=200.0MiB registry-url=https://registry-1.docker.io tmpdir=/\\r
+    usb1/docker/pull\r\\r
+    \n\r\\r
+    \n/container mounts\r\\r
+    \nadd dst=/opt/adguardhome/conf name=adguard_home_conf src=/usb1/docker_co\\r
+    nfigs/adguard_home\r\\r
+    \n\r\\r
+    \n/container\r\\r
+    \nadd cmd=\"-c /opt/adguardhome/conf/AdGuardHome.yaml -h 0.0.0.0 -w /opt/a\\r
+    dguardhome/work\" entrypoint=/opt/adguardhome/AdGuardHome interface=ADGUAR\\r
+    D-HOME logging=yes mounts=\\\r\\r
+    \n    adguard_home_conf root-dir=/usb1/docker/adguard_home workdir=/opt/ad\\r
+    guardhome/work remote-image=adguard/adguardhome:latest\r\\r
+    \n\r\\r
+    \n/container/start [find where interface=ADGUARD-HOME]\r\\r
+    \n\r\\r
+    \n# ADH available on http://192.168.254.5:300 , configure before use\r\\r
+    \n# Choose one of the options below\r\\r
+    \n# uncomment lines before copying to terminal\r\\r
+    \n\r\\r
+    \n# OPTION 1\r\\r
+    \n# Just set AGH ip as DNS server.\r\\r
+    \n# /!\\ DNS FWD will work.\r\\r
+    \n# /!\\ No device-related stats will be gathered (all dns requests are co\\r
+    ming from mikrotik)\r\\r
+    \n#/ip dns\r\\r
+    \n#set allow-remote-requests=yes servers=192.168.254.5\r\\r
+    \n#/ip firewall nat\r\\r
+    \n#add action=redirect chain=dstnat comment=\"Incoming DNS redirect\" dst-\\r
+    address-type=!local dst-port=53 in-interface-list=LAN protocol=udp\r\\r
+    \n#add action=redirect chain=dstnat comment=\"Incoming DNS redirect\" dst-\\r
+    address-type=!local dst-port=53 in-interface-list=LAN protocol=tcp\r\\r
+    \n\r\\r
+    \n\r\\r
+    \n# OPTION 2\r\\r
+    \n# Forward all DNS requests to ADH\r\\r
+    \n# /!\\ DNS FWD will NOT work\r\\r
+    \n# /!\\ WILL SHOW stats for every LAN device\r\\r
+    \n#/ip firewall nat\r\\r
+    \n#add action=dst-nat chain=dstnat comment=\"local AdGuard udp -  NO NAT L\\r
+    oopback / local addresses only!\" dst-port=53 in-interface-list=LAN protoc\\r
+    ol=udp src-address=\\\r\\r
+    \n#    192.168.88.0/24 to-addresses=192.168.254.5 to-ports=53\r\\r
+    \n#add action=dst-nat chain=dstnat comment=\"local AdGuard tcp\" dst-port=\\r
+    53 in-interface-list=LAN protocol=tcp src-address=192.168.88.0/24 to-addre\\r
+    sses=192.168.254.5 to-ports=53\r\\r
+    \n# cat adguardhome_container.rsc\r\\r
+    \n# adguard home to container | by @xdenb43\r\\r
+    \n# tested on hap ax3/RoS 7.17.2+\r\\r
+    \n\r\\r
+    \n# enable containers, follow https://help.mikrotik.com/docs/spaces/ROS/pa\\r
+    ges/84901929/Container\r\\r
+    \n/system/device-mode/update container=yes\r\\r
+    \n\r\\r
+    \n# MAIN PART STARTS HERE\r\\r
+    \n/interface veth\r\\r
+    \nadd address=192.168.254.5/24 gateway=192.168.254.1 name=ADGUARD-HOME\r\\r
+    \n\r\\r
+    \n/interface bridge\r\\r
+    \nadd name=Bridge-Docker port-cost-mode=short\r\\r
+    \n/interface bridge port\r\\r
+    \nadd bridge=Bridge-Docker interface=ADGUARD-HOME\r\\r
+    \n/ip address\r\\r
+    \nadd address=192.168.254.1/24 interface=Bridge-Docker network=192.168.254\\r
+    .0\r\\r
+    \n\r\\r
+    \n/ip firewall nat\r\\r
+    \nadd action=masquerade chain=srcnat comment=AdGuardHome src-address=192.1\\r
+    68.254.5\r\\r
+    \n\r\\r
+    \n# USB flash drive, FS ext4\r\\r
+    \n/container config\r\\r
+    \nset ram-high=200.0MiB registry-url=https://registry-1.docker.io tmpdir=/\\r
+    usb1/docker/pull\r\\r
+    \n\r\\r
+    \n/container mounts\r\\r
+    \nadd dst=/opt/adguardhome/conf name=adguard_home_conf src=/usb1/docker_co\\r
+    nfigs/adguard_home\r\\r
+    \n\r\\r
+    \n/container\r\\r
+    \nadd cmd=\"-c /opt/adguardhome/conf/AdGuardHome.yaml -h 0.0.0.0 -w /opt/a\\r
+    dguardhome/work\" entrypoint=/opt/adguardhome/AdGuardHome interface=ADGUAR\\r
+    D-HOME logging=yes mounts=\\\r\\r
+    \n    adguard_home_conf root-dir=/usb1/docker/adguard_home workdir=/opt/ad\\r
+    guardhome/work remote-image=adguard/adguardhome:latest\r\\r
+    \n\r\\r
+    \n/container/start [find where interface=ADGUARD-HOME]\r\\r
+    \n\r\\r
+    \n# ADH available on http://192.168.254.5:300 , configure before use\r\\r
+    \n# Choose one of the options below\r\\r
+    \n# uncomment lines before copying to terminal\r\\r
+    \n\r\\r
+    \n# OPTION 1\r\\r
+    \n# Just set AGH ip as DNS server.\r\\r
+    \n# /!\\ DNS FWD will work.\r\\r
+    \n# /!\\ No device-related stats will be gathered (all dns requests are co\\r
+    ming from mikrotik)\r\\r
+    \n#/ip dns\r\\r
+    \n#set allow-remote-requests=yes servers=192.168.254.5\r\\r
+    \n#/ip firewall nat\r\\r
+    \n#add action=redirect chain=dstnat comment=\"Incoming DNS redirect\" dst-\\r
+    address-type=!local dst-port=53 in-interface-list=LAN protocol=udp\r\\r
+    \n#add action=redirect chain=dstnat comment=\"Incoming DNS redirect\" dst-\\r
+    address-type=!local dst-port=53 in-interface-list=LAN protocol=tcp\r\\r
+    \n\r\\r
+    \n\r\\r
+    \n# OPTION 2\r\\r
+    \n# Forward all DNS requests to ADH\r\\r
+    \n# /!\\ DNS FWD will NOT work\r\\r
+    \n# /!\\ WILL SHOW stats for every LAN device\r\\r
+    \n#/ip firewall nat\r\\r
+    \n#add action=dst-nat chain=dstnat comment=\"local AdGuard udp -  NO NAT L\\r
+    oopback / local addresses only!\" dst-port=53 in-interface-list=LAN protoc\\r
+    ol=udp src-address=\\\r\\r
+    \n#    192.168.88.0/24 to-addresses=192.168.254.5 to-ports=53\r\\r
+    \n#add action=dst-nat chain=dstnat comment=\"local AdGuard tcp\" dst-port=\\r
+    53 in-interface-list=LAN protocol=tcp src-address=192.168.88.0/24 to-addre\\r
+    sses=192.168.254.5 to-ports=53"\r
+/user group\r
+add name=backup policy="telnet,ssh,ftp,read,write,policy,test,sniff,sensitive,\\r
+    !local,!reboot,!winbox,!password,!web,!api,!romon,!rest-api"\r
+/interface bridge\r
+add admin-mac=48:8F:5A:8E:1A:BC auto-mac=no mlag-peer-port="ether1 - Unet" \\r
+    name=Bridge-LAN port-cost-mode=short\r
+/interface wireless\r
+# same mac-address as ether1 - Unet\r
+set [ find default-name=wlan1 ] ampdu-priorities=0,1,2,3,4,5,6,7 band=\\r
+    2ghz-b/g/n basic-rates-a/g=\\r
+    6Mbps,9Mbps,12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps basic-rates-b=\\r
+    1Mbps,2Mbps,5.5Mbps,11Mbps channel-width=20/40mhz-XX country=belarus \\r
+    disabled=no frequency=auto hw-protection-mode=rts-cts mode=ap-bridge \\r
+    rate-set=configured skip-dfs-channels=10min-cac ssid=vados \\r
+    wds-default-bridge=Bridge-LAN wds-mode=dynamic-mesh wireless-protocol=\\r
+    802.11 wmm-support=enabled wps-mode=disabled\r
+set [ find default-name=wlan2 ] ampdu-priorities=0,1,2,3,4,5,6,7 band=\\r
+    5ghz-a/n/ac basic-rates-a/g=\\r
+    6Mbps,9Mbps,12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps channel-width=\\r
+    20/40/80mhz-XXXX country=belarus disabled=no frequency=auto \\r
+    hw-protection-mode=rts-cts mode=ap-bridge rate-set=configured \\r
+    skip-dfs-channels=10min-cac ssid=vados5g wds-default-bridge=Bridge-LAN \\r
+    wds-mode=dynamic-mesh wireless-protocol=802.11 wmm-support=enabled \\r
+    wps-mode=disabled\r
+/interface wireless nstreme\r
+# same mac-address as ether1 - Unet\r
+set wlan1 enable-nstreme=yes\r
+set wlan2 enable-nstreme=yes\r
+/caps-man provisioning\r
+add action=create-dynamic-enabled hw-supported-modes=gn master-configuration=\\r
+    cfg-2ghz name-format=prefix-identity name-prefix=2ghz\r
+add action=create-dynamic-enabled hw-supported-modes=ac master-configuration=\\r
+    cfg-5ghz-ac name-format=prefix-identity name-prefix=5ghz-ac\r
+add action=create-dynamic-enabled hw-supported-modes=an master-configuration=\\r
+    cfg-5ghz-an name-format=prefix-identity name-prefix=5ghz-an\r
+/certificate settings\r
+set builtin-trust-store="ipsec,wpa-eap,capsman,fetch,sstp,ovpn,radius,containe\\r
+    r,userman,wiliot,openflow,tr069,dot1x,dns,www,api,reverse-proxy,logging"\r
+/interface bridge port\r
+add bridge=Bridge-LAN disabled=yes interface="ether1 - Unet"\r
+add bridge=Bridge-LAN interface=ether2\r
+add bridge=Bridge-LAN interface=ether3\r
+add bridge=Bridge-LAN interface=ether4\r
+add bridge=Bridge-LAN interface=ether5\r
+add bridge=Bridge-LAN interface=wlan2\r
+add bridge=Bridge-LAN interface=wlan1\r
+/ip firewall connection tracking\r
+# ipv6 neighbor configuration has changed, please restart the device in order to apply the new settings\r
+set udp-timeout=10s\r
+/ip neighbor discovery-settings\r
+# ipv6 neighbor configuration has changed, please restart the device in order to apply the new settings\r
+set discover-interface-list=LAN\r
+/ip settings\r
+# ipv6 neighbor configuration has changed, please restart the device in order to apply the new settings\r
+set max-neighbor-entries=8192 secure-redirects=no\r
+/ipv6 settings\r
+# ipv6 neighbor configuration has changed, please restart the device in order to apply the new settings\r
+set max-neighbor-entries=8192\r
+/interface detect-internet\r
+set detect-interface-list=WAN internet-interface-list=WAN lan-interface-list=\\r
+    LAN wan-interface-list=WAN\r
+/interface l2tp-server server\r
+set authentication=mschap2 use-ipsec=yes\r
+/interface list member\r
+add interface="ether1 - Unet" list=WAN\r
+add interface=Bridge-LAN list=LAN\r
+/interface ovpn-server server\r
+add auth=sha1,md5 mac-address=FE:82:A5:78:8E:84 name=ovpn-server1\r
+/interface wifi configuration\r
+add channel=2G-AX datapath=xs-DataPath disabled=no mode=ap name=2G-AX \\r
+    security=sec2g security.ft=yes .ft-over-ds=yes ssid=vados\r
+add channel=2G-N datapath=xs-DataPath disabled=no mode=ap name=2G-N security=\\r
+    sec2g security.ft=yes .ft-over-ds=yes ssid=vados\r
+add channel=5G-AC datapath=xs-DataPath disabled=no mode=ap name=5G-AC \\r
+    security=sec5G security.authentication-types="" .ft=yes .ft-over-ds=yes \\r
+    ssid=vados\r
+add channel=2G-G datapath=xs-DataPath disabled=no mode=ap name=2G-G security=\\r
+    sec2g security.authentication-types="" .ft=yes .ft-over-ds=yes ssid=vados\r
+/interface wifi datapath\r
+add bridge=Bridge-LAN disabled=no interface-list=all name=xs-DataPath\r
+/interface wireguard peers\r
+add allowed-address=0.0.0.0/0,::/0 client-allowed-address=::/0 \\r
+    endpoint-address=89.110.101.17 endpoint-port=29185 interface=WG name=\\r
+    MikroVados persistent-keepalive=25s public-key=\\r
+    "64Y25EUZQQt8EIeAJYD8qWt+te8qvGEepnswdBgmzlY="\r
+/interface wireless cap\r
+set bridge=Bridge-LAN caps-man-addresses=10.30.30.10 \\r
+    caps-man-certificate-common-names=CAPsMAN-51B25E507D07 certificate=\\r
+    CAP-488F5A8E1ABC discovery-interfaces=ether2 interfaces=wlan1,wlan2 \\r
+    lock-to-caps-man=yes\r
+/ip address\r
+add address=10.30.30.81/24 interface=Bridge-LAN network=10.30.30.0\r
+add address=10.8.0.2/24 interface=WG network=10.8.0.0\r
+add address=10.8.0.2 interface=*F network=10.8.0.2\r
+/ip dhcp-client\r
+add add-default-route=special-classless default-route-distance=2 \\r
+    default-route-tables=main dhcp-options=clientid,clientid_duid interface=\\r
+    "ether1 - Unet" name=client1 use-peer-dns=no use-peer-ntp=no\r
+/ip dhcp-server\r
+add add-arp=yes address-pool=dhcp always-broadcast=yes bootp-support=none \\r
+    dhcp-option-set=domain-search-set interface=Bridge-LAN lease-time=10m \\r
+    name=masterDHCP server-address=10.30.30.81\r
+/ip dhcp-server config\r
+set accounting=no\r
+/ip dhcp-server lease\r
+add address=10.30.30.101 client-id=1:48:8f:5a:8e:ee:a8 mac-address=\\r
+    48:8F:5A:8E:EE:A8 server=masterDHCP\r
+add address=10.30.30.107 client-id=1:f0:de:f1:91:d:1e mac-address=\\r
+    F0:DE:F1:91:0D:1E server=masterDHCP\r
+add address=10.30.30.83 client-id=1:0:80:77:ec:43:86 mac-address=\\r
+    00:80:77:EC:43:86 server=masterDHCP\r
+add address=10.30.30.70 dhcp-option=domain-search-list,HostName \\r
+    dhcp-option-set=HP1505n mac-address=00:1E:0B:1A:88:8D server=masterDHCP\r
+add address=10.30.30.50 client-id=1:4:7c:16:36:f5:37 mac-address=\\r
+    04:7C:16:36:F5:37 server=masterDHCP\r
+add address=10.30.30.71 client-id=1:10:2d:41:2c:20:c2 mac-address=\\r
+    10:2D:41:2C:20:C2 server=masterDHCP\r
+add address=10.30.30.61 client-id=1:10:8:c1:81:59:5f mac-address=\\r
+    10:08:C1:81:59:5F server=masterDHCP\r
+add address=10.30.30.72 client-id=1:10:38:1f:d2:5f:13 mac-address=\\r
+    10:38:1F:D2:5F:13 server=masterDHCP\r
+add address=10.30.30.99 client-id=1:10:b1:df:e9:d0:d5 mac-address=\\r
+    10:B1:DF:E9:D0:D5 server=masterDHCP\r
+add address=10.30.30.111 client-id=1:fe:2:52:be:3f:16 mac-address=\\r
+    FE:02:52:BE:3F:16 server=masterDHCP\r
+add address=10.30.30.92 client-id=1:d4:6d:6d:fd:e5:49 mac-address=\\r
+    D4:6D:6D:FD:E5:49 server=masterDHCP\r
+add address=10.30.30.93 client-id=1:7e:8b:1e:cb:b8:cb mac-address=\\r
+    CC:42:10:12:46:94 server=masterDHCP\r
+add address=10.30.30.94 client-id=1:50:cc:f8:85:96:a mac-address=\\r
+    50:CC:F8:85:96:0A server=masterDHCP\r
+add address=10.30.30.82 client-id=1:e4:18:6b:58:34:ab mac-address=\\r
+    E4:18:6B:58:34:AB server=masterDHCP\r
+add address=10.30.30.75 client-id=1:0:27:15:41:97:a9 mac-address=\\r
+    00:27:15:41:97:A9 server=masterDHCP\r
+add address=10.30.30.77 dhcp-option=HostName dhcp-option-set=StartLife1 \\r
+    mac-address=C4:82:E1:03:49:10 server=masterDHCP\r
+add address=10.30.30.73 client-id=1:10:38:1f:82:81:f2 mac-address=\\r
+    10:38:1F:82:81:F2 server=masterDHCP\r
+add address=10.30.30.95 client-id=1:88:ae:dd:60:39:54 dhcp-option=HostName \\r
+    dhcp-option-set=VADOS-NUC mac-address=88:AE:DD:60:39:54 server=masterDHCP\r
+add address=10.30.30.98 client-id=1:c8:5b:76:d8:cc:bf dhcp-option=HostName \\r
+    dhcp-option-set=VADOS-LEN mac-address=C8:5B:76:D8:CC:BF server=masterDHCP\r
+add address=10.30.30.96 client-id=iPhone mac-address=4A:91:ED:0E:1F:39 \\r
+    server=masterDHCP\r
+add address=10.30.30.74 client-id=MiTV dhcp-option=HostName dhcp-option-set=\\r
+    MiTV mac-address=20:72:A9:D3:34:36 server=masterDHCP\r
+add address=10.30.30.30 dhcp-option=HostName dhcp-option-set=miller \\r
+    mac-address=F0:75:5D:1E:5F:71 server=masterDHCP\r
+add address=10.30.30.100 client-id=iVados dhcp-option=HostName \\r
+    dhcp-option-set="=\"Client ID\"" mac-address=DE:4D:72:F3:1A:9F server=\\r
+    masterDHCP\r
+/ip dhcp-server network\r
+add address=10.30.30.0/24 caps-manager=10.30.30.10 dhcp-option=\\r
+    domain-search-list dhcp-option-set=domain-search-set dns-server=\\r
+    10.30.30.81 domain=WORKGROUP gateway=10.30.30.81 netmask=24 ntp-server=\\r
+    10.30.30.81,10.30.30.10 wins-server=10.30.30.95,10.30.30.98\r
+/ip dns\r
+set allow-remote-requests=yes cache-max-ttl=1d doh-max-concurrent-queries=100 \\r
+    doh-max-server-connections=20 servers=8.8.4.4,8.8.8.8\r
+/ip dns static\r
+add address=8.8.4.4 comment="Google-dns IPv4 2" name=dns.google type=A\r
+add address=8.8.8.8 comment="Google-dns IPv4 1" name=dns.google type=A\r
+add address=10.30.30.33 comment=AMSTER name=amster.vados.ru type=A\r
+add address=10.30.30.33 name=ros.vados.ru type=A\r
+add address=10.30.30.95 name=vados-nuc type=A\r
+add address=10.30.30.33 name=amster-nuc type=A\r
+add address=10.30.30.33 name=amster type=A\r
+add address=10.30.30.33 name=amster-reg type=A\r
+add address=10.30.30.33 name=mng.vados.ru type=A\r
+add address=10.30.30.33 name=mgr.vados.ru type=A\r
+add address=10.30.30.33 name=prt.vados.ru type=A\r
+add address=10.30.30.33 name=reg.vados.ru type=A\r
+add address=10.30.30.33 match-subdomain=yes name=mikrots.vados.ru type=A\r
+add address=10.30.30.33 name=oxidized.vados.ru type=A\r
+add address=10.30.30.30 comment=MILLER name=miller.vados.ru type=A\r
+add address=10.30.30.30 name=MILLER-LEN type=A\r
+add address=10.30.30.30 name=miller type=A\r
+add address=1.0.0.1 comment="CloudFlare-doh IPv4 2" disabled=yes name=\\r
+    security.cloudflare-dns.com type=A\r
+add address=1.1.1.1 comment="CloudFlare-doh IPv4 1" disabled=yes name=\\r
+    security.cloudflare-dns.com type=A\r
+add address=149.112.112.112 comment="Cuad9-dns IPv4 2" disabled=yes name=\\r
+    dns.quad9.net type=A\r
+add address=9.9.9.9 comment="Cuad9-dns IPv4 1" disabled=yes name=\\r
+    dns.quad9.net type=A\r
+add address=91.192.189.2 comment=Unet-DNS disabled=yes name=ns1.unet.ws type=\\r
+    A\r
+add address=10.30.30.81 comment=LocalNet name=MikroVados type=A\r
+add address=10.30.30.10 name=MikroNUC type=A\r
+add address=10.30.30.86 name=MikroYellow type=A\r
+add address=10.30.30.85 name=MikroMic type=A\r
+add address=10.30.30.95 name=VADOS-NUC type=A\r
+add address=10.30.30.98 name=VADOS-LEN type=A\r
+add address=10.30.30.20 name=garage type=A\r
+add address=91.192.189.2 comment=Unet-DNS disabled=yes name=ns1.unet.ws type=\\r
+    A\r
+/ip firewall address-list\r
+add address=91.215.120.206 list=TRUSTED\r
+add address=185.71.70.78 disabled=yes list=TRUSTED\r
+add address=176.53.203.171 disabled=yes list=TRUSTED\r
+add address=176.53.203.170 disabled=yes list=TRUSTED\r
+add address=176.53.202.194 disabled=yes list=TRUSTED\r
+add address=10.30.30.100-255 list=KIDS\r
+add address=8.8.4.0/24 list=YouTube\r
+add address=8.8.8.0/24 list=YouTube\r
+add address=8.34.208.0/20 list=YouTube\r
+add address=8.35.192.0/20 list=YouTube\r
+add address=23.236.48.0/20 list=YouTube\r
+add address=23.251.128.0/19 list=YouTube\r
+add address=34.0.0.0/15 list=YouTube\r
+add address=34.2.0.0/16 list=YouTube\r
+add address=34.3.0.0/23 list=YouTube\r
+add address=34.3.3.0/24 list=YouTube\r
+add address=34.3.4.0/24 list=YouTube\r
+add address=34.3.8.0/21 list=YouTube\r
+add address=34.3.16.0/20 list=YouTube\r
+add address=34.3.32.0/19 list=YouTube\r
+add address=34.3.64.0/18 list=YouTube\r
+add address=34.4.0.0/14 list=YouTube\r
+add address=34.8.0.0/13 list=YouTube\r
+add address=34.16.0.0/12 list=YouTube\r
+add address=34.32.0.0/11 list=YouTube\r
+add address=34.64.0.0/10 list=YouTube\r
+add address=34.128.0.0/10 list=YouTube\r
+add address=35.184.0.0/13 list=YouTube\r
+add address=35.192.0.0/14 list=YouTube\r
+add address=35.196.0.0/15 list=YouTube\r
+add address=35.198.0.0/16 list=YouTube\r
+add address=35.199.0.0/17 list=YouTube\r
+add address=35.199.128.0/18 list=YouTube\r
+add address=35.200.0.0/13 list=YouTube\r
+add address=35.208.0.0/12 list=YouTube\r
+add address=35.224.0.0/12 list=YouTube\r
+add address=35.240.0.0/13 list=YouTube\r
+add address=57.140.192.0/18 list=YouTube\r
+add address=64.15.112.0/20 list=YouTube\r
+add address=64.233.160.0/19 list=YouTube\r
+add address=66.22.228.0/23 list=YouTube\r
+add address=66.102.0.0/20 list=YouTube\r
+add address=66.249.64.0/19 list=YouTube\r
+add address=70.32.128.0/19 list=YouTube\r
+add address=72.14.192.0/18 list=YouTube\r
+add address=74.125.0.0/16 list=YouTube\r
+add address=104.154.0.0/15 list=YouTube\r
+add address=104.196.0.0/14 list=YouTube\r
+add address=104.237.160.0/19 list=YouTube\r
+add address=107.167.160.0/19 list=YouTube\r
+add address=107.178.192.0/18 list=YouTube\r
+add address=108.59.80.0/20 list=YouTube\r
+add address=108.170.192.0/18 list=YouTube\r
+add address=108.177.0.0/17 list=YouTube\r
+add address=130.211.0.0/16 list=YouTube\r
+add address=136.22.160.0/20 list=YouTube\r
+add address=136.22.176.0/21 list=YouTube\r
+add address=136.22.184.0/23 list=YouTube\r
+add address=136.22.186.0/24 list=YouTube\r
+add address=142.250.0.0/15 list=YouTube\r
+add address=146.148.0.0/17 list=YouTube\r
+add address=152.65.208.0/22 list=YouTube\r
+add address=152.65.214.0/23 list=YouTube\r
+add address=152.65.218.0/23 list=YouTube\r
+add address=152.65.222.0/23 list=YouTube\r
+add address=152.65.224.0/19 list=YouTube\r
+add address=162.120.128.0/17 list=YouTube\r
+add address=162.216.148.0/22 list=YouTube\r
+add address=162.222.176.0/21 list=YouTube\r
+add address=172.110.32.0/21 list=YouTube\r
+add address=172.217.0.0/16 list=YouTube\r
+add address=172.253.0.0/16 list=YouTube\r
+add address=173.194.0.0/16 list=YouTube\r
+add address=173.255.112.0/20 list=YouTube\r
+add address=192.158.28.0/22 list=YouTube\r
+add address=192.178.0.0/15 list=YouTube\r
+add address=193.186.4.0/24 list=YouTube\r
+add address=199.36.154.0/23 list=YouTube\r
+add address=199.36.156.0/24 list=YouTube\r
+add address=199.192.112.0/22 list=YouTube\r
+add address=199.223.232.0/21 list=YouTube\r
+add address=207.223.160.0/20 list=YouTube\r
+add address=208.65.152.0/22 list=YouTube\r
+add address=208.68.108.0/22 list=YouTube\r
+add address=208.81.188.0/22 list=YouTube\r
+add address=208.117.224.0/19 list=YouTube\r
+add address=209.85.128.0/17 list=YouTube\r
+add address=216.58.192.0/19 list=YouTube\r
+add address=216.73.80.0/20 list=YouTube\r
+add address=216.239.32.0/19 list=YouTube\r
+add address=2ip.ru list=Test\r
+add address=157.240.247.174 list=Instagram\r
+add address=46.53.178.107 list=Instagram\r
+add address=179.60.195.174 list=Instagram\r
+add address=157.240.205.174 list=Instagram\r
+add address=31.13.24.0/21 list=Instagram\r
+add address=31.13.64.0/18 list=Instagram\r
+add address=45.64.40.0/22 list=Instagram\r
+add address=66.220.144.0/20 list=Instagram\r
+add address=69.63.176.0/20 list=Instagram\r
+add address=69.171.224.0/19 list=Instagram\r
+add address=74.119.76.0/22 list=Instagram\r
+add address=103.4.96.0/22 list=Instagram\r
+add address=129.134.0.0/16 list=Instagram\r
+add address=157.240.0.0/16 list=Instagram\r
+add address=173.252.64.0/18 list=Instagram\r
+add address=179.60.192.0/22 list=Instagram\r
+add address=185.60.216.0/22 list=Instagram\r
+add address=204.15.20.0/22 list=Instagram\r
+add address=157.240.200.63 list=Instagram\r
+add address=185.60.219.63 list=Instagram\r
+add address=129.134.31.12 list=Instagram\r
+add address=66.81.203.132 list=Instagram\r
+add address=185.89.218.12 list=Instagram\r
+add address=31.13.66.63 list=Instagram\r
+add address=84.15.65.162 list=Instagram\r
+add address=68.66.224.28 list=Instagram\r
+add address=157.240.253.63 list=Instagram\r
+add address=83.174.11.224 list=Instagram\r
+add address=157.240.9.52 list=Instagram\r
+add address=157.240.252.174 list=Instagram\r
+add address=157.240.195.63 list=Instagram\r
+add address=31.13.71.52 list=Instagram\r
+add address=57.144.110.192 list=Instagram\r
+add address=157.240.252.17 list=Instagram\r
+add address=84.15.66.97 list=Instagram\r
+add address=217.168.6.33 list=Instagram\r
+add address=31.13.83.52 list=Instagram\r
+add address=157.240.241.63 list=Instagram\r
+add address=129.134.30.12 list=Instagram\r
+add address=185.89.219.12 list=Instagram\r
+add address=157.240.252.10 list=Instagram\r
+add address=157.240.201.63 list=Instagram\r
+add address=66.81.203.197 list=Instagram\r
+add address=179.60.195.52 list=Instagram\r
+add address=66.81.203.7 list=Instagram\r
+add address=216.40.34.41 list=Instagram\r
+add address=157.240.202.63 list=Instagram\r
+add address=157.240.229.63 list=Instagram\r
+add address=157.240.252.63 list=Instagram\r
+add address=31.13.72.53 list=Instagram\r
+add address=124.108.16.224 list=Instagram\r
+add address=157.240.205.63 list=Instagram\r
+add address=92.46.37.96 list=Instagram\r
+add address=157.240.247.63 list=Instagram\r
+add address=157.240.234.63 list=Instagram\r
+add address=157.240.235.63 list=Instagram\r
+add address=87.245.208.97 list=Instagram\r
+add address=216.58.192.0/19 list=Instagram\r
+add address=209.85.128.0/17 list=Instagram\r
+add address=198.105.240.0/20 list=Instagram\r
+add address=173.194.0.0/16 list=Instagram\r
+add address=172.217.0.0/16 list=Instagram\r
+add address=142.250.0.0/15 list=Instagram\r
+add address=108.177.0.0/17 list=Instagram\r
+add address=87.245.197.140 list=Instagram\r
+add address=74.125.0.0/16 list=Instagram\r
+add address=64.233.160.0/19 list=Instagram\r
+add address=157.240.0.1 list=Instagram\r
+add address=157.240.238.63 list=Instagram\r
+add address=157.240.238.174 list=Instagram\r
+add address=157.240.0.63 list=Instagram\r
+add address=157.240.224.63 list=Instagram\r
+add address=157.240.224.174 list=Instagram\r
+add address=157.240.251.36 list=Instagram\r
+add address=157.240.253.12 list=Instagram\r
+add address=157.240.253.35 list=Instagram\r
+add address=157.240.238.13 list=Instagram\r
+add address=157.240.238.56 list=Instagram\r
+add address=157.240.238.175 list=Instagram\r
+add address=57.144.112.141 list=Instagram\r
+add address=157.240.251.60 list=Instagram\r
+add address=157.240.251.128 list=Instagram\r
+add address=157.240.238.5 list=Instagram\r
+add address=157.240.253.13 list=Instagram\r
+add address=157.240.253.5 list=Instagram\r
+add address=157.240.238.2 list=Instagram\r
+add address=157.240.238.37 list=Instagram\r
+add address=157.240.251.5 list=Instagram\r
+add address=157.240.251.34 list=Instagram\r
+add address=57.144.112.1 list=Instagram\r
+add address=157.240.238.54 list=Instagram\r
+add address=129.134.26.123 list=Instagram\r
+add address=157.240.252.3 list=Instagram\r
+add address=31.13.84.4 list=Instagram\r
+add address=157.240.224.12 list=Instagram\r
+add address=157.240.238.4 list=Instagram\r
+add address=157.240.0.13 list=Instagram\r
+add address=3.33.139.32 list=Instagram\r
+add address=157.240.0.35 list=Instagram\r
+add address=157.240.238.14 list=Instagram\r
+add address=157.240.238.60 list=Instagram\r
+add address=57.144.112.145 list=Instagram\r
+add address=157.240.251.35 list=Instagram\r
+add address=151.101.84.159 list=Twitter\r
+add address=pbs.twimg.com list=Twitter\r
+add address=89.110.101.17 comment=VDSIna list=TRUSTED\r
+add address=10.8.0.0/24 comment="WG VDSIna" list=TRUSTED\r
+add address=ikus.pesc.ru comment=ikus.pesc.ru list=NoVdsina\r
+add address=love.ru comment=love.ru list=NoVdsina\r
+add address=gosuslugi.ru comment=gosuslugi.ru list=NoVdsina\r
+add address=pochta.ru comment=pochta.ru list=NoVdsina\r
+add address=vdsina.com list=NoVdsina\r
+add address=vdsina.ru list=NoVdsina\r
+add address=youla.ru list=NoVdsina\r
+add address=kupiprodai.ru list=NoVdsina\r
+add address=myip.ru list=Test\r
+add address=geoip.co list=NoVdsina\r
+add address=x.com list=Twitter\r
+add address=facebook.com list=facebook\r
+add address=fbcd.net list=facebook\r
+add address=comp-lenta.ru list=NoVdsina\r
+add address=128.85.102.70 comment=update.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=wu-b-net.trafficmanager.net. comment=\\r
+    ctldl.windowsupdate.com.delivery.microsoft.com list=windowsupdateslist\r
+add address=ctldl.windowsupdate.com.delivery.microsoft.com. comment=\\r
+    ctldl.windowsupdate.com list=windowsupdateslist\r
+add address=redir.update.msft.com.trafficmanager.net. comment=\\r
+    update.microsoft.com list=windowsupdateslist\r
+add address=geo.prod.do.dsp.trafficmanager.net. comment=\\r
+    geo.prod.do.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=13.74.139.29 comment=array605.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=kv801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\\r
+    kv801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=e12437.d.akamaiedge.net. comment=\\r
+    kv801.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist\r
+add address=displaycatalog-rp.md.mp.microsoft.com.akadns.net. comment=\\r
+    displaycatalog.mp.microsoft.com list=windowsupdateslist\r
+add address=rp-consumer-prod-displaycatalog-geomap.trafficmanager.net. \\r
+    comment=displaycatalog-rp.md.mp.microsoft.com.akadns.net list=\\r
+    windowsupdateslist\r
+add address=sls.update.microsoft.com. comment=slscr.update.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=glb.sls.prod.dcat.dsp.trafficmanager.net. comment=\\r
+    sls.update.microsoft.com list=windowsupdateslist\r
+add address=fe3.delivery.mp.microsoft.com. comment=\\r
+    fe3cr.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=glb.cws.prod.dcat.dsp.trafficmanager.net. comment=\\r
+    fe3.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=fe2cr.update.msft.com.trafficmanager.net. comment=\\r
+    fe2cr.update.microsoft.com list=windowsupdateslist\r
+add address=download.windowsupdate.com.delivery.microsoft.com. comment=\\r
+    download.windowsupdate.com list=windowsupdateslist\r
+add address=wu-f-net.trafficmanager.net. comment=\\r
+    download.windowsupdate.com.delivery.microsoft.com list=windowsupdateslist\r
+add address=tsfe.trafficmanager.net. comment=\\r
+    tsfe.trafficshaping.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=edge.ds-c7110-microsoft.global.dns.qwilted-cds.cqloud.com. \\r
+    comment=9.au.download.windowsupdate.com list=windowsupdateslist\r
+add address=52.158.227.125 comment=array812.prod.do.dsp.mp.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=au.download.windowsupdate.com.delivery.microsoft.com. comment=\\r
+    au.download.windowsupdate.com list=windowsupdateslist\r
+add address=a767.dspw65.akamai.net. comment=\\r
+    download.windowsupdate.com.edgesuite.net list=windowsupdateslist\r
+add address=52.151.58.88 comment=array810.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=consumer-licensing-aks2aks.md.mp.microsoft.com.akadns.net. \\r
+    comment=licensing.mp.microsoft.com list=windowsupdateslist\r
+add address=licensing-prod-frontdoor-geomap.trafficmanager.net. comment=\\r
+    consumer-licensing-aks2aks.md.mp.microsoft.com.akadns.net list=\\r
+    windowsupdateslist\r
+add address=star.f.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \\r
+    comment=msedge.f.dl.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=cdp-f-nlu-net.trafficmanager.net. comment=\\r
+    star.f.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=star.b.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \\r
+    comment=msedge.b.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=cdp-f-tlu-net.trafficmanager.net. comment=\\r
+    star.b.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=storeedgefd.xbetservices.akadns.net. comment=\\r
+    storeedgefd.dsx.mp.microsoft.com list=windowsupdateslist\r
+add address=\\r
+    storeedgefd.dsx.mp.microsoft.com.edgekey.net.globalredir.akadns.net. \\r
+    comment=storeedgefd.dsx.mp.microsoft.com.edgekey.net list=\\r
+    windowsupdateslist\r
+add address=e16646.dscg.akamaiedge.net. comment=\\r
+    storeedgefd.dsx.mp.microsoft.com.edgekey.net.globalredir.akadns.net list=\\r
+    windowsupdateslist\r
+add address=40.69.76.189 comment=array621.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=bg.microsoft.map.fastly.net. comment=\\r
+    3.au.download.windowsupdate.com list=windowsupdateslist\r
+add list=windowsupdateslist\r
+add address=40.69.75.33 comment=array613.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=star.sf.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \\r
+    comment=msedgeextensions.sf.tlu.dl.delivery.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=cdp-f-ssl-tlu-net.trafficmanager.net. comment=\\r
+    star.sf.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=a2033.dscd.akamai.net. comment=\\r
+    star.sb.tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=\\r
+    windowsupdateslist\r
+add address=13.74.138.242 comment=array602.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=dl.delivery.mp.microsoft.com.delivery.microsoft.com. comment=\\r
+    dl.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=dcat-f-nlu-net.trafficmanager.net. comment=\\r
+    dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=1d.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \\r
+    comment=1D.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=dcat-b-tlu-net.trafficmanager.net. comment=\\r
+    1d.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=a122.dscg3.akamai.net. comment=\\r
+    tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=windowsupdateslist\r
+add address=geover.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\\r
+    geover.prod.do.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=e10370.d.akamaiedge.net. comment=\\r
+    geover.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist\r
+add address=52.232.182.21 comment=array511.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=40.70.77.95 comment=array519.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=a1683.dscd.akamai.net. comment=\\r
+    dl.delivery.mp.microsoft.com-c.edgesuite.net list=windowsupdateslist\r
+add address=consumer-collections-aks2eap.md.mp.microsoft.com.akadns.net. \\r
+    comment=collections.mp.microsoft.com list=windowsupdateslist\r
+add address=a1847.dscd.akamai.net. comment=\\r
+    wildcard.f.tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=\\r
+    windowsupdateslist\r
+add address=13.74.142.6 comment=array607.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=au.download.windowsupdate.com.edgesuite.net. comment=\\r
+    2.au.download.windowsupdate.com list=windowsupdateslist\r
+add address=a767.dscg3.akamai.net. comment=\\r
+    au.download.windowsupdate.com.edgesuite.net list=windowsupdateslist\r
+add address=52.156.123.84 comment=array818.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=40.69.78.254 comment=array610.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=4.au.download.windowsupdate.com.delivery.microsoft.com. comment=\\r
+    4.au.download.windowsupdate.com list=windowsupdateslist\r
+add address=cl-glcb907925.gcdn.co. comment=\\r
+    4.au.download.windowsupdate.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.167.167.111 comment=array510.prod.do.dsp.mp.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=40.69.70.43 comment=array623.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=tsfe.trafficshaping.dsp.mp.microsoft.com.delivery.microsoft.com. \\r
+    comment=tsfe.trafficshaping.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=ts-frontend.trafficmanager.net. comment=\\r
+    tsfe.trafficshaping.dsp.mp.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=40.69.75.248 comment=array616.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=40.69.74.84 comment=array615.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=sds.trafficmanager.net. comment=software-download.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=40.69.74.80 comment=array611.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.175.242.182 comment=array804.prod.do.dsp.mp.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=dlc-shim.trafficmanager.net. comment=download.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=e12671.dscd.akamaiedge.net. comment=\\r
+    download.microsoft.com.edgekey.net list=windowsupdateslist\r
+add address=20.187.55.34 comment=array808.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.167.167.231 comment=array513.prod.do.dsp.mp.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=52.167.222.13 comment=array518.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=kv601.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\\r
+    kv601.prod.do.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=e12358.d.akamaiedge.net. comment=\\r
+    kv601.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist\r
+add address=tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. comment=\\r
+    tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=dcat-f-tlu-net.trafficmanager.net. comment=\\r
+    tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=a1856.dspw65.akamai.net. comment=\\r
+    tlu.dl.delivery.mp.microsoft.com-c.edgesuite.net list=windowsupdateslist\r
+add address=52.167.164.252 comment=array506.prod.do.dsp.mp.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=13.74.137.54 comment=array601.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=kv501.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\\r
+    kv501.prod.do.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=collections-prod-frontdoor-geomap.trafficmanager.net. comment=\\r
+    consumer-collections-aks2eap.md.mp.microsoft.com.akadns.net list=\\r
+    windowsupdateslist\r
+add address=52.167.160.173 comment=array509.prod.do.dsp.mp.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=40.70.77.148 comment=array516.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.167.200.126 comment=array507.prod.do.dsp.mp.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=52.167.167.59 comment=array508.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=40.69.76.172 comment=array620.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=82.202.162.184 comment=comp-lenta.ru list=NoWG\r
+add address=smtp.mail.me.com.akadns.net. comment=smtp.mail.me.com list=NoWG\r
+add address=17.57.155.37 comment=smtp.mail.me.com.akadns.net list=NoWG\r
+add address=smtp.mail.me.com comment=smtp.mail.me.com list=NoVdsina\r
+add address=40.70.76.5 comment=array514.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=13.74.186.119 comment=array618.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.177.176.186 comment=array520.prod.do.dsp.mp.microsoft.com \\r
+    list=windowsupdateslist\r
+add address=40.70.76.27 comment=array515.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.167.160.43 comment=array503.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.110 comment=array817.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=13.74.142.8 comment=array614.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=13.74.138.254 comment=array603.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.167.167.96 comment=array501.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=40.69.76.215 comment=array622.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=13.74.143.200 comment=array606.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.111 comment=array818.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.112 comment=array819.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=13.74.137.53 comment=array608.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.98 comment=array805.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.96 comment=array803.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.104 comment=array811.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.101 comment=array808.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.99 comment=array806.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.17 comment=array802.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.97 comment=array804.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.103 comment=array810.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.16 comment=array801.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=40.70.77.177 comment=array517.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.167.164.84 comment=array512.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.105 comment=array812.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.107 comment=array814.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.232.161.82 comment=array502.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.108 comment=array815.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=52.167.161.91 comment=array505.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.102 comment=array809.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.109 comment=array816.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.106 comment=array813.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.117 comment=array622.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.107 comment=array612.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.108 comment=array613.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.105 comment=array610.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.113 comment=array618.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.116 comment=array621.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.98 comment=array603.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.114 comment=array619.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.111 comment=array616.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.97 comment=array602.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.106 comment=array611.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.110 comment=array615.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.119 comment=array624.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.135 comment=array514.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.97 comment=array503.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.99 comment=array604.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.61 comment=array504.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.131 comment=array510.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.132 comment=array511.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.96 comment=array601.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.104 comment=array609.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.138 comment=array517.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.60 comment=array501.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.139 comment=array518.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.118 comment=array623.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.113 comment=array820.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.103 comment=array608.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.154.7.100 comment=array807.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.129 comment=array508.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.134 comment=array513.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.62 comment=array505.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.137 comment=array516.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.101 comment=array606.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.96 comment=array502.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.130 comment=array509.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.112 comment=array617.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.100 comment=array605.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.115 comment=array620.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.136 comment=array515.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=purchase.md.mp.microsoft.com.akadns.net. comment=\\r
+    purchase.mp.microsoft.com list=windowsupdateslist\r
+add address=e110219.a.akamaiedge.net. comment=\\r
+    purchase.mp.microsoft.com.edgekey.net list=windowsupdateslist\r
+add address=72.153.5.140 comment=array519.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.141 list=windowsupdateslist\r
+add address=72.153.5.63 comment=array506.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.128 comment=array507.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.102 comment=array607.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=storesdk.xbetservices.akadns.net. comment=\\r
+    storesdk.dsx.mp.microsoft.com list=windowsupdateslist\r
+add address=e16646.g.akamaiedge.net. comment=\\r
+    storesdk.dsx.mp.microsoft.com.edgekey.net list=windowsupdateslist\r
+add address=software-download.microsoft.com.delivery.microsoft.com. comment=\\r
+    software-download.microsoft.com list=windowsupdateslist\r
+add address=download.prss.microsoft.com.akamaized.net. comment=\\r
+    software-download.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.145.35.109 comment=array614.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=72.153.5.133 comment=array512.prod.do.dsp.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=213.180.192.0/19 comment=YandexDisk list=NoVdsina\r
+add address=87.250.250.50 comment=YandexDisk list=NoVdsina\r
+add address=consumer-prod-bcfd-v7-afd.trafficmanager.net. comment=\\r
+    displaycatalog.mp.microsoft.com list=windowsupdateslist\r
+add address=purchase-europeeap.md.mp.microsoft.com.akadns.net. comment=\\r
+    purchase.md.mp.microsoft.com.akadns.net list=windowsupdateslist\r
+add address=ne-az-conspurchase-mp.trafficmanager.net. comment=\\r
+    purchase-europeeap.md.mp.microsoft.com.akadns.net list=windowsupdateslist\r
+add address=storeedgefd.dsx.mp.microsoft.com.edgekey.net. comment=\\r
+    cdn.storeedgefd.dsx.mp.microsoft.com list=windowsupdateslist\r
+add address=star.f.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \\r
+    comment=msedge.f.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=a1996.dscd.akamai.net. comment=\\r
+    wildcard.f.dl.delivery.mp.microsoft.com.edgesuite.net list=\\r
+    windowsupdateslist\r
+add address=cp801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\\r
+    cp801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=glb.tas02.sls-prod.dcat.dsp.mp.microsoft.com. comment=\\r
+    tas02.sls.update.microsoft.com list=windowsupdateslist\r
+add address=cp601.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\\r
+    cp601.prod.do.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=star.sb.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \\r
+    comment=msedgeextensions.sb.tlu.dl.delivery.mp.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=star.sf.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \\r
+    comment=msedge.sf.dl.delivery.mp.microsoft.com list=windowsupdateslist\r
+add address=cdp-f-ssl-nlu-net.trafficmanager.net. comment=\\r
+    star.sf.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\\r
+    windowsupdateslist\r
+add address=tm-pifd-prod-gbl-weight.trafficmanager.net. comment=\\r
+    paymentinstruments.mp.microsoft.com list=windowsupdateslist\r
+add address=10.30.30.33 comment=NUC disabled=yes list=NoWG\r
+add address=10.30.30.10 comment=MikroNUC disabled=yes list=NoWG\r
+add address=89.110.101.17 comment=!!!VDSINA!!!! list=NoWG\r
+add address=wg.vados.ru comment=VDSina-vpn list=Trusted-VPN\r
+add address=80.85.244.9 list=TRUSTED\r
+add address=disc801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\\r
+    disc801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist\r
+add address=185.71.70.78 disabled=yes list=TRUSTED\r
+add address=176.53.203.171 disabled=yes list=TRUSTED\r
+add address=176.53.203.170 disabled=yes list=TRUSTED\r
+add address=176.53.202.194 disabled=yes list=TRUSTED\r
+add address=89.110.101.17 comment="!!!VDSina Server!!!" disabled=yes list=\\r
+    NoVdsina\r
+add address=dns.quad9.net comment=Quad9-dns disabled=yes list=Trusted-DNS\r
+add address=dns.google comment=Google-dns list=Trusted-DNS\r
+add address=security.cloudflare-dns.com comment=CloudFlare-dns list=\\r
+    Trusted-DNS\r
+add address=time.google.com comment=Google-time list=Trusted-NTP\r
+add address=0.ru.pool.ntp.org comment=ru.pool.ntp.org disabled=yes list=\\r
+    Trusted-NTP\r
+add address=1.ru.pool.ntp.org disabled=yes list=Trusted-NTP\r
+add address=2.ru.pool.ntp.org comment=2.ru.pool.ntp.org disabled=yes list=\\r
+    Trusted-NTP\r
+add address=3.ru.pool.ntp.org comment=3.ru.pool.ntp.org disabled=yes list=\\r
+    Trusted-NTP\r
+add address=cp.vdsina.com comment=VDSina-vpn list=Trusted-VPN\r
+add address=vdsina.ru comment=VDSina-vpn list=Trusted-VPN\r
+add address=ns.vados.ru comment=VDSina-vpn list=Trusted-VPN\r
+add address=vdsina.com comment=VDSina-vpn list=Trusted-VPN\r
+add address=cp.vdsina.ru comment=VDSina-vpn list=Trusted-VPN\r
+add address=ns1.vdsina.ru comment=VDSina-vpn list=Trusted-VPN\r
+add address=ghcr.io comment=GitHub list=Trusted-VPN\r
+add address=github.com comment=GitHub list=Trusted-VPN\r
+add address=149.154.164.13 comment=telegra.ph list=FuckRKN\r
+add address=109.70.26.37 comment=grani.ru list=FuckRKN\r
+add address=194.85.61.76 comment=grani.ru list=FuckRKN\r
+add address=104.16.3.81 comment=xhamster.com list=FuckRKN\r
+add address=104.16.4.81 comment=xhamster.com list=FuckRKN\r
+add address=188.114.96.1 comment=lostfilm.tv list=FuckRKN\r
+add address=188.114.97.1 comment=lostfilm.tv list=FuckRKN\r
+add address=172.67.182.196 comment=rutracker.org list=FuckRKN\r
+add address=104.21.32.39 comment=rutracker.org list=FuckRKN\r
+add address=104.247.81.99 comment=lurkmore.to list=FuckRKN\r
+add address=8.6.112.6 comment=dou.ua list=FuckRKN\r
+add address=8.47.69.6 comment=dou.ua list=FuckRKN\r
+add address=66.254.114.79 comment=youporn.com list=FuckRKN\r
+add address=185.110.92.41 comment=pornolab.net list=FuckRKN\r
+add address=185.110.92.40 comment=pornolab.net list=FuckRKN\r
+add address=104.21.71.238 comment=crimerussia.com list=FuckRKN\r
+add address=172.67.172.95 comment=crimerussia.com list=FuckRKN\r
+add address=149.154.167.99 comment=telegram.org list=FuckRKN\r
+add address=149.154.166.110 comment=api.telegram.org list=FuckRKN\r
+/ip firewall filter\r
+add action=add-src-to-address-list address-list="Honeypot Hacker" \\r
+    address-list-timeout=12h chain=input comment="block honeypot DNS" \\r
+    connection-state=new dst-port=53 in-interface-list=WAN protocol=udp \\r
+    src-address=!10.30.30.0/24 src-address-list=!Trusted-DNS\r
+add action=add-src-to-address-list address-list="Honeypot Hacker" \\r
+    address-list-timeout=4w2d chain=input connection-state=new dst-port=53 \\r
+    in-interface-list=WAN protocol=tcp src-address=!10.30.30.0/24 \\r
+    src-address-list=!Trusted-DNS\r
+add action=add-src-to-address-list address-list="Honeypot Hacker" \\r
+    address-list-timeout=4w2d chain=input comment=\\r
+    "block honeypot ssh rdp winbox" connection-state=new dst-port=\\r
+    22,8291,2222 in-interface-list=WAN protocol=tcp src-address-list=!TRUSTED\r
+add action=add-src-to-address-list address-list="Honeypot Hacker" \\r
+    address-list-timeout=4w2d chain=input comment="block honeypot asterisk" \\r
+    connection-state=new dst-port=5060 in-interface-list=WAN protocol=udp \\r
+    src-address-list=!TRUSTED\r
+add action=add-src-to-address-list address-list="Honeypot Hacker" \\r
+    address-list-timeout=5d chain=input comment="block honeypot NTP" \\r
+    connection-state=new dst-port=123 in-interface-list=WAN protocol=udp \\r
+    src-address=!10.30.30.0/24 src-address-list=!Trusted-NTP\r
+add action=fasttrack-connection chain=forward comment=\\r
+    "FastTrack for non-VPN connections" connection-mark=!VPN_No_FastTrack \\r
+    connection-state=established,related,new disabled=yes\r
+add action=accept chain=output comment="Accept Rule for Trusted-NTP Servers" \\r
+    dst-address-list=Trusted-NTP dst-port=123 out-interface-list=WAN \\r
+    protocol=udp\r
+add action=accept chain=input comment=\\r
+    "accept NTP clients on local area network" disabled=yes dst-port=123 \\r
+    in-interface-list=LAN protocol=udp src-address=10.30.30.0/24\r
+add action=accept chain=output comment="accept WireGuard" disabled=yes \\r
+    dst-address-list=VPN-Server dst-port=13231 out-interface="ether1 - Unet" \\r
+    protocol=udp\r
+add action=accept chain=output disabled=yes dst-address-list=VPN-Server \\r
+    dst-port=29185 out-interface="ether1 - Unet" protocol=udp\r
+add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \\r
+    connection-state=established,related,new disabled=yes routing-mark=\\r
+    !To-VPN\r
+add action=accept chain=input disabled=yes dst-port=443 in-interface=\\r
+    "ether1 - Unet" protocol=tcp\r
+add action=accept chain=output disabled=yes protocol=tcp src-port=443\r
+add action=accept chain=input comment=\\r
+    "defconf: accept established,related,untracked" connection-state=\\r
+    established,related,untracked\r
+add action=drop chain=input comment="defconf: drop invalid" connection-state=\\r
+    invalid\r
+add action=accept chain=input comment="defconf: accept ICMP" disabled=yes \\r
+    protocol=icmp\r
+add action=accept chain=input comment=\\r
+    "defconf: accept to local loopback (for CAPsMAN)" disabled=yes \\r
+    dst-address=127.0.0.1\r
+add action=accept chain=output disabled=yes src-address=127.0.0.1\r
+add action=accept chain=forward comment="defconf: accept in ipsec policy" \\r
+    ipsec-policy=in,ipsec\r
+add action=accept chain=forward comment="defconf: accept out ipsec policy" \\r
+    ipsec-policy=out,ipsec\r
+add action=accept chain=forward comment=\\r
+    "defconf: accept established,related, untracked" connection-state=\\r
+    established,related,untracked\r
+add action=drop chain=forward comment="defconf: drop invalid" \\r
+    connection-state=invalid\r
+add action=drop chain=forward comment=\\r
+    "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \\r
+    connection-state=new in-interface="ether1 - Unet"\r
+add action=accept chain=input connection-state=established disabled=yes\r
+add action=accept chain=input connection-state=related disabled=yes\r
+add action=drop chain=input disabled=yes in-interface-list=!LAN\r
+add action=drop chain=forward comment=\\r
+    "Filter Rule to block FB address LIST : )" disabled=yes dst-address-list=\\r
+    facebook\r
+add action=drop chain=forward comment=\\r
+    "Filter Rule to block YOUTUBE address LIST : )" disabled=yes \\r
+    dst-address-list=YouTube\r
+/ip firewall mangle\r
+add action=mark-routing chain=prerouting comment="Test sites" disabled=yes \\r
+    dst-address=!10.30.30.0/24 dst-address-list=Test new-routing-mark=To-VPN \\r
+    src-address=10.30.30.0/24\r
+add action=mark-routing chain=prerouting comment=FuckRKN disabled=yes \\r
+    dst-address-list=FuckRKN new-routing-mark=To-VPN passthrough=no \\r
+    src-address=10.30.30.0/24 src-address-list=!NoWG\r
+add action=mark-routing chain=prerouting comment=Instagram dst-address-list=\\r
+    Instagram new-routing-mark=To-VPN src-address=10.30.30.0/24 \\r
+    src-address-list=!NoWG\r
+add action=mark-routing chain=prerouting comment=Twitter dst-address-list=\\r
+    Twitter new-routing-mark=To-VPN src-address=10.30.30.0/24 \\r
+    src-address-list=!NoWG\r
+add action=mark-routing chain=prerouting comment=YouTube dst-address-list=\\r
+    YouTube new-routing-mark=To-VPN src-address=10.30.30.0/24 \\r
+    src-address-list=!NoWG\r
+add action=mark-routing chain=prerouting comment=facebook dst-address-list=\\r
+    facebook new-routing-mark=To-VPN src-address=10.30.30.0/24 \\r
+    src-address-list=!NoWG\r
+add action=mark-routing chain=prerouting comment="VDSIna for All sites" \\r
+    dst-address=!10.30.30.0/24 dst-address-list=!Trusted-VPN log-prefix=\\r
+    VPN-all new-routing-mark=To-VPN passthrough=no src-address=10.30.30.0/24\r
+add action=change-mss chain=forward comment="MSS on WG" new-mss=1380 \\r
+    out-interface=WG passthrough=no protocol=tcp routing-mark=To-VPN \\r
+    tcp-flags=syn tcp-mss=1381-65535\r
+add action=mark-connection chain=prerouting comment=\\r
+    "Mark VPN connections to exclude from FastTrack" disabled=yes \\r
+    in-interface=WG log-prefix=Mark-VPN-FT new-connection-mark=\\r
+    VPN_No_FastTrack passthrough=no\r
+add action=mark-routing chain=prerouting comment="VPN Network" dst-address=\\r
+    10.8.0.0/24 log-prefix=VPN-Net new-routing-mark=To-VPN passthrough=no \\r
+    src-address=10.30.30.0/24\r
+/ip firewall nat\r
+add action=redirect chain=dstnat comment=\\r
+    "FORCE DNS TO LOCAL MIKROTIK DNS SERVER" dst-port=53 protocol=tcp \\r
+    src-address=10.30.30.0/24 to-ports=53\r
+add action=redirect chain=dstnat dst-port=53 protocol=udp src-address=\\r
+    10.30.30.0/24 to-ports=53\r
+add action=masquerade chain=srcnat comment="masquerade Default" ipsec-policy=\\r
+    out,none out-interface="ether1 - Unet"\r
+add action=masquerade chain=srcnat comment=WG dst-address-list=!NoVdsina \\r
+    log-prefix=WG-nat out-interface=WG\r
+add action=dst-nat chain=dstnat comment=amster.vados.ruhttps dst-port=443 \\r
+    in-interface="ether1 - Unet" log-prefix=2Amster protocol=tcp \\r
+    routing-mark=!To-VPN to-addresses=10.30.30.33 to-ports=443\r
+add action=dst-nat chain=dstnat comment=npm dst-port=81 in-interface=\\r
+    "ether1 - Unet" protocol=tcp routing-mark=!To-VPN to-addresses=\\r
+    10.30.30.33 to-ports=81\r
+add action=dst-nat chain=dstnat comment="amster.vados.ru For Certbot HTTP" \\r
+    dst-port=80 in-interface="ether1 - Unet" protocol=tcp routing-mark=\\r
+    !To-VPN to-addresses=10.30.30.33 to-ports=80\r
+add action=dst-nat chain=dstnat disabled=yes dst-port=22 in-interface=\\r
+    "ether1 - Unet" protocol=tcp routing-mark=!To-VPN to-addresses=\\r
+    10.30.30.33 to-ports=22\r
+add action=dst-nat chain=dstnat comment="Yandex.DNS Family" disabled=yes \\r
+    dst-port=53 in-interface=Bridge-LAN protocol=udp src-address-list=KIDS \\r
+    time=6h-15m,sun,mon,tue,wed,thu,fri,sat to-addresses=77.88.8.3\r
+add action=dst-nat chain=dstnat disabled=yes dst-port=53 in-interface=\\r
+    Bridge-LAN protocol=tcp src-address-list=KIDS time=\\r
+    6h-15m,sun,mon,tue,wed,thu,fri,sat to-addresses=77.88.8.3\r
+/ip firewall raw\r
+add action=drop chain=prerouting comment="Drop Honeypot Hackers" \\r
+    in-interface="ether1 - Unet" src-address-list="Honeypot Hacker"\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=\\r
+    extras.getpagespeed.com content=extras.getpagespeed.com disabled=yes\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=linux.duke.edu \\r
+    content=linux.duke.edu disabled=yes\r
+add action=accept chain=prerouting comment="Trusted DNS" disabled=yes \\r
+    in-interface-list=WAN src-address-list=Trusted-DNS\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=vk.com \\r
+    content=vk.com\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=ok.ru content=\\r
+    ok.ru\r
+add action=add-dst-to-address-list address-list=Instagram \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=Instagram \\r
+    content=instagram.com\r
+add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\\r
+    none-dynamic chain=prerouting comment=Twitter content=twimg.com\r
+add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\\r
+    none-dynamic chain=prerouting content=x.com\r
+add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\\r
+    none-dynamic chain=prerouting content=twitter.com\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting comment=YouTube content=youtube.com\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting content=googleapis.com\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting content=ggpht.com\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting content=youtu.be\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting content=ytimg.com\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting content=googlevideo.com\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting content=gstatic.com\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting content=googleusercontent.com\r
+add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\\r
+    none-dynamic chain=prerouting content=nhacmp3youtube.com\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=rutube.ru \\r
+    content=rutube.ru\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=me.com \\r
+    content=me.com\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=icloud.com \\r
+    content=icloud.com\r
+add action=add-dst-to-address-list address-list=facebook \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=facebook \\r
+    content=fbcd.net\r
+add action=add-dst-to-address-list address-list=facebook \\r
+    address-list-timeout=none-dynamic chain=prerouting content=facebook.com\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=comp-lenta.ru \\r
+    content=comp-lenta.ru\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=\\r
+    smtp.mail.me.com content=smtp.mail.me.com\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=gov.ru \\r
+    content=gov.ru\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=\\r
+    r78.fssp.gov.ru content=r78.fssp.gov.ru\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=api.db-ip.com \\r
+    content=api.db-ip.com\r
+add action=add-dst-to-address-list address-list=NoVdsina \\r
+    address-list-timeout=none-dynamic chain=prerouting comment=\\r
+    api.telegram.org content=api.telegram.org\r
+/ip firewall service-port\r
+set ftp disabled=yes\r
+set tftp disabled=yes\r
+set irc disabled=no\r
+set sip disabled=yes\r
+set pptp disabled=yes\r
+set rtsp disabled=no\r
+/ip hotspot user profile\r
+set [ find default=yes ] address-pool=dhcp\r
+/ip hotspot walled-garden\r
+add server=*1\r
+add server=*1\r
+/ip ipsec settings\r
+set accounting=no\r
+/ip ipsec policy\r
+set 0 disabled=yes dst-address=0.0.0.0/0 src-address=0.0.0.0/0\r
+/ip ipsec profile\r
+set [ find default=yes ] dpd-interval=2m dpd-maximum-failures=5\r
+/ip proxy\r
+set cache-administrator="" max-cache-size=none port=80,443 src-address=\\r
+    0.0.0.0\r
+/ip route\r
+add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=WG routing-table=\\r
+    To-VPN scope=30 target-scope=10\r
+/ip service\r
+set ftp disabled=yes\r
+set telnet disabled=yes\r
+set reverse-proxy disabled=yes\r
+set ssh address=10.30.30.0/24 port=2222\r
+set winbox address=10.30.30.0/24\r
+set api address=10.30.30.0/24 disabled=yes\r
+set api-ssl address=10.30.30.0/24 disabled=yes\r
+set www-ssl port=18443\r
+set www address=10.30.30.0/24 disabled=yes port=18880\r
+/ip service webserver\r
+set acme-plain=no crl-plain=no graphs-plain=no graphs-secure=no index-plain=\\r
+    no index-secure=no rest-plain=no rest-secure=no scep-plain=no \\r
+    webfig-plain=no webfig-secure=no\r
+/ip ssh\r
+set forwarding-enabled=both publickey-authentication-options=verify-required \\r
+    strong-crypto=yes\r
+/ip upnp\r
+set enabled=yes\r
+/ip upnp interfaces\r
+add interface=Bridge-LAN type=internal\r
+add interface="ether1 - Unet" type=external\r
+add interface=WG type=external\r
+add interface=wlan2 type=internal\r
+/ipv6 address\r
+add address=fdcc:ad94:bacf:61a4::cafe:2/128 advertise=no interface=*F\r
+/snmp community\r
+set [ find default=yes ] addresses=10.30.30.0/24 read-access=no security=\\r
+    private\r
+/system clock\r
+set time-zone-autodetect=no time-zone-name=Europe/Moscow\r
+/system clock manual\r
+set time-zone=+03:00\r
+/system identity\r
+set name=MikroMaster\r
+/system logging\r
+add action=email disabled=yes regex="* added|changed|removed *" topics=\\r
+    system,info\r
+/system note\r
+set show-at-login=no\r
+/system ntp client\r
+set enabled=yes\r
+/system ntp server\r
+set enabled=yes manycast=yes multicast=yes use-local-clock=yes\r
+/system ntp client servers\r
+add address=0.ru.pool.ntp.org\r
+add address=1.ru.pool.ntp.org\r
+add address=2.ru.pool.ntp.org\r
+add address=3.ru.pool.ntp.org\r
+add address=time.google.com disabled=yes\r
+/system package update\r
+set channel=development\r
+/system scheduler\r
+add comment="Scheduler for Update Certificates CloudFlare Quad9" disabled=yes \\r
+    interval=1w name="Update Certificates CloudFlare Quad9" on-event=\\r
+    "/system/script { run Update-Certificates; }" policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \\r
+    start-date=2025-11-28 start-time=05:45:40\r
+add comment="Every Day Set Global Environment Variables" name=AM-SetGlobalEnv \\r
+    on-event="/system/script { run AM-GlobalConfig; run AM-GlobalFunc; }" \\r
+    policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \\r
+    start-time=startup\r
+add comment="Every Day Check For Update Scripts" interval=1d name=\\r
+    AM-ScriptInstallUpdate on-event=\\r
+    ":global ScriptInstallUpdate; \$ScriptInstallUpdate;" policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \\r
+    start-time=startup\r
+add comment="Update RKN DNS Looup" interval=20m name=AM-RKN-dnsLookup \\r
+    on-event="/system/script { run AM-RKN-dnsLookup; }" policy=\\r
+    ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \\r
+    start-time=startup\r
+/system watchdog\r
+set watchdog-timer=no\r
+/tool e-mail\r
+set certificate-verification=no from=MikroVados<vadossio@icloud.com> port=587 \\r
+    server=smtp.mail.me.com tls=starttls user=vadossio@icloud.com\r
+/tool mac-server\r
+set allowed-interface-list=LAN\r
+/tool mac-server mac-winbox\r
+set allowed-interface-list=LAN\r
+/tool netwatch\r
+add comment="doh, doh-url=https://security.cloudflare-dns.com/dns-query, notif\\r
+    y, name=CloudFlare-doh IPv4 1" disabled=yes down-script="" host=1.1.1.1 \\r
+    http-codes="" test-script="" type=simple up-script=""\r
+add check-certificate=no comment="doh-fallback, doh-url=https://security.cloud\\r
+    flare-dns.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=Cl\\r
+    oudFlare-doh IPv4" disabled=yes down-script="" host=1.0.0.1 http-codes="" \\r
+    port=443 test-script="" type=simple up-script=""\r
+add comment="dns-fallback, notify, name=Google-DNS IPv4" disabled=yes \\r
+    down-script="" host=8.8.8.8 http-codes="" test-script="" type=simple \\r
+    up-script=""\r
+add comment="doh-fallback, doh-url=https://dns.google/dns-query, doh-cert=GTS \\r
+    Root R1, notify, name=Google-DOH IPv4" disabled=yes down-script="" host=\\r
+    8.8.4.4 http-codes="" test-script="" type=simple up-script=""\r
+add comment="dns, notify, name=Cuad9-DOH IPv4" disabled=yes down-script="" \\r
+    host=9.9.9.9 http-codes="" test-script="" type=simple up-script=""\r
+add comment="doh-fallback, doh-url=https://dns.quad9.net/dns-query, name=Cuad9\\r
+    -DOH IPv4" disabled=yes down-script="" host=149.112.112.112 http-codes="" \\r
+    test-script="" type=simple up-script=""\r
+add comment="dns-fallback, notify, name=ns1.unet.ws" disabled=yes \\r
+    down-script="" host=91.192.189.2 http-codes="" test-script="" type=simple \\r
+    up-script=""\r
+/tool sniffer\r
+set filter-interface=Bridge-LAN filter-src-ip-address=10.30.30.50/32\r
+/user aaa\r
+set accounting=no\r
diff --git a/MikroMaster/history/20260512/20260512100002-Diff-Config.rsc b/MikroMaster/history/20260512/20260512100002-Diff-Config.rsc
new file mode 100644 (file)
index 0000000..7688d46
--- /dev/null
@@ -0,0 +1,8 @@
+4297d4296
+< add address=109.70.26.37 comment=grani.ru list=FuckRKN\r
+4299c4298
+< add address=104.16.3.81 comment=xhamster.com list=FuckRKN\r
+---
+> add address=109.70.26.37 comment=grani.ru list=FuckRKN\r
+4300a4300
+> add address=104.16.3.81 comment=xhamster.com list=FuckRKN\r