From: vados-dev Date: Sun, 5 Apr 2026 01:02:50 +0000 (+0300) Subject: Backup for MikroMaster sucessfully creatd at Apr 05 04:02:50. X-Git-Url: https://git.vados.ru/gitweb.cgi?a=commitdiff_plain;h=473d6654dc71dc98c1e38c3ba0fe7f741e8d6f4e;p=Mikrotiks%2Fbackups.git Backup for MikroMaster sucessfully creatd at Apr 05 04:02:50. --- diff --git a/MikroMaster/20260405/20260405040243-Binary.backup b/MikroMaster/20260405/20260405040243-Binary.backup new file mode 100644 index 0000000..2bb5f18 Binary files /dev/null and b/MikroMaster/20260405/20260405040243-Binary.backup differ diff --git a/MikroMaster/20260405/20260405040243-Config.rsc b/MikroMaster/20260405/20260405040243-Config.rsc new file mode 100644 index 0000000..332ec17 --- /dev/null +++ b/MikroMaster/20260405/20260405040243-Config.rsc @@ -0,0 +1,4518 @@ +# 2026-04-05 04:02:43 by RouterOS 7.22 +# software id = 2961-C4ZZ +# +# model = RBD52G-5HacD2HnD +# serial number = HCX084RAVFA +/interface bridge +add admin-mac=48:8F:5A:60:A1:0B auto-mac=no name=Bridge-LAN port-cost-mode=\ + short +/interface ethernet +set [ find default-name=ether1 ] comment="WAN - Unet" mac-address=\ + F6:BE:9D:85:53:F5 name="ether1 - Unet" +set [ find default-name=ether3 ] comment=LEN +set [ find default-name=ether4 ] comment=NUC +/interface l2tp-server +add comment=Server disabled=yes name=l2tp-in1 user=vados +/interface l2tp-client +add comment="Starless 2 MikroSPb" connect-to=176.53.203.171 name=l2tp-EoIP \ + user=vados +add allow=mschap2 allow-fast-path=yes comment=Starless connect-to=\ + vpn.starless.ru max-mru=1280 name=l2tp-vpn use-ipsec=yes use-peer-dns=yes \ + user=vados +/interface wireless +# managed by CAPsMAN +# channel: 2422/20-Ce/gn(17dBm), SSID: vados, local forwarding +set [ find default-name=wlan1 ] ampdu-priorities=0,1,2,3,4,5,6,7 band=\ + 2ghz-b/g/n basic-rates-a/g=\ + 6Mbps,9Mbps,12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps basic-rates-b=\ + 1Mbps,2Mbps,5.5Mbps,11Mbps channel-width=20/40mhz-XX country=belarus \ + disabled=no frequency=auto hw-protection-mode=rts-cts mode=ap-bridge \ + rate-set=configured skip-dfs-channels=10min-cac ssid=vados \ + station-roaming=enabled wds-default-bridge=Bridge-LAN wds-mode=\ + dynamic-mesh wireless-protocol=802.11 wmm-support=enabled wps-mode=\ + disabled +# managed by CAPsMAN +# channel: 5260/20-Ceee/ac/DP(17dBm), SSID: vados5g, local forwarding +set [ find default-name=wlan2 ] ampdu-priorities=0,1,2,3,4,5,6,7 band=\ + 5ghz-a/n/ac basic-rates-a/g=\ + 6Mbps,9Mbps,12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps channel-width=\ + 20/40/80mhz-XXXX country=belarus disabled=no frequency=auto \ + hw-protection-mode=rts-cts mode=ap-bridge rate-set=configured \ + skip-dfs-channels=10min-cac ssid=vados5g station-roaming=enabled \ + wds-default-bridge=Bridge-LAN wds-mode=dynamic-mesh wireless-protocol=\ + 802.11 wmm-support=enabled wps-mode=disabled +/interface wireguard +add listen-port=13231 mtu=1280 name=WG +/interface wireless nstreme +# managed by CAPsMAN +# channel: 2422/20-Ce/gn(17dBm), SSID: vados, local forwarding +set wlan1 enable-nstreme=yes +# managed by CAPsMAN +# channel: 5260/20-Ceee/ac/DP(17dBm), SSID: vados5g, local forwarding +set wlan2 enable-nstreme=yes +/caps-man security +add authentication-types=wpa-psk,wpa2-psk encryption=aes-ccm \ + group-encryption=aes-ccm name=security +/caps-man configuration +add channel.band=2ghz-b/g/n .control-channel-width=20mhz .extension-channel=\ + XX country=belarus datapath.client-to-client-forwarding=yes \ + .local-forwarding=yes name=cfg-2ghz security=security ssid=vados +add channel.band=5ghz-a/n/ac .control-channel-width=20mhz .extension-channel=\ + XXXX country=belarus datapath.client-to-client-forwarding=yes \ + .local-forwarding=yes name=cfg-5ghz-ac security=security ssid=vados5g +add channel.band=5ghz-a/n .control-channel-width=20mhz .extension-channel=XX \ + country=belarus datapath.client-to-client-forwarding=yes \ + .local-forwarding=yes name=cfg-5ghz-an security=security ssid=vados5g +/disk +add media-interface=lo slot=tmpfs tmpfs-max-size=44739242 type=tmpfs +# mountpoint [tmpfs] taken by tmpfs +set usb1 mount-point-template="[tmpfs]" +/interface list +add comment=defconf name=WAN +add comment=defconf name=LAN +/interface lte apn +set [ find default=yes ] ip-type=ipv4 use-network-apn=no +/interface wifi channel +add band=5ghz-ax disabled=no frequency=5180,5200,5220,5240 name=5G-AX +add band=5ghz-ac disabled=no frequency=5180,5200,5220,5240 name=5G-AC +add band=2ghz-n disabled=no frequency=2422,2442,2462 name=2G-N +add band=2ghz-ax disabled=no frequency=2422,2442,2462 name=2G-AX +add band=2ghz-g disabled=no frequency=2422,2442,2462 name=2G-G +add band=5ghz-n disabled=no frequency=5180,5200,5220,5240 name=5G-AN +/interface wifi datapath +add bridge=Bridge-LAN disabled=no interface-list=all name=xs-DataPath +/interface wifi security +add authentication-types=wpa2-psk,wpa3-psk disabled=no group-encryption=ccmp \ + group-key-update=1h management-protection=allowed name=sec2g +add authentication-types=wpa3-psk disable-pmkid=yes disabled=no \ + group-encryption=ccmp group-key-update=5m management-encryption=cmac \ + management-protection=required name=sec5G +/interface wifi configuration +add channel=2G-AX datapath=xs-DataPath disabled=no mode=ap name=2G-AX \ + security=sec2g security.ft=yes .ft-over-ds=yes ssid=vados +add channel=2G-N datapath=xs-DataPath disabled=no mode=ap name=2G-N security=\ + sec2g security.ft=yes .ft-over-ds=yes ssid=vados +add channel=5G-AX disabled=no mode=ap name=5G-AX security=sec5G security.ft=\ + yes .ft-over-ds=yes ssid=vados +add channel=5G-AC datapath=xs-DataPath disabled=no mode=ap name=5G-AC \ + security=sec5G security.authentication-types="" .ft=yes .ft-over-ds=yes \ + ssid=vados +add channel=2G-G datapath=xs-DataPath disabled=no mode=ap name=2G-G security=\ + sec2g security.authentication-types="" .ft=yes .ft-over-ds=yes ssid=vados +add channel=5G-AN disabled=no mode=ap name=5G-AN security=sec5G ssid=vados +/interface wireless security-profiles +set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\ + dynamic-keys supplicant-identity=MikroTik +/ip dhcp-server option +add code=12 name=HostName +add code=119 force=yes name=domain-search-list value="0x03'WORKGROUP'0x00" +/ip dhcp-server option sets +add name=HP1505n options=HostName +add name=StartLife1 options=HostName +add name=amsterDev options=HostName +add name=MiTV options=HostName +add name=miller options=HostName +add name=amster options=HostName +add name=garage options=HostName +add name=domain-search-set options=domain-search-list +add name=VADOS-LEN options=HostName +add name=VADOS-NUC options=HostName +add name=MikroNUC options=HostName +add name=master options=HostName +add name=MikroYellow options=HostName +add name="=\"Client ID\"" options=HostName +add name=mVados options=HostName +/ip dns forwarders +add dns-servers=1.1.1.1,1.0.0.1 name=blsp.at verify-doh-cert=no +add comment=Kra dns-servers=1.0.0.1,1.1.1.1 name=slon2.to verify-doh-cert=no +add dns-servers=1.1.1.1,1.0.0.1 name=slon3.at verify-doh-cert=no +add dns-servers=1.0.0.1,1.1.1.1 name=slon3.cc verify-doh-cert=no +add dns-servers=1.1.1.1,1.0.0.1 name=bs2web.at verify-doh-cert=no +add dns-servers=1.1.1.1,1.0.0.1 name=bs2best.at verify-doh-cert=no +add dns-servers=1.0.0.1,1.1.1.1 name=psrms.is verify-doh-cert=no +add dns-servers=1.0.0.1,1.1.1.1 name=m.blsp.at verify-doh-cert=no +/ip ipsec proposal +set [ find default=yes ] disabled=yes +/ip pool +add name=dhcp ranges=10.30.30.150-10.30.30.200 +/ip dhcp-server +add add-arp=yes address-pool=dhcp dhcp-option-set=domain-search-set \ + dynamic-lease-identifiers=client-mac,client-id,opt-82 interface=\ + Bridge-LAN lease-time=10m name=masterDHCP server-address=10.30.30.81 \ + use-reconfigure=yes +/ip hotspot user profile +set [ find default=yes ] address-pool=dhcp +/ip smb users +set [ find default=yes ] disabled=yes +add disabled=yes name=vados +/ppp profile +set *FFFFFFFE use-upnp=no +/routing bgp template +set default disabled=no output.network=bgp-networks +/routing table +add disabled=no fib name=To-VPN +/snmp community +set [ find default=yes ] addresses=10.30.30.0/24 read-access=no security=\ + private +/system logging action +add email-start-tls=yes email-to=vados@vados.ru name=email target=email +/system script +add comment="Example add WU servers to AddrList" dont-require-permissions=no \ + name=WU-add-to-list owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + \_Script to add target web sites DNS IP addresses into address list\r\ + \n# Tested with Mikrotik 6.4x\r\ + \n# Syed Jahanzaib / aacable@hotmail.com\r\ + \n# List name\r\ + \n:local LISTNAME \"windowsupdateslist\"\r\ + \n# Web site names which will be added in address list\r\ + \n:local TARGET1 \"update.microsoft.com\"\r\ + \n:local TARGET2 \"download.windowsupdate.com\"\r\ + \n:local TARGET3 \"download.microsoft.com\"\r\ + \n:local TARGET4 \"windowsupdate.com\"\r\ + \n:local TARGET5 \"ntservicepack.microsoft.com\"\r\ + \n:local TARGET6 \"wustat.windows.com\"\r\ + \n:local TARGET7 \"stats.microsoft.com\"\r\ + \n:local TARGET8 \"mp.microsoft.com\"\r\ + \n:local TARGET9 \"ws.microsoft.com\"\r\ + \n:local TARGET10 \"sls.update.microsoft.com.akadns.net\"\r\ + \n:local TARGET11 \"vortex.data.microsoft.com\"\r\ + \n:local TARGET12 \"vortex-win.data.microsoft.com\"\r\ + \n:local TARGET13 \"fe2.update.microsoft.com.akadns.net\"\r\ + \n:local TARGET14 \"statsfe2.update.microsoft.com.akadns.net\"\r\ + \n \r\ + \n# 1st time runner, check if address list is not created previously and a\ + dd entries in it for 1st time usage\r\ + \n:if ( [/ip firewall address-list find where list=\$LISTNAME] = \"\") do=\ + {\r\ + \n:log warning \"No address list for \$TARGET1 found ! creating and adding\ + \_resolved entry for 1st time usage ... zaib\"\r\ + \n \r\ + \n:local FirstAddr [resolve \$TARGET1];\r\ + \n\r\ + \n/ip firewall address-list add address=\$FirstAddr list=\$LISTNAME commen\ + t=\$TARGET1;\r\ + \n} else={\r\ + \n:log warning \"Previous List for \$LISTNAME found ! moving forward and c\ + hecking if DNS entries can be added in it ...\"\r\ + \n}\r\ + \n \r\ + \n# Check DNS entries and collect matching names\r\ + \n:foreach i in=[/ip dns cache find name~\"(\$TARGET1|\$TARGET2|\$TARGET3|\ + \$TARGET4|\$TARGET5|\$TARGET6|\$TARGET7|\$TARGET8|\$TARGET9|\$TARGET10|\$T\ + ARGET11|\$TARGET12|\$TARGET13|\$TARGET14)\" && \$type ~ \"^(A|CNAME)\\\$\"\ + \_] do={\r\ + \n \r\ + \n# Get IP Address from the names and hold it in temporary buffer\r\ + \n:local Buffer [/ip dns cache get \$i data];\r\ + \ndelay delay-time=10ms\r\ + \n \r\ + \n# Check if entry is already not exists, then OK, otherwise ignore duplic\ + ation\r\ + \n:if ( [/ip firewall address-list find where address=\$Buffer] = \"\") do\ + ={\r\ + \n \r\ + \n# Fetch DNS names for the entries\r\ + \n:local sitednsname [/ip dns cache get \$i name] ;\r\ + \n \r\ + \n# Print name in LOG window\r\ + \n:log info (\"added entry: \$sitednsname \$Buffer\");\r\ + \n \r\ + \n# Add IP addresses and there names to the address list\r\ + \n/ip firewall address-list add address=\$Buffer list=\$LISTNAME comment=\ + \$sitednsname;\r\ + \n}\r\ + \n}" +add comment="Add Hosts DNS names to NoWG addres list" \ + dont-require-permissions=no name=Add2vdsina owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + \_Script to add target web sites DNS IP addresses into address list\r\ + \n# Tested with Mikrotik 6.4x\r\ + \n# \r\ + \n# List name\r\ + \n:local LISTNAME \"NoWG\"\r\ + \n#\r\ + \n# Web site names which will be added in address list\r\ + \n:local TARGET1 \"comp-lenta.ru\"\r\ + \n:local TARGET2 \"ok.ru\"\r\ + \n:local TARGET3 \"vk.com\"\r\ + \n#:local TARGET4 \"smtp.mail.me.com\"\r\ + \n#:local TARGET4 \"windowsupdate.com\"\r\ + \n#:local TARGET5 \"ntservicepack.microsoft.com\"\r\ + \n#:local TARGET6 \"wustat.windows.com\"\r\ + \n#:local TARGET7 \"stats.microsoft.com\"\r\ + \n#:local TARGET8 \"mp.microsoft.com\"\r\ + \n#:local TARGET9 \"ws.microsoft.com\"\r\ + \n#:local TARGET10 \"sls.update.microsoft.com.akadns.net\"\r\ + \n#:local TARGET11 \"vortex.data.microsoft.com\"\r\ + \n#:local TARGET12 \"vortex-win.data.microsoft.com\"\r\ + \n#:local TARGET13 \"fe2.update.microsoft.com.akadns.net\"\r\ + \n#:local TARGET14 \"statsfe2.update.microsoft.com.akadns.net\"\r\ + \n \r\ + \n# 1st time runner, check if address list is not created previously and a\ + dd entries in it for 1st time usage\r\ + \n:if ( [/ip firewall address-list find where list=\$LISTNAME] = \"\") do=\ + {\r\ + \n:log warning \"No address list for \$TARGET1 found ! creating and adding\ + \_resolved entry for 1st time usage ... zaib\"\r\ + \n\r\ + \n:local FirstAddr [resolve \$TARGET1];\r\ + \n\r\ + \n/ip firewall address-list add address=\$FirstAddr list=\$LISTNAME commen\ + t=\$TARGET1;\r\ + \n\r\ + \n} else={\r\ + \n:log warning \"Previous List for \$LISTNAME found ! moving forward and c\ + hecking if DNS entries can be added in it ...\"\r\ + \n}\r\ + \n\r\ + \n# Check DNS entries and collect matching names\r\ + \n:foreach i in=[/ip dns cache find name~\"(\$TARGET1|\$TARGET2|\$TARGET3|\ + \$TARGET4)\" && \$type ~ \"^(A|CNAME)\\\$\" ] do={\r\ + \n\r\ + \n:log info (\"start entry: \$c \$sitednsname \$Buffer\");\r\ + \n\r\ + \n# Get IP Address from the names and hold it in temporary buffer\r\ + \n:local Buffer [/ip dns cache get \$i data];\r\ + \ndelay delay-time=10ms\r\ + \n:log info (\"1: \$Buffer\"); \r\ + \n\r\ + \n# Check if entry is already not exists, then OK, otherwise ignore duplic\ + ation\r\ + \n:if ( [/ip firewall address-list find where address=\$Buffer] = \"\") do\ + ={\r\ + \n\r\ + \n:log info (\"2: \$Buffer\"); \r\ + \n \r\ + \n# Fetch DNS names for the entries\r\ + \n:local sitednsname [/ip dns cache get \$i name] ;\r\ + \n \r\ + \n# Print name in LOG window\r\ + \n:log info (\"added entry: \$i \$sitednsname \$Buffer\");\r\ + \n \r\ + \n# Add IP addresses and there names to the address list\r\ + \n/ip firewall address-list add address=\$Buffer list=\$LISTNAME comment=\ + \$sitednsname;\r\ + \n}\r\ + \n}" +add comment="Flush DNS Cache" dont-require-permissions=no name=\ + DNS_Flush_Cache owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\ + "/ip dns cache flush" +add dont-require-permissions=no name=create_mkdir_function owner=vados \ + policy=read,write source="# Written by Phillip Stromberg in 2019\r\ + \n# Distributed under the MIT license\r\ + \n# \r\ + \n# \r\ + \n# this creates a function called \$mkdir\r\ + \n# from the command line you will be able to just type \"\$mkdir some/new\ + /folder\"\r\ + \n# and all the folders that need to be created will be\r\ + \n# if the folder already existed, it is ignored\r\ + \n\r\ + \n:log info \"Creating \\\$mkdir function...\"\r\ + \n\r\ + \n:global mkdir do={\r\ + \n # \$1 refers to the input variable the user passed in to us\r\ + \n :local newFolder \$1;\r\ + \n\r\ + \n # we'll use this variable to report error messages that may arise\r\ + \n :local errorMsg;\r\ + \n\r\ + \n # if the user put a slash on the end of the new folder name, remove \ + it\r\ + \n # i.e. \"some/test/\" becomes \"some/test\"\r\ + \n :while (([:pick \$newFolder ([:len \$newFolder] - 1)]) = \"/\") do={\ + \r\ + \n :set newFolder [:pick \$newFolder 0 ([:len \$newFolder] - 1)]\r\ + \n }\r\ + \n\r\ + \n # if the user put a slash at the beginning of the new folder name, r\ + emove it\r\ + \n # i.e. \"/some/test\" becomes \"some/test\"\r\ + \n :while ([:pick \$newFolder 0] = \"/\") do={\r\ + \n :set newFolder [:pick \$newFolder 1 [:len \$newFolder]]\r\ + \n }\r\ + \n\r\ + \n :if ([/file find name=\$newFolder] != \"\") do={\r\ + \n :set errorMsg \"'\$newFolder' already exists.\";\r\ + \n :log debug \"mkdir: \$errorMsg\";\r\ + \n :return \$newFolder;\r\ + \n }\r\ + \n\r\ + \n # the name of the temp file to create\r\ + \n :local tempfile \"mkdir_temp_file.txt\";\r\ + \n\r\ + \n # port 0 is unlikely to be open to HTTP requests...\r\ + \n :local fakeURL \"http://127.0.0.1:0/should-not-exist.txt\";\r\ + \n\r\ + \n :local fullTempPath (\$newFolder . \"/\" . \$tempfile);\r\ + \n\r\ + \n # this is where the folder creation happens\r\ + \n # `as-value` prevents status messages from printing\r\ + \n # wrapping in a `:do {...} on-error` prevents error messages from pr\ + inting.\r\ + \n :do {\r\ + \n /tool fetch dst-path=\"\$fullTempPath\" url=\"\$fakeURL\" durati\ + on=0.001s as-value;\r\ + \n } on-error={}\r\ + \n\r\ + \n # this waits for the temporary dir to show up so there isn't a race \ + \r\ + \n # condition where you call mkdir and then try to do something before\ + \_the \r\ + \n # folder is actually created\r\ + \n :local count 0;\r\ + \n :while ([/file find name=\"\$newFolder\"] = \"\") do={\r\ + \n :if (\$count >= 50) do={\r\ + \n # after 50 * 0.1s delays, it's been 5 seconds, which should \ + be long enough\r\ + \n :set errorMsg \"New folder could not be created at \$newFold\ + er\";\r\ + \n :log error \"mkdir: \$errorMsg\"\r\ + \n :error \$errorMsg\r\ + \n }\r\ + \n :delay 0.1s;\r\ + \n :set count (\$count + 1);\r\ + \n }\r\ + \n\r\ + \n :return \$newFolder;\r\ + \n}\r\ + \n\r\ + \n:log info \"Created function \\\$mkdir\"\r\ + \n" +add comment="Certificates CloudFlare, Quad9 " dont-require-permissions=no \ + name=Update-Certificates owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + \_CloudFlare\r\ + \n/tool/fetch mode=https url=https://cacerts.digicert.com/DigiCertGlobalRo\ + otCA.crt.pem;\r\ + \n/certificate/import file-name=DigiCertGlobalRootCA.crt.pem passphrase=\"\ + \";\r\ + \n/tool/ fetch mode=https url=https://cacerts.digicert.com/DigiCertGlobalG\ + 2TLSRSASHA2562020CA1-1.crt.pem;\r\ + \n/certificate/import file-name=DigiCertGlobalG2TLSRSASHA2562020CA1-1.crt.\ + pem passphrase=\"\";\r\ + \n# Quad9\r\ + \n/tool/fetch mode=https url=\"https://cacerts.digicert.com/DigiCertGlobal\ + G3TLSECCSHA3842020CA1-1.crt.pem\"\r\ + \n/certificate/import file-name=DigiCertGlobalG3TLSECCSHA3842020CA1-1.crt.\ + pem passphrase=\"\";\r\ + \n\r\ + \n#:global AmScriptsUrl;\r\ + \n#google\r\ + \n#:local CertName \"GTS-Root-R1.pem\";\r\ + \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ + \r\ + \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ + \n#:set CertName \"GTS-Root-R4.pem\";\r\ + \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ + \r\ + \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ + \n#:set CertName \"GTS-Root-RX.pem\";\r\ + \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ + \r\ + \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ + \n#internet\r\ + \n#:set CertName \"ISRG-Root-X1.pem\";\r\ + \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ + \r\ + \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ + \n#:set CertName \"ISRG-Root-X2.pem\";\r\ + \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ + \r\ + \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ + \n#:set CertName \"Starfield-Root-Certificate-Authority-G2.pem\";\r\ + \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ + \r\ + \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ + \n\r\ + \n#/ip/dns/set allow-remote-requests=yes doh-max-concurrent-queries=100 do\ + h-max-server-connections=20 use-doh-server=https://security.cloudflare-dns\ + .com/dns-query verify-doh-cert=yes;\r\ + \n#/ip/dns/static remove [find where address=1.1.1.1];\r\ + \n#/ip/dns/static add address=1.1.1.1 name=security.cloudflare-dns.com com\ + ment=\"cloudflare-dns IPv4 1\";\r\ + \n#/ip/dns/static remove [find where address=1.0.0.1];\r\ + \n#/ip/dns/static add address=1.0.0.1 name=security.cloudflare-dns.com com\ + ment=\"cloudflare-dns IPv4 2\"\r\ + \n#/ip dns static add address=2606:4700:4700::1111 name=security.cloudflar\ + e-dns.com type=AAAA\r\ + \n#/ip dns static add address=2606:4700:4700::1001 name=security.cloudflar\ + e-dns.com type=AAAA\r\ + \n#/ip/dns set servers=\"1.0.0.1, 8.8.4.4\";\r\ + \n#/ip/dns set servers=\"\";" +add dont-require-permissions=no name=script1 owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/\ + tool/netwatch/add comment=\"doh-fallback, doh-url=https://security.cloudfl\ + are-dns.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=Clou\ + dFlare-doh IPv4 1\" host=1.1.1.1;\r\ + \n/tool/netwatch/add comment=\"doh, doh-url=https://security.cloudflare-dn\ + s.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=CloudFlare\ + -doh IPv4 2\" host=1.0.0.1;\r\ + \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\ + /dns.google/dns-query, doh-cert=DigiCert Global Root G2, notify, name=Goog\ + le-doh IPv4 1\" host=8.8.8.8;\r\ + \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\ + /dns.google/dns-query, doh-cert=DigiCert Global Root G2, notify, name=Goog\ + le-doh IPv4 2\" host=8.8.4.4;\r\ + \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\ + /dns.quad9.net/dns-query, doh-cert=DigiCert Global Root G3, notify, name=C\ + uad9-doh IPv4 1\" host=9.9.9.9;\r\ + \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\ + /dns.quad9.net/dns-query, doh-cert=DigiCert Global Root G3, notify, name=C\ + uad9-doh IPv4 2\" host=149.112.112.112;\r\ + \n\r\ + \n/tool/netwatch/add comment=\"dns, notify, name=ns1.unet.ws\" host=91.192\ + .189.2;" +add dont-require-permissions=no name=script2 owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + \r\ + \n\r\ + \n:global InspectVar;\r\ + \n#:global RouterBoard;\r\ + \n#:do {:set RouterBoard [[ :parse \"/system/routerboard/get\" ]]} on-erro\ + r={}\r\ + \n#:global Resources;\r\ + \n#:do {:set Resources [[ :parse \"/system/resource/get\" ]]} on-error={}\ + \r\ + \n\r\ + \n#:global Updates;\r\ + \n#:do {:set Updates [[ :parse \"/system/package/update/get\" ]]} on-error\ + ={}\r\ + \n\r\ + \n#:global PkgUpdStatus \"undefined\";\r\ + \n#:local Update [/system/package/update/get];\r\ + \n#:retry command={:set PkgUpdStatus (\$Update->\"status\")} delay=200ms m\ + ax=5 on-error={};\r\ + \n\r\ + \n#:log warning [\$InspectVar \$RouterBoard];\r\ + \n#:put [\$InspectVar \$RouterBoard];\r\ + \n\r\ + \n#:retry command={/system/package/update check-for-updates without-paging\ + \_as-value} delay=300ms max=5 on-error={};\r\ + \n\r\ + \n#:global arrDeviceInfo ({});\r\ + \n#:local arrDeviceInfo ({\"section\":{\"key\":\"\"; \"value\":\"\";};});\ + \r\ + \n#:set (\$arrDeviceInfo->\"RouterBoard\") [[ :parse \"/system/routerboard\ + /get\" ]];\r\ + \n#:retry command={:set (\$arrDeviceInfo->\"Updates\") [[ :parse \"/system\ + /package/update/get\" ]]} delay=500ms max=5 on-error={:log error (\"Error\ + \")};\r\ + \n# [:toarray {\"section\"={\"key\"=\"\"; \"value\"=\"\";} }];\r\ + \n# [:toarray \"\"];\r\ + \n:local arrDeviceInfo ({});\r\ + \n\r\ + \n:set (\$arrDeviceInfo->\"devUpdates\") {\"channel\"; \"stable\";};\r\ + \n#:do {:set (arrDeviceInfo->\"Updates\") [[ :parse \"/system/package/upda\ + te/get\" ]]} on-error={:log error (\$error)}\r\ + \n\$InspectVar \$arrDeviceInfo;\r\ + \n" +add dont-require-permissions=no name=AM-setup owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + \_RouterOS Setup Script: AM-setup\r\ + \n# \r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n# requires device-mode, fetch\r\ + \n\r\ + \n## Additional commands:\r\ + \n#\r\ + \n# For scripts:\r\ + \n#:if ([ :len [ /system/script/find where name=\$ScriptName ]] = 0 ) do={\ + \r\ + \n# :local ScriptName [ :jobname ];\r\ + \n# :global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ + \n# /system/script/add name=\$ScriptName owner=\$ScriptName source=([ /too\ + l/fetch check-certificate=yes-without-crl (\$GlobalScriptsUrl . \$ScriptNa\ + me . \".rsc\") output=user as-value ]->\"data\");\r\ + \n#}\r\ + \n# For run from terminal:\r\ + \n# /system/script/add name=AM-setup owner=AM-Setup source=([ /tool/fetch \ + check-certificate=yes-without-crl \"https://ros.vados.ru/AM-setup.rsc\" ou\ + tput=user as-value ]->\"data\");\r\ + \n#\r\ + \n# /system/script/set source=[ :tocrlf [ get \$ScriptName source ] ] \$Sc\ + riptName;\r\ + \n:local ScriptName [ :jobname ];\r\ + \n\r\ + \n:local RemoveThisScript false;\r\ + \n\r\ + \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ + \n\r\ + \n{\r\ + \n :local ScriptName;\r\ + \n :local RemoveThisScript;\r\ + \n :global GlobalScriptsUrl;\r\ + \n :local AllDone;\r\ + \n :local CertCommonName \"Root YE\";\r\ + \n :local CertFileName \"Root-YE.pem\";\r\ + \n :local CertFingerprint \"e14ffcad5b0025731006caa43a121a22d8e9700f4fb9c\ + f852f02a708aa5d5666\";\r\ + \n\r\ + \n :local CertSettings [ /certificate/settings/get ];\r\ + \n :if (!(((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" || \ + \\\r\ + \n (\$CertSettings->\"builtin-trust-store\") ~ \"fetch\" || \\\r\ + \n (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\r\ + \n [ :len [ /certificate/builtin/find where common-name=\$CertComm\ + onName ] ] > 0)) do={\r\ + \n :put \"Importing certificate...\";\r\ + \n:log warning (\"\\n\\\$GlobalScriptsUrl = \" . \$GlobalScriptsUrl);\r\ + \n /tool/fetch (\$GlobalScriptsUrl . \"certs/\" . \$CertFileName) dst-p\ + ath=\$CertFileName as-value;\r\ + \n :delay 1s;\r\ + \n /certificate/import file-name=\$CertFileName passphrase=\"\";\r\ + \n :if ([ :len [ /certificate/find where fingerprint=\$CertFingerprint \ + ] ] != 1) do={\r\ + \n :error \"Something is wrong with your certificates!\";\r\ + \n };\r\ + \n :delay 1s;\r\ + \n };\r\ + \n :put \"Renaming AM-GlobalConfig, if exists...\";\r\ + \n :local ConfOldName (\"AM-GlobalConfig-\" . [ /system/clock/get date ] \ + . [ /system/clock/get time ] . \".rsc\");\r\ + \n /system/script/set name=\$ConfOldName [ find where name=\"AM-GlobalCon\ + fig\" ];\r\ + \n :foreach Script in={ \"AM-GlobalConfig\"; \"AM-GlobalFunc\" } do={\r\ + \n :put \"Installing \$Script...\";\r\ + \n /system/script/remove [ find where name=\$Script ];\r\ + \n /system/script/add name=\$Script owner=\$Script source=([ /tool/fetc\ + h check-certificate=yes-without-crl url=(\$GlobalScriptsUrl . \$Script . \ + \".rsc\") output=user as-value ]->\"data\");\r\ + \n };\r\ + \n\r\ + \n :if ([ :len [ /certificate/find where fingerprint=\$CertFingerprint ] \ + ] > 0) do={\r\ + \n :put \"Renaming certificate by its common-name...\";\r\ + \n :global CertificateNameByCN;\r\ + \n \$CertificateNameByCN \$CertFingerprint;\r\ + \n };\r\ + \n\r\ + \n :put \"Add Schedulers...\";\r\ + \n :delay 1;\r\ + \n :put \"Add Global scheduler...\";\r\ + \n :local OnEvent \"/system/script { run AM-GlobalConfig; run AM-GlobalFu\ + nc; }\";\r\ + \n :local Comment \"Setup Global Environment for scripts\";\r\ + \n :if ([ :len [ /system/scheduler/find where name=\"AM-SetGlobalEnv\" ] \ + ] = 0) do={\r\ + \n /system/scheduler/add name=\"AM-SetGlobalEnv\" comment=\$Comment on-\ + event=\$OnEvent start-time=startup;\r\ + \n }\r\ + \n :if ([ /system/scheduler/get \"AM-SetGlobalEnv\" comment ] != \$Commen\ + t) do={\r\ + \n /system/scheduler/set \"AM-SetGlobalEnv\" comment=\$Comment;\r\ + \n }\r\ + \n :if ([ /system/scheduler/get \"AM-SetGlobalEnv\" on-event ] != \$OnEve\ + nt) do={\r\ + \n /system/scheduler/set \"AM-SetGlobalEnv\" on-event=\$OnEvent;\r\ + \n }\r\ + \n :delay 1;\r\ + \n :put \"Add Update Script scheduler\";\r\ + \n :set OnEvent \":global ScriptInstallUpdate; \\\$ScriptInstallUpdate;\"\ + ;\r\ + \n :set Comment \"Every Day Check For Update Scripts\";\r\ + \n :if ([ :len [ /system/scheduler/find where name=\"AM-ScriptInstallUpda\ + te\" ] ] = 0) do={\r\ + \n /system/scheduler/add name=\"AM-ScriptInstallUpdate\" comment=\$Commen\ + t start-time=startup interval=1d on-event=\$OnEvent;\r\ + \n }\r\ + \n\r\ + \n :delay 1;\r\ + \n :put \"Loading configuration and functions...\";\r\ + \n :do { \r\ + \n /system/script { run AM-GlobalConfig; run AM-GlobalFunc; };\r\ + \n :global ScriptInstallUpdate; \$ScriptInstallUpdate;\r\ + \n :set AllDone true;\r\ + \n } on-error={\r\ + \n :set AllDone false;\r\ + \n :local ErrorMsg \"Loading configuration and functions error!\";\r\ + \n :log error (\$ScriptName . \$ErrorMsg . :error);\r\ + \n :error \$ErrorMsg;\r\ + \n }\r\ + \n\r\ + \n :delay 5s;\r\ + \n :if (\$AllDone = true && \$RemoveThisScript = true) do={\r\ + \n :put \"Add Scheduler for remove this script...\";\r\ + \n :set OnEvent \":delay 30s; /system/script/remove [ find where name=\$S\ + criptName ]; :delay5s; /system/scheduler/remove [ find where name=\\\"_Rem\ + oveSetup\\\" ];\";\r\ + \n :set Comment \"_RemoveSetup tmp scheduler for remove setup script.\";\ + \r\ + \n /system/scheduler/add name=\"_RemoveSetup\" comment=\$Comment start-ti\ + me=startup interval=30s on-event=\$OnEvent;\r\ + \n :log warning (\$ScriptName . \"\\nI've done everything, and now I'm ti\ + red... I'm leaving. ))\\nThere will be an error below, this is normal.\");\ + \r\ + \n }\r\ + \n};\r\ + \n" +add dont-require-permissions=no name=fetchCustom owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="\ + \r\ + \n#root.mnuc.backuper\r\ + \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ + \n#/tool/fetch mode=https url=(\$GlobalScriptsUrl . \".bak/mikro_bak_rsa@1\ + 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 ch\ + eck-certificate=yes-without-crl url=(\$GlobalScriptsUrl . \$Script . \".rs\ + c\") output=user as-value ]->\"data\");\r\ + \n#/usb1/mikro_bak_rsa.pub" +add comment="Global functions" dont-require-permissions=no name=AM-GlobalFunc \ + owner=AM-GlobalFunc policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\r\ + \n# RouterOS script: AM-GglobalFunc\r\ + \n# Script comment: Global functions\r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n# requires device-mode, fetch, scheduler\r\ + \n:local ExitOK false;\r\ + \n:local ScriptName [ :jobname ];\r\ + \n#:global checkRunJob \$SriptName;\r\ + \n#:global fixCRLF;\r\ + \n#:if (\$fixCRLF != false) do={\r\ + \n#:foreach fixScript in=([ /system/script/find where name~\"*\" ]) do={/s\ + ystem/script/set source=[ :tocrlf [ get \$fixScript source ] ] \$fixScript\ + }\r\ + \n#:if (\$fixCRLF != \"LF\") do={ /system/script/set source=[ :tocrlf [ g\ + et \$fixScript source ] ] \$fixScript};};\r\ + \n#}\r\ + \n:global GlobalFuncReady false;\r\ + \n\r\ + \n# Git commit id & info, expected configuration version\r\ + \n:global CommitId \"main/226/e1cd7257\";\r\ + \n:global CommitTAG \"unknown\";\r\ + \n:global CommitInfo \"Autocommit in repo: ros.vados.ru, generated by owne\ + r: root, in 09:45:02 01.04.2026.\";\r\ + \n\r\ + \n# The variables are received right here.\r\ + \n:global GlobalConfVersion 138;\r\ + \n\r\ + \n:global SumsDirAndFileName \"tmp/checksums.json\";\r\ + \n\r\ + \n:global Identity [/system/identity/get name];\r\ + \n:global IdentityShort [:pick \$Identity 0 18];\r\ + \n\r\ + \n:global devBoardName [/system/resource/get board-name];\r\ + \n:global devMode [/system/device-mode/get mode];\r\ + \n:global devCurArch [/system/resource/get architecture-name];\r\ + \n:global devCurVersion [/system/resource/get version];\r\ + \n\r\ + \n# Variables defined in AM-GlobalConfig.rsc\r\ + \n:global TerminalColorOutput;\r\ + \n:global CommentsInScripts;\r\ + \n:global DetectIpAddrDefault;\r\ + \n:global DetectIpAddrFallback;\r\ + \n:global updateChannel;\r\ + \n:global Domain;\r\ + \n:global EmailGeneralTo;\r\ + \n:global BackupAndUpdateMode;\r\ + \n\r\ + \n# Single functions, without nested functions.\r\ + \n:global GlobalEnvRemove;\r\ + \n:global MiniDateTimeStamp;\r\ + \n\r\ + \n# Include globals \$PrintDebug and \$PrintDebugOverride\r\ + \n:global LogPrint;\r\ + \n\r\ + \n# DeviceInfo and Updates\r\ + \n:global IsCheckUpdates;\r\ + \n:global WaitCheckUpdates;\r\ + \n:global GetPubIp;\r\ + \n\r\ + \n:global GetArrDeviceInfo;\r\ + \n:global WaitArrDeviceInfo;\r\ + \n\r\ + \n:global devModel;\r\ + \n:global devRunningMode;\r\ + \n\r\ + \n:global devRbRevision;\r\ + \n:global devRbSerialNumber;\r\ + \n:global devRbVerAvail;\r\ + \n\r\ + \n:global runningChannelVersion;\r\ + \n:global runningChannel;\r\ + \n:global runningVersion;\r\ + \n\r\ + \n:global devBuildTime;\r\ + \n#:global ROsVerAvail;\r\ + \n:global PkgUpdStatus;\r\ + \n:global currentUpdateChannel;\r\ + \n\r\ + \n:global ScriptInstallUpdate;\r\ + \n\r\ + \n:global DeviceInfo;\r\ + \n\r\ + \n:global OldMode;\r\ + \n\r\ + \n:global ParseKeyValueStore;\r\ + \n:global RandomDelay;\r\ + \n:global GetRandomNumber;\r\ + \n:global EscapeForRegEx;\r\ + \n:global ExitError;\r\ + \n:global CharacterMultiply;\r\ + \n:global CharacterReplace;\r\ + \n:global CleanFilePath;\r\ + \n:global CleanName;\r\ + \n\r\ + \n:global CommitBrief;\r\ + \n\r\ + \n:global EitherOr;\r\ + \n:global FormatLine;\r\ + \n:global GetRandom20CharAlNum;\r\ + \n:global Grep;\r\ + \n:global IfThenElse;\r\ + \n:global MAX;\r\ + \n:global MIN;\r\ + \n:global HumanReadableNum;\r\ + \n\r\ + \n:global IsFullyConnected;\r\ + \n:global IsDNSResolving;\r\ + \n:global IsTimeSync;\r\ + \n:global IsTimeSyncCached;\r\ + \n:global IsTimeSyncResetNtp;\r\ + \n\r\ + \n:global WaitDNSResolving;\r\ + \n:global WaitFullyConnected;\r\ + \n:global WaitTimeSync;\r\ + \n:global MkDir;\r\ + \n:global RmDir;\r\ + \n:global RmFile;\r\ + \n:global FileGet;\r\ + \n:global Unix2Dos;\r\ + \n:global UrlEncode;\r\ + \n:global WaitForFile;\r\ + \n:global ScriptLock;\r\ + \n:global SendTelegram;\r\ + \n:global NotificationFunctions;\r\ + \n:global SendNotification;\r\ + \n:global SendNotification2;\r\ + \n:global SymbolForNotification;\r\ + \n:global SymbolByUnicodeName;\r\ + \n:global ValidateSyntax;\r\ + \n:global CheckSumsVerify;\r\ + \n:global GlobalConfChanges;\r\ + \n:global GlobalConfMigration;\r\ + \n:global VersionToNum;\r\ + \n:global RequiredRouterOS;\r\ + \n:global FetchLargeFiles;\r\ + \n:global FetchUserAgentStr;\r\ + \n:global CertificateAvailable;\r\ + \n:global CertificateDownload;\r\ + \n:global CertificateNameByCN;\r\ + \n:global CharacterMultiply;\r\ + \n\r\ + \n:global InspectVar;\r\ + \n:global InspectVarRet;\r\ + \n:global ParseCustom;\r\ + \n\r\ + \n:set IsCheckUpdates do={\r\ + \n :local isInfo [:tobool \$1];\r\ + \n :global LogPrint;\r\ + \n :global updateChannel;\r\ + \n :global PkgUpdStatus;\r\ + \n \$LogPrint debug \$0 (\"\\\$isInfo = \" . \$isInfo); \r\ + \n :local CurrentChannel [ /system/package/update/get channel ];\r\ + \n :if (\$CurrentChannel != \$updateChannel) do={\r\ + \n :retry command={/system/package/update set channel=\$updateChannel} \ + \_delay=300ms max=5 on-error={};\r\ + \n \$LogPrint debug \$0 (\"Set updates channel to: \$updateChannel\");\ + \r\ + \n }\r\ + \n\r\ + \n :local Update [ /system/package/update/get ];\r\ + \n :local Channel (\$Update->\"channel\");\r\ + \n \$LogPrint debug \$0 (\"Update Channel: \" . \$Channel . \".\");\r\ + \n\r\ + \n :local StatusPkg \"undefined\";\r\ + \n \$LogPrint debug \$0 (\"Checking for updates...\");\r\ + \n :retry command={:set \$StatusPkg ([/system/package/update/check-for-up\ + dates without-paging as-value]->\"status\")} \\\r\ + \n delay=300ms max=5 on-error={};\r\ + \n \$LogPrint debug \$0 (\"\\\$StatusPkg = \" . \$StatusPkg);\r\ + \n :if (\$StatusPkg = \"New version is available\") do={ :set PkgUpdStatu\ + s true; } else={ :set PkgUpdStatus false; }\r\ + \n \$LogPrint debug \$0 (\"\\\$PkgUpdStatus = \" . \$PkgUpdStatus);\r\ + \n :if (\$isInfo != false || \$PkgUpdStatus = true) do={\r\ + \n \$LogPrint debug \$0 (\"\\\$PkgUpdStatus = \" . \$PkgUpdStatus);\r\ + \n :if ([:len \$arrDeviceInfo] = 0) do={\r\ + \n :global arrDeviceInfo ({});\r\ + \n :local arrDeviceInfo ({\"section\":{\"key\":\"\"; \"value\":\"\";};}\ + );\r\ + \n }\r\ + \n # else={:local arrDeviceInfo ({})}\r\ + \n :retry command={:set (\$arrDeviceInfo->\"devUpdates\") [[ :parse \"/\ + system/package/update/get\" ]]} delay=500ms max=5 on-error={:log error (\"\ + Error\")};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentChannel\"; \$Cu\ + rrentChannel;};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentVersion\"; (\$U\ + pdate->\"installed-version\");};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentChannelVersion\ + \"; [/system/resource/get version];};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devUpdateChannel\"; [\$up\ + dateChannel];};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devUpdateVersion\"; (\$Up\ + date->\"latest-version\");};\r\ + \n } else={\r\ + \n :return \$PkgUpdStatus;\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set WaitArrDeviceInfo do={\r\ + \n :global GetArrDeviceInfo;\r\ + \n :while ([ \$GetArrDeviceInfo ] = false) do={\r\ + \n :delay 1s;\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set GetArrDeviceInfo do={\r\ + \n :global LogPrint;\r\ + \n\r\ + \n :global devBoardName;\r\ + \n :global devModel;\r\ + \n\r\ + \n :global arrDeviceInfo [:toarray {\"section\"={\"key\"=\"\"; \"value\"\ + =\"\";} }];\r\ + \n #:do {:set (\$arrDeviceInfo->\"Updates\") [[ :parse \"/system/package\ + /update/get\" ]]} on-error={}\r\ + \n :global devRbRevision;\r\ + \n :global devRbSerialNumber;\r\ + \n :global devRbCurrentFw;\r\ + \n :global devRbUpgradeFw;\r\ + \n\r\ + \n :global devRunning;\r\ + \n :global devCurArch;\r\ + \n :global ROsVerCurrent;\r\ + \n :global ROsChannelCurrent;\r\ + \n :global ROsVerAvail;\r\ + \n\r\ + \n :global ParseCustom;\r\ + \n :global runningChannelVersion;\r\ + \n :global runningChannel;\r\ + \n :global runningVersion;\r\ + \n :global devBuildTime;\r\ + \n :global GetPubIp;\r\ + \n\r\ + \n :local License [/system/license/get];\r\ + \n :local Resource [/system/resource/get];\r\ + \n :set devBuildTime (\$Resource->\"build-time\");\r\ + \n :set runningChannelVersion (\$Resource->\"version\");\r\ + \n :set runningChannel [\$ParseCustom \$runningChannelVersion \"(\" \")\ + \" 1];\r\ + \n :set runningVersion [\$ParseCustom \$runningChannelVersion \" \"];\r\ + \n\r\ + \n :do {\r\ + \n :if ([:pick \$devBoardName 0 3] != \"CHR\" or [:pick \$devBoardName 0\ + \_3] != \"x86\") do={\r\ + \n :local RouterBoard;\r\ + \n :do {:set RouterBoard [[ :parse \"/system/routerboard/get\" ]]} on\ + -error={}\r\ + \n :set devModel (\$RouterBoard->\"model\");\r\ + \n :set devRbRevision (\$RouterBoard->\"revision\");\r\ + \n :set devRbSerialNumber (\$RouterBoard->\"serial-number\");\r\ + \n #:set devRbCurrentFw (\$RouterBoard->\"current-firmware\");\r\ + \n #:set devRbUpgradeFw (\$RouterBoard->\"upgrade-firmware\");\r\ + \n :if (\$devCurArch = \"mipsbe\" || \$devCurArch = \"arm\") do={\r\ + \n :global devRunning [ /system/device-mode/get mode ];\r\ + \n } else={\r\ + \n :global devRunning [/system/device-mode/get running];}\r\ + \n } else={\r\ + \n :set devModel \$devBoardName;\r\ + \n \r\ + \n :set devRbRevision false;\r\ + \n :set devRbSerialNumber false;\r\ + \n# :set devRbCurrentFw false;\r\ + \n# :set devRbUpgradeFw false;\r\ + \n #:set devCurrentFw \$runningVersion;#:set devUpgradeFw \$ROsVerAvail\ + ;\r\ + \n :set devRunning [/system/device-mode/get running];\r\ + \n }\r\ + \n } on-error={\r\ + \n \$LogPrint error \$0 (\"Error in Function getDevice!\");\r\ + \n :return false;\r\ + \n }\r\ + \n:return true;\r\ + \n}\r\ + \n\r\ + \n:set DeviceInfo do={\r\ + \n :global WaitArrDeviceInfo;\r\ + \n # \$WaitDeviceInfo;\r\ + \n :global devBoardName;\r\ + \n :global devCurArch;\r\ + \n :global devModel;\r\ + \n :global devRunning;\r\ + \n :global devRbRevision;\r\ + \n :global devRbSerialNumber;\r\ + \n :global PiblicIpAddress;\r\ + \n\r\ + \n :global GlobalConfVersion;\r\ + \n :global Identity;\r\ + \n :global IfThenElse;\r\ + \n :global FormatLine;\r\ + \n :local Return;\r\ + \n :local License [/system/license/get];\r\ + \n :local Resource [/system/resource/get];\r\ + \n :local Snmp [ /snmp/get ];\r\ + \n :local Update [ /system/package/update/get ];\r\ + \n\r\ + \n :set Return ([ \$FormatLine \"Hostname:\" \$Identity ] . \"\\n\" . \\\ + \r\ + \n [ \$IfThenElse ([ :len (\$Snmp->\"location\") ] > 0) \\\r\ + \n ([ \$FormatLine \"Location:\" (\$Snmp->\"location\") ] . \"\\n\") \ + ] . \\\r\ + \n [ \$IfThenElse ([ :len (\$Snmp->\"contact\") ] > 0) \\\r\ + \n ([ \$FormatLine \"Contact:\" (\$Snmp->\"contact\") ] . \"\\n\") ] \ + . \\\r\ + \n \"Hardware:\\n\" . \\\r\ + \n [ \$FormatLine \" Board:\" . \$devBoardName ] . \"\\n\" . \\\r\ + \n [ \$FormatLine \" Arch:\" . \$devCurArch ] . \"\\n\" . \\\r\ + \n [ \$FormatLine \" Model:\" \$devModel ] . \\\r\ + \n [ \$IfThenElse ([ :len \$devRbRevision ] > 0) \\\r\ + \n (\" \" . \$devRbRevision) ] . \"\\n\" . \\\r\ + \n [ \$IfThenElse ([ :len \$devRbSerialNumber ] > 0) \\\r\ + \n ([ \$FormatLine \" Serial:\" . \$devRbSerialNumber ] . \"\\n\"\ + ) ] . \\\r\ + \n [ \$IfThenElse ([ :len (\$License->\"nlevel\") ] > 0) \\\r\ + \n ([ \$FormatLine \" License:\" (\"level \" . (\$License->\"nleve\ + l\")) ] . \"\\n\") ] . \"RouterOS:\\n\" . \\\r\ + \n [ \$IfThenElse ([ :len (\$License->\"level\") ] > 0) \\\r\ + \n ([ \$FormatLine \" License:\" (\"level \" . (\$License->\"level\ + \")) ] . \"\\n\") ] . \\\r\ + \n [ \$FormatLine \"Running Channel\" \$runningChannel ] . \"\\n\" . \\\ + \r\ + \n [ \$FormatLine \" Installed:\" (\$Update->\"installed-version\") \ + ] . \"\\n\" . \\\r\ + \n [ \$IfThenElse ([ :typeof (\$Update->\"latest-version\") ] != \"noth\ + ing\" && \\\r\ + \n \$Update->\"installed-version\" != \$Update->\"latest-version\")\ + \_\\\r\ + \n ([ \$FormatLine \" Available\" (\$Update->\"latest-version\") ]\ + \_. \"\\n\") ] . \\\r\ + \n [ \$IfThenElse (\$RouterBoard->\"routerboard\" = true && \\\r\ + \n \$RouterBoard->\"current-firmware\" != \$RouterBoard->\"upgrade-\ + firmware\") \\\r\ + \n ([ \$FormatLine \" Firmware\" (\$RouterBoard->\"current-firmwar\ + e\") ] . \"\\n\") ] . \\ \r\ + \n \"RouterOS-Scripts:\\n\" . \\\r\ + \n [ \$FormatLine \" Commit\" [ \$CommitBrief ] ] . \"\\n\" . \\\r\ + \n [ \$FormatLine \" Version\" \$GlobalConfVersion ]);\r\ + \n}\r\ + \n\r\ + \n:if ([ :typeof \$NotificationFunctions ] != \"array\") do={:set Notifica\ + tionFunctions ({})}\r\ + \n:set GetRandom20CharAlNum do={\r\ + \n :global EitherOr;\r\ + \n :return [ :rndstr length=[ \$EitherOr [ :tonum \$1 ] 20 ] from=\"ABCDE\ + FGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\" ];\r\ + \n}\r\ + \n\r\ + \n:global checkRunJob;\r\ + \n:set checkRunJob do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :global ScriptLock; \r\ + \n :if ([ \$ScriptLock \$Script ] = false) do={:return false}\r\ + \n :foreach Job in=[ /system/script/job/find where script=\$Script ] do={\ + :set Job [ /system/script/job/get \$Job ];\r\ + \n :while ([ :typeof (\$Job->\"parent\") ] = \"id\") do={:set Job [ /sy\ + stem/script/job/get [ find where .id=(\$Job->\"parent\") ] ]}\r\ + \n :if ((\$Job->\"type\") = \"login\") do={:return true};}; :return fa\ + lse; \r\ + \n}\r\ + \n\r\ + \n:set InspectVar do={\r\ + \n :global InspectVarRet;\r\ + \n :put [ :tocrlf [ \$InspectVarRet \$1 ] ];\r\ + \n}\r\ + \n\r\ + \n:set CommitBrief do={\r\ + \n :global CommitId;\r\ + \n :global CommitInfo;\r\ + \n :if (\$CommitId = \"unknown\") do={\r\ + \n :return \"unknown\";\r\ + \n }\r\ + \n :return (\$CommitInfo . \"/\" . [ :pick \$CommitId 0 8 ]);\r\ + \n}\r\ + \n\r\ + \n:set InspectVarRet do={\r\ + \n :local Input \$1;\r\ + \n :local Level (0 + [ :tonum \$2 ]);\r\ + \n :global CharacterReplace;\r\ + \n :global IfThenElse;\r\ + \n :global InspectVarRet;\r\ + \n :local IndentReturn do={\r\ + \n :local Prefix [ :tostr \$1 ];\r\ + \n :local Value [ :tostr \$2 ];\r\ + \n :local Level [ :tonum \$3 ];\r\ + \n :global CharacterMultiply;\r\ + \n :return ([ \$CharacterMultiply \" \" (\$Level * 2) ] . \"-\" . \$Pre\ + fix . \"-> \" . \$Value);\r\ + \n }\r\ + \n :local TypeOf [ :typeof \$Input ];\r\ + \n :local Len [ :len \$Input ];\r\ + \n :local Return [ \$IndentReturn \"type\" \$TypeOf \$Level ];\r\ + \n :if (\$TypeOf = \"array\") do={\r\ + \n :foreach Key,Value in=\$Input do={\r\ + \n :set \$Return (\$Return . \"\\n\" . \\\r\ + \n [ \$IndentReturn \"key\" \$Key (\$Level + 1) ] . \"\\n\" . \\\r\ + \n [ \$InspectVarRet \$Value (\$Level + 2) ]);\r\ + \n }\r\ + \n } else={\r\ + \n :if (\$TypeOf = \"str\") do={\r\ + \n :set \$Return (\$Return . \"\\n\" . \\\r\ + \n [ \$IndentReturn \"len\" \$Len \$Level ]);\r\ + \n :if ([ :typeof [ :find \$Input (\"\\r\") ] ] = \"num\") do={\r\ + \n :set Input [ \$CharacterReplace \$Input (\"\\r\") \"\" ];\r\ + \n }\r\ + \n :if ([ :typeof [ :find \$Input (\"\\n\") ] ] = \"num\") do={\r\ + \n :set Input [ \$CharacterReplace \$Input (\"\\n\") \" \" ];\r\ + \n }\r\ + \n }\r\ + \n :if (\$TypeOf != \"nothing\") do={\r\ + \n :set \$Return (\$Return . \"\\n\" . \\\r\ + \n [ \$IndentReturn \"value\" [ \$IfThenElse ([ :len \$Input ] > 80)\ + \_\\\r\ + \n ([ :pick \$Input 0 77 ] . \"...\") \$Input ] \$Level ]);\r\ + \n }\r\ + \n }\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n# !!! The function is not ready !!!\r\ + \n:global FetchHttpInfo do={\r\ + \n :local Mac [ :tostr \$1 ];\r\ + \n :global CertificateAvailable;\r\ + \n :global IsMacLocallyAdministered;\r\ + \n :global LogPrint;\r\ + \n :local Url \"https://api.macvendors.com/\";\r\ + \n :if ([ \$IsMacLocallyAdministered \$Mac ] = true) do={:return \"locall\ + y administered\";}\r\ + \n :do {\r\ + \n :if ([ \$CertificateAvailable \"GTS Root R4\" \"fetch\" ] = false) d\ + o={\r\ + \n \$LogPrint warning \$0 (\"Downloading required certificate failed.\ + \");\r\ + \n :error false;\r\ + \n }\r\ + \n :local Vendor ([ /tool/fetch \r\ + \n (\$Url . [ :pick \$Mac 0 8 ]) output=user as-value ]->\"data\");\r\ + \n :return \$Vendor;\r\ + \n } on-error={\r\ + \n :onerror Err {\r\ + \n /tool/fetch check-certificate=yes-without-crl (\$Url) output=none \ + as-value;\r\ + \n \$LogPrint debug \$0 (\"The mac vendor is not known in database.\"\ + );\r\ + \n } do={ \$LogPrint warning \$0 (\"Failed getting mac vendor: \" . \$E\ + rr); }\r\ + \n :return \"unknown vendor\";\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set GetPubIp do={\r\ + \n :global DetectIpAddrDefault;\r\ + \n :global DetectIpAddrFallback;\r\ + \n :global LogPrint;\r\ + \n \r\ + \n :local PubIpAddr false;\r\ + \n :local Url \$DetectIpAddrDefault;\r\ + \n\r\ + \n# :retry command={abc} delay=1 max=2 on-error={:put \"got error\"} \r\ + \n :do {\r\ + \n \$LogPrint debug \$0 (\"Trying to detect public IP using default s\ + ervice: \" . \$Url . \"...\");\r\ + \n :retry command={:set PubIpAddr ([ /tool/fetch http-method=\"get\"\ + \_check-certificate=yes-without-crl \$Url output=user as-value ]->\"data\"\ + )} \\\r\ + \n delay=50ms max=5 on-error={\$LogPrint error [ :jobname ] (\"Fail\ + ed to detect public IP using default service: \" . \$Url . \".\")}\r\ + \n #:error \"Failed to detect public IP using default service: \$Url\ + .\"};\r\ + \n } on-error={\r\ + \n \$LogPrint error \$0 (\"Failed to detect public IP using default s\ + ervice: \" . \$Url . \".\");\r\ + \n :set Url \$DetectIpAddrFallBack;\r\ + \n \$LogPrint debug \$0 (\"Trying to detect public IP using fallback \ + service: \" . \$Url . \"...\");\r\ + \n :retry command={:set PubIpAddr ([ /tool/fetch http-method=\"get\"\ + \_check-certificate=yes-without-crl \$Url output=user as-value ]->\"data\"\ + )} \\\r\ + \n delay=200ms max=5 on-error={\$LogPrint error [ :jobname ] (\"Fai\ + led to detect public IP using fallback service: \" . \$Url . \".\")}\r\ + \n };\r\ + \n :if (\$PubIpAddr = false) do={\r\ + \n :set PubIpAddr \"not-detected\";\r\ + \n } else={\r\ + \n :set PubIpAddr [ :pick \$PubIpAddr 0 15];\r\ + \n }\r\ + \n :return \$PubIpAddr;\r\ + \n}\r\ + \n\r\ + \n:set FormatLine do={\r\ + \n :local Key [ :tostr \$1 ];\r\ + \n :local Value [ :tostr \$2 ];\r\ + \n :local Indent [ :tonum \$3 ];\r\ + \n :local Spaces;\r\ + \n :local Return \"\";\r\ + \n :global CharacterMultiply;\r\ + \n :global EitherOr;\r\ + \n :set Indent [ \$EitherOr \$Indent 16 ];\r\ + \n :local Spaces [ \$CharacterMultiply \" \" \$Indent ];\r\ + \n :if ([ :len \$Key ] > 0) do={ :set Return (\$Key . \":\")}\r\ + \n :if ([ :len \$Key ] > (\$Indent - 2)) do={:set Return (\$Return . \"\\\ + n\" . [ :pick \$Spaces 0 \$Indent ] . \$Value);\r\ + \n } else={:set Return (\$Return . [ :pick \$Spaces 0 (\$Indent - [ :len \ + \$Return ]) ] . \$Value)}\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set ParseCustom do={\r\ + \n :local Str [ :tostr \$1 ];\r\ + \n :local Start [:find [ \$Str ] [:tostr \$2]];\r\ + \n :local End [ :tostr \$3 ];\r\ + \n :local Num [ :tonum \$4 ];\r\ + \n :local Return;\r\ + \n :if ([:len \$Num] = 0) do={:set Num \"0\"}\r\ + \n :local rest [:pick \$Str (\$Start+\$Num) [:len \$Str]]; \r\ + \n :if ([:len \$End ] = 0) do={:set Return [:pick \$Str \$Num \$Start]} e\ + lse={\r\ + \n :set End [:find \$rest \$End];\r\ + \n :set Return [:pick \$rest 0 \$End];\r\ + \n }\r\ + \n:return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set LogPrint do={\r\ + \n :local Severity [ :tostr \$1 ];\r\ + \n :local Name [ :tostr \$2 ];\r\ + \n :local Message [ :tostr \$3 ];\r\ + \n :global PrintDebug;\r\ + \n :global PrintDebugOverride;\r\ + \n :global EitherOr;\r\ + \n :local Debug [ \$EitherOr (\$PrintDebugOverride->\$Name) \$PrintDebug \ + ];\r\ + \n :local PrintSeverity do={\r\ + \n :global TerminalColorOutput;\r\ + \n :if (\$TerminalColorOutput != true) do={:return \$1}\r\ + \n :local Color { debug=96; info=97; warning=93; error=91 };\r\ + \n :return (\"\\1B[\" . \$Color->\$1 . \"m\" . \$1 . \"\\1B[0m\");\r\ + \n}\r\ + \n :local Log ([ \$EitherOr \$Name \"\" ] . \": \" . \$Message);\ + \r\ + \n :if (\$Severity ~ (\"^(custom|debug|error|info)\\\$\")) do={\r\ + \n :if (\$Severity = \"debug\") do={:log debug \$Log}\r\ + \n :if (\$Severity = \"error\") do={:log error \$Log}\r\ + \n :if (\$Severity = \"info\" ) do={:log info \$Log}\r\ + \n } else={:log warning \$Log; :set Severity \"warning\"}\r\ + \n :if (\$Severity != \"debug\" || \$Debug = true) do={:put ([ \$PrintSev\ + erity \$Severity ] . \": \" . \$Message)}\r\ + \n}\r\ + \n\r\ + \n:set CertificateAvailable do={\r\ + \n :local CommonName [ :tostr \$1 ];\r\ + \n :local UseFor [ :tostr \$2 ];\r\ + \n :global CertificateDownload;\r\ + \n :global EitherOr;\r\ + \n :global LogPrint;\r\ + \n :global ParseKeyValueStore;\r\ + \n :set UseFor [ \$EitherOr \$UseFor \"undefined\" ];\r\ + \n :if ([ /system/resource/get free-hdd-space ] < 8388608 && \\\r\ + \n [ /certificate/settings/get crl-download ] = true && \\\r\ + \n [ /certificate/settings/get crl-store ] = \"system\") do={\r\ + \n \$LogPrint warning \$0 (\"This system has low free flash space but \ + \" . \\\r\ + \n \"is configured to download certificate CRLs to system!\");\r\ + \n }\r\ + \n :if ([ :len \$CommonName ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"No CommonName given!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local CertSettings [ /certificate/settings/get ];\r\ + \n :if (((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" || \\\ + \r\ + \n (\$CertSettings->\"builtin-trust-store\") ~ \$UseFor || \\\r\ + \n (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\r\ + \n [ :len [ /certificate/builtin/find where common-name=\$CommonName\ + \_] ] > 0) do={\r\ + \n :return true;\r\ + \n }\r\ + \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] = 0\ + ) do={\r\ + \n \$LogPrint info \$0 (\"Certificate with CommonName '\" . \$CommonNam\ + e . \"' not available.\");\r\ + \n :if ([ \$CertificateDownload \$CommonName ] = false) do={:return fal\ + se}\r\ + \n }\r\ + \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] > 1\ + ) do={\r\ + \n \$LogPrint info \$0 (\"There are \" . \$CertCount . \" Certificates \ + with CommonName '\" . \$CommonName . \"'. Should be ok.\");\r\ + \n :return true;\r\ + \n }\r\ + \n :local CertVal [ /certificate/get [ find where common-name=\$CommonNam\ + e ] ];\r\ + \n :while ((\$CertVal->\"akid\") != \"\" && (\$CertVal->\"akid\") != (\$C\ + ertVal->\"skid\")) do={\r\ + \n :if ([ :len [ /certificate/find where skid=(\$CertVal->\"akid\") ] ]\ + \_= 0) do={\r\ + \n :local IssuerCN ([ \$ParseKeyValueStore (\$CertVal->\"issuer\") ]-\ + >\"CN\");\r\ + \n \$LogPrint info \$0 (\"Certificate chain for '\" . \$CommonName . \ + \"' is incomplete, missing '\" . \$IssuerCN . \"'.\");\r\ + \n :if ([ \$CertificateDownload \$IssuerCN ] = false) do={:return fal\ + se}\r\ + \n }\r\ + \n :set CertVal [ /certificate/get [ find where skid=(\$CertVal->\"akid\ + \") ] ];\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set CertificateDownload do={\r\ + \n :local CommonName [ :tostr \$1 ];\r\ + \n :global GlobalScriptsUrl;\r\ + \n :global GlobalScriptsUrlSuffix;\r\ + \n :global CertificateNameByCN;\r\ + \n :global CleanName;\r\ + \n :global FetchUserAgentStr;\r\ + \n :global LogPrint;\r\ + \n :global RmFile;\r\ + \n :global WaitForFile;\r\ + \n \r\ + \n \$LogPrint info \$0 (\"Downloading and importing certificate with Comm\ + onName '\" . \$CommonName . \"'.\");\r\ + \n \r\ + \n :local FileName ([ \$CleanName \$CommonName ] . \".pem\");\r\ + \n :do {\r\ + \n /tool/fetch check-certificate=yes-without-crl http-header-field=({ [\ + \_\$FetchUserAgentStr \$0 ] }) \\\r\ + \n (\$GlobalScriptsUrl . \"certs/\" . \$FileName . \$GlobalScriptsUrl\ + Suffix) dst-path=\$FileName as-value;\r\ + \n \$WaitForFile \$FileName;\r\ + \n } on-error={\r\ + \n \$LogPrint warning \$0 (\"Failed downloading certificate with Common\ + Name '\" . \$CommonName . \\\r\ + \n \"' from repository! Trying fallback to mkcert.org...\");\r\ + \n :do {\r\ + \n :if ([ :len [ /certificate/find where common-name=\"ISRG Root X1\"\ + \_] ] = 0) do={\r\ + \n \$LogPrint error \$0 (\"Required certificate is not available.\"\ + );\r\ + \n :return false;\r\ + \n }\r\ + \n /tool/fetch check-certificate=yes-without-crl http-header-field=({\ + \_[ \$FetchUserAgentStr \$0 ] }) \\\r\ + \n \"https://mkcert.org/generate/\" http-data=[ :serialize to=json \ + ({ \$CommonName }) ] \\\r\ + \n dst-path=\$FileName as-value;\r\ + \n \$WaitForFile \$FileName;\r\ + \n :if ([ /file/get \$FileName size ] = 0) do={\r\ + \n \$RmFile \$FileName;\r\ + \n :error false;\r\ + \n }\r\ + \n } on-error={\r\ + \n \$LogPrint warning \$0 (\"Failed downloading certificate with Comm\ + onName '\" . \$CommonName . \"'!\");\r\ + \n :return false;\r\ + \n }\r\ + \n }\r\ + \n\r\ + \n /certificate/import file-name=\$FileName passphrase=\"\" as-value;\r\ + \n :delay 1s;\r\ + \n \$RmFile \$FileName;\r\ + \n\r\ + \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] = 0\ + ) do={\r\ + \n /certificate/remove [ find where name~(\"^\" . \$FileName . \"_[0-9]\ + +\\\$\") ];\r\ + \n \$LogPrint warning \$0 (\"Certificate with CommonName '\" . \$Common\ + Name . \"' still unavailable!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :foreach Cert in=[ /certificate/find where name~(\"^\" . \$FileName . \ + \"_[0-9]+\\\$\") ] do={\r\ + \n \$CertificateNameByCN [ /certificate/get \$Cert common-name ];\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set CertificateNameByCN do={\r\ + \n :local Match [ :tostr \$1 ];\r\ + \n :global CleanName;\r\ + \n :global LogPrint;\r\ + \n :local Cert ([ /certificate/find where (common-name=\$Match or fingerp\ + rint=\$Match or name=\$Match) ]->0);\r\ + \n :if ([ :len \$Cert ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"No matching certificate found.\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local CommonName [ /certificate/get \$Cert common-name ];\r\ + \n /certificate/set \$Cert name=[ \$CleanName \$CommonName ];\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set CharacterMultiply do={\r\ + \n :local Str [ :tostr \$1 ];\r\ + \n :local Num [ :tonum \$2 ];\r\ + \n :if (\$Num = 0) do={:return \"\"}\r\ + \n :local Return \"\";\r\ + \n :for I from=1 to=\$Num do={:set Return (\$Return . \$Str)}\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set FetchUserAgentStr do={\r\ + \n :local Caller [ :tostr \$1 ];\r\ + \n :global IfThenElse;\r\ + \n :local Resource [ /system/resource/get ];\r\ + \n :return (\"User-Agent: Mikrotik/\" . \$Resource->\"version\" . \" \" .\ + \_\$Resource->\"architecture-name\" . \\\r\ + \n \" \" . \$Caller . \"/Fetch (https://amster.vados.ru/; main/3419/3ee\ + 19780)\");\r\ + \n}\r\ + \n\r\ + \n:set Grep do={\r\ + \n :local Input ([ :tostr \$1 ] . \"\\n\");\r\ + \n :local Pattern [ :tostr \$2 ];\r\ + \n :if ([ :typeof [ :find \$Input \$Pattern ] ] = \"nil\") do={:return []\ + }\r\ + \n :do {\r\ + \n :local Line [ :pick \$Input 0 [ :find \$Input \"\\n\" ] ];\r\ + \n :if ([ :typeof [ :find \$Line \$Pattern ] ] = \"num\") do={:return \ + \$Line}\r\ + \n :set Input [ :pick \$Input ([ :find \$Input \"\\n\" ] + 1) [ :len \$\ + Input ] ];\r\ + \n } while=([ :len \$Input ] > 0);\r\ + \n :return [];\r\ + \n}\r\ + \n\r\ + \n:set HumanReadableNum do={\r\ + \n :local Input [ :tonum \$1 ];\r\ + \n :local Base [ :tonum \$2 ];\r\ + \n :global EitherOr;\r\ + \n :global IfThenElse;\r\ + \n :local Prefix \"kMGTPE\";\r\ + \n :local Pow 1;\r\ + \n :set Base [ \$EitherOr \$Base 1024 ];\r\ + \n :local Bin [ \$IfThenElse (\$Base = 1024) \"i\" \"\" ];\r\ + \n :if (\$Input < \$Base) do={:return \$Input}\r\ + \n :for I from=0 to=[ :len \$Prefix ] do={\r\ + \n :set Pow (\$Pow * \$Base);\r\ + \n :if (\$Input / \$Base < \$Pow) do={\r\ + \n :set Prefix [ :pick \$Prefix \$I ];\r\ + \n :local Tmp1 (\$Input * 100 / \$Pow);\r\ + \n :local Tmp2 (\$Tmp1 / 100);\r\ + \n :if (\$Tmp2 >= 100) do={:return (\$Tmp2 . \$Prefix . \$Bin)}\r\ + \n :return (\$Tmp2 . \".\" . \\\r\ + \n [ :pick \$Tmp1 [ :len \$Tmp2 ] ([ :len \$Tmp1 ] - [ :len \$Tmp\ + 2 ] + 1) ] . \\\r\ + \n \$Prefix . \$Bin);\r\ + \n }\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set CleanName do={\r\ + \n :local Input [ :tostr \$1 ];\r\ + \n :local Return \"\";\r\ + \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ + \n :local Char [ :pick \$Input \$I ];\r\ + \n :if ([ :typeof [ find \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr\ + stuvwxyz0123456789\" \$Char ] ] = \"nil\") do={\r\ + \n :do {:if ([ :len \$Return ] = 0) do={:error true};\r\ + \n :if ([ :pick \$Return ([ :len \$Return ] - 1) ] = \"-\") do={:er\ + ror true}; :set Char \"-\"} on-error={:set Char \"\"}; \r\ + \n };\r\ + \n :set Return (\$Return . \$Char)};\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set GetRandomNumber do={\r\ + \n :global EitherOr;\r\ + \n :return [ :rndnum from=0 to=[ \$EitherOr [ :tonum \$1 ] 4294967295 ] ]\ + \r\ + \n}\r\ + \n\r\ + \n:set RandomDelay do={\r\ + \n :local Time [ :tonum \$1 ];\r\ + \n :local Unit [ :tostr \$2 ];\r\ + \n :global EitherOr;\r\ + \n :global GetRandomNumber;\r\ + \n :global MAX;\r\ + \n :if (\$Time = 0) do={:return false}\r\ + \n :delay ([ \$MAX 10 [ \$GetRandomNumber ([ :tonsec [ :totime (\$Time . \ + [ \$EitherOr \$Unit \"s\" ]) ] ] / 1000000) ] ] . \"ms\");\r\ + \n}\r\ + \n\r\ + \n:set EscapeForRegEx do={\r\ + \n :local Input [ :tostr \$1 ];\r\ + \n :if ([ :len \$Input ] = 0) do={:return \"\"}\r\ + \n :local Return \"\";\r\ + \n :local Chars (\"^.[]\\\$()|*+\?{}\\\\\");\r\ + \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ + \n :local Char [ :pick \$Input \$I ];\r\ + \n :if ([ :find \$Chars \$Char ]) do={:set Char (\"\\\\\" . \$Char)}\r\ + \n :set Return (\$Return . \$Char);\r\ + \n }\r\ + \n :return \$Return;\r\ + \n}\r\ + \n:set ExitError do={\r\ + \n :local ExitOK [ :tostr \$1 ];\r\ + \n :local Name [ :tostr \$2 ];\r\ + \n :local Error [ :tostr \$3 ];\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :if (\$ExitOK = \"false\") do={\r\ + \n \$LogPrint error \$Name ([ \$IfThenElse ([ :pick \$Name 0 1 ] = \"\\\ + \$\") \\\r\ + \n \"Function\" \"Script\" ] . \" '\" . \$Name . \"' exited with er\ + ror\" . \\\r\ + \n [ \$IfThenElse (!(\$Error ~ \"^(|true|false)\\\$\")) (\": \" . \ + \$Error) \".\" ]);\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set MiniDateTimeStamp do={\r\ + \n /system/clock;\r\ + \n :local vdate [get date];\r\ + \n :local vtime [get time];\r\ + \n :local vdoff [:toarray \"0,4,5,7,8,10\"];\r\ + \n :local MM [:pick \$vdate (\$vdoff->2) (\$vdoff->3)];\r\ + \n :local M [:tonum \$MM];\r\ + \n :if (\$vdate ~ \".../../....\") do={\r\ + \n :set vdoff [:toarray \"7,11,1,3,4,6\"];\r\ + \n :set M ([:find \"xxanebarprayunulugepctovecANEBARPRAYUNULUGE\ + PCTOVEC\" [:pick \$vdate (\$vdoff->2) (\$vdoff->3)] -1] / 2);\r\ + \n :if (\$M>12) do={:set M (\$M - 12)}\r\ + \n :set MM [:pick (100 + \$M) 1 3];\r\ + \n }\r\ + \n :local yyyy [:pick \$vdate (\$vdoff->0) (\$vdoff->1)];\r\ + \n :local dd [:pick \$vdate (\$vdoff->4) (\$vdoff->5)];\r\ + \n :local HH [:pick \$vtime 0 2];\r\ + \n :local mm [:pick \$vtime 3 5];\r\ + \n :local ss [:pick \$vtime 6 8];\r\ + \n :return ([\$yyyy] . [\$MM] . [\$dd] . [\$HH] . [\$mm] . [\$ss]);\r\ + \n}\r\ + \n\r\ + \n:set WaitForFile do={\r\ + \n :local FileName [ :tostr \$1 ];\r\ + \n :local WaitTime [ :totime \$2 ];\r\ + \n :global CleanFilePath;\r\ + \n :global EitherOr;\r\ + \n :global MAX;\r\ + \n :set FileName [ \$CleanFilePath \$FileName ];\r\ + \n :local Delay ([ \$MAX [ \$EitherOr \$WaitTime 2s ] 100ms ] / 9);\r\ + \n :do {\r\ + \n :retry {\r\ + \n /file/get \$FileName;\r\ + \n :return true;\r\ + \n } delay=\$Delay max=10;\r\ + \n } on-error={ }\r\ + \n :while ([ :len [ /file/find where name=\$FileName ] ] > 0) do={\r\ + \n :do {\r\ + \n /file/get \$FileName;\r\ + \n :return true;\r\ + \n } on-error={ }\r\ + \n :delay \$Delay;\r\ + \n :set Delay (\$Delay * 3 / 2);\r\ + \n }\r\ + \n :return false;\r\ + \n}\r\ + \n\r\ + \n:set FileGet do={\r\ + \n :local FileName [ :tostr \$1 ];\r\ + \n :global WaitForFile;\r\ + \n :if ([ \$WaitForFile \$FileName 0s ] = false) do={:return false}\r\ + \n :local FileVal false;\r\ + \n :do {:set FileVal [ /file/get \$FileName ];\r\ + \n } on-error={ }\r\ + \n :return \$FileVal;\r\ + \n}\r\ + \n\r\ + \n:set RmDir do={\r\ + \n :local DirName [ :tostr \$1 ];\r\ + \n :global FileGet;\r\ + \n :global LogPrint;\r\ + \n \$LogPrint debug \$0 (\"Removing directory: \". \$DirName);\r\ + \n :local DirVal [ \$FileGet \$DirName ];\r\ + \n :if (\$DirVal = false) do={\$LogPrint debug \$0 (\"... which does not \ + exist.\"); :return true};\r\ + \n :if (\$DirVal->\"type\" != \"directory\") do={\$LogPrint error \$0 (\"\ + Directory '\" . \$DirName . \"' is not a directory.\"); :return false};\r\ + \n :onerror Err {/file/remove \$DirName} do={\$LogPrint error \$0 (\"Remo\ + ving directory '\" . \$DirName . \"' failed: \" . \$Err); :return false};\ + \r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set RmFile do={\r\ + \n :local FileName [ :tostr \$1 ];\r\ + \n :global FileGet;\r\ + \n :global LogPrint;\r\ + \n \$LogPrint debug \$0 (\"Removing file: \". \$FileName);\r\ + \n :local FileVal [ \$FileGet \$FileName ];\r\ + \n :if (\$FileVal = false) do={\$LogPrint debug \$0 (\"... which does not\ + \_exist.\"); :return true}\r\ + \n :if (\$FileVal->\"type\" = \"directory\" || \$FileVal->\"type\" = \"di\ + sk\") do={\r\ + \n \$LogPrint error \$0 (\"File '\" . \$FileName . \"' is not a file.\"\ + ); :return false}\r\ + \n :onerror Err {\r\ + \n /file/remove \$FileName;\r\ + \n } do={\$LogPrint error \$0 (\"Removing file '\" . \$FileName . \"' fai\ + led: \" . \$Err); :return false}\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set MkDir do={\r\ + \n :local Path [ :tostr \$1 ];\r\ + \n :global CleanFilePath;\r\ + \n :global FileGet;\r\ + \n :global RmDir;\r\ + \n :global WaitForFile;\r\ + \n :global LogPrint;\r\ + \n :local MkTmpfs do={\r\ + \n :global WaitForFile;\r\ + \n :local TmpFs [ /disk/find where slot=tmpfs type=tmpfs ];\r\ + \n :if ([ :len \$TmpFs ] = 1) do={\r\ + \n :if ([ /disk/get \$TmpFs disabled ] = true) do={\r\ + \n \$LogPrint info \$0 (\"The tmpfs is disabled, enabling.\");\r\ + \n /disk/enable \$TmpFs;\r\ + \n }\r\ + \n :return true;\r\ + \n }\r\ + \n \$LogPrint info \$0 (\"Creating disk of type tmpfs.\");\r\ + \n \$RmDir \"tmpfs\";\r\ + \n :onerror Err {\r\ + \n /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource\ + /get total-memory ] / 3);\r\ + \n \$WaitForFile \"tmpfs\";\r\ + \n } do={\r\ + \n \$LogPrint warning \$0 (\"Creating disk of type tmpfs failed: \" .\ + \_\$Err);\r\ + \n :return false;\r\ + \n }\r\ + \n :return true;\r\ + \n }\r\ + \n :set Path [ \$CleanFilePath \$Path ];\r\ + \n :if (\$Path = \"\") do={\r\ + \n :return true;\r\ + \n }\r\ + \n \$LogPrint debug \$0 (\"Making directory: \" . \$Path);\r\ + \n :local PathVal [ \$FileGet \$Path ];\r\ + \n :if (\$PathVal->\"type\" = \"directory\") do={\r\ + \n \$LogPrint debug \$0 (\"... which already exists.\");\r\ + \n :return true;\r\ + \n }\r\ + \n :if ([ :pick \$Path 0 5 ] = \"tmpfs\") do={\r\ + \n :if ([ \$MkTmpfs ] = false) do={\r\ + \n :return false;\r\ + \n }\r\ + \n }\r\ + \n :onerror Err {\r\ + \n /file/add type=\"directory\" name=\$Path;\r\ + \n \$WaitForFile \$Path;\r\ + \n } do={\r\ + \n \$LogPrint warning \$0 (\"Making directory '\" . \$Path . \"' failed\ + : \" . \$Err);\r\ + \n :return false;\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set MAX do={:if (\$1 > \$2) do={:return \$1}\r\ + \n :return \$2;\r\ + \n}\r\ + \n:set MIN do={:if (\$1 < \$2) do={:return \$1}\r\ + \n :return \$2;\r\ + \n}\r\ + \n\r\ + \n:set CharacterMultiply do={\r\ + \n :local Str [ :tostr \$1 ];\r\ + \n :local Num [ :tonum \$2 ];\r\ + \n :if (\$Num = 0) do={:return \"\"}\r\ + \n :local Return \"\";\r\ + \n :for I from=1 to=\$Num do={:set Return (\$Return . \$Str)}\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set CharacterReplace do={\r\ + \n :local String [ :tostr \$1 ];\r\ + \n :local ReplaceFrom [ :tostr \$2 ];\r\ + \n :local ReplaceWith [ :tostr \$3 ];\r\ + \n :local Return \"\";\r\ + \n :if (\$ReplaceFrom = \"\") do={:return \$String}\r\ + \n :while ([ :typeof [ :find \$String \$ReplaceFrom ] ] != \"nil\") do={\ + \r\ + \n :local Pos [ :find \$String \$ReplaceFrom ];\r\ + \n :set Return (\$Return . [ :pick \$String 0 \$Pos ] . \$ReplaceWith);\ + \r\ + \n :set String [ :pick \$String (\$Pos + [ :len \$ReplaceFrom ]) [ :len\ + \_\$String ] ];\r\ + \n }\r\ + \n :return (\$Return . \$String);\r\ + \n}\r\ + \n\r\ + \n:set CleanFilePath do={\r\ + \n :local Path [ :tostr \$1 ];\r\ + \n :global CharacterReplace;\r\ + \n :while (\$Path ~ \"//\") do={:set \$Path [ \$CharacterReplace \$Path \ + \"//\" \"/\" ]};\r\ + \n :if ([ :pick \$Path 0 ] = \"/\") do={:set Path [ :pick \$Path 1 [ :len\ + \_\$Path ] ]};\r\ + \n :if ([ :pick \$Path ([ :len \$Path ] - 1) ] = \"/\") do={:set Path [ :\ + pick \$Path 0 ([ :len \$Path ] - 1) ]};\r\ + \n :return \$Path;\r\ + \n}\r\ + \n\r\ + \n:set IfThenElse do={\r\ + \n :if ([ :tostr \$1 ] = \"true\" || [ :tobool \$1 ] = true) do={:return \ + \$2};\r\ + \n :return \$3;\r\ + \n}\r\ + \n\r\ + \n:set EitherOr do={\r\ + \n :global IfThenElse;\r\ + \n :if ([ :typeof \$1 ] = \"num\") do={:return [ \$IfThenElse (\$1 != 0) \ + \$1 \$2 ]}\r\ + \n :if ([ :typeof \$1 ] = \"time\") do={:return [ \$IfThenElse (\$1 > 0s)\ + \_\$1 \$2 ]}\r\ + \n# this works for boolean values, literal ones with parentheses\r\ + \n :return [ \$IfThenElse ([ :len [ :tostr \$1 ] ] > 0) \$1 \$2 ];\r\ + \n}\r\ + \n\r\ + \n:set ParseKeyValueStore do={\r\ + \n :local Source \$1;\r\ + \n :if ([ :pick \$Source 0 1 ] = \"{\") do={\r\ + \n :do {\r\ + \n :return [ :deserialize from=json \$Source ];\r\ + \n } on-error={ }\r\ + \n } \r\ + \n :if ([ :typeof \$Source ] != \"array\") do={:set Source [ :tostr \$1 ]\ + }\r\ + \n :local Result ({});\r\ + \n :foreach KeyValue in=[ :toarray \$Source ] do={\r\ + \n :if ([ :find \$KeyValue \"=\" ]) do={\r\ + \n :local Key [ :pick \$KeyValue 0 [ :find \$KeyValue \"=\" ] ];\r\ + \n :local Value [ :pick \$KeyValue ([ :find \$KeyValue \"=\" ] + 1) [\ + \_:len \$KeyValue ] ];\r\ + \n :if (\$Value=\"true\") do={:set Value true}\r\ + \n :if (\$Value=\"false\") do={:set Value false}\r\ + \n :set (\$Result->\$Key) \$Value;\r\ + \n } else={:set (\$Result->\$KeyValue) true}\r\ + \n }\r\ + \n :return \$Result;\r\ + \n}\r\ + \n:set RequiredRouterOS do={\r\ + \n :local Caller [ :tostr \$1 ];\r\ + \n :local Required [ :tostr \$2 ];\r\ + \n :local Warn [ :tostr \$3 ];\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global VersionToNum;\r\ + \n :if (!(\$Required ~ \"^\\\\d+\\\\.\\\\d+((alpha|beta|rc|\\\\.)\\\\d+|)\ + \\\$\")) do={\r\ + \n \$LogPrint error \$0 (\"No valid RouterOS version: \" . \$Required);\ + \r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ \$VersionToNum \$Required ] > [ \$VersionToNum [ /system/packag\ + e/update/get installed-version ] ]) do={\r\ + \n :if (\$Warn = \"true\") do={\r\ + \n \$LogPrint warning \$0 (\"This \" . [ \$IfThenElse ([ :pick \$Call\ + er 0 ] = (\"\\\$\")) \"function\" \"script\" ] . \\\r\ + \n \" '\" . \$Caller . \"' (at least specific functionality) requir\ + es RouterOS \" . \$Required . \". Please update!\");\r\ + \n }\r\ + \n :return false;\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n:set VersionToNum do={\r\ + \n :local Input [ :tostr \$1 ];\r\ + \n :local Multi 0x1000000;\r\ + \n :local Return 0;\r\ + \n :global CharacterReplace;\r\ + \n :set Input [ \$CharacterReplace \$Input \".\" \",\" ];\r\ + \n :foreach I in={ \"zero\"; \"alpha\"; \"beta\"; \"rc\" } do={\r\ + \n :set Input [ \$CharacterReplace \$Input \$I (\",\" . \$I . \",\") ];\ + \r\ + \n }\r\ + \n :foreach Value in=([ :toarray \$Input ], 0) do={\r\ + \n :local Num [ :tonum \$Value ];\r\ + \n :if (\$Multi = 0x100) do={\r\ + \n :if ([ :typeof \$Num ] = \"num\") do={\r\ + \n :set Return (\$Return + 0xff00);\r\ + \n :set Multi (\$Multi / 0x100);\r\ + \n } else={\r\ + \n :if (\$Value = \"zero\") do={ }\r\ + \n :if (\$Value = \"alpha\") do={ :set Return (\$Return + 0x3f00); \ + }\r\ + \n :if (\$Value = \"beta\") do={ :set Return (\$Return + 0x5f00); }\ + \r\ + \n :if (\$Value = \"rc\") do={ :set Return (\$Return + 0x7f00); }\r\ + \n }\r\ + \n }\r\ + \n :if ([ :typeof \$Num ] = \"num\") do={ :set Return (\$Return + (\$Va\ + lue * \$Multi)); }\r\ + \n :set Multi (\$Multi / 0x100);\r\ + \n }\r\ + \n :return \$Return;\r\ + \n}\r\ + \n:set ScriptLock do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :local WaitMax [ :totime \$2 ];\r\ + \n :global GetRandom20CharAlNum;\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global ScriptLockOrder;\r\ + \n :if ([ :typeof \$ScriptLockOrder ] = \"nothing\") do={\r\ + \n :set ScriptLockOrder ({});\r\ + \n }\r\ + \n :if ([ :typeof (\$ScriptLockOrder->\$Script) ] = \"nothing\") do={\r\ + \n :set (\$ScriptLockOrder->\$Script) ({});\r\ + \n }\r\ + \n :local JobCount do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :return [ :len [ /system/script/job/find where script=\$Script ] ];\ + \r\ + \n }\r\ + \n :local TicketCount do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :local Count 0;\r\ + \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ + \n :if ([ :typeof \$Ticket ] != \"nothing\") do={:set Count (\$Count \ + + 1)}\r\ + \n }\r\ + \n :return \$Count;\r\ + \n }\r\ + \n :local IsFirstTicket do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :local Check [ :tostr \$2 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ + \n :if (\$Ticket = \$Check) do={:return true}\r\ + \n :if ([ :typeof \$Ticket ] != \"nothing\" && \$Ticket != \$Check) d\ + o={:return false}\r\ + \n }\r\ + \n :return false;\r\ + \n }\r\ + \n :local AddTicket do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :local Add [ :tostr \$2 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :while (true) do={\r\ + \n :local Pos [ :len (\$ScriptLockOrder->\$Script) ];\r\ + \n :set (\$ScriptLockOrder->\$Script->\$Pos) \$Add;\r\ + \n :delay 10ms;\r\ + \n :if ((\$ScriptLockOrder->\$Script->\$Pos) = \$Add) do={:return tru\ + e}\r\ + \n }\r\ + \n }\r\ + \n :local RemoveTicket do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :local Remove [ :tostr \$2 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :foreach Id,Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ + \n :while ((\$ScriptLockOrder->\$Script->\$Id) = \$Remove) do={\r\ + \n :set (\$ScriptLockOrder->\$Script->\$Id);\r\ + \n :delay 10ms;\r\ + \n }\r\ + \n }\r\ + \n }\r\ + \n :local CleanupTickets do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ + \n :if ([ :typeof \$Ticket ] != \"nothing\") do={:return false}\r\ + \n }\r\ + \n :set (\$ScriptLockOrder->\$Script) ({});\r\ + \n }\r\ + \n :if ([ :typeof \$WaitMax ] = \"nil\" ) do={:set WaitMax 0s}\r\ + \n :if ([ :len [ /system/script/find where name=\$Script ] ] = 0) do={\r\ + \n \$LogPrint error \$0 (\"A script named '\" . \$Script . \"' does not\ + \_exist!\");\r\ + \n :error false;\r\ + \n }\r\ + \n :if ([ \$JobCount \$Script ] = 0) do={\r\ + \n \$LogPrint error \$0 (\"No script '\" . \$Script . \"' is running!\"\ + );\r\ + \n :error false;\r\ + \n }\r\ + \n :if ([ \$TicketCount \$Script ] >= [ \$JobCount \$Script ]) do={\r\ + \n \$LogPrint error \$0 (\"More tickets than running scripts '\" . \$Sc\ + ript . \"', resetting!\");\r\ + \n :set (\$ScriptLockOrder->\$Script) ({});\r\ + \n /system/script/job/remove [ find where script=\$Script ];\r\ + \n }\r\ + \n :local MyTicket [ \$GetRandom20CharAlNum 6 ];\r\ + \n \$AddTicket \$Script \$MyTicket;\r\ + \n :local WaitInterval (\$WaitMax / 20);\r\ + \n :local WaitTime \$WaitMax;\r\ + \n :while (\$WaitTime > 0 && \\\r\ + \n ([ \$IsFirstTicket \$Script \$MyTicket ] = false || \\\r\ + \n [ \$TicketCount \$Script ] < [ \$JobCount \$Script ])) do={\r\ + \n :set WaitTime (\$WaitTime - \$WaitInterval);\r\ + \n :delay \$WaitInterval;\r\ + \n }\r\ + \n :if ([ \$IsFirstTicket \$Script \$MyTicket ] = true && \\\r\ + \n [ \$TicketCount \$Script ] = [ \$JobCount \$Script ]) do={\r\ + \n \$RemoveTicket \$Script \$MyTicket;\r\ + \n \$CleanupTickets \$Script;\r\ + \n :return true;\r\ + \n }\r\ + \n \$RemoveTicket \$Script \$MyTicket;\r\ + \n \$LogPrint debug \$0 (\"Script '\" . \$Script . \"' started more than \ + once\" . \\\r\ + \n [ \$IfThenElse (\$WaitTime < \$WaitMax) \" and timed out waiting for\ + \_lock\" \"\" ] . \"...\");\r\ + \n :return false;\r\ + \n}\r\ + \n:set SendNotification do={ :onerror Err {\r\ + \n :global SendNotification2;\r\ + \n \$SendNotification2 ({ origin=\$0; subject=\$1; message=\$2; link=\$3;\ + \_silent=\$4 });\r\ + \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err}\r\ + \n}\r\ + \n:set SendNotification2 do={\r\ + \n :local Notification \$1;\r\ + \n :global NotificationFunctions;\r\ + \n :foreach FunctionName,Discard in=\$NotificationFunctions do={\r\ + \n (\$NotificationFunctions->\$FunctionName) (\"\\\$NotificationFunctio\ + ns->\\\"\" . \$FunctionName . \"\\\"\") \$Notification;\r\ + \n }\r\ + \n}\r\ + \n:set SymbolByUnicodeName do={\r\ + \n :local Name [ :tostr \$1 ];\r\ + \n :global EitherOr;\r\ + \n :global LogPrint;\r\ + \n :global SymbolsExtra;\r\ + \n :local Symbols ({\r\ + \n \"abacus\"=\"\\F0\\9F\\A7\\AE\";\r\ + \n \"alarm-clock\"=\"\\E2\\8F\\B0\";\r\ + \n \"arrow-down\"=\"\\E2\\AC\\87\";\r\ + \n \"arrow-up\"=\"\\E2\\AC\\86\";\r\ + \n \"calendar\"=\"\\F0\\9F\\93\\85\";\r\ + \n \"card-file-box\"=\"\\F0\\9F\\97\\83\";\r\ + \n \"chart-decreasing\"=\"\\F0\\9F\\93\\89\";\r\ + \n \"chart-increasing\"=\"\\F0\\9F\\93\\88\";\r\ + \n \"cloud\"=\"\\E2\\98\\81\";\r\ + \n \"cross-mark\"=\"\\E2\\9D\\8C\";\r\ + \n \"earth\"=\"\\F0\\9F\\8C\\8D\";\r\ + \n \"fire\"=\"\\F0\\9F\\94\\A5\";\r\ + \n \"floppy-disk\"=\"\\F0\\9F\\92\\BE\";\r\ + \n \"gear\"=\"\\E2\\9A\\99\";\r\ + \n \"heart\"=\"\\E2\\99\\A5\";\r\ + \n \"high-voltage-sign\"=\"\\E2\\9A\\A1\";\r\ + \n \"incoming-envelope\"=\"\\F0\\9F\\93\\A8\";\r\ + \n \"information\"=\"\\E2\\84\\B9\";\r\ + \n \"large-orange-circle\"=\"\\F0\\9F\\9F\\A0\";\r\ + \n \"large-red-circle\"=\"\\F0\\9F\\94\\B4\";\r\ + \n \"link\"=\"\\F0\\9F\\94\\97\";\r\ + \n \"lock-with-ink-pen\"=\"\\F0\\9F\\94\\8F\";\r\ + \n \"memo\"=\"\\F0\\9F\\93\\9D\";\r\ + \n \"mobile-phone\"=\"\\F0\\9F\\93\\B1\";\r\ + \n \"pushpin\"=\"\\F0\\9F\\93\\8C\";\r\ + \n \"scissors\"=\"\\E2\\9C\\82\";\r\ + \n \"scroll\"=\"\\F0\\9F\\93\\9C\";\r\ + \n \"smiley-partying-face\"=\"\\F0\\9F\\A5\\B3\";\r\ + \n \"smiley-smiling-face\"=\"\\E2\\98\\BA\";\r\ + \n \"smiley-winking-face-with-tongue\"=\"\\F0\\9F\\98\\9C\";\r\ + \n \"sparkles\"=\"\\E2\\9C\\A8\";\r\ + \n \"speech-balloon\"=\"\\F0\\9F\\92\\AC\";\r\ + \n \"star\"=\"\\E2\\AD\\90\";\r\ + \n \"warning-sign\"=\"\\E2\\9A\\A0\";\r\ + \n \"white-heavy-check-mark\"=\"\\E2\\9C\\85\"\r\ + \n }, \$SymbolsExtra);\r\ + \n :local Magic [ :pick [ /system/clock/get date ] 4 10 ];\r\ + \n :local Special {\r\ + \n \"information-04-01\"=\"\\F0\\9F\\9A\\BB\";\r\ + \n \"large-orange-circle-04-01\"=\"\\F0\\9F\\8D\\8A\";\r\ + \n \"large-orange-circle-10-31\"=\"\\F0\\9F\\8E\\83\";\r\ + \n \"large-red-circle-04-01\"=\"\\F0\\9F\\8D\\92\" };\r\ + \n :if ([ :len (\$Symbols->\$Name) ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"No symbol available for name '\" . \$Name \ + . \"'!\");\r\ + \n :return \"\";\r\ + \n }\r\ + \n :return ([ \$EitherOr (\$Special->(\$Name . \$Magic)) (\$Symbols->\$Na\ + me) ] . \"\\EF\\B8\\8F\");\r\ + \n}\r\ + \n:set SymbolForNotification do={\r\ + \n :global NotificationsWithSymbols;\r\ + \n :global SymbolByUnicodeName;\r\ + \n :global IfThenElse;\r\ + \n :if (\$NotificationsWithSymbols != true) do={:return [ \$IfThenElse ([\ + \_:len \$2 ] > 0) ([ :tostr \$2 ] . \" \") \"\" ]}\r\ + \n :local Return \"\";\r\ + \n :foreach Symbol in=[ :toarray \$1 ] do={:set Return (\$Return . [ \$Sy\ + mbolByUnicodeName \$Symbol ])}\r\ + \n :return (\$Return . \" \");\r\ + \n}\r\ + \n:set Unix2Dos do={:return [ :tocrlf [ :tostr \$1 ] ]}\r\ + \n:set UrlEncode do={\r\ + \n :local Input [ :tostr \$1 ];\r\ + \n :if ([ :len \$Input ] = 0) do={:return \"\"}\r\ + \n :local Return \"\";\r\ + \n :local Chars (\"\\n\\r !\\\"#\\\$%&'()*+,:;<=>\?@[\\\\]^`{|}~\");\r\ + \n :local Subs { \"%0A\"; \"%0D\"; \"%20\"; \"%21\"; \"%22\"; \"%23\"; \"\ + %24\"; \"%25\"; \"%26\"; \"%27\";\r\ + \n \"%28\"; \"%29\"; \"%2A\"; \"%2B\"; \"%2C\"; \"%3A\"; \"%3B\"; \ + \"%3C\"; \"%3D\"; \"%3E\"; \"%3F\";\r\ + \n \"%40\"; \"%5B\"; \"%5C\"; \"%5D\"; \"%5E\"; \"%60\"; \"%7B\"; \ + \"%7C\"; \"%7D\"; \"%7E\" };\r\ + \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ + \n :local Char [ :pick \$Input \$I ];\r\ + \n :local Replace [ :find \$Chars \$Char ];\r\ + \n :if ([ :typeof \$Replace ] = \"num\") do={:set Char (\$Subs->\$Repla\ + ce)}\r\ + \n :set Return (\$Return . \$Char);\r\ + \n }\r\ + \n :return \$Return;\r\ + \n}\r\ + \n:set ValidateSyntax do={\r\ + \n :local Code [ :tostr \$1 ];\r\ + \n :global LogPrint;\r\ + \n :onerror Err {\r\ + \n [ :parse (\":local Validate do={\\n\" . \$Code . \"\\n}\") ];\r\ + \n } do={\r\ + \n \$LogPrint debug \$0 (\"Valdation failed: \" . \$Err);\r\ + \n :return false;\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n:set IsDNSResolving do={\r\ + \n :do {:resolve \"api.telegram.org\"} on-error={:return false}\r\ + \n :return true;\r\ + \n}\r\ + \n:set IsFullyConnected do={\r\ + \n :global IsDNSResolving;\r\ + \n :global IsTimeSync;\r\ + \n :if ([ \$IsDNSResolving ] = false) do={:return false};\r\ + \n :if ([ \$IsTimeSync ] = false) do={:return false};\r\ + \n :return true;\r\ + \n}\r\ + \n:set IsTimeSync do={\r\ + \n :global IsTimeSyncCached;\r\ + \n :global IsTimeSyncResetNtp;\r\ + \n :if (\$IsTimeSyncCached = true) do={:return true}\r\ + \n :if ([ /system/ntp/client/get enabled ] = true) do={\r\ + \n :if ([ /system/ntp/client/get status ] = \"synchronized\") do={\r\ + \n :set IsTimeSyncCached true;\r\ + \n :return true;\r\ + \n }\r\ + \n :local Uptime [ /system/resource/get uptime ];\r\ + \n :if ([ :typeof \$IsTimeSyncResetNtp ] = \"nothing\") do={\r\ + \n :set IsTimeSyncResetNtp \$Uptime;\r\ + \n }\r\ + \n :if (\$Uptime - \$IsTimeSyncResetNtp < 3m) do={:return false}\r\ + \n :log warning \"\$0 The ntp client is configured, but did not sync.\"\ + ;\r\ + \n :set IsTimeSyncResetNtp \$Uptime;\r\ + \n /system/ntp/client/set enabled=no;\r\ + \n :delay 20ms;\r\ + \n /system/ntp/client/set enabled=yes;\r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ /system/license/get ]->\"level\" = \"free\" || \\\r\ + \n [ /system/resource/get ]->\"board-name\" = \"x86\") do={\r\ + \n :log debug \"\$0 No ntp client configured, relying on RTC for CHR fr\ + ee license and x86.\";\r\ + \n :return true;\r\ + \n }\r\ + \n :if ([ /ip/cloud/get update-time ] = true) do={\r\ + \n :if ([ :typeof [ /ip/cloud/get public-address ] ] = \"ip\") do={\r\ + \n :set IsTimeSyncCached true;\r\ + \n :return true;\r\ + \n }\r\ + \n :return false;\r\ + \n }\r\ + \n :log debug \"\$0 No time source configured! Returning gracefully...\";\ + \r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n# read parts of a large file\r\ + \n:set FetchLargeFiles do={\r\ + \n :local ScriptName [:tostr \$1];\r\ + \n :local fetchUrl [:tostr \$2];\r\ + \n :local CheckCert [:tostr \$3];\r\ + \n :local fetchMode [:tostr \$4];\r\ + \n :local fetchMethod [:tostr \$5];\r\ + \n :local FetchString \"undefined\";\r\ + \n \r\ + \n :global CleanName;\r\ + \n :global FetchUserAgentStr;\r\ + \n :global GetRandom20CharAlNum;\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global MkDir;\r\ + \n :global RmDir;\r\ + \n :global RmFile;\r\ + \n :global WaitForFile;\r\ + \n\r\ + \n :set CheckCert [ \$IfThenElse (\$CheckCert = \"false\") \"no\" \"yes-w\ + ithout-crl\" ];\r\ + \n #:set fetchMode [ \$IfThenElse (\$fetchMode != \"false\") [:tostr (\"m\ + ode=\" . \$fetchMode)] ];\r\ + \n #:set fetchMethod [\$IfThenElse (\$fetchMethod != \"false\") [:tostr (\ + \"http-method=\\\"\" . \$fetchMethod . \"\\\"\") ]];\r\ + \n \r\ + \n :local DirName (\"tmpfs/\" . [ \$CleanName \$ScriptName ]);\r\ + \n :if ([ \$MkDir \$DirName ] = false) do={\r\ + \n \$LogPrint error \$0 (\"Failed creating directory!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local FileName (\$DirName . \"/\" . [ \$CleanName \$0 ] . \"-\" . [ \ + \$GetRandom20CharAlNum ]);\r\ + \n #/tool/fetch check-certificate=\$CheckCert \$Url dst-path=\$FileName h\ + ttp-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] }) as-value;\r\ + \n #:log warning (\"\\\$fUrl =\" . \$2 . ({[ \$fMode ]}));\r\ + \n :onerror Err {\r\ + \n :set FetchString (\"/tool/fetch \" . \\\r\ + \n [\$IfThenElse ([\$fetchMethod] != \"false\") (\"http-method=\\\"\"\ + \_. \$fetchMethod . \"\\\" \")] . \\\r\ + \n \"check-certificate=\" . \$CheckCert . \" url=(\\\"\" . \$fetchUrl\ + \_. \"\\\") \" . \\\r\ + \n [\$IfThenElse ([\$fetchMode] != \"false\") (\"mode=\" . \$fetchMod\ + e . \" \")] . \\\r\ + \n http-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] }) as-va\ + lue);\r\ + \n :log warning (\"\\\$FetchSring = \" . \$FetchString);\r\ + \n :put [\$FetchString];\r\ + \n #:put [/tool/fetch \$fetchMode check-certificate=\$CheckCert url=(\$\ + fetchUrl) dst-path=(\$FileName) http-header-field=({ [ \$FetchUserAgentStr\ + \_\$ScriptName ] }) as-value];\r\ + \n } do={\r\ + \n :if ([ \$WaitForFile \$FileName 500ms ] = true) do={\r\ + \n \$RmFile \$FileName;\r\ + \n }\r\ + \n \$LogPrint debug \$0 (\"Failed downloading from \" . \$fetchUrl . \"\ + \_- \" . \$Err);\r\ + \n \$RmDir \$DirName;\r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ \$WaitForFile \$FileName 5s ] = false) do={\r\ + \n \$LogPrint debug \$0 (\"The file downloaded from \" . \$fetchUrl . \ + \" did not show up.\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local FileSize [ /file/get \$FileName size ];\r\ + \n :local Return \"\";\r\ + \n :local VarSize 0;\r\ + \n :while (\$VarSize != \$FileSize) do={\r\ + \n :set Return (\$Return . ([ /file/read offset=\$VarSize chunk-size=32\ + 768 file=\$FileName as-value ]->\"data\"));\r\ + \n :set FileSize [ /file/get \$FileName size ];\r\ + \n :set VarSize [ :len \$Return ];\r\ + \n :if (\$VarSize > \$FileSize) do={\r\ + \n :delay 100ms;\r\ + \n }\r\ + \n }\r\ + \n \$RmDir \$DirName;\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set ScriptInstallUpdate do={ :onerror Err {\r\ + \n :local Scripts [ :toarray \$1 ];\r\ + \n :local NewComment [ :tostr \$2 ];\r\ + \n :global InitSetup;\r\ + \n\r\ + \n :global CommitId;\r\ + \n :global ScriptUpdatesCRLF;\r\ + \n :global GlobalConfVersion;\r\ + \n :global Identity;\r\ + \n :global CertificateAvailable;\r\ + \n :global CheckSumsVerify;\r\ + \n :global GlobalScriptsUrl;\r\ + \n :global SumsDirAndFileName;\r\ + \n :global GlobalScriptsUrlSuffix;\r\ + \n :global EitherOr;\r\ + \n :global FetchUserAgentStr;\r\ + \n :global Grep;\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global ParseKeyValueStore;\r\ + \n :global RequiredRouterOS;\r\ + \n :global SendNotification2;\r\ + \n :global SymbolForNotification;\r\ + \n :global ValidateSyntax;\r\ + \n :global CommentsInScripts;\r\ + \n\r\ + \n :if ([ \$CertificateAvailable \"Root YE\" \"fetch\" ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Downloading certificate failed, trying wit\ + hout.\");\r\ + \n }\r\ + \n\r\ + \n :foreach Script in=\$Scripts do={\r\ + \n :if ([ :len [ /system/script/find where name=\$Script ] ] = 0) do={\ + \r\ + \n \$LogPrint info \$0 (\"Adding new script: \" . \$Script);\r\ + \n /system/script/add name=\$Script owner=\$Script source=\"#!rsc by \ + Vados\\n\" comment=\$NewComment;\r\ + \n }\r\ + \n }\r\ + \n\r\ + \n :local CommitIdBefore \$CommitId;\r\ + \n :local GlobalConfVersionBefore \$GlobalConfVersion;\r\ + \n :local ReloadGlobal false;\r\ + \n :local DeviceMode [ /system/device-mode/get ];\r\ + \n\r\ + \n :if (\$CheckSumsVerify = true) do={\r\ + \n :local CheckSums ({});\r\ + \n :do {\r\ + \n :local Url (\$GlobalScriptsUrl . \$SumsDirAndFileName . \$GlobalScr\ + iptsUrlSuffix);\r\ + \n \$LogPrint debug \$0 (\"Fetching checksums from url: \" . \$Url);\ + \r\ + \n :set CheckSums [ :deserialize from=json ([ /tool/fetch check-certi\ + ficate=yes-without-crl \\\r\ + \n http-header-field=({ [ \$FetchUserAgentStr \$0 ] }) \$Url output\ + =user as-value ]->\"data\") ];\r\ + \n } on-error={ \$LogPrint warning \$0 (\"Err = \" . \$Err); }\r\ + \n }\r\ + \n\r\ + \n :foreach Script in=[ /system/script/find where source~\"^#!rsc by Vado\ + s\" ] do={\r\ + \n :local ScriptVal [ /system/script/get \$Script ];\r\ + \n :local ScriptInfo [ \$ParseKeyValueStore (\$ScriptVal->\"comment\") \ + ];\r\ + \n :local SourceNew;\r\ + \n\r\ + \n :foreach Scheduler in=[ /system/scheduler/find where on-event~(\"\\\ + \\b\" . \$ScriptVal->\"name\" . \"\\\\b\") ] do={\r\ + \n :local SchedulerVal [ /system/scheduler/get \$Scheduler ];\r\ + \n :if (\$ScriptVal->\"policy\" != \$SchedulerVal->\"policy\") do={\r\ + \n \$LogPrint warning \$0 (\"Policies differ for script '\" . \$Scr\ + iptVal->\"name\" . \"' and its scheduler '\" . \$SchedulerVal->\"name\" . \ + \"'!\");\r\ + \n }\r\ + \n }\r\ + \n :do {\r\ + \n :if (\$ScriptInfo->\"ignore\" = true) do={\r\ + \n \$LogPrint debug \$0 (\"Ignoring script '\" . \$ScriptVal->\"nam\ + e\" . \"', as requested.\");\r\ + \n :error true;\r\ + \n }\r\ + \n :if (\$CheckSumsVerify = true) do={\r\ + \n :local CheckSum (\$CheckSums->(\$ScriptVal->\"name\"));\r\ + \n :if ([ :len (\$ScriptInfo->\"base-url\") ] = 0 && [ :len (\$Scri\ + ptInfo->\"url-suffix\") ] = 0 && \\\r\ + \n [ :convert transform=md5 to=hex [ :tolf (\$ScriptVal->\"sou\ + rce\") ] ] = \$CheckSum) do={\r\ + \n \$LogPrint debug \$0 (\"Checksum for script '\" . \$ScriptVal-\ + >\"name\" . \"' matches, ignoring.\");\r\ + \n :error true;\r\ + \n }\r\ + \n }\r\ + \n :if ([ :len (\$ScriptInfo->\"certificate\") ] > 0) do={\r\ + \n :if ([ \$CertificateAvailable (\$ScriptInfo->\"certificate\") \"\ + fetch\" ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Downloading certificate failed, tryi\ + ng without.\");\r\ + \n }\r\ + \n }\r\ + \n :onerror Err {\r\ + \n :local BaseUrl [ \$EitherOr (\$ScriptInfo->\"base-url\") \$Globa\ + lScriptsUrl ];\r\ + \n :local UrlSuffix [ \$EitherOr (\$ScriptInfo->\"url-suffix\") \$G\ + lobalScriptsUrlSuffix ];\r\ + \n :local Url (\$BaseUrl . \$ScriptVal->\"name\" . \".rsc\" . \$Url\ + Suffix);\r\ + \n \$LogPrint warning \$0 (\"Fetching script '\" . (\$ScriptVal->\"\ + name\") . \"' from url: \" . \$Url);\r\ + \n :local Result [ /tool/fetch check-certificate=yes-without-crl \\\ + \r\ + \n http-header-field=({ [ \$FetchUserAgentStr \$0 ] }) \$Url outp\ + ut=user as-value ];\r\ + \n :if (\$Result->\"status\" = \"finished\") do={\r\ + \n :set SourceNew [ :tolf (\$Result->\"data\") ];\r\ + \n } \r\ + \n } do={\r\ + \n \$LogPrint warning \$0 (\"Failed fetching script '\" . \$ScriptV\ + al->\"name\" . \"': \" . \$Err);\r\ + \n :if (\$Err != \"Fetch failed with status 404\") do={\r\ + \n :error false;\r\ + \n }\r\ + \n :if (\$ScriptVal->\"source\" = \"#!rsc by Vados\") do={\r\ + \n \$LogPrint warning \$0 (\"Removing dummy. Typo on installation\ + \?\");\r\ + \n /system/script/remove \$Script;\r\ + \n :error false;\r\ + \n }\r\ + \n :if (\$CheckSumsVerify = true) do={\r\ + \n :if ([ :len (\$ScriptInfo->\"base-url\") ] = 0 && [ :len (\$Sc\ + riptInfo->\"url-suffix\") ] = 0 && \\\r\ + \n [ :len \$CheckSum ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"Added the script manually\? Skip u\ + pdates with 'ignore=true' in comment.\");\r\ + \n }\r\ + \n }\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :if ([ :len \$SourceNew ] = 0) do={\r\ + \n \$LogPrint debug \$0 (\"No update for script '\" . (\$ScriptVal-\ + >\"name\") . \"'.\");\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :local SourceCRLF [ :tocrlf \$SourceNew ];\r\ + \n :if (\$InitSetup != true && ((\$ScriptVal->\"name\") != \"AM-Globa\ + lConfig\" || (\$ScriptVal->\"name\") != \"AM-GlobalFunc\")) do={\r\ + \n :if (\$SourceNew = (\$ScriptVal->\"source\") || \$SourceCRLF = (\ + \$ScriptVal->\"source\")) do={\r\ + \n \$LogPrint debug \$0 (\"Script '\" . (\$ScriptVal->\"name\") \ + . \"' source did not change. End of lines set to CRLF.\");\r\ + \n if (\$ScriptUpdatesCRLF = false) do={\r\ + \n :put [ :tolf \$SourceNew ];\r\ + \n \$LogPrint debug \$0 (\"Script '\" . (\$ScriptVal->\"name\"\ + ) . \"' source update end of lines to LF.\");\r\ + \n }\r\ + \n :error false;\r\ + \n }\r\ + \n }\r\ + \n\r\ + \n :if ([ :pick \$SourceNew 0 14 ] != \"#!rsc by Vados\") do={\r\ + \n \$LogPrint warning \$0 (\"Looks like new script '\" . \$ScriptVa\ + l->\"name\" . \"' is not valid (missing shebang = '\$shebang') Ignoring!\"\ + );\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :if (\$CommentsInScripts = true) do={\r\ + \n :local CommentLine [ \$Grep \$SourceNew (\"\\23 Script comment:\ + \_\") ];\r\ + \n :if ([ :len \$CommentLine ] = 0) do={\r\ + \n \$LogPrint debug \$0 (\"The search in new script '\" . (\$Scr\ + iptVal->\"name\") . \"' for comment in script body, is not found result Ig\ + noring!\");\r\ + \n :error false;\r\ + \n } else={\r\ + \n :if ([ :len (\$ScriptVal->\"comment\")] = 0 || [ :len (\$Scri\ + ptVal->\"comment\")] != [ :pick \$CommentLine ([ :find \$CommentLine \":\"\ + ] + 2) [ :len \$CommentLine] ]) do={\r\ + \n \$LogPrint debug \$0 (\"Exsiting comment for script '\" . (\ + \$ScriptVal->\"name\") . \"' is '\" . (\$ScriptVal->\"comment\") . \"'.\")\ + ;\r\ + \n :set (\$ScriptVal->\"comment\") [ :pick \$CommentLine ([ :f\ + ind \$CommentLine \":\"] + 2) [ :len \$CommentLine] ];\r\ + \n \$LogPrint debug \$0 (\"New comment (\" . (\$ScriptVal->\"c\ + omment\") . \") for script '\" . (\$ScriptVal->\"name\") . \"' has been ad\ + ded!\");\r\ + \n } else={\r\ + \n \$LogPrint debug \$0 (\"Comment for script '\" . (\$ScriptV\ + al->\"name\") . \"' did not change.\");\r\ + \n :error false;\r\ + \n }\r\ + \n } \r\ + \n }\r\ + \n\r\ + \n :local RequiredROS ([ \$ParseKeyValueStore [ \$Grep \$SourceNew (\ + \"\\23 requires RouterOS, \") ] ]->version);\r\ + \n :if ([ \$RequiredRouterOS \$0 [ \$EitherOr \$RequiredROS \"0.0\" ]\ + \_false ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"The script '\" . (\$ScriptVal->\"name\ + \") . \"' requires RouterOS \" . \\\r\ + \n \$RequiredROS . \", which is not met by your installation. I\ + gnoring!\");\r\ + \n :error false;\r\ + \n }\r\ + \n :local RequiredDM [ \$ParseKeyValueStore [ \$Grep \$SourceNew (\"\ + \\23 requires device-mode, \") ] ];\r\ + \n :local MissingDM ({});\r\ + \n :foreach Feature,Value in=\$RequiredDM do={\r\ + \n :if ([ :typeof (\$DeviceMode->\$Feature) ] = \"bool\" && (\$Devi\ + ceMode->\$Feature) = false) do={\r\ + \n :set MissingDM (\$MissingDM, \$Feature);\r\ + \n }\r\ + \n }\r\ + \n :if ([ :len \$MissingDM ] > 0) do={\r\ + \n \$LogPrint warning \$0 (\"The script '\" . (\$ScriptVal->\"name\ + \") . \"' requires disabled \" . \\\r\ + \n \"device-mode features (\" . [ :tostr \$MissingDM ] . \"). I\ + gnoring!\");\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :if ([ \$ValidateSyntax \$SourceNew ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Syntax validation for script '\" . (\$\ + ScriptVal->\"name\") . \"' failed! Ignoring!\");\r\ + \n :error false;\r\ + \n }\r\ + \n \r\ + \n :log info (\"Updating script: \" . (\$ScriptVal->\"name\") . \" Sc\ + ript comment: \" . (\$ScriptVal->\"comment\"));\r\ + \n\r\ + \n /system/script/set owner=(\$ScriptVal->\"name\") comment=(\$Script\ + Val->\"comment\") \\\r\ + \n source=[ \$IfThenElse (\$ScriptUpdatesCRLF = true) \$SourceCRL\ + F \$SourceNew ] \$Script;\r\ + \n :if (\$ScriptVal->\"name\" = \"AM-GlobalConfig\" || \\\r\ + \n \$ScriptVal->\"name\" = \"AM-GlobalFunc\" || \\\r\ + \n \$ScriptVal->\"name\" ~ (\"^(AM-GlobalFunc\\\\.d|mod)/.\")) d\ + o={\r\ + \n :set ReloadGlobal true;\r\ + \n }\r\ + \n } on-error={ }\r\ + \n }\r\ + \n :if (\$ReloadGlobal = true) do={\r\ + \n \$LogPrint info \$0 (\"Reloading global configuration and functions.\ + \");\r\ + \n :onerror Err {\r\ + \n :global InitSetup (a);\r\ + \n /system/script {run AM-GlobalConfig; run AM-GlobalFunc;};\r\ + \n } do={\$LogPrint error \$0 (\"Reloading global configuration and fun\ + ctions failed! \" . \$Err)}\r\ + \n }\r\ + \n :if (\$GlobalConfVersionBefore > \$GlobalConfVersion) do={\r\ + \n \$LogPrint warning \$0 (\"The configuration version decreased from \ + \" . \\\r\ + \n \$GlobalConfVersionBefore . \" to \" . \$GlobalConfVersion . \\\r\ + \n \". Installed an older version\?\");\r\ + \n }\r\ + \n :if (\$GlobalConfVersionBefore < \$GlobalConfVersion) do={\r\ + \n :global GlobalConfChanges;\r\ + \n :global GlobalConfMigration;\r\ + \n :local ChangeLogCode;\r\ + \n :if ([ :len \$ChangeLogCode ] > 0) do={\r\ + \n :if ([ \$ValidateSyntax \$ChangeLogCode ] = true) do={\r\ + \n :onerror Err {\r\ + \n [ :parse \$ChangeLogCode ];\r\ + \n } do={\$LogPrint warning \$0 (\"The changelog failed to run: \" \ + . \$Err)}\r\ + \n } else={\$LogPrint warning \$0 (\"The changelog failed syntax vali\ + dation!\")}\r\ + \n }\r\ + \n :if ([ :len \$GlobalConfMigration ] > 0) do={\r\ + \n :for I from=(\$GlobalConfVersionBefore + 1) to=\$GlobalConfVersion\ + \_do={\r\ + \n :local Migration (\$GlobalConfMigration->[ :tostr \$I ]);\r\ + \n :do {\r\ + \n :if ([ :typeof \$Migration ] != \"str\") do={\r\ + \n \$LogPrint debug \$0 (\"Migration code for change \" . \$I .\ + \_\" is not available.\");\r\ + \n :error false;\r\ + \n }\r\ + \n :if ([ \$ValidateSyntax \$Migration ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Migration code for change \" . \$I\ + \_. \" failed syntax validation!\");\r\ + \n :error false}\r\ + \n \$LogPrint info \$0 (\"Applying migration for change \" . \$I \ + . \": \" . \$Migration);\r\ + \n :onerror Err {\r\ + \n [ :parse \$Migration ];\r\ + \n } do={\$LogPrint warning \$0 (\"Migration code for change \" .\ + \_\$I . \" failed to run: \" . \$Err)}\r\ + \n } on-error={ }\r\ + \n }\r\ + \n }\r\ + \n :local NotificationMessage (\"The configuration version on \" . \$Id\ + entity . \" increased \" . \\\r\ + \n \"to \" . \$GlobalConfVersion . \", current configuration may nee\ + d modification. \" . \\\r\ + \n \"Please review and update global-config-overlay, then re-run glo\ + bal-config.\");\r\ + \n \$LogPrint info \$0 (\$NotificationMessage);\r\ + \n :if ([ :len \$GlobalConfChanges ] > 0) do={\r\ + \n :set NotificationMessage (\$NotificationMessage . \"\\n\\nChanges:\ + \");\r\ + \n :for I from=(\$GlobalConfVersionBefore + 1) to=\$GlobalConfVersion\ + \_do={\r\ + \n :local Change (\$GlobalConfChanges->[ :tostr \$I ]);\r\ + \n :set NotificationMessage (\$NotificationMessage . \"\\n \" . \\\ + \r\ + \n [ \$SymbolForNotification \"pushpin\" \"*\" ] . \$Change);\r\ + \n \$LogPrint info \$0 (\"Change \" . \$I . \": \" . \$Change);\r\ + \n }\r\ + \n } else={:set NotificationMessage (\$NotificationMessage . \"\\n\\nNe\ + ws and changes are not available.\")}\r\ + \n\r\ + \n :set GlobalConfChanges;\r\ + \n :set GlobalConfMigration;\r\ + \n }\r\ + \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err}\r\ + \n}\r\ + \n\r\ + \n# Global Environment clear. Use: \"\$GlobalEnvRemove True;\".\r\ + \n:set GlobalEnvRemove do={\r\ + \n :local doRmEnv [ :tostr \$1 ];\r\ + \n :global GlobalScriptsUrl;\r\ + \n :local ScriptsUrl;\r\ + \n :global LogPrint;\r\ + \n :if (\$doRmEnv != \"True\") do={\r\ + \n \$LogPrint error \"GlobalEnvRemove\" (\"This script is needed \\\"T\ + rue\\\" for confirm to remove global environment variables!\");\r\ + \n :return [];\r\ + \n :error true; \r\ + \n } else={\r\ + \n :set ScriptsUrl \$GlobalScriptsUrl;\r\ + \n :delay 5;\r\ + \n :foreach var in=[/system/script/environment print as-value] do={/sy\ + stem/script/environment remove (\$var->\".id\")}\r\ + \n :delay 5;\r\ + \n :global GlobalScriptsUrl \$ScriptsUrl;\r\ + \n \$LogPrint warning \"GlobalEnvRemove\" (\"Done!\");\r\ + \n :return [];\r\ + \n :error false;\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n# Add and fix global scheduler\r\ + \n:put \"Add or/and fix Global scheduler...\";\r\ + \n:local OnEvent \"/system/script { run AM-GlobalConfig; run AM-GlobalFunc\ + ; }\";\r\ + \n:local Comment \"Setup Global Environment for scripts\";\r\ + \n:if ([ :len [ /system/scheduler/find where name=\"AM-SetGlobalEnv\" ] ] \ + = 0) do={\r\ + \n /system/scheduler/add name=\"AM-SetGlobalEnv\" comment=\$Comment on-ev\ + ent=\$OnEvent start-time=startup;\r\ + \n}\r\ + \n:if ([ /system/scheduler/get \"AM-SetGlobalEnv\" comment ] != \$Comment)\ + \_do={\r\ + \n /system/scheduler/set \"AM-SetGlobalEnv\" comment=\$Comment;\r\ + \n}\r\ + \n:if ([ /system/scheduler/get \"AM-SetGlobalEnv\" on-event ] != \$OnEvent\ + ) do={\r\ + \n /system/scheduler/set \"AM-SetGlobalEnv\" on-event=\$OnEvent;\r\ + \n}\r\ + \n# Add Update Script scheduler\r\ + \n:put \"Add or/and fix Update Script scheduler\";\r\ + \n:set OnEvent \":global ScriptInstallUpdate; \\\$ScriptInstallUpdate;\";\ + \r\ + \n:set Comment \"Every Day Check For Update Scripts\";\r\ + \n:if ([ :len [ /system/scheduler/find where name=\"AM-ScriptInstallUpdate\ + \" ] ] = 0) do={\r\ + \n/system/scheduler/add name=\"AM-ScriptInstallUpdate\" comment=\$Comment \ + start-time=startup interval=1d on-event=\$OnEvent;\r\ + \n}\r\ + \n\r\ + \n#:local Resource [ /system/resource/get ];\r\ + \n#:log info (\$ScriptName . \" Loaded on \" . \$Resource->\"board-name\" \ + . \" with RouterOS \" . \$Resource->\"version\" . \" and Architecture \" .\ + \".\");\r\ + \n\r\ + \n:onerror Err {\r\ + \n :global GlobalConfReady;\r\ + \n :retry { :if (\$GlobalConfReady != true) do={ :error (\"Global configs\ + \_not ready.\"); }; } delay=100ms max=5;\r\ + \n\r\ + \n# signal we are ready\r\ + \n:set GlobalFuncReady true;\r\ + \n:set ExitOK true;\r\ + \n:log warning (\"This script \$ScriptName Loaded \" . \\\r\ + \n [ \$IfThenElse (\$CommitId != \"unknown\") ([ \$CommitBrief ] . \" \ + \") ] . \\\r\ + \n \"on \" . \$devBoardName . \"\\nRouterOS: \" . \$devCurVersion . \"\ + \\nArchitecture: \" . \$devCurArch . \"\\nIdentity: \" . \$Identity);\r\ + \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err;}\r\ + \n\r\ + \n#} do={:global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err}\r\ + \n# log the successful load of the script, or an error if it failed\r\ + \n#:if ([\$GlobalFuncReady] = true && [\$GlobalConfReady] = true) do={\r\ + \n" +add comment="Import ssh keys for public key authentication" \ + dont-require-permissions=no name=AM-SshKeysImport owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\r\ + \n# RouterOS script: AM-SshKeysImport\r\ + \n# Script comment: Import ssh keys for public key authentication\r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n#\r\ + \n:local ExitOK false;\r\ + \n:onerror Err {\r\ + \n :global GlobalConfReady; :global GlobalFuncReady;\r\ + \n :retry { :if (\$GlobalConfReady != true || \$GlobalFuncReady != true) \ + \\\r\ + \n do={ :error (\"Global configs or functions not ready.\"); }; } del\ + ay=500ms max=50;\r\ + \n :local ScriptName [ :jobname ];\r\ + \n\r\ + \n:global SSHKeysImport;\r\ + \n:global SSHKeysImportFile;\r\ + \n\r\ + \n# import single key passed as string\r\ + \n:set SSHKeysImport do={ :onerror Err {\r\ + \n :local Key [ :tostr \$1 ];\r\ + \n :local User [ :tostr \$2 ];\r\ + \n :global GetRandom20CharAlNum;\r\ + \n :global LogPrint;\r\ + \n :global MkDir;\r\ + \n :global RmDir;\r\ + \n :global WaitForFile;\r\ + \n :if ([ :len \$Key ] = 0 || [ :len \$User ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"Missing argument(s), please pass key and u\ + ser!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ :len [ /user/find where name=\$User ] ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"User '\" . \$User . \"' does not exist.\")\ + ;\r\ + \n :return false;\r\ + \n }\r\ + \n :local KeyVal ([ :deserialize \$Key delimiter=\" \" from=dsv options=d\ + sv.plain ]->0);\r\ + \n :if (!(\$KeyVal->0 = \"ssh-ed25519\" || \$KeyVal->0 = \"ssh-rsa\")) do\ + ={\r\ + \n \$LogPrint warning \$0 (\"SSH key of type '\" . \$KeyVal->0 . \"' is\ + \_not supported.\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local FingerPrintMD5 [ :convert from=base64 transform=md5 to=hex (\$K\ + eyVal->1) ];\r\ + \n :local RegEx (\"\\\\bmd5=\" . \$FingerPrintMD5 . \"\\\\b\");\r\ + \n :if ([ :len [ /user/ssh-keys/find where user=\$User \\\r\ + \n (key-owner~\$RegEx or info~\$RegEx) ] ] > 0) do={\r\ + \n \$LogPrint warning \$0 (\"The ssh public key (MD5:\" . \$FingerPrint\ + MD5 . \\\r\ + \n \") is already available for user '\" . \$User . \"'.\");\r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ \$MkDir \"tmpfs/ssh-keys-import\" ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Creating directory 'tmpfs/ssh-keys-import'\ + \_failed!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local FileName (\"tmpfs/ssh-keys-import/key-\" . [ \$GetRandom20CharA\ + lNum 6 ] . \".pub\");\r\ + \n /file/add name=\$FileName contents=(\$Key . \", md5=\" . \$FingerPrint\ + MD5);\r\ + \n \$WaitForFile \$FileName;\r\ + \n :onerror Err {\r\ + \n /user/ssh-keys/import public-key-file=\$FileName user=\$User;\r\ + \n \$LogPrint info \$0 (\"Imported ssh public key (\" . \$KeyVal->2 . \ + \", \" . \$KeyVal->0 . \", \" . \\\r\ + \n \"MD5:\" . \$FingerPrintMD5 . \") for user '\" . \$User . \"'.\");\ + \r\ + \n \$RmDir \"tmpfs/ssh-keys-import\";\r\ + \n } do={\r\ + \n \$LogPrint warning \$0 (\"Failed importing key: \" . \$Err);\r\ + \n \$RmDir \"tmpfs/ssh-keys-import\";\r\ + \n :return false;\r\ + \n }\r\ + \n} do={\r\ + \n :global ExitOnError; \$ExitOnError \$0 \$Err;\r\ + \n} }\r\ + \n\r\ + \n# import keys from a file\r\ + \n:set SSHKeysImportFile do={ :onerror Err {\r\ + \n :local FileName [ :tostr \$1 ];\r\ + \n :local User [ :tostr \$2 ];\r\ + \n :global EitherOr;\r\ + \n :global FileExists;\r\ + \n :global LogPrint;\r\ + \n :global ParseKeyValueStore;\r\ + \n :global SSHKeysImport;\r\ + \n :if ([ :len \$FileName ] = 0 || [ :len \$User ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"Missing argument(s), please pass file name\ + \_and user!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ \$FileExists \$FileName ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"File '\" . \$FileName . \"' does not exist\ + .\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local Keys [ :tolf [ /file/get \$FileName contents ] ];\r\ + \n :foreach KeyVal in=[ :deserialize \$Keys delimiter=\" \" from=dsv opti\ + ons=dsv.plain ] do={\r\ + \n :local Continue false;\r\ + \n :if (\$KeyVal->0 = \"ssh-ed25519\" || \$KeyVal->0 = \"ssh-rsa\") do=\ + {\r\ + \n :if ([ \$SSHKeysImport (\$KeyVal->0 . \" \" . \$KeyVal->1 . \" \" \ + . \$KeyVal->2) \$User ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Failed importing key for user '\" . \$\ + User . \"'.\");\r\ + \n }\r\ + \n :set Continue true;\r\ + \n }\r\ + \n :if (\$Continue = false && \$KeyVal->0 = \"#\") do={\r\ + \n :set User [ \$EitherOr ([ \$ParseKeyValueStore (\$KeyVal->1) ]->\"\ + user\") \$User ];\r\ + \n :set Continue true;\r\ + \n }\r\ + \n :if (\$Continue = false && [ :len (\$KeyVal->0) ] > 0) do={\r\ + \n \$LogPrint warning \$0 (\"SSH key of type '\" . \$KeyVal->0 . \"' \ + is not supported.\");\r\ + \n }\r\ + \n }\r\ + \n} do={\r\ + \n :global ExitOnError; \$ExitOnError \$0 \$Err;\r\ + \n} }\r\ + \n} do={:global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err}\r\ + \n" +add comment="Enable or disable ip addresses based on bridge port state" \ + dont-require-permissions=no name=mod/AM-IPbridge owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\r\ + \n# RouterOS script: mod/AM-IPbridge\r\ + \n# Script comment: Enable or disable ip addresses based on bridge port st\ + ate\r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n# requires device-mode, fetch\r\ + \n#\r\ + \n:local ScriptName [ :jobname ];\r\ + \n\r\ + \n# Add this Script scheduler\r\ + \n:if ([ :len [ /system/scheduler/find where name=\$ScriptName ] ] = 0) do\ + ={\r\ + \n:log warning (\"SystemScheduler for script: \" . \$ScriptName . \" is NO\ + T SET! Fix It Now!\");\r\ + \n:local OnEvent \"/system/script/run \$ScriptName;\";\r\ + \n:local Comment \"Every Day Check For Fake Bridges\";\r\ + \n/system/scheduler/add name=\$ScriptName comment=\$Comment start-time=sta\ + rtup interval=1d on-event=\$OnEvent;\r\ + \n}\r\ + \n\r\ + \n:foreach Bridge in=[ /interface/bridge/find ] do={\r\ + \n :local BrName [ /interface/bridge/get \$Bridge name ];\r\ + \n :if ([ :len [ /interface/bridge/port/find where bridge=\$BrName ] ] > \ + 0) do={\r\ + \n :if ([ :len [ /interface/bridge/port/find where bridge=\$BrName and \ + inactive=no ] ] = 0) do={\r\ + \n /ip/address/disable [ find where !dynamic interface=\$BrName ];\r\ + \n } else={\r\ + \n /ip/address/enable [ find where !dynamic interface=\$BrName ];\r\ + \n }\r\ + \n }\r\ + \n}\r\ + \n" +add comment="Check for certificates validity" dont-require-permissions=no \ + name=AM-CheckCerts owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\r\ + \n# RouterOS script: AM-CheckCerts\r\ + \n# Script comment: Check for certificates validity\r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n# requires device-mode, fetch\r\ + \n\r\ + \n:local ExitOK false;\r\ + \n:onerror Err {\r\ + \n :global GlobalConfReady; :global GlobalFuncReady;\r\ + \n :retry { :if (\$GlobalConfReady != true || \$GlobalFuncReady != true) \ + \\\r\ + \n do={ :error (\"Global config and/or functions not ready.\"); }; } \ + delay=500ms max=50;\r\ + \n :local ScriptName [ :jobname ];\r\ + \n\r\ + \n :global CertRenewTime;\r\ + \n :global CertRenewUrl;\r\ + \n :global CertWarnTime;\r\ + \n :global Identity;\r\ + \n\r\ + \n :global CertificateAvailable;\r\ + \n :global EscapeForRegEx;\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global ParseKeyValueStore;\r\ + \n :global ScriptLock;\r\ + \n :global SendNotification2;\r\ + \n :global SymbolForNotification;\r\ + \n :global UrlEncode;\r\ + \n# :global WaitFullyConnected;\r\ + \n\r\ + \n# Add this Script scheduler\r\ + \n:if ([ :len [ /system/scheduler/find where name=\$ScriptName ] ] = 0) do\ + ={\r\ + \n:log warning (\"System Scheduler for script: \" . \$ScriptName . \" is N\ + OT SET! Fix It Now!\");\r\ + \n:local OnEvent \"/system/script/run \$ScriptName;\";\r\ + \n:local Comment \"Every Day Check For Renew Certificates\";\r\ + \n/system/scheduler/add name=\$ScriptName comment=\$Comment start-time=sta\ + rtup interval=1d on-event=\$OnEvent;\r\ + \n}\r\ + \n\r\ + \n\r\ + \n :local CheckCertificatesDownloadImport do={\r\ + \n :local ScriptName [ :tostr \$1 ];\r\ + \n :local CertName [ :tostr \$2 ];\r\ + \n :local FetchName [ :tostr \$3 ];\r\ + \n\r\ + \n :global CertRenewUrl;\r\ + \n :global CertRenewPass;\r\ + \n\r\ + \n :global CertificateNameByCN;\r\ + \n :global EscapeForRegEx;\r\ + \n :global FetchUserAgentStr;\r\ + \n :global LogPrint;\r\ + \n :global RmFile;\r\ + \n :global UrlEncode;\r\ + \n :global WaitForFile;\r\ + \n\r\ + \n :foreach Type in={ \"p12\"; \"pem\" } do={\r\ + \n :local CertFileName ([ \$UrlEncode \$FetchName ] . \".\" . \$Type)\ + ;\r\ + \n \$LogPrint debug \$ScriptName (\"Trying type '\" . \$Type . \"' fo\ + r '\" . \$CertName . \\\r\ + \n \"' (file '\" . \$CertFileName . \"')...\");\r\ + \n\r\ + \n :do {\r\ + \n :onerror Err {\r\ + \n /tool/fetch check-certificate=yes-without-crl \\\r\ + \n http-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] \ + }) \\\r\ + \n (\$CertRenewUrl . \$CertFileName) dst-path=\$CertFileName \ + as-value;\r\ + \n } do={\r\ + \n :if (!(\$Err ~ \"[Ss]tatus 404\")) do={\r\ + \n \$LogPrint warning \$0 (\"Failed fetching certificate: \" . \ + \$Err);\r\ + \n }\r\ + \n :error false;\r\ + \n }\r\ + \n \$WaitForFile \$CertFileName; \r\ + \n\r\ + \n :local DecryptionFailed true;\r\ + \n :foreach I,PassPhrase in=\$CertRenewPass do={\r\ + \n :do {\r\ + \n \$LogPrint debug \$ScriptName (\"Trying \" . \$I . \". passp\ + hrase... \");\r\ + \n :local Result [ /certificate/import file-name=\$CertFileName\ + \_passphrase=\$PassPhrase as-value ];\r\ + \n :if (\$Result->\"decryption-failures\" = 0) do={\r\ + \n \$LogPrint debug \$ScriptName (\"Success!\");\r\ + \n :set DecryptionFailed false;\r\ + \n }\r\ + \n } on-error={ }\r\ + \n }\r\ + \n \$RmFile \$CertFileName;\r\ + \n\r\ + \n :if (\$DecryptionFailed = true) do={\r\ + \n \$LogPrint warning \$ScriptName (\"Decryption failed for certi\ + ficate file '\" . \$CertFileName . \"'.\");\r\ + \n }\r\ + \n\r\ + \n :foreach CertInChain in=[ /certificate/find where common-name!=\ + \$CertName !private-key \\\r\ + \n name~(\"^\" . [ \$EscapeForRegEx \$CertFileName ] . \"_[0-9]\ + +\\\$\") \\\r\ + \n !(subject-alt-name~(\"(^|\\\\W)(DNS|IP):\" . [ \$EscapeForRe\ + gEx \$CertName ] . \"(\\\\W|\\\$)\")) \\\r\ + \n !(common-name=[]) ] do={\r\ + \n \$CertificateNameByCN [ /certificate/get \$CertInChain common-\ + name ];\r\ + \n }\r\ + \n\r\ + \n :return true;\r\ + \n } on-error={\r\ + \n \$LogPrint debug \$ScriptName (\"Could not download certificate \ + file '\" . \$CertFileName . \"'.\");\r\ + \n }\r\ + \n }\r\ + \n\r\ + \n :return false;\r\ + \n }\r\ + \n\r\ + \n :local FormatInfo do={\r\ + \n :local Cert \$1;\r\ + \n\r\ + \n :global FormatLine;\r\ + \n :global FormatMultiLines;\r\ + \n :global IfThenElse;\r\ + \n\r\ + \n :local FormatExpire do={\r\ + \n :global CharacterReplace;\r\ + \n :return [ \$CharacterReplace [ \$CharacterReplace [ :tostr \$1 ] \ + \"w\" \"w \" ] \"d\" \"d \" ];\r\ + \n }\r\ + \n\r\ + \n :local FormatCertChain do={\r\ + \n :local Cert \$1;\r\ + \n\r\ + \n :global ParseKeyValueStore;\r\ + \n\r\ + \n :local CertVal [ /certificate/get \$Cert ];\r\ + \n\r\ + \n :if ([ :typeof (\$CertVal->\"issuer\") ] = \"nothing\") do={\r\ + \n :return \"self-signed\";\r\ + \n }\r\ + \n\r\ + \n :local Return \"\";\r\ + \n :for I from=0 to=5 do={\r\ + \n :set Return (\$Return . [ \$ParseKeyValueStore (\$CertVal->\"iss\ + uer\") ]->\"CN\");\r\ + \n :if ([ :len [ /certificate/builtin/find where skid=(\$CertVal->\ + \"akid\") ] ] > 0) do={\r\ + \n :return \$Return;\r\ + \n }\r\ + \n :do {\r\ + \n :set CertVal [ /certificate/get [ find where skid=(\$CertVal->\ + \"akid\") ] ];\r\ + \n } on-error={\r\ + \n :return (\$Return . \" (possibly incomplete!)\");\r\ + \n }\r\ + \n :if ((\$CertVal->\"akid\") = \"\" || (\$CertVal->\"akid\") = (\$\ + CertVal->\"skid\")) do={\r\ + \n :return \$Return;\r\ + \n }\r\ + \n :set Return (\$Return . \" -> \");\r\ + \n }\r\ + \n :return (\$Return . \"...\");\r\ + \n }\r\ + \n\r\ + \n :local CertVal [ /certificate/get \$Cert ];\r\ + \n\r\ + \n :return ( \\\r\ + \n [ \$FormatLine \"Name\" (\$CertVal->\"name\") ] . \"\\n\" . \\\r\ + \n [ \$IfThenElse ([ :len (\$CertVal->\"common-name\") ] > 0) ([ \$Fo\ + rmatLine \"CommonName\" (\$CertVal->\"common-name\") ] . \"\\n\") ] . \\\r\ + \n [ \$IfThenElse ([ :len (\$CertVal->\"subject-alt-name\") ] > 0) ([\ + \_\$FormatMultiLines \"SubjectAltNames\" (\$CertVal->\"subject-alt-name\")\ + \_] . \"\\n\") ] . \\\r\ + \n [ \$FormatLine \"Private key\" [ \$IfThenElse ((\$CertVal->\"priva\ + te-key\") = true) \"available\" \"missing\" ] ] . \"\\n\" . \\\r\ + \n [ \$FormatLine \"Fingerprint\" (\$CertVal->\"fingerprint\") ] . \"\ + \\n\" . \\\r\ + \n [ \$IfThenElse ([ :len (\$CertVal->\"ca\") ] > 0) [ \$FormatLine \ + \"Issuer\" (\$CertVal->\"ca\") ] [ \$FormatLine \"Issuer chain\" [ \$Forma\ + tCertChain \$Cert ] ] ] . \"\\n\" . \\\r\ + \n \"Validity:\\n\" . \\\r\ + \n [ \$FormatLine \" days\" (\$CertVal->\"days-valid\") ] . \"\\n\ + \" . \\\r\ + \n [ \$FormatLine \" from\" (\$CertVal->\"invalid-before\") ] . \"\ + \\n\" . \\\r\ + \n [ \$FormatLine \" to\" (\$CertVal->\"invalid-after\") ] . \"\\n\ + \" . \\\r\ + \n [ \$FormatLine \" time left\" [ \$IfThenElse ((\$CertVal->\"exp\ + ired\") = true) \"expired\" [ \$FormatExpire (\$CertVal->\"expires-after\"\ + ) ] ] ]);\r\ + \n }\r\ + \n\r\ + \n :if ([ \$ScriptLock \$ScriptName ] = false) do={\r\ + \n :set ExitOK true;\r\ + \n :error false;\r\ + \n }\r\ + \n# \$WaitFullyConnected;\r\ + \n\r\ + \n :foreach Cert in=[ /certificate/find where !revoked !ca !scep-url expi\ + res-after<\$CertRenewTime ] do={\r\ + \n :local CertVal [ /certificate/get \$Cert ];\r\ + \n :local LastName;\r\ + \n :local FetchName;\r\ + \n\r\ + \n :do {\r\ + \n :if ([ :len \$CertRenewUrl ] = 0) do={\r\ + \n \$LogPrint info \$ScriptName (\"No CertRenewUrl given.\");\r\ + \n :error false;\r\ + \n }\r\ + \n \$LogPrint info \$ScriptName (\"Attempting to renew certificate '\ + \" . (\$CertVal->\"name\") . \"'.\");\r\ + \n\r\ + \n :local ImportSuccess false;\r\ + \n :if ([ :len (\$CertVal->\"common-name\") ] > 0) do={\r\ + \n :set LastName (\$CertVal->\"common-name\");\r\ + \n :set FetchName \$LastName;\r\ + \n :set ImportSuccess [ \$CheckCertificatesDownloadImport \$ScriptN\ + ame \$LastName \$FetchName ];\r\ + \n }\r\ + \n :foreach SAN in=(\$CertVal->\"subject-alt-name\") do={\r\ + \n :if (\$ImportSuccess = false) do={\r\ + \n :set LastName [ :pick \$SAN ([ :find \$SAN \":\" ] + 1) [ :len\ + \_\$SAN ] ];\r\ + \n :set FetchName \$LastName;\r\ + \n :set ImportSuccess [ \$CheckCertificatesDownloadImport \$Scrip\ + tName \$LastName \$FetchName ];\r\ + \n :if (\$ImportSuccess = false && [ :pick \$LastName 0 2 ] = \"*\ + .\") do={\r\ + \n :set FetchName (\"star.\" . [ :pick \$LastName 2 [ :len \$La\ + stName ] ]);\r\ + \n :set ImportSuccess [ \$CheckCertificatesDownloadImport \$Scr\ + iptName \$LastName \$FetchName ];\r\ + \n }\r\ + \n }\r\ + \n }\r\ + \n :if (\$ImportSuccess = false) do={ :error false; }\r\ + \n\r\ + \n :if ([ :len (\$CertVal->\"fingerprint\") ] > 0 && \$CertVal->\"fin\ + gerprint\" != [ /certificate/get \$Cert fingerprint ]) do={\r\ + \n \$LogPrint debug \$ScriptName (\"Certificate '\" . \$CertVal->\"\ + name\" . \"' was updated in place.\");\r\ + \n :set CertVal [ /certificate/get \$Cert ];\r\ + \n } else={\r\ + \n \$LogPrint debug \$ScriptName (\"Certificate '\" . \$CertVal->\"\ + name\" . \"' was not updated, but replaced.\");\r\ + \n\r\ + \n :local CertNew [ /certificate/find where name~(\"^\" . [ \$Escap\ + eForRegEx [ \$UrlEncode \$FetchName ] ] . \"\\\\.(p12|pem)_[0-9]+\\\$\") \ + \\\r\ + \n (common-name=(\$CertVal->\"common-name\") or subject-alt-name~\ + (\"(^|\\\\W)(DNS|IP):\" . [ \$EscapeForRegEx \$LastName ] . \"(\\\\W|\\\$)\ + \")) \\\r\ + \n fingerprint!=[ :tostr (\$CertVal->\"fingerprint\") ] ];\r\ + \n :local CertNewVal [ /certificate/get \$CertNew ];\r\ + \n\r\ + \n :if ((\$CertVal->\"expires-after\") > (\$CertNewVal->\"expires-a\ + fter\")) do={\r\ + \n /certificate/remove \$CertNew;\r\ + \n \$LogPrint warning \$ScriptName (\"Old certificate is newer th\ + an the new one. Aborting renew.\");\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :if ((\$CertVal->\"private-key\") = true && (\$CertVal->\"privat\ + e-key\") != (\$CertNewVal->\"private-key\")) do={\r\ + \n /certificate/remove \$CertNew;\r\ + \n \$LogPrint warning \$ScriptName (\"Old certificate '\" . (\$Ce\ + rtVal->\"name\") . \"' has a private key, new certificate does not. Aborti\ + ng renew.\");\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :if ([ \$CertificateAvailable ([ \$ParseKeyValueStore (\$CertNew\ + Val->\"issuer\") ]->\"CN\") \"fetch\" ] = false) do={\r\ + \n \$LogPrint warning \$ScriptName (\"The certificate chain is no\ + t available!\");\r\ + \n }\r\ + \n\r\ + \n /ip/service/set certificate=(\$CertNewVal->\"name\") [ find wher\ + e certificate=(\$CertVal->\"name\") ];\r\ + \n\r\ + \n /ip/ipsec/identity/set certificate=(\$CertNewVal->\"name\") [ fi\ + nd where certificate=(\$CertVal->\"name\") ];\r\ + \n /ip/ipsec/identity/set remote-certificate=(\$CertNewVal->\"name\ + \") [ find where remote-certificate=(\$CertVal->\"name\") ];\r\ + \n\r\ + \n /ip/hotspot/profile/set ssl-certificate=(\$CertNewVal->\"name\")\ + \_[ find where ssl-certificate=(\$CertVal->\"name\") ];\r\ + \n\r\ + \n /certificate/remove \$Cert;\r\ + \n /certificate/set \$CertNew name=(\$CertVal->\"name\");\r\ + \n :set Cert \$CertNew;\r\ + \n :set CertVal [ /certificate/get \$CertNew ];\r\ + \n }\r\ + \n\r\ + \n \$SendNotification2 ({ origin=\$ScriptName; silent=true; \\\r\ + \n subject=([ \$SymbolForNotification \"lock-with-ink-pen\" ] . \"C\ + ertificate renewed: \" . (\$CertVal->\"name\")); \\\r\ + \n message=(\"A certificate on \" . \$Identity . \" has been renewe\ + d.\\n\\n\" . [ \$FormatInfo \$Cert ]) });\r\ + \n \$LogPrint info \$ScriptName (\"The certificate '\" . (\$CertVal->\ + \"name\") . \"' has been renewed.\");\r\ + \n } on-error={\r\ + \n \$LogPrint debug \$ScriptName (\"Could not renew certificate '\" .\ + \_(\$CertVal->\"name\") . \"'.\");\r\ + \n }\r\ + \n }\r\ + \n\r\ + \n :foreach Cert in=[ /certificate/find where !revoked !scep-url !(expire\ + s-after=[]) \\\r\ + \n expires-after<\$CertWarnTime !(fingerprint=[]) ] do\ + ={\r\ + \n :local CertVal [ /certificate/get \$Cert ];\r\ + \n\r\ + \n :if ([ :len [ /certificate/scep-server/find where ca-cert=(\$CertVal\ + ->\"ca\") ] ] > 0) do={\r\ + \n \$LogPrint debug \$ScriptName (\"Certificate '\" . (\$CertVal->\"n\ + ame\") . \"' is handled by SCEP, skipping.\");\r\ + \n } else={\r\ + \n :local State [ \$IfThenElse ((\$CertVal->\"expired\") = true) \"ex\ + pired\" \"is about to expire\" ];\r\ + \n\r\ + \n \$SendNotification2 ({ origin=\$ScriptName; \\\r\ + \n subject=([ \$SymbolForNotification \"lock-with-ink-pen,warning-s\ + ign\" ] . \"Certificate warning: \" . (\$CertVal->\"name\")); \\\r\ + \n message=(\"A certificate on \" . \$Identity . \" \" . \$State . \ + \".\\n\\n\" . [ \$FormatInfo \$Cert ]) });\r\ + \n \$LogPrint info \$ScriptName (\"The certificate '\" . (\$CertVal->\ + \"name\") . \"' \" . \$State . \\\r\ + \n \", it is invalid after \" . (\$CertVal->\"invalid-after\") . \ + \".\");\r\ + \n }\r\ + \n }\r\ + \n} do={\r\ + \n :global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err;\r\ + \n}\r\ + \n" +add comment="Global Config Script" dont-require-permissions=no name=\ + AM-GlobalConfig owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\ + \n# RouterOS script: AM-GlobalConfig\ + \n# Script comment: Global Config Script\ + \n# Copyright (c) 2007-2026 Vados \ + \n#\ + \n#\ + \n# Warning: Dont touch this line!\ + \n:global GlobalConfReady false;\ + \n#\ + \n#\ + \n# Global Url For Amster scripts to fetch\ + \n# most be defined in AM-Init-Script or AM-setup scripts\ + \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\ + \n:global ScriptsUrlSuffix \"\";\ + \n:global CheckSumsVerify true;\ + \n\ + \n:global ScriptUpdatesCRLF true;\ + \n:global CommentsInScripts true;\ + \n\ + \n# Debug output:\ + \n:global PrintDebug true; #false;\ + \n\ + \n# Debug output for specific script:\ + \n:set (\$PrintDebugOverride->\"AM-GlobalFunc\") true;\ + \n\ + \n# Debug logs\ + \n# Other actions (disk, email, remote or support) can be used as well.\ + \n# I do not recommend using echo - use debug output instead (https://rsc.\ + eworm.de/main/DEBUG.html#debug-output).\ + \n#/system/logging/add topics=script,debug action=memory;\ + \n\ + \n:global MikrotikUpgradeUrl \"https://upgrade.mikrotik.com/routeros\";\ + \n:global Domain \"WORKGROUP\";\ + \n\ + \n:global EmailGeneralTo \"vados@vados.ru\";\ + \n#:global EmailGeneralCc \"\";\ + \n\ + \n# \$ScriptInstallUpdate mod/notification-telegram\ + \n:global TelegramTokenId \"8390868324:AAG3_d1hfVR2M6pGAgDK6ZvhOe4J97nyopw\ + \";\ + \n:global TelegramChatId \"-1003631309063\"; #\"454403445\";\ + \n# Use this to send notifications to a specific topic in group.\ + \n#:global TelegramThreadId \"30\";\ + \n# Using telegram-chat you have to define trusted chat ids (not group ids\ + !)\ + \n# or user names. Groups allow to chat with devices simultaneously.\ + \n:global TelegramChatIdsTrusted {\ + \n \"454403445\"\ + \n \"-1003631309063\"\ + \n \"-5124482807\"\ + \n \"1087968824\";\ + \n};\ + \n# \"-5294757340\";\ + \n\ + \n:global TelegramChatGroups \"(all)\";\ + \n#:global TelegramChatGroups \"(all|home|office)\";\ + \n\ + \n:global NotificationFunctions {\ + \n \"email\"\ + \n \"telegram\";\ + \n};\ + \n# Toggle this to disable symbols in notifications.\ + \n:global NotificationsWithSymbols true;\ + \n:global TerminalColorOutput true;\ + \n\ + \n:global DetectIpAddrDefault \"https://ipv4.mikrotik.ovh/\";\ + \n:global DetectIpAddrFallback \"https://api.ipify.org/\";\ + \n\ + \n## Update channel. Possible values: stable, long-term, testing, developm\ + ent\ + \n:global updateChannel \"stable\";\ + \n\ + \n:global CertRenewUrl (\$GlobalScriptsUrl . \"certs/\");\ + \n:global CertRenewTime 2w;\ + \n:global CertRenewPass {\ + \n \"\";\ + \n# \"v3ry-s3cr3t\";\ + \n# \"4n0th3r-s3cr3t\";\ + \n};\ + \n:global CertWarnTime 1w;\ + \n:global CertIssuedExportPass {\ + \n \"\";\ + \n# \"cert1-cn\"=\"v3ry-s3cr3t\";\ + \n# \"cert2-cn\"=\"4n0th3r-s3cr3t\";\ + \n};\ + \n\ + \n# Script BackupAndUpdate mode, possible values: backup,\ + \n# updateOnce - Update once as \"osnotify\" and back \"osnotify\" mode (i\ + n terminal run :set OSUpdateMode updateOnce; \$OSUpdateMode;). \ + \n# osupdate - Update if available and creates backups before/after update\ + \_(ignores `forceBackup`)\ + \n# Set `forceBackup` to true to always create backups, even\ + \_without updates\ + \n# osnotify - Set `forceBackup` to always create backups on every run\ + \n:global DevInfoIncludeIP true;\ + \n:global BackupAndUpdateMode \"osnotify\"\ + \n\ + \n:global forceBackup true;\ + \n:global BackupPassword \"Peskar55\";\ + \n\ + \n# SFTP Backup Variables\ + \n:global BackupRandomDelay 0;\ + \n:global BackupUploadUrl \"sftp://amster.vados.ru/upload/\";\ + \n:global BackupUploadUser \$Identity;\ + \n:global BackupUploadPass \"root.mnuc.backuper\";\ + \n\ + \n:global BackupSendBinary true;\ + \n:global BackupSendExport true;\ + \n:global BackupSendGlobalConfig true;\ + \n:global BackupSendScripts true;\ + \n\ + \n# Remove local file after uploading if no errors\ + \n:global BackupRmLocal true;\ + \n\ + \n# Local Backups Root Directory \ + \n:global BackupLocalRoot \"tmpfs\";\ + \n\ + \n# Encrypt Backup\ + \n:global BackupEncrypt true;\ + \n\ + \n# Sensitive information in Backups\ + \n:global BackupSens true;\ + \n\ + \n# User Export\ + \n:global BackupUser true;\ + \n\ + \n# License Export (not for CHR, will silently skip)\ + \n:global BackupLicense false;\ + \n\ + \n# SSH Keys\ + \n:global BackupSshKeys true;\ + \n\ + \n# Certificate Export\ + \n:global BackupCerts true;\ + \n\ + \n# Certificate Password\ + \n:global BackupCertsPasswd \"\";\ + \n\ + \n# User-Manager Export\ + \n:global BackupUserMan false;\ + \n\ + \n# The Dude Export\ + \n:global BackupDude false;\ + \n\ + \n# User Files to export, comma-separated string or array of strings\ + \n# User Files are not removed on backup\ + \n# Any directory paths will be removed (/ -> _) on remote file\ + \n# Nonpresent files are silently skipped\ + \n:global BackupUserList \"autosupout.rif,autosupout.old.rif\";\ + \n\ + \n# load functions and any custom scripts\ + \n# [ /system/script/find where name=\"global-config-ov\ + erlay\" ], \\\ + \n# [ /system/script/find where name~\"^global-config-o\ + verlay\\\\.d/.\" ]\ + \n#\ + \n#:foreach Script in=([ /system/script/find where name=\"Amster-TGglobalV\ + ars\" ], [ /system/script/find where name=\"Amster-TGglobalFunc\" ]) do={\ + \n# :onerror Err {\ + \n# /system/script/run \$Script;\ + \n# } do={\ + \n# :log error (\"Loading configuration from configs and functions\"\ + \_. [ /system/script/get \$Script name ] . \" failed: \" . \$Err);\ + \n# }\ + \n#}\ + \n#:log info \"\\ndevMode = \$devMode\";\ + \n#:log info \"\\ndevRunning = \$devRunning\";\ + \n:foreach Script in=[ /system/script/find where source~\"^#!rsc by Vados \ + GlobalRUN\\r\?\\n\" ] do={\ + \n :onerror Err {\ + \n /system/script/run \$Script;\ + \n } do={\ + \n :log error (\"Run script \" . [ /system/script/get \$Script name \ + ] . \" width marker \\\" GlobalRUN\\\" failed: \" . \$Err);\ + \n }\ + \n}\ + \n\ + \n# signal we are ready\ + \n:set GlobalConfReady true;\ + \n:while (\$GlobalConfReady != true) do={:delay 500ms};\ + \n" +add comment="Renew locally issued certificates" dont-require-permissions=no \ + name=AM-CertsRenew owner=AM-CertsRenew policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\r\ + \n# RouterOS script: AM-CertsRenew\r\ + \n# Script comment: Renew locally issued certificates\r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n#\r\ + \n:local ExitOK false;\r\ + \n:onerror Err {\r\ + \n :global GlobalConfReady; :global GlobalFuncReady;\r\ + \n :retry { :if (\$GlobalConfReady != true || \$GlobalFuncReady != true) \ + \\\r\ + \n do={ :error (\"Global config and/or functions not ready.\"); }; } \ + delay=500ms max=50;\r\ + \n :local ScriptName [ :jobname ];\r\ + \n\r\ + \n :global CertIssuedExportPass;\r\ + \n\r\ + \n :global LogPrint;\r\ + \n :global MkDir;\r\ + \n :global ScriptLock;\r\ + \n\r\ + \n# Add this Script scheduler\r\ + \n:if ([ :len [ /system/scheduler/find where name=\$ScriptName ] ] = 0) do\ + ={\r\ + \n:log warning (\"System Scheduler for script: \" . \$ScriptName . \" is N\ + OT SET! Fix It Now!\");\r\ + \n:local OnEvent \"/system/script/run \$ScriptName;\";\r\ + \n:local Comment \"Every Day Check For Update Local Issued Certificates.\"\ + ;\r\ + \n#/system/scheduler/add name=\$ScriptName comment=\$Comment start-time=st\ + artup interval=1d on-event=\$OnEvent;\r\ + \n}\r\ + \n\r\ + \n :if ([ \$ScriptLock \$ScriptName ] = false) do={\r\ + \n :set ExitOK true;\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :foreach Cert in=[ /certificate/find where issued expires-after<3w ] d\ + o={\r\ + \n :local CertVal [ /certificate/get \$Cert ];\r\ + \n /certificate/issued-revoke \$Cert;\r\ + \n /certificate/set name=(\$CertVal->\"name\" . \"-revoked-\" . [ /syst\ + em/clock/get date ]) \$Cert;\r\ + \n /certificate/add name=(\$CertVal->\"name\") common-name=(\$CertVal->\ + \"common-name\") \\\r\ + \n key-usage=(\$CertVal->\"key-usage\") subject-alt-name=(\$CertVal\ + ->\"subject-alt-name\");\r\ + \n /certificate/sign (\$CertVal->\"name\") ca=(\$CertVal->\"ca\");\r\ + \n :if ([ :typeof (\$CertIssuedExportPass->(\$CertVal->\"common-name\")\ + ) ] = \"str\") do={\r\ + \n :if ([ \$MkDir \"cert-issued\" ] = true) do={\r\ + \n /certificate/export-certificate (\$CertVal->\"name\") type=pkcs1\ + 2 \\\r\ + \n file-name=(\"cert-issued/\" . \$CertVal->\"common-name\") \\\ + \r\ + \n export-passphrase=(\$CertIssuedExportPass->(\$CertVal->\"com\ + mon-name\"));\r\ + \n \$LogPrint info \$ScriptName (\"Issued a new certificate for '\"\ + \_. \$CertVal->\"common-name\" . \\\r\ + \n \"', exported to 'cert-issued/\" . \$CertVal->\"common-name\" \ + . \".p12'.\");\r\ + \n } else={\r\ + \n \$LogPrint warning \$ScriptName (\"Failed creating directory, no\ + t exporting certificate.\");\r\ + \n }\r\ + \n } else={\r\ + \n \$LogPrint info \$ScriptName (\"Issued a new certificate for '\" .\ + \_\$CertVal->\"common-name\" . \"'.\");\r\ + \n }\r\ + \n }\r\ + \n} do={\r\ + \n :global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err;\r\ + \n}\r\ + \n" +/user group +add name=backup policy="telnet,ssh,ftp,read,write,policy,test,sniff,sensitive,\ + !local,!reboot,!winbox,!password,!web,!api,!romon,!rest-api" +/caps-man provisioning +add action=create-dynamic-enabled hw-supported-modes=gn master-configuration=\ + cfg-2ghz name-format=prefix-identity name-prefix=2ghz +add action=create-dynamic-enabled hw-supported-modes=ac master-configuration=\ + cfg-5ghz-ac name-format=prefix-identity name-prefix=5ghz-ac +add action=create-dynamic-enabled hw-supported-modes=an master-configuration=\ + cfg-5ghz-an name-format=prefix-identity name-prefix=5ghz-an +/certificate settings +set builtin-trust-store=fetch +/disk settings +set auto-media-interface=lo default-mount-point-template="[tmpfs]" +/ip smb +set comment=MikroVados domain=WORKGROUP enabled=yes interfaces=Bridge-LAN +/interface bridge port +add bridge=Bridge-LAN ingress-filtering=no interface=ether2 \ + internal-path-cost=10 path-cost=10 +add bridge=Bridge-LAN comment=LEN ingress-filtering=no interface=ether3 \ + internal-path-cost=10 path-cost=10 +add bridge=Bridge-LAN comment=NUC ingress-filtering=no interface=ether4 \ + internal-path-cost=10 path-cost=10 +add bridge=Bridge-LAN ingress-filtering=no interface=ether5 \ + internal-path-cost=10 path-cost=10 +/ip firewall connection tracking +set udp-timeout=10s +/ip neighbor discovery-settings +set discover-interface-list=LAN +/ip settings +set max-neighbor-entries=8192 secure-redirects=no +/ipv6 settings +set disable-ipv6=yes max-neighbor-entries=8192 +/interface detect-internet +set detect-interface-list=WAN internet-interface-list=WAN lan-interface-list=\ + LAN wan-interface-list=WAN +/interface l2tp-server server +set authentication=mschap2 use-ipsec=yes +/interface list member +add comment=WAN interface="ether1 - Unet" list=WAN +add interface=Bridge-LAN list=LAN +/interface ovpn-server server +add auth=sha1,md5 mac-address=FE:82:A5:78:8E:84 name=ovpn-server1 +/interface wifi cap +set caps-man-addresses=10.30.30.10 certificate=request discovery-interfaces=\ + wlan1,wlan2 lock-to-caps-man=no slaves-static=no +/interface wifi capsman +set package-path="" require-peer-certificate=no upgrade-policy=none +/interface wifi provisioning +add action=create-dynamic-enabled disabled=no master-configuration=2G-N \ + name-format=2G-%I slave-configurations=2G-G supported-bands=\ + 2ghz-n,2ghz-g,2ghz-g +add action=create-dynamic-enabled disabled=no master-configuration=5G-AC \ + name-format=5G-%I supported-bands=5ghz-ac,5ghz-ac +/interface wireguard peers +add allowed-address=10.8.0.2/32,0.0.0.0/0 client-allowed-address=0.0.0.0/0 \ + endpoint-address=89.110.101.17 endpoint-port=29185 interface=WG name=\ + MikroVados persistent-keepalive=10s public-key=\ + "64Y25EUZQQt8EIeAJYD8qWt+te8qvGEepnswdBgmzlY=" +/interface wireless cap +# +set bridge=Bridge-LAN caps-man-addresses=10.30.30.10 \ + caps-man-certificate-common-names=CAPsMAN-51B25E507D07 certificate=\ + CAP-18FD746E5814 discovery-interfaces=Bridge-LAN enabled=yes interfaces=\ + wlan1,wlan2 lock-to-caps-man=yes +/interface wireless sniffer +set file-name=24g +/ip address +add address=10.30.30.81/24 interface=Bridge-LAN network=10.30.30.0 +add address=10.8.0.2/24 interface=WG network=10.8.0.0 +/ip dhcp-client +add add-default-route=special-classless default-route-distance=2 \ + default-route-tables=main interface="ether1 - Unet" name="ether1 - Unet" \ + use-peer-dns=no +/ip dhcp-server config +set accounting=no +/ip dhcp-server lease +add address=10.30.30.101 client-id=1:48:8f:5a:8e:ee:a8 mac-address=\ + 48:8F:5A:8E:EE:A8 server=masterDHCP +add address=10.30.30.107 client-id=1:f0:de:f1:91:d:1e mac-address=\ + F0:DE:F1:91:0D:1E server=masterDHCP +add address=10.30.30.83 client-id=1:0:80:77:ec:43:86 mac-address=\ + 00:80:77:EC:43:86 server=masterDHCP +add address=10.30.30.70 dhcp-option=domain-search-list,HostName \ + dhcp-option-set=HP1505n mac-address=00:1E:0B:1A:88:8D server=masterDHCP +add address=10.30.30.50 client-id=1:4:7c:16:36:f5:37 mac-address=\ + 04:7C:16:36:F5:37 server=masterDHCP +add address=10.30.30.71 client-id=1:10:2d:41:2c:20:c2 mac-address=\ + 10:2D:41:2C:20:C2 server=masterDHCP +add address=10.30.30.61 client-id=1:10:8:c1:81:59:5f mac-address=\ + 10:08:C1:81:59:5F server=masterDHCP +add address=10.30.30.72 client-id=1:10:38:1f:d2:5f:13 mac-address=\ + 10:38:1F:D2:5F:13 server=masterDHCP +add address=10.30.30.99 client-id=1:10:b1:df:e9:d0:d5 mac-address=\ + 10:B1:DF:E9:D0:D5 server=masterDHCP +add address=10.30.30.111 client-id=1:fe:2:52:be:3f:16 mac-address=\ + FE:02:52:BE:3F:16 server=masterDHCP +add address=10.30.30.93 client-id=1:7e:8b:1e:cb:b8:cb mac-address=\ + CC:42:10:12:46:94 server=masterDHCP +add address=10.30.30.94 client-id=1:50:cc:f8:85:96:a mac-address=\ + 50:CC:F8:85:96:0A server=masterDHCP +add address=10.30.30.82 client-id=1:e4:18:6b:58:34:ab mac-address=\ + E4:18:6B:58:34:AB server=masterDHCP +add address=10.30.30.77 dhcp-option=HostName dhcp-option-set=StartLife1 \ + mac-address=C4:82:E1:03:49:10 server=masterDHCP +add address=10.30.30.73 client-id=1:10:38:1f:82:81:f2 mac-address=\ + 10:38:1F:82:81:F2 server=masterDHCP +add address=10.30.30.95 client-id=1:88:ae:dd:60:39:54 dhcp-option=HostName \ + dhcp-option-set=VADOS-NUC mac-address=88:AE:DD:60:39:54 server=masterDHCP +add address=10.30.30.98 client-id=1:c8:5b:76:d8:cc:bf dhcp-option=HostName \ + dhcp-option-set=VADOS-LEN mac-address=C8:5B:76:D8:CC:BF server=masterDHCP +add address=10.30.30.96 client-id=iPhone mac-address=4A:91:ED:0E:1F:39 \ + server=masterDHCP +add address=10.30.30.74 client-id=1:20:72:a9:d3:34:36 dhcp-option=HostName \ + dhcp-option-set=MiTV mac-address=20:72:A9:D3:34:36 server=masterDHCP \ + use-src-mac=yes +add address=10.30.30.30 dhcp-option=HostName dhcp-option-set=miller \ + mac-address=F0:75:5D:1E:5F:71 server=masterDHCP +add address=10.30.30.100 client-id=iVados dhcp-option=HostName \ + dhcp-option-set="=\"Client ID\"" mac-address=DE:4D:72:F3:1A:9F server=\ + masterDHCP +add address=10.30.30.86 dhcp-option=HostName dhcp-option-set=MikroYellow \ + mac-address=48:8F:5A:8E:1A:C2 server=masterDHCP +/ip dhcp-server network +add address=10.30.30.0/24 caps-manager=10.30.30.10 dhcp-option=\ + domain-search-list dhcp-option-set=domain-search-set dns-server=\ + 10.30.30.81 domain=WORKGROUP gateway=10.30.30.81 netmask=24 ntp-server=\ + 10.30.30.81,10.30.30.10 wins-server=10.30.30.95,10.30.30.98 +/ip dns +set allow-remote-requests=yes cache-max-ttl=1d doh-max-concurrent-queries=100 \ + doh-max-server-connections=20 servers=8.8.8.8,8.8.4.4 verify-doh-cert=yes +/ip dns static +add address=10.30.30.33 name=amster-nuc type=A +add address=10.30.30.33 comment=AMSTER name=amster.vados.ru type=A +add address=10.30.30.33 name=amster type=A +add address=10.30.30.33 name=amster-reg type=A +add address=10.30.30.33 name=mng.vados.ru type=A +add address=10.30.30.33 name=mgr.vados.ru type=A +add address=10.30.30.33 name=prt.vados.ru type=A +add address=10.30.30.33 name=git.vados.ru type=A +add address=10.30.30.33 name=reg.vados.ru type=A +add address=10.30.30.33 match-subdomain=yes name=ros.vados.ru type=A +add address=10.30.30.33 match-subdomain=yes name=mikrots.vados.ru type=A +add address=10.30.30.33 name=oxidized.vados.ru type=A +add address=8.8.4.4 comment="Google-dns IPv4 2" name=dns.google type=A +add address=8.8.8.8 comment="Google-dns IPv4 1" name=dns.google type=A +add address=10.30.30.30 comment=MILLER name=miller.vados.ru type=A +add address=10.30.30.30 name=MILLER-LEN type=A +add address=10.30.30.30 name=miller type=A +add address=1.1.1.1 comment="CloudFlare-doh IPv4 1" name=\ + security.cloudflare-dns.com type=A +add address=1.0.0.1 comment="CloudFlare-doh IPv4 2" name=\ + security.cloudflare-dns.com type=A +add address=9.9.9.9 comment="Cuad9-dns IPv4 1" disabled=yes name=\ + dns.quad9.net type=A +add address=149.112.112.112 comment="Cuad9-dns IPv4 2" disabled=yes name=\ + dns.quad9.net type=A +add address=91.192.189.2 comment=Unet-DNS disabled=yes name=ns1.unet.ws type=\ + A +add address=10.30.30.81 comment=LocalNet name=MikroVados type=A +add address=10.30.30.10 name=MikroNUC type=A +add address=10.30.30.86 name=MikroYellow type=A +add address=10.30.30.85 name=MikroMic type=A +add address=10.30.30.95 name=VADOS-NUC type=A +add address=10.30.30.98 name=VADOS-LEN type=A +add address=10.30.30.20 name=garage type=A +add address=2606:4700:4700::1111 disabled=yes name=\ + security.cloudflare-dns.com type=AAAA +add address=2606:4700:4700::1001 disabled=yes name=\ + security.cloudflare-dns.com type=AAAA +/ip firewall address-list +add address=91.215.120.206 list=TRUSTED +add address=185.71.70.78 disabled=yes list=TRUSTED +add address=176.53.203.171 disabled=yes list=TRUSTED +add address=176.53.203.170 disabled=yes list=TRUSTED +add address=176.53.202.194 disabled=yes list=TRUSTED +add address=10.30.30.100-255 list=KIDS +add address=8.8.4.0/24 list=YouTube +add address=8.8.8.0/24 list=YouTube +add address=8.34.208.0/20 list=YouTube +add address=8.35.192.0/20 list=YouTube +add address=23.236.48.0/20 list=YouTube +add address=23.251.128.0/19 list=YouTube +add address=34.0.0.0/15 list=YouTube +add address=34.2.0.0/16 list=YouTube +add address=34.3.0.0/23 list=YouTube +add address=34.3.3.0/24 list=YouTube +add address=34.3.4.0/24 list=YouTube +add address=34.3.8.0/21 list=YouTube +add address=34.3.16.0/20 list=YouTube +add address=34.3.32.0/19 list=YouTube +add address=34.3.64.0/18 list=YouTube +add address=34.4.0.0/14 list=YouTube +add address=34.8.0.0/13 list=YouTube +add address=34.16.0.0/12 list=YouTube +add address=34.32.0.0/11 list=YouTube +add address=34.64.0.0/10 list=YouTube +add address=34.128.0.0/10 list=YouTube +add address=35.184.0.0/13 list=YouTube +add address=35.192.0.0/14 list=YouTube +add address=35.196.0.0/15 list=YouTube +add address=35.198.0.0/16 list=YouTube +add address=35.199.0.0/17 list=YouTube +add address=35.199.128.0/18 list=YouTube +add address=35.200.0.0/13 list=YouTube +add address=35.208.0.0/12 list=YouTube +add address=35.224.0.0/12 list=YouTube +add address=35.240.0.0/13 list=YouTube +add address=57.140.192.0/18 list=YouTube +add address=64.15.112.0/20 list=YouTube +add address=64.233.160.0/19 list=YouTube +add address=66.22.228.0/23 list=YouTube +add address=66.102.0.0/20 list=YouTube +add address=66.249.64.0/19 list=YouTube +add address=70.32.128.0/19 list=YouTube +add address=72.14.192.0/18 list=YouTube +add address=74.125.0.0/16 list=YouTube +add address=104.154.0.0/15 list=YouTube +add address=104.196.0.0/14 list=YouTube +add address=104.237.160.0/19 list=YouTube +add address=107.167.160.0/19 list=YouTube +add address=107.178.192.0/18 list=YouTube +add address=108.59.80.0/20 list=YouTube +add address=108.170.192.0/18 list=YouTube +add address=108.177.0.0/17 list=YouTube +add address=130.211.0.0/16 list=YouTube +add address=136.22.160.0/20 list=YouTube +add address=136.22.176.0/21 list=YouTube +add address=136.22.184.0/23 list=YouTube +add address=136.22.186.0/24 list=YouTube +add address=142.250.0.0/15 list=YouTube +add address=146.148.0.0/17 list=YouTube +add address=152.65.208.0/22 list=YouTube +add address=152.65.214.0/23 list=YouTube +add address=152.65.218.0/23 list=YouTube +add address=152.65.222.0/23 list=YouTube +add address=152.65.224.0/19 list=YouTube +add address=162.120.128.0/17 list=YouTube +add address=162.216.148.0/22 list=YouTube +add address=162.222.176.0/21 list=YouTube +add address=172.110.32.0/21 list=YouTube +add address=172.217.0.0/16 list=YouTube +add address=172.253.0.0/16 list=YouTube +add address=173.194.0.0/16 list=YouTube +add address=173.255.112.0/20 list=YouTube +add address=192.158.28.0/22 list=YouTube +add address=192.178.0.0/15 list=YouTube +add address=193.186.4.0/24 list=YouTube +add address=199.36.154.0/23 list=YouTube +add address=199.36.156.0/24 list=YouTube +add address=199.192.112.0/22 list=YouTube +add address=199.223.232.0/21 list=YouTube +add address=207.223.160.0/20 list=YouTube +add address=208.65.152.0/22 list=YouTube +add address=208.68.108.0/22 list=YouTube +add address=208.81.188.0/22 list=YouTube +add address=208.117.224.0/19 list=YouTube +add address=209.85.128.0/17 list=YouTube +add address=216.58.192.0/19 list=YouTube +add address=216.73.80.0/20 list=YouTube +add address=216.239.32.0/19 list=YouTube +add address=2ip.ru list=Test +add address=157.240.247.174 list=Instagram +add address=46.53.178.107 list=Instagram +add address=179.60.195.174 list=Instagram +add address=157.240.205.174 list=Instagram +add address=31.13.24.0/21 list=Instagram +add address=31.13.64.0/18 list=Instagram +add address=45.64.40.0/22 list=Instagram +add address=66.220.144.0/20 list=Instagram +add address=69.63.176.0/20 list=Instagram +add address=69.171.224.0/19 list=Instagram +add address=74.119.76.0/22 list=Instagram +add address=103.4.96.0/22 list=Instagram +add address=129.134.0.0/16 list=Instagram +add address=157.240.0.0/16 list=Instagram +add address=173.252.64.0/18 list=Instagram +add address=179.60.192.0/22 list=Instagram +add address=185.60.216.0/22 list=Instagram +add address=204.15.20.0/22 list=Instagram +add address=157.240.200.63 list=Instagram +add address=185.60.219.63 list=Instagram +add address=129.134.31.12 list=Instagram +add address=66.81.203.132 list=Instagram +add address=185.89.218.12 list=Instagram +add address=31.13.66.63 list=Instagram +add address=84.15.65.162 list=Instagram +add address=68.66.224.28 list=Instagram +add address=157.240.253.63 list=Instagram +add address=83.174.11.224 list=Instagram +add address=157.240.9.52 list=Instagram +add address=157.240.252.174 list=Instagram +add address=157.240.195.63 list=Instagram +add address=31.13.71.52 list=Instagram +add address=57.144.110.192 list=Instagram +add address=157.240.252.17 list=Instagram +add address=84.15.66.97 list=Instagram +add address=217.168.6.33 list=Instagram +add address=31.13.83.52 list=Instagram +add address=157.240.241.63 list=Instagram +add address=129.134.30.12 list=Instagram +add address=185.89.219.12 list=Instagram +add address=157.240.252.10 list=Instagram +add address=157.240.201.63 list=Instagram +add address=66.81.203.197 list=Instagram +add address=179.60.195.52 list=Instagram +add address=66.81.203.7 list=Instagram +add address=216.40.34.41 list=Instagram +add address=157.240.202.63 list=Instagram +add address=157.240.229.63 list=Instagram +add address=157.240.252.63 list=Instagram +add address=31.13.72.53 list=Instagram +add address=124.108.16.224 list=Instagram +add address=157.240.205.63 list=Instagram +add address=92.46.37.96 list=Instagram +add address=157.240.247.63 list=Instagram +add address=157.240.234.63 list=Instagram +add address=157.240.235.63 list=Instagram +add address=87.245.208.97 list=Instagram +add address=216.58.192.0/19 list=Instagram +add address=209.85.128.0/17 list=Instagram +add address=198.105.240.0/20 list=Instagram +add address=173.194.0.0/16 list=Instagram +add address=172.217.0.0/16 list=Instagram +add address=142.250.0.0/15 list=Instagram +add address=108.177.0.0/17 list=Instagram +add address=87.245.197.140 list=Instagram +add address=74.125.0.0/16 list=Instagram +add address=64.233.160.0/19 list=Instagram +add address=157.240.0.1 list=Instagram +add address=157.240.238.63 list=Instagram +add address=157.240.238.174 list=Instagram +add address=157.240.0.63 list=Instagram +add address=157.240.224.63 list=Instagram +add address=157.240.224.174 list=Instagram +add address=157.240.251.36 list=Instagram +add address=157.240.253.12 list=Instagram +add address=157.240.253.35 list=Instagram +add address=157.240.238.13 list=Instagram +add address=157.240.238.56 list=Instagram +add address=157.240.238.175 list=Instagram +add address=57.144.112.141 list=Instagram +add address=157.240.251.60 list=Instagram +add address=157.240.251.128 list=Instagram +add address=157.240.238.5 list=Instagram +add address=157.240.253.13 list=Instagram +add address=157.240.253.5 list=Instagram +add address=157.240.238.2 list=Instagram +add address=157.240.238.37 list=Instagram +add address=157.240.251.5 list=Instagram +add address=157.240.251.34 list=Instagram +add address=57.144.112.1 list=Instagram +add address=157.240.238.54 list=Instagram +add address=129.134.26.123 list=Instagram +add address=157.240.252.3 list=Instagram +add address=31.13.84.4 list=Instagram +add address=157.240.224.12 list=Instagram +add address=157.240.238.4 list=Instagram +add address=157.240.0.13 list=Instagram +add address=3.33.139.32 list=Instagram +add address=157.240.0.35 list=Instagram +add address=157.240.238.14 list=Instagram +add address=157.240.238.60 list=Instagram +add address=57.144.112.145 list=Instagram +add address=157.240.251.35 list=Instagram +add address=151.101.84.159 list=Twitter +add address=pbs.twimg.com list=Twitter +add address=89.110.101.17 comment=VDSIna list=TRUSTED +add address=10.8.0.0/24 comment="WG VDSIna" list=TRUSTED +add address=ikus.pesc.ru comment=ikus.pesc.ru list=NoVdsina +add address=love.ru comment=love.ru list=NoVdsina +add address=gosuslugi.ru comment=gosuslugi.ru list=NoVdsina +add address=pochta.ru comment=pochta.ru list=NoVdsina +add address=vdsina.com list=NoVdsina +add address=vdsina.ru list=NoVdsina +add address=youla.ru list=NoVdsina +add address=kupiprodai.ru list=NoVdsina +add address=myip.ru list=Test +add address=geoip.co list=NoVdsina +add address=x.com list=Twitter +add address=facebook.com list=facebook +add address=fbcd.net list=facebook +add address=comp-lenta.ru list=NoVdsina +add address=128.85.102.70 comment=update.microsoft.com list=\ + windowsupdateslist +add address=wu-b-net.trafficmanager.net. comment=\ + ctldl.windowsupdate.com.delivery.microsoft.com list=windowsupdateslist +add address=ctldl.windowsupdate.com.delivery.microsoft.com. comment=\ + ctldl.windowsupdate.com list=windowsupdateslist +add address=redir.update.msft.com.trafficmanager.net. comment=\ + update.microsoft.com list=windowsupdateslist +add address=geo.prod.do.dsp.trafficmanager.net. comment=\ + geo.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +add address=13.74.139.29 comment=array605.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=kv801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ + kv801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +add address=e12437.d.akamaiedge.net. comment=\ + kv801.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist +add address=displaycatalog-rp.md.mp.microsoft.com.akadns.net. comment=\ + displaycatalog.mp.microsoft.com list=windowsupdateslist +add address=rp-consumer-prod-displaycatalog-geomap.trafficmanager.net. \ + comment=displaycatalog-rp.md.mp.microsoft.com.akadns.net list=\ + windowsupdateslist +add address=sls.update.microsoft.com. comment=slscr.update.microsoft.com \ + list=windowsupdateslist +add address=glb.sls.prod.dcat.dsp.trafficmanager.net. comment=\ + sls.update.microsoft.com list=windowsupdateslist +add address=fe3.delivery.mp.microsoft.com. comment=\ + fe3cr.delivery.mp.microsoft.com list=windowsupdateslist +add address=glb.cws.prod.dcat.dsp.trafficmanager.net. comment=\ + fe3.delivery.mp.microsoft.com list=windowsupdateslist +add address=fe2cr.update.msft.com.trafficmanager.net. comment=\ + fe2cr.update.microsoft.com list=windowsupdateslist +add address=download.windowsupdate.com.delivery.microsoft.com. comment=\ + download.windowsupdate.com list=windowsupdateslist +add address=wu-f-net.trafficmanager.net. comment=\ + download.windowsupdate.com.delivery.microsoft.com list=windowsupdateslist +add address=tsfe.trafficmanager.net. comment=\ + tsfe.trafficshaping.dsp.mp.microsoft.com list=windowsupdateslist +add address=edge.ds-c7110-microsoft.global.dns.qwilted-cds.cqloud.com. \ + comment=9.au.download.windowsupdate.com list=windowsupdateslist +add address=52.158.227.125 comment=array812.prod.do.dsp.mp.microsoft.com \ + list=windowsupdateslist +add address=au.download.windowsupdate.com.delivery.microsoft.com. comment=\ + au.download.windowsupdate.com list=windowsupdateslist +add address=a767.dspw65.akamai.net. comment=\ + download.windowsupdate.com.edgesuite.net list=windowsupdateslist +add address=52.151.58.88 comment=array810.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=consumer-licensing-aks2aks.md.mp.microsoft.com.akadns.net. \ + comment=licensing.mp.microsoft.com list=windowsupdateslist +add address=licensing-prod-frontdoor-geomap.trafficmanager.net. comment=\ + consumer-licensing-aks2aks.md.mp.microsoft.com.akadns.net list=\ + windowsupdateslist +add address=star.f.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ + comment=msedge.f.dl.delivery.mp.microsoft.com list=windowsupdateslist +add address=cdp-f-nlu-net.trafficmanager.net. comment=\ + star.f.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=star.b.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ + comment=msedge.b.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist +add address=cdp-f-tlu-net.trafficmanager.net. comment=\ + star.b.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=storeedgefd.xbetservices.akadns.net. comment=\ + storeedgefd.dsx.mp.microsoft.com list=windowsupdateslist +add address=\ + storeedgefd.dsx.mp.microsoft.com.edgekey.net.globalredir.akadns.net. \ + comment=storeedgefd.dsx.mp.microsoft.com.edgekey.net list=\ + windowsupdateslist +add address=e16646.dscg.akamaiedge.net. comment=\ + storeedgefd.dsx.mp.microsoft.com.edgekey.net.globalredir.akadns.net list=\ + windowsupdateslist +add address=40.69.76.189 comment=array621.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=bg.microsoft.map.fastly.net. comment=\ + 3.au.download.windowsupdate.com list=windowsupdateslist +add list=windowsupdateslist +add address=40.69.75.33 comment=array613.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=star.sf.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ + comment=msedgeextensions.sf.tlu.dl.delivery.mp.microsoft.com list=\ + windowsupdateslist +add address=cdp-f-ssl-tlu-net.trafficmanager.net. comment=\ + star.sf.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=a2033.dscd.akamai.net. comment=\ + star.sb.tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=\ + windowsupdateslist +add address=13.74.138.242 comment=array602.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=dl.delivery.mp.microsoft.com.delivery.microsoft.com. comment=\ + dl.delivery.mp.microsoft.com list=windowsupdateslist +add address=dcat-f-nlu-net.trafficmanager.net. comment=\ + dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=1d.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ + comment=1D.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist +add address=dcat-b-tlu-net.trafficmanager.net. comment=\ + 1d.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=a122.dscg3.akamai.net. comment=\ + tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=windowsupdateslist +add address=geover.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ + geover.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +add address=e10370.d.akamaiedge.net. comment=\ + geover.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist +add address=52.232.182.21 comment=array511.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=40.70.77.95 comment=array519.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=a1683.dscd.akamai.net. comment=\ + dl.delivery.mp.microsoft.com-c.edgesuite.net list=windowsupdateslist +add address=consumer-collections-aks2eap.md.mp.microsoft.com.akadns.net. \ + comment=collections.mp.microsoft.com list=windowsupdateslist +add address=a1847.dscd.akamai.net. comment=\ + wildcard.f.tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=\ + windowsupdateslist +add address=13.74.142.6 comment=array607.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=au.download.windowsupdate.com.edgesuite.net. comment=\ + 2.au.download.windowsupdate.com list=windowsupdateslist +add address=a767.dscg3.akamai.net. comment=\ + au.download.windowsupdate.com.edgesuite.net list=windowsupdateslist +add address=52.156.123.84 comment=array818.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=40.69.78.254 comment=array610.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=4.au.download.windowsupdate.com.delivery.microsoft.com. comment=\ + 4.au.download.windowsupdate.com list=windowsupdateslist +add address=cl-glcb907925.gcdn.co. comment=\ + 4.au.download.windowsupdate.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=52.167.167.111 comment=array510.prod.do.dsp.mp.microsoft.com \ + list=windowsupdateslist +add address=40.69.70.43 comment=array623.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=tsfe.trafficshaping.dsp.mp.microsoft.com.delivery.microsoft.com. \ + comment=tsfe.trafficshaping.dsp.mp.microsoft.com list=windowsupdateslist +add address=ts-frontend.trafficmanager.net. comment=\ + tsfe.trafficshaping.dsp.mp.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=40.69.75.248 comment=array616.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=40.69.74.84 comment=array615.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=sds.trafficmanager.net. comment=software-download.microsoft.com \ + list=windowsupdateslist +add address=40.69.74.80 comment=array611.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.175.242.182 comment=array804.prod.do.dsp.mp.microsoft.com \ + list=windowsupdateslist +add address=dlc-shim.trafficmanager.net. comment=download.microsoft.com list=\ + windowsupdateslist +add address=e12671.dscd.akamaiedge.net. comment=\ + download.microsoft.com.edgekey.net list=windowsupdateslist +add address=20.187.55.34 comment=array808.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.167.167.231 comment=array513.prod.do.dsp.mp.microsoft.com \ + list=windowsupdateslist +add address=52.167.222.13 comment=array518.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=kv601.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ + kv601.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +add address=e12358.d.akamaiedge.net. comment=\ + kv601.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist +add address=tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. comment=\ + tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist +add address=dcat-f-tlu-net.trafficmanager.net. comment=\ + tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=a1856.dspw65.akamai.net. comment=\ + tlu.dl.delivery.mp.microsoft.com-c.edgesuite.net list=windowsupdateslist +add address=52.167.164.252 comment=array506.prod.do.dsp.mp.microsoft.com \ + list=windowsupdateslist +add address=13.74.137.54 comment=array601.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=kv501.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ + kv501.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +add address=collections-prod-frontdoor-geomap.trafficmanager.net. comment=\ + consumer-collections-aks2eap.md.mp.microsoft.com.akadns.net list=\ + windowsupdateslist +add address=52.167.160.173 comment=array509.prod.do.dsp.mp.microsoft.com \ + list=windowsupdateslist +add address=40.70.77.148 comment=array516.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.167.200.126 comment=array507.prod.do.dsp.mp.microsoft.com \ + list=windowsupdateslist +add address=52.167.167.59 comment=array508.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=40.69.76.172 comment=array620.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=82.202.162.184 comment=comp-lenta.ru list=NoWG +add address=smtp.mail.me.com.akadns.net. comment=smtp.mail.me.com list=NoWG +add address=17.57.155.37 comment=smtp.mail.me.com.akadns.net list=NoWG +add address=smtp.mail.me.com comment=smtp.mail.me.com list=NoVdsina +add address=40.70.76.5 comment=array514.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=13.74.186.119 comment=array618.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.177.176.186 comment=array520.prod.do.dsp.mp.microsoft.com \ + list=windowsupdateslist +add address=40.70.76.27 comment=array515.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.167.160.43 comment=array503.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.110 comment=array817.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=13.74.142.8 comment=array614.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=13.74.138.254 comment=array603.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.167.167.96 comment=array501.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=40.69.76.215 comment=array622.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=13.74.143.200 comment=array606.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.111 comment=array818.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.112 comment=array819.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=13.74.137.53 comment=array608.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.98 comment=array805.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.96 comment=array803.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.104 comment=array811.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.101 comment=array808.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.99 comment=array806.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.17 comment=array802.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.97 comment=array804.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.103 comment=array810.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.16 comment=array801.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=40.70.77.177 comment=array517.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.167.164.84 comment=array512.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.105 comment=array812.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.107 comment=array814.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.232.161.82 comment=array502.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.108 comment=array815.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=52.167.161.91 comment=array505.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.102 comment=array809.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.109 comment=array816.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.106 comment=array813.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.117 comment=array622.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.107 comment=array612.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.108 comment=array613.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.105 comment=array610.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.113 comment=array618.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.116 comment=array621.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.98 comment=array603.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.114 comment=array619.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.111 comment=array616.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.97 comment=array602.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.106 comment=array611.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.110 comment=array615.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.119 comment=array624.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.135 comment=array514.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.97 comment=array503.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.99 comment=array604.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.61 comment=array504.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.131 comment=array510.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.132 comment=array511.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.96 comment=array601.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.104 comment=array609.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.138 comment=array517.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.60 comment=array501.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.139 comment=array518.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.118 comment=array623.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.113 comment=array820.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.103 comment=array608.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.154.7.100 comment=array807.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.129 comment=array508.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.134 comment=array513.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.62 comment=array505.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.137 comment=array516.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.101 comment=array606.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.96 comment=array502.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.130 comment=array509.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.112 comment=array617.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.100 comment=array605.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.115 comment=array620.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.136 comment=array515.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=purchase.md.mp.microsoft.com.akadns.net. comment=\ + purchase.mp.microsoft.com list=windowsupdateslist +add address=e110219.a.akamaiedge.net. comment=\ + purchase.mp.microsoft.com.edgekey.net list=windowsupdateslist +add address=72.153.5.140 comment=array519.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.141 list=windowsupdateslist +add address=72.153.5.63 comment=array506.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.128 comment=array507.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.102 comment=array607.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=storesdk.xbetservices.akadns.net. comment=\ + storesdk.dsx.mp.microsoft.com list=windowsupdateslist +add address=e16646.g.akamaiedge.net. comment=\ + storesdk.dsx.mp.microsoft.com.edgekey.net list=windowsupdateslist +add address=software-download.microsoft.com.delivery.microsoft.com. comment=\ + software-download.microsoft.com list=windowsupdateslist +add address=download.prss.microsoft.com.akamaized.net. comment=\ + software-download.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=72.145.35.109 comment=array614.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=72.153.5.133 comment=array512.prod.do.dsp.mp.microsoft.com list=\ + windowsupdateslist +add address=213.180.192.0/19 comment=YandexDisk list=NoVdsina +add address=87.250.250.50 comment=YandexDisk list=NoVdsina +add address=consumer-prod-bcfd-v7-afd.trafficmanager.net. comment=\ + displaycatalog.mp.microsoft.com list=windowsupdateslist +add address=purchase-europeeap.md.mp.microsoft.com.akadns.net. comment=\ + purchase.md.mp.microsoft.com.akadns.net list=windowsupdateslist +add address=ne-az-conspurchase-mp.trafficmanager.net. comment=\ + purchase-europeeap.md.mp.microsoft.com.akadns.net list=windowsupdateslist +add address=storeedgefd.dsx.mp.microsoft.com.edgekey.net. comment=\ + cdn.storeedgefd.dsx.mp.microsoft.com list=windowsupdateslist +add address=star.f.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ + comment=msedge.f.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist +add address=a1996.dscd.akamai.net. comment=\ + wildcard.f.dl.delivery.mp.microsoft.com.edgesuite.net list=\ + windowsupdateslist +add address=cp801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ + cp801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +add address=glb.tas02.sls-prod.dcat.dsp.mp.microsoft.com. comment=\ + tas02.sls.update.microsoft.com list=windowsupdateslist +add address=cp601.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ + cp601.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +add address=star.sb.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ + comment=msedgeextensions.sb.tlu.dl.delivery.mp.microsoft.com list=\ + windowsupdateslist +add address=star.sf.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ + comment=msedge.sf.dl.delivery.mp.microsoft.com list=windowsupdateslist +add address=cdp-f-ssl-nlu-net.trafficmanager.net. comment=\ + star.sf.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ + windowsupdateslist +add address=tm-pifd-prod-gbl-weight.trafficmanager.net. comment=\ + paymentinstruments.mp.microsoft.com list=windowsupdateslist +add address=10.30.30.33 comment=amster-nuc list=NoWG +add address=10.30.30.11 comment=MikroNUC list=NoWG +add address=89.110.101.17 comment=!!!VDSINA!!!! list=NoWG +add address=89.110.101.17 list=VPN-Server +add address=80.85.244.9 list=TRUSTED +add address=8.8.8.8 list=TRUSTED +add address=8.8.4.4 list=TRUSTED +add address=disc801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ + disc801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +add address=10.30.30.95 comment=NUC list=NoWG +add address=glb.tas02.cws-prod.dcat.dsp.mp.microsoft.com. comment=\ + tas02.cws.update.microsoft.com list=windowsupdateslist +/ip firewall filter +add action=add-src-to-address-list address-list="Honeypot Hacker" \ + address-list-timeout=12h chain=input comment="block honeypot DNS" \ + connection-state=new dst-port=53 in-interface="ether1 - Unet" protocol=\ + udp +add action=add-src-to-address-list address-list="Honeypot Hacker" \ + address-list-timeout=4w2d chain=input connection-state=new dst-port=53 \ + in-interface="ether1 - Unet" protocol=tcp +add action=add-src-to-address-list address-list="Honeypot Hacker" \ + address-list-timeout=4w2d chain=input comment=\ + "block honeypot ssh rdp winbox" connection-state=new dst-port=\ + 22,8291,2222 in-interface="ether1 - Unet" protocol=tcp src-address-list=\ + !TRUSTED +add action=add-src-to-address-list address-list="Honeypot Hacker" \ + address-list-timeout=4w2d chain=input comment="block honeypot asterisk" \ + connection-state=new dst-port=5060 in-interface="ether1 - Unet" protocol=\ + udp +add action=add-src-to-address-list address-list="Honeypot Hacker" \ + address-list-timeout=5d chain=input comment="block honeypot NTP" \ + connection-state=new dst-port=123 in-interface="ether1 - Unet" protocol=\ + udp src-address=!10.30.30.0/24 +add action=accept chain=input comment=\ + "accept NTP clients on local area network" dst-port=123 in-interface=\ + Bridge-LAN in-interface-list=LAN protocol=udp +add action=accept chain=input comment="accept WireGuard" dst-port=13231 \ + in-interface="ether1 - Unet" protocol=udp src-address-list=VPN-Server +add action=accept chain=input disabled=yes dst-port=443 in-interface=\ + "ether1 - Unet" protocol=tcp +add action=accept chain=output disabled=yes protocol=tcp src-port=443 +add action=fasttrack-connection chain=forward comment=\ + "FastTrack for non-VPN connections" connection-mark=!VPN_No_FastTrack \ + connection-state=established,related,new disabled=yes +add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \ + connection-state=established,related,new disabled=yes routing-mark=\ + !To-VPN +add action=accept chain=input comment=\ + "defconf: accept established,related,untracked" connection-state=\ + established,related,untracked +add action=drop chain=input comment="defconf: drop invalid" connection-state=\ + invalid +add action=accept chain=input comment="defconf: accept ICMP" disabled=yes \ + protocol=icmp +add action=accept chain=input comment=\ + "defconf: accept to local loopback (for CAPsMAN)" disabled=yes \ + dst-address=127.0.0.1 +add action=accept chain=output disabled=yes src-address=127.0.0.1 +add action=accept chain=forward comment="defconf: accept in ipsec policy" \ + ipsec-policy=in,ipsec +add action=accept chain=forward comment="defconf: accept out ipsec policy" \ + ipsec-policy=out,ipsec +add action=accept chain=forward comment=\ + "defconf: accept established,related, untracked" connection-state=\ + established,related,untracked +add action=drop chain=forward comment="defconf: drop invalid" \ + connection-state=invalid disabled=yes +add action=drop chain=forward comment=\ + "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \ + connection-state=new in-interface="ether1 - Unet" +add action=accept chain=input connection-state=established disabled=yes +add action=accept chain=input connection-state=related disabled=yes +add action=drop chain=input disabled=yes in-interface-list=!LAN +add action=drop chain=forward comment=\ + "Filter Rule to block FB address LIST : )" disabled=yes dst-address-list=\ + facebook +add action=drop chain=forward comment=\ + "Filter Rule to block YOUTUBE address LIST : )" disabled=yes \ + dst-address-list=YouTube +/ip firewall mangle +add action=mark-connection chain=prerouting comment=\ + "Mark VPN connections to exclude from FastTrack" in-interface=WG \ + log-prefix=Mark-VPN-FT new-connection-mark=VPN_No_FastTrack +add action=mark-routing chain=prerouting comment="Test sites" disabled=yes \ + dst-address=!10.30.30.0/24 dst-address-list=Test new-routing-mark=To-VPN \ + passthrough=no src-address=10.30.30.0/24 +add action=mark-routing chain=prerouting comment=Instagram dst-address=\ + !10.30.30.0/24 dst-address-list=Instagram new-routing-mark=To-VPN \ + src-address=10.30.30.0/24 src-address-list=!NoWG +add action=mark-routing chain=prerouting comment=Twitter dst-address=\ + !10.30.30.0/24 dst-address-list=Twitter new-routing-mark=To-VPN \ + src-address=10.30.30.0/24 src-address-list=!NoWG +add action=mark-routing chain=prerouting comment=YouTube dst-address=\ + !10.30.30.0/24 dst-address-list=YouTube new-routing-mark=To-VPN \ + src-address=10.30.30.0/24 src-address-list=!NoWG +add action=mark-routing chain=prerouting comment=facebook dst-address=\ + !10.30.30.0/24 dst-address-list=facebook new-routing-mark=To-VPN \ + src-address=10.30.30.0/24 src-address-list=!NoWG +add action=mark-routing chain=prerouting comment="VDSIna for All sites" \ + dst-address=!10.30.30.0/24 dst-address-list=!NoVdsina log-prefix=VPN-all \ + new-routing-mark=To-VPN src-address=10.30.30.0/24 src-address-list=!NoWG +add action=change-mss chain=forward comment="MSS on WG" new-mss=1380 \ + out-interface=WG protocol=tcp tcp-flags=syn tcp-mss=1381-65535 +add action=mark-routing chain=prerouting comment="VPN Network" dst-address=\ + 10.8.0.0/24 dst-address-list=!NoVdsina log=yes log-prefix=VPN-Net \ + new-routing-mark=To-VPN src-address=10.30.30.0/24 src-address-list=!NoWG +/ip firewall nat +add action=redirect chain=dstnat comment=\ + "FORCE DNS TO LOCAL MIKROTIK DNS SERVER" dst-port=53 protocol=tcp \ + src-address=10.30.30.0/24 to-ports=53 +add action=redirect chain=dstnat dst-port=53 protocol=udp src-address=\ + 10.30.30.0/24 to-ports=53 +add action=masquerade chain=srcnat comment="masquerade Default" ipsec-policy=\ + out,none out-interface="ether1 - Unet" routing-mark=!To-VPN +add action=masquerade chain=srcnat comment=WG dst-address-list=!NoVdsina \ + in-interface=Bridge-LAN log-prefix=WG-nat out-interface=WG routing-mark=\ + To-VPN +add action=dst-nat chain=dstnat comment=npm disabled=yes dst-port=81 \ + in-interface="ether1 - Unet" protocol=tcp to-addresses=10.30.30.33 \ + to-ports=81 +add action=dst-nat chain=dstnat comment=amster.vados.ruhttps disabled=yes \ + dst-port=443 in-interface="ether1 - Unet" protocol=tcp to-addresses=\ + 10.30.30.33 to-ports=443 +add action=dst-nat chain=dstnat comment="amster.vados.ru For Certbot HTTP" \ + disabled=yes dst-port=80 in-interface="ether1 - Unet" protocol=tcp \ + to-addresses=10.30.30.33 to-ports=80 +add action=dst-nat chain=dstnat disabled=yes dst-port=80 in-interface=\ + "ether1 - Unet" protocol=tcp to-addresses=10.30.30.33 to-ports=80 +add action=dst-nat chain=dstnat comment="Yandex.DNS Family" disabled=yes \ + dst-port=53 in-interface=Bridge-LAN protocol=udp src-address-list=KIDS \ + time=6h-15m,sun,mon,tue,wed,thu,fri,sat to-addresses=77.88.8.3 +add action=dst-nat chain=dstnat disabled=yes dst-port=53 in-interface=\ + Bridge-LAN protocol=tcp src-address-list=KIDS time=\ + 6h-15m,sun,mon,tue,wed,thu,fri,sat to-addresses=77.88.8.3 +add action=dst-nat chain=dstnat dst-address=146.120.64.211 dst-port=32000 \ + in-interface="ether1 - Unet" protocol=tcp to-addresses=10.30.30.95 \ + to-ports=32000 +add action=dst-nat chain=dstnat dst-address=146.120.64.211 dst-port=32000 \ + in-interface="ether1 - Unet" protocol=udp to-addresses=10.30.30.95 \ + to-ports=32000 +add action=dst-nat chain=dstnat dst-port=32000 protocol=tcp routing-mark=\ + To-VPN to-addresses=10.30.30.95 to-ports=32000 +add action=dst-nat chain=dstnat dst-port=32000 protocol=udp routing-mark=\ + To-VPN to-addresses=10.30.30.95 to-ports=32000 +/ip firewall raw +add action=drop chain=prerouting comment="Drop Honeypot Hackers" \ + in-interface="ether1 - Unet" src-address-list="Honeypot Hacker" +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=\ + extras.getpagespeed.com content=extras.getpagespeed.com disabled=yes +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=linux.duke.edu \ + content=linux.duke.edu disabled=yes +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=vk.com \ + content=vk.com +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=ok.ru content=\ + ok.ru +add action=add-dst-to-address-list address-list=Instagram \ + address-list-timeout=none-dynamic chain=prerouting comment=Instagram \ + content=instagram.com +add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\ + none-dynamic chain=prerouting comment=Twitter content=twimg.com +add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\ + none-dynamic chain=prerouting content=x.com +add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\ + none-dynamic chain=prerouting content=twitter.com +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting comment=YouTube content=youtube.com +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting content=googleapis.com +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting content=ggpht.com +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting content=youtu.be +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting content=ytimg.com +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting content=googlevideo.com +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting content=gstatic.com +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting content=googleusercontent.com +add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ + none-dynamic chain=prerouting content=nhacmp3youtube.com +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=rutube.ru \ + content=rutube.ru +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=me.com \ + content=me.com +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=icloud.com \ + content=icloud.com +add action=add-dst-to-address-list address-list=facebook \ + address-list-timeout=none-dynamic chain=prerouting comment=facebook \ + content=fbcd.net +add action=add-dst-to-address-list address-list=facebook \ + address-list-timeout=none-dynamic chain=prerouting content=facebook.com +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=comp-lenta.ru \ + content=comp-lenta.ru +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=\ + smtp.mail.me.com content=smtp.mail.me.com log=yes +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=gov.ru \ + content=gov.ru +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=\ + r78.fssp.gov.ru content=r78.fssp.gov.ru +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=api.db-ip.com \ + content=api.db-ip.com +add action=add-dst-to-address-list address-list=NoVdsina \ + address-list-timeout=none-dynamic chain=prerouting comment=\ + api.telegram.org content=api.telegram.org +/ip firewall service-port +set ftp disabled=yes +set tftp disabled=yes +set irc disabled=no +set sip disabled=yes +set pptp disabled=yes +set rtsp disabled=no +/ip hotspot walled-garden +add server=*1 +/ip ipsec settings +set accounting=no +/ip ipsec policy +set 0 disabled=yes dst-address=0.0.0.0/0 src-address=0.0.0.0/0 +/ip ipsec profile +set [ find default=yes ] dpd-interval=2m dpd-maximum-failures=5 +/ip proxy +set cache-administrator="" max-cache-size=none port=80,443 src-address=\ + 0.0.0.0 +/ip route +add disabled=no distance=3 dst-address=192.168.0.0/24 gateway=l2tp-vpn +add disabled=no distance=4 dst-address=192.168.5.0/24 gateway=l2tp-vpn +add disabled=no distance=3 dst-address=192.168.0.0/24 gateway=l2tp-vpn +add disabled=no distance=4 dst-address=192.168.5.0/24 gateway=l2tp-vpn +add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=WG routing-table=\ + To-VPN scope=30 target-scope=10 +add disabled=yes distance=2 dst-address=0.0.0.0/0 gateway=146.120.64.209 \ + routing-table=main scope=30 target-scope=10 +/ip service +set ftp disabled=yes +set telnet disabled=yes +set ssh address=10.30.30.0/24 port=2222 +set winbox address=10.30.30.0/24 +set api address=10.30.30.0/24 disabled=yes +set api-ssl address=10.30.30.0/24 +set www-ssl port=18443 +set www address=10.30.30.0/24 disabled=yes port=18880 +/ip service webserver +set acme-plain=no crl-plain=no graphs-plain=no graphs-secure=no index-plain=\ + no index-secure=no rest-plain=no rest-secure=no scep-plain=no \ + webfig-plain=no webfig-secure=no +/ip ssh +set forwarding-enabled=both publickey-authentication-options=verify-required \ + strong-crypto=yes +/ip upnp +set enabled=yes +/ip upnp interfaces +add interface=Bridge-LAN type=internal +add interface="ether1 - Unet" type=external +/ipv6 firewall address-list +add address=::/128 comment="defconf: unspecified address" list=bad_ipv6 +add address=::1/128 comment="defconf: lo" list=bad_ipv6 +add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6 +add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6 +add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6 +add address=100::/64 comment="defconf: discard only " list=bad_ipv6 +add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6 +add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6 +add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6 +/ipv6 firewall filter +add action=add-src-to-address-list address-list=bad_ipv6 \ + address-list-timeout=none-dynamic chain=input comment=\ + "defconf: accept established,related,untracked" connection-state=\ + established,related,untracked in-interface=WG in-interface-list=WAN \ + src-address-list="" +add action=drop chain=input comment="defconf: drop invalid" connection-state=\ + invalid +add action=accept chain=input comment="defconf: accept ICMPv6" protocol=\ + icmpv6 +add action=accept chain=input comment="defconf: accept UDP traceroute" \ + dst-port=33434-33534 protocol=udp +add action=accept chain=input comment=\ + "defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\ + udp src-address=fe80::/10 +add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \ + protocol=udp +add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\ + ipsec-ah +add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\ + ipsec-esp +add action=accept chain=input comment=\ + "defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec +add action=drop chain=input comment=\ + "defconf: drop everything else not coming from LAN" in-interface-list=\ + !LAN +add action=accept chain=forward comment=\ + "defconf: accept established,related,untracked" connection-state=\ + established,related,untracked +add action=drop chain=forward comment="defconf: drop invalid" \ + connection-state=invalid +add action=drop chain=forward comment=\ + "defconf: drop packets with bad src ipv6" src-address-list=bad_ipv6 +add action=drop chain=forward comment=\ + "defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6 +add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \ + hop-limit=equal:1 protocol=icmpv6 +add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\ + icmpv6 +add action=accept chain=forward comment="defconf: accept HIP" protocol=139 +add action=accept chain=forward comment="defconf: accept IKE" dst-port=\ + 500,4500 protocol=udp +add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\ + ipsec-ah +add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\ + ipsec-esp +add action=accept chain=forward comment=\ + "defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec +add action=drop chain=forward comment=\ + "defconf: drop everything else not coming from LAN" in-interface-list=\ + !LAN +/ipv6 nd +set [ find default=yes ] advertise-dns=yes +/ppp secret +add local-address=192.168.60.1 name=vados remote-address=192.168.60.2 \ + service=l2tp +/routing bfd configuration +add disabled=no +/snmp +set contact=@AmsterNL enabled=yes engine-id-suffix=MikroMaster location=NL \ + src-address=10.30.30.81 trap-interfaces=Bridge-LAN,WG trap-target=\ + 10.30.30.10 +/system clock +set time-zone-autodetect=no time-zone-name=Europe/Moscow +/system clock manual +set time-zone=+03:00 +/system identity +set name=MikroMaster +/system logging +add action=email disabled=yes regex="* added|changed|removed *" topics=\ + system,info +/system ntp client +set enabled=yes +/system ntp server +set enabled=yes manycast=yes multicast=yes use-local-clock=yes +/system ntp client servers +add address=0.ru.pool.ntp.org +add address=1.ru.pool.ntp.org +add address=2.ru.pool.ntp.org +add address=3.ru.pool.ntp.org +add address=time.google.com disabled=yes +/system scheduler +add comment="Windows Update script" interval=2d5m name=WU-script-run-schedule \ + on-event=WU-add-to-list policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-date=2014-02-11 start-time=00:00:00 +add comment="Backup Every Week" disabled=yes interval=1w name=BackupEveryWeek \ + on-event=BackupAndUpdate policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-date=2025-07-07 start-time=03:41:27 +add comment="DoH Cache Flush" interval=1d name="DNS Cache Flush" on-event=\ + DNS_Flush_Cache policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-date=2019-12-06 start-time=05:30:00 +add comment="Create mkdir function on startup" name=\ + create_mkdir_function_on_startup on-event=\ + "/system script run create_mkdir_function;" policy=read,write,policy,test \ + start-time=startup +add comment="Scheduler for Update Certificates CloudFlare Quad9" interval=1w \ + name="Update Certificates CloudFlare Quad9" on-event=\ + "/system/script { run Update-Certificates; }" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-date=2025-11-28 start-time=05:45:40 +add comment="Scheduler for Amster-Backup-UpdateEmail" disabled=yes interval=\ + 1w name=Amster-Backup-UpdateEmail on-event=\ + "/system/script { run Amster-Backup-UpdateEmail; }" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-date=2026-02-13 start-time=03:41:27 +add comment="Setup Global Environment for scripts" name=AM-SetGlobalEnv \ + on-event="/system/script { run AM-GlobalConfig; run AM-GlobalFunc; }" \ + policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +add comment="Every Day Check For Update Scripts" interval=1d name=\ + AM-ScriptInstallUpdate on-event=\ + ":global ScriptInstallUpdate; \$ScriptInstallUpdate;" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +add comment="Every Day Check For Fake Bridges" interval=1d name=\ + mod/AM-IPbridge on-event="/system/script/run mod/AM-IPbridge;" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +add comment="Every Day Check For Renew Certificates" interval=1d name=\ + AM-CheckCerts on-event="/system/script/run AM-CheckCerts;" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +/system watchdog +set watchdog-timer=no +/tool e-mail +set certificate-verification=no from=MikroVados port=587 \ + server=smtp.mail.me.com tls=starttls user=vadossio@icloud.com +/tool mac-server +set allowed-interface-list=LAN +/tool mac-server mac-winbox +set allowed-interface-list=LAN +/tool netwatch +add comment="doh, doh-url=https://security.cloudflare-dns.com/dns-query, notif\ + y, name=CloudFlare-doh IPv4 1" disabled=yes down-script="" host=1.1.1.1 \ + http-codes="" test-script="" type=simple up-script="" +add check-certificate=no comment="doh-fallback, doh-url=https://security.cloud\ + flare-dns.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=Cl\ + oudFlare-doh IPv4" disabled=yes down-script="" host=1.0.0.1 http-codes="" \ + port=443 test-script="" type=simple up-script="" +add comment="dns-fallback, notify, name=Google-DNS IPv4" disabled=yes \ + down-script="" host=8.8.8.8 http-codes="" test-script="" type=simple \ + up-script="" +add comment="doh-fallback, doh-url=https://dns.google/dns-query, doh-cert=GTS \ + Root R1, notify, name=Google-DOH IPv4" disabled=yes down-script="" host=\ + 8.8.4.4 http-codes="" test-script="" type=simple up-script="" +add comment="dns, notify, name=Cuad9-DOH IPv4" disabled=yes down-script="" \ + host=9.9.9.9 http-codes="" test-script="" type=simple up-script="" +add comment="doh-fallback, doh-url=https://dns.quad9.net/dns-query, name=Cuad9\ + -DOH IPv4" disabled=yes down-script="" host=149.112.112.112 http-codes="" \ + test-script="" type=simple up-script="" +add comment="dns-fallback, notify, name=ns1.unet.ws" disabled=yes \ + down-script="" host=91.192.189.2 http-codes="" test-script="" type=simple \ + up-script="" +/tool sniffer +set filter-interface=Bridge-LAN filter-src-ip-address=10.30.30.50/32 +/user aaa +set accounting=no diff --git a/MikroMaster/history/20260405/20260405040243-Diff-Config.rsc b/MikroMaster/history/20260405/20260405040243-Diff-Config.rsc new file mode 100644 index 0000000..6788892 --- /dev/null +++ b/MikroMaster/history/20260405/20260405040243-Diff-Config.rsc @@ -0,0 +1,4519 @@ +1,4518d0 +< # 2026-04-05 04:02:43 by RouterOS 7.22 +< # software id = 2961-C4ZZ +< # +< # model = RBD52G-5HacD2HnD +< # serial number = HCX084RAVFA +< /interface bridge +< add admin-mac=48:8F:5A:60:A1:0B auto-mac=no name=Bridge-LAN port-cost-mode=\ +< short +< /interface ethernet +< set [ find default-name=ether1 ] comment="WAN - Unet" mac-address=\ +< F6:BE:9D:85:53:F5 name="ether1 - Unet" +< set [ find default-name=ether3 ] comment=LEN +< set [ find default-name=ether4 ] comment=NUC +< /interface l2tp-server +< add comment=Server disabled=yes name=l2tp-in1 user=vados +< /interface l2tp-client +< add comment="Starless 2 MikroSPb" connect-to=176.53.203.171 name=l2tp-EoIP \ +< user=vados +< add allow=mschap2 allow-fast-path=yes comment=Starless connect-to=\ +< vpn.starless.ru max-mru=1280 name=l2tp-vpn use-ipsec=yes use-peer-dns=yes \ +< user=vados +< /interface wireless +< # managed by CAPsMAN +< # channel: 2422/20-Ce/gn(17dBm), SSID: vados, local forwarding +< set [ find default-name=wlan1 ] ampdu-priorities=0,1,2,3,4,5,6,7 band=\ +< 2ghz-b/g/n basic-rates-a/g=\ +< 6Mbps,9Mbps,12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps basic-rates-b=\ +< 1Mbps,2Mbps,5.5Mbps,11Mbps channel-width=20/40mhz-XX country=belarus \ +< disabled=no frequency=auto hw-protection-mode=rts-cts mode=ap-bridge \ +< rate-set=configured skip-dfs-channels=10min-cac ssid=vados \ +< station-roaming=enabled wds-default-bridge=Bridge-LAN wds-mode=\ +< dynamic-mesh wireless-protocol=802.11 wmm-support=enabled wps-mode=\ +< disabled +< # managed by CAPsMAN +< # channel: 5260/20-Ceee/ac/DP(17dBm), SSID: vados5g, local forwarding +< set [ find default-name=wlan2 ] ampdu-priorities=0,1,2,3,4,5,6,7 band=\ +< 5ghz-a/n/ac basic-rates-a/g=\ +< 6Mbps,9Mbps,12Mbps,18Mbps,24Mbps,36Mbps,48Mbps,54Mbps channel-width=\ +< 20/40/80mhz-XXXX country=belarus disabled=no frequency=auto \ +< hw-protection-mode=rts-cts mode=ap-bridge rate-set=configured \ +< skip-dfs-channels=10min-cac ssid=vados5g station-roaming=enabled \ +< wds-default-bridge=Bridge-LAN wds-mode=dynamic-mesh wireless-protocol=\ +< 802.11 wmm-support=enabled wps-mode=disabled +< /interface wireguard +< add listen-port=13231 mtu=1280 name=WG +< /interface wireless nstreme +< # managed by CAPsMAN +< # channel: 2422/20-Ce/gn(17dBm), SSID: vados, local forwarding +< set wlan1 enable-nstreme=yes +< # managed by CAPsMAN +< # channel: 5260/20-Ceee/ac/DP(17dBm), SSID: vados5g, local forwarding +< set wlan2 enable-nstreme=yes +< /caps-man security +< add authentication-types=wpa-psk,wpa2-psk encryption=aes-ccm \ +< group-encryption=aes-ccm name=security +< /caps-man configuration +< add channel.band=2ghz-b/g/n .control-channel-width=20mhz .extension-channel=\ +< XX country=belarus datapath.client-to-client-forwarding=yes \ +< .local-forwarding=yes name=cfg-2ghz security=security ssid=vados +< add channel.band=5ghz-a/n/ac .control-channel-width=20mhz .extension-channel=\ +< XXXX country=belarus datapath.client-to-client-forwarding=yes \ +< .local-forwarding=yes name=cfg-5ghz-ac security=security ssid=vados5g +< add channel.band=5ghz-a/n .control-channel-width=20mhz .extension-channel=XX \ +< country=belarus datapath.client-to-client-forwarding=yes \ +< .local-forwarding=yes name=cfg-5ghz-an security=security ssid=vados5g +< /disk +< add media-interface=lo slot=tmpfs tmpfs-max-size=44739242 type=tmpfs +< # mountpoint [tmpfs] taken by tmpfs +< set usb1 mount-point-template="[tmpfs]" +< /interface list +< add comment=defconf name=WAN +< add comment=defconf name=LAN +< /interface lte apn +< set [ find default=yes ] ip-type=ipv4 use-network-apn=no +< /interface wifi channel +< add band=5ghz-ax disabled=no frequency=5180,5200,5220,5240 name=5G-AX +< add band=5ghz-ac disabled=no frequency=5180,5200,5220,5240 name=5G-AC +< add band=2ghz-n disabled=no frequency=2422,2442,2462 name=2G-N +< add band=2ghz-ax disabled=no frequency=2422,2442,2462 name=2G-AX +< add band=2ghz-g disabled=no frequency=2422,2442,2462 name=2G-G +< add band=5ghz-n disabled=no frequency=5180,5200,5220,5240 name=5G-AN +< /interface wifi datapath +< add bridge=Bridge-LAN disabled=no interface-list=all name=xs-DataPath +< /interface wifi security +< add authentication-types=wpa2-psk,wpa3-psk disabled=no group-encryption=ccmp \ +< group-key-update=1h management-protection=allowed name=sec2g +< add authentication-types=wpa3-psk disable-pmkid=yes disabled=no \ +< group-encryption=ccmp group-key-update=5m management-encryption=cmac \ +< management-protection=required name=sec5G +< /interface wifi configuration +< add channel=2G-AX datapath=xs-DataPath disabled=no mode=ap name=2G-AX \ +< security=sec2g security.ft=yes .ft-over-ds=yes ssid=vados +< add channel=2G-N datapath=xs-DataPath disabled=no mode=ap name=2G-N security=\ +< sec2g security.ft=yes .ft-over-ds=yes ssid=vados +< add channel=5G-AX disabled=no mode=ap name=5G-AX security=sec5G security.ft=\ +< yes .ft-over-ds=yes ssid=vados +< add channel=5G-AC datapath=xs-DataPath disabled=no mode=ap name=5G-AC \ +< security=sec5G security.authentication-types="" .ft=yes .ft-over-ds=yes \ +< ssid=vados +< add channel=2G-G datapath=xs-DataPath disabled=no mode=ap name=2G-G security=\ +< sec2g security.authentication-types="" .ft=yes .ft-over-ds=yes ssid=vados +< add channel=5G-AN disabled=no mode=ap name=5G-AN security=sec5G ssid=vados +< /interface wireless security-profiles +< set [ find default=yes ] authentication-types=wpa-psk,wpa2-psk mode=\ +< dynamic-keys supplicant-identity=MikroTik +< /ip dhcp-server option +< add code=12 name=HostName +< add code=119 force=yes name=domain-search-list value="0x03'WORKGROUP'0x00" +< /ip dhcp-server option sets +< add name=HP1505n options=HostName +< add name=StartLife1 options=HostName +< add name=amsterDev options=HostName +< add name=MiTV options=HostName +< add name=miller options=HostName +< add name=amster options=HostName +< add name=garage options=HostName +< add name=domain-search-set options=domain-search-list +< add name=VADOS-LEN options=HostName +< add name=VADOS-NUC options=HostName +< add name=MikroNUC options=HostName +< add name=master options=HostName +< add name=MikroYellow options=HostName +< add name="=\"Client ID\"" options=HostName +< add name=mVados options=HostName +< /ip dns forwarders +< add dns-servers=1.1.1.1,1.0.0.1 name=blsp.at verify-doh-cert=no +< add comment=Kra dns-servers=1.0.0.1,1.1.1.1 name=slon2.to verify-doh-cert=no +< add dns-servers=1.1.1.1,1.0.0.1 name=slon3.at verify-doh-cert=no +< add dns-servers=1.0.0.1,1.1.1.1 name=slon3.cc verify-doh-cert=no +< add dns-servers=1.1.1.1,1.0.0.1 name=bs2web.at verify-doh-cert=no +< add dns-servers=1.1.1.1,1.0.0.1 name=bs2best.at verify-doh-cert=no +< add dns-servers=1.0.0.1,1.1.1.1 name=psrms.is verify-doh-cert=no +< add dns-servers=1.0.0.1,1.1.1.1 name=m.blsp.at verify-doh-cert=no +< /ip ipsec proposal +< set [ find default=yes ] disabled=yes +< /ip pool +< add name=dhcp ranges=10.30.30.150-10.30.30.200 +< /ip dhcp-server +< add add-arp=yes address-pool=dhcp dhcp-option-set=domain-search-set \ +< dynamic-lease-identifiers=client-mac,client-id,opt-82 interface=\ +< Bridge-LAN lease-time=10m name=masterDHCP server-address=10.30.30.81 \ +< use-reconfigure=yes +< /ip hotspot user profile +< set [ find default=yes ] address-pool=dhcp +< /ip smb users +< set [ find default=yes ] disabled=yes +< add disabled=yes name=vados +< /ppp profile +< set *FFFFFFFE use-upnp=no +< /routing bgp template +< set default disabled=no output.network=bgp-networks +< /routing table +< add disabled=no fib name=To-VPN +< /snmp community +< set [ find default=yes ] addresses=10.30.30.0/24 read-access=no security=\ +< private +< /system logging action +< add email-start-tls=yes email-to=vados@vados.ru name=email target=email +< /system script +< add comment="Example add WU servers to AddrList" dont-require-permissions=no \ +< name=WU-add-to-list owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< \_Script to add target web sites DNS IP addresses into address list\r\ +< \n# Tested with Mikrotik 6.4x\r\ +< \n# Syed Jahanzaib / aacable@hotmail.com\r\ +< \n# List name\r\ +< \n:local LISTNAME \"windowsupdateslist\"\r\ +< \n# Web site names which will be added in address list\r\ +< \n:local TARGET1 \"update.microsoft.com\"\r\ +< \n:local TARGET2 \"download.windowsupdate.com\"\r\ +< \n:local TARGET3 \"download.microsoft.com\"\r\ +< \n:local TARGET4 \"windowsupdate.com\"\r\ +< \n:local TARGET5 \"ntservicepack.microsoft.com\"\r\ +< \n:local TARGET6 \"wustat.windows.com\"\r\ +< \n:local TARGET7 \"stats.microsoft.com\"\r\ +< \n:local TARGET8 \"mp.microsoft.com\"\r\ +< \n:local TARGET9 \"ws.microsoft.com\"\r\ +< \n:local TARGET10 \"sls.update.microsoft.com.akadns.net\"\r\ +< \n:local TARGET11 \"vortex.data.microsoft.com\"\r\ +< \n:local TARGET12 \"vortex-win.data.microsoft.com\"\r\ +< \n:local TARGET13 \"fe2.update.microsoft.com.akadns.net\"\r\ +< \n:local TARGET14 \"statsfe2.update.microsoft.com.akadns.net\"\r\ +< \n \r\ +< \n# 1st time runner, check if address list is not created previously and a\ +< dd entries in it for 1st time usage\r\ +< \n:if ( [/ip firewall address-list find where list=\$LISTNAME] = \"\") do=\ +< {\r\ +< \n:log warning \"No address list for \$TARGET1 found ! creating and adding\ +< \_resolved entry for 1st time usage ... zaib\"\r\ +< \n \r\ +< \n:local FirstAddr [resolve \$TARGET1];\r\ +< \n\r\ +< \n/ip firewall address-list add address=\$FirstAddr list=\$LISTNAME commen\ +< t=\$TARGET1;\r\ +< \n} else={\r\ +< \n:log warning \"Previous List for \$LISTNAME found ! moving forward and c\ +< hecking if DNS entries can be added in it ...\"\r\ +< \n}\r\ +< \n \r\ +< \n# Check DNS entries and collect matching names\r\ +< \n:foreach i in=[/ip dns cache find name~\"(\$TARGET1|\$TARGET2|\$TARGET3|\ +< \$TARGET4|\$TARGET5|\$TARGET6|\$TARGET7|\$TARGET8|\$TARGET9|\$TARGET10|\$T\ +< ARGET11|\$TARGET12|\$TARGET13|\$TARGET14)\" && \$type ~ \"^(A|CNAME)\\\$\"\ +< \_] do={\r\ +< \n \r\ +< \n# Get IP Address from the names and hold it in temporary buffer\r\ +< \n:local Buffer [/ip dns cache get \$i data];\r\ +< \ndelay delay-time=10ms\r\ +< \n \r\ +< \n# Check if entry is already not exists, then OK, otherwise ignore duplic\ +< ation\r\ +< \n:if ( [/ip firewall address-list find where address=\$Buffer] = \"\") do\ +< ={\r\ +< \n \r\ +< \n# Fetch DNS names for the entries\r\ +< \n:local sitednsname [/ip dns cache get \$i name] ;\r\ +< \n \r\ +< \n# Print name in LOG window\r\ +< \n:log info (\"added entry: \$sitednsname \$Buffer\");\r\ +< \n \r\ +< \n# Add IP addresses and there names to the address list\r\ +< \n/ip firewall address-list add address=\$Buffer list=\$LISTNAME comment=\ +< \$sitednsname;\r\ +< \n}\r\ +< \n}" +< add comment="Add Hosts DNS names to NoWG addres list" \ +< dont-require-permissions=no name=Add2vdsina owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< \_Script to add target web sites DNS IP addresses into address list\r\ +< \n# Tested with Mikrotik 6.4x\r\ +< \n# \r\ +< \n# List name\r\ +< \n:local LISTNAME \"NoWG\"\r\ +< \n#\r\ +< \n# Web site names which will be added in address list\r\ +< \n:local TARGET1 \"comp-lenta.ru\"\r\ +< \n:local TARGET2 \"ok.ru\"\r\ +< \n:local TARGET3 \"vk.com\"\r\ +< \n#:local TARGET4 \"smtp.mail.me.com\"\r\ +< \n#:local TARGET4 \"windowsupdate.com\"\r\ +< \n#:local TARGET5 \"ntservicepack.microsoft.com\"\r\ +< \n#:local TARGET6 \"wustat.windows.com\"\r\ +< \n#:local TARGET7 \"stats.microsoft.com\"\r\ +< \n#:local TARGET8 \"mp.microsoft.com\"\r\ +< \n#:local TARGET9 \"ws.microsoft.com\"\r\ +< \n#:local TARGET10 \"sls.update.microsoft.com.akadns.net\"\r\ +< \n#:local TARGET11 \"vortex.data.microsoft.com\"\r\ +< \n#:local TARGET12 \"vortex-win.data.microsoft.com\"\r\ +< \n#:local TARGET13 \"fe2.update.microsoft.com.akadns.net\"\r\ +< \n#:local TARGET14 \"statsfe2.update.microsoft.com.akadns.net\"\r\ +< \n \r\ +< \n# 1st time runner, check if address list is not created previously and a\ +< dd entries in it for 1st time usage\r\ +< \n:if ( [/ip firewall address-list find where list=\$LISTNAME] = \"\") do=\ +< {\r\ +< \n:log warning \"No address list for \$TARGET1 found ! creating and adding\ +< \_resolved entry for 1st time usage ... zaib\"\r\ +< \n\r\ +< \n:local FirstAddr [resolve \$TARGET1];\r\ +< \n\r\ +< \n/ip firewall address-list add address=\$FirstAddr list=\$LISTNAME commen\ +< t=\$TARGET1;\r\ +< \n\r\ +< \n} else={\r\ +< \n:log warning \"Previous List for \$LISTNAME found ! moving forward and c\ +< hecking if DNS entries can be added in it ...\"\r\ +< \n}\r\ +< \n\r\ +< \n# Check DNS entries and collect matching names\r\ +< \n:foreach i in=[/ip dns cache find name~\"(\$TARGET1|\$TARGET2|\$TARGET3|\ +< \$TARGET4)\" && \$type ~ \"^(A|CNAME)\\\$\" ] do={\r\ +< \n\r\ +< \n:log info (\"start entry: \$c \$sitednsname \$Buffer\");\r\ +< \n\r\ +< \n# Get IP Address from the names and hold it in temporary buffer\r\ +< \n:local Buffer [/ip dns cache get \$i data];\r\ +< \ndelay delay-time=10ms\r\ +< \n:log info (\"1: \$Buffer\"); \r\ +< \n\r\ +< \n# Check if entry is already not exists, then OK, otherwise ignore duplic\ +< ation\r\ +< \n:if ( [/ip firewall address-list find where address=\$Buffer] = \"\") do\ +< ={\r\ +< \n\r\ +< \n:log info (\"2: \$Buffer\"); \r\ +< \n \r\ +< \n# Fetch DNS names for the entries\r\ +< \n:local sitednsname [/ip dns cache get \$i name] ;\r\ +< \n \r\ +< \n# Print name in LOG window\r\ +< \n:log info (\"added entry: \$i \$sitednsname \$Buffer\");\r\ +< \n \r\ +< \n# Add IP addresses and there names to the address list\r\ +< \n/ip firewall address-list add address=\$Buffer list=\$LISTNAME comment=\ +< \$sitednsname;\r\ +< \n}\r\ +< \n}" +< add comment="Flush DNS Cache" dont-require-permissions=no name=\ +< DNS_Flush_Cache owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=\ +< "/ip dns cache flush" +< add dont-require-permissions=no name=create_mkdir_function owner=vados \ +< policy=read,write source="# Written by Phillip Stromberg in 2019\r\ +< \n# Distributed under the MIT license\r\ +< \n# \r\ +< \n# \r\ +< \n# this creates a function called \$mkdir\r\ +< \n# from the command line you will be able to just type \"\$mkdir some/new\ +< /folder\"\r\ +< \n# and all the folders that need to be created will be\r\ +< \n# if the folder already existed, it is ignored\r\ +< \n\r\ +< \n:log info \"Creating \\\$mkdir function...\"\r\ +< \n\r\ +< \n:global mkdir do={\r\ +< \n # \$1 refers to the input variable the user passed in to us\r\ +< \n :local newFolder \$1;\r\ +< \n\r\ +< \n # we'll use this variable to report error messages that may arise\r\ +< \n :local errorMsg;\r\ +< \n\r\ +< \n # if the user put a slash on the end of the new folder name, remove \ +< it\r\ +< \n # i.e. \"some/test/\" becomes \"some/test\"\r\ +< \n :while (([:pick \$newFolder ([:len \$newFolder] - 1)]) = \"/\") do={\ +< \r\ +< \n :set newFolder [:pick \$newFolder 0 ([:len \$newFolder] - 1)]\r\ +< \n }\r\ +< \n\r\ +< \n # if the user put a slash at the beginning of the new folder name, r\ +< emove it\r\ +< \n # i.e. \"/some/test\" becomes \"some/test\"\r\ +< \n :while ([:pick \$newFolder 0] = \"/\") do={\r\ +< \n :set newFolder [:pick \$newFolder 1 [:len \$newFolder]]\r\ +< \n }\r\ +< \n\r\ +< \n :if ([/file find name=\$newFolder] != \"\") do={\r\ +< \n :set errorMsg \"'\$newFolder' already exists.\";\r\ +< \n :log debug \"mkdir: \$errorMsg\";\r\ +< \n :return \$newFolder;\r\ +< \n }\r\ +< \n\r\ +< \n # the name of the temp file to create\r\ +< \n :local tempfile \"mkdir_temp_file.txt\";\r\ +< \n\r\ +< \n # port 0 is unlikely to be open to HTTP requests...\r\ +< \n :local fakeURL \"http://127.0.0.1:0/should-not-exist.txt\";\r\ +< \n\r\ +< \n :local fullTempPath (\$newFolder . \"/\" . \$tempfile);\r\ +< \n\r\ +< \n # this is where the folder creation happens\r\ +< \n # `as-value` prevents status messages from printing\r\ +< \n # wrapping in a `:do {...} on-error` prevents error messages from pr\ +< inting.\r\ +< \n :do {\r\ +< \n /tool fetch dst-path=\"\$fullTempPath\" url=\"\$fakeURL\" durati\ +< on=0.001s as-value;\r\ +< \n } on-error={}\r\ +< \n\r\ +< \n # this waits for the temporary dir to show up so there isn't a race \ +< \r\ +< \n # condition where you call mkdir and then try to do something before\ +< \_the \r\ +< \n # folder is actually created\r\ +< \n :local count 0;\r\ +< \n :while ([/file find name=\"\$newFolder\"] = \"\") do={\r\ +< \n :if (\$count >= 50) do={\r\ +< \n # after 50 * 0.1s delays, it's been 5 seconds, which should \ +< be long enough\r\ +< \n :set errorMsg \"New folder could not be created at \$newFold\ +< er\";\r\ +< \n :log error \"mkdir: \$errorMsg\"\r\ +< \n :error \$errorMsg\r\ +< \n }\r\ +< \n :delay 0.1s;\r\ +< \n :set count (\$count + 1);\r\ +< \n }\r\ +< \n\r\ +< \n :return \$newFolder;\r\ +< \n}\r\ +< \n\r\ +< \n:log info \"Created function \\\$mkdir\"\r\ +< \n" +< add comment="Certificates CloudFlare, Quad9 " dont-require-permissions=no \ +< name=Update-Certificates owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< \_CloudFlare\r\ +< \n/tool/fetch mode=https url=https://cacerts.digicert.com/DigiCertGlobalRo\ +< otCA.crt.pem;\r\ +< \n/certificate/import file-name=DigiCertGlobalRootCA.crt.pem passphrase=\"\ +< \";\r\ +< \n/tool/ fetch mode=https url=https://cacerts.digicert.com/DigiCertGlobalG\ +< 2TLSRSASHA2562020CA1-1.crt.pem;\r\ +< \n/certificate/import file-name=DigiCertGlobalG2TLSRSASHA2562020CA1-1.crt.\ +< pem passphrase=\"\";\r\ +< \n# Quad9\r\ +< \n/tool/fetch mode=https url=\"https://cacerts.digicert.com/DigiCertGlobal\ +< G3TLSECCSHA3842020CA1-1.crt.pem\"\r\ +< \n/certificate/import file-name=DigiCertGlobalG3TLSECCSHA3842020CA1-1.crt.\ +< pem passphrase=\"\";\r\ +< \n\r\ +< \n#:global AmScriptsUrl;\r\ +< \n#google\r\ +< \n#:local CertName \"GTS-Root-R1.pem\";\r\ +< \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ +< \r\ +< \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ +< \n#:set CertName \"GTS-Root-R4.pem\";\r\ +< \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ +< \r\ +< \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ +< \n#:set CertName \"GTS-Root-RX.pem\";\r\ +< \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ +< \r\ +< \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ +< \n#internet\r\ +< \n#:set CertName \"ISRG-Root-X1.pem\";\r\ +< \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ +< \r\ +< \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ +< \n#:set CertName \"ISRG-Root-X2.pem\";\r\ +< \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ +< \r\ +< \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ +< \n#:set CertName \"Starfield-Root-Certificate-Authority-G2.pem\";\r\ +< \n#/tool/fetch mode=https url=(\$AmScriptsUrl . \"certs/\" . \$CertName);\ +< \r\ +< \n#/certificate/import file-name=\$CertName passphrase=\"\";\r\ +< \n\r\ +< \n#/ip/dns/set allow-remote-requests=yes doh-max-concurrent-queries=100 do\ +< h-max-server-connections=20 use-doh-server=https://security.cloudflare-dns\ +< .com/dns-query verify-doh-cert=yes;\r\ +< \n#/ip/dns/static remove [find where address=1.1.1.1];\r\ +< \n#/ip/dns/static add address=1.1.1.1 name=security.cloudflare-dns.com com\ +< ment=\"cloudflare-dns IPv4 1\";\r\ +< \n#/ip/dns/static remove [find where address=1.0.0.1];\r\ +< \n#/ip/dns/static add address=1.0.0.1 name=security.cloudflare-dns.com com\ +< ment=\"cloudflare-dns IPv4 2\"\r\ +< \n#/ip dns static add address=2606:4700:4700::1111 name=security.cloudflar\ +< e-dns.com type=AAAA\r\ +< \n#/ip dns static add address=2606:4700:4700::1001 name=security.cloudflar\ +< e-dns.com type=AAAA\r\ +< \n#/ip/dns set servers=\"1.0.0.1, 8.8.4.4\";\r\ +< \n#/ip/dns set servers=\"\";" +< add dont-require-permissions=no name=script1 owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/\ +< tool/netwatch/add comment=\"doh-fallback, doh-url=https://security.cloudfl\ +< are-dns.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=Clou\ +< dFlare-doh IPv4 1\" host=1.1.1.1;\r\ +< \n/tool/netwatch/add comment=\"doh, doh-url=https://security.cloudflare-dn\ +< s.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=CloudFlare\ +< -doh IPv4 2\" host=1.0.0.1;\r\ +< \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\ +< /dns.google/dns-query, doh-cert=DigiCert Global Root G2, notify, name=Goog\ +< le-doh IPv4 1\" host=8.8.8.8;\r\ +< \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\ +< /dns.google/dns-query, doh-cert=DigiCert Global Root G2, notify, name=Goog\ +< le-doh IPv4 2\" host=8.8.4.4;\r\ +< \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\ +< /dns.quad9.net/dns-query, doh-cert=DigiCert Global Root G3, notify, name=C\ +< uad9-doh IPv4 1\" host=9.9.9.9;\r\ +< \n/tool/netwatch/add comment=\"doh-fallback, dns-fallback, doh-url=https:/\ +< /dns.quad9.net/dns-query, doh-cert=DigiCert Global Root G3, notify, name=C\ +< uad9-doh IPv4 2\" host=149.112.112.112;\r\ +< \n\r\ +< \n/tool/netwatch/add comment=\"dns, notify, name=ns1.unet.ws\" host=91.192\ +< .189.2;" +< add dont-require-permissions=no name=script2 owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< \r\ +< \n\r\ +< \n:global InspectVar;\r\ +< \n#:global RouterBoard;\r\ +< \n#:do {:set RouterBoard [[ :parse \"/system/routerboard/get\" ]]} on-erro\ +< r={}\r\ +< \n#:global Resources;\r\ +< \n#:do {:set Resources [[ :parse \"/system/resource/get\" ]]} on-error={}\ +< \r\ +< \n\r\ +< \n#:global Updates;\r\ +< \n#:do {:set Updates [[ :parse \"/system/package/update/get\" ]]} on-error\ +< ={}\r\ +< \n\r\ +< \n#:global PkgUpdStatus \"undefined\";\r\ +< \n#:local Update [/system/package/update/get];\r\ +< \n#:retry command={:set PkgUpdStatus (\$Update->\"status\")} delay=200ms m\ +< ax=5 on-error={};\r\ +< \n\r\ +< \n#:log warning [\$InspectVar \$RouterBoard];\r\ +< \n#:put [\$InspectVar \$RouterBoard];\r\ +< \n\r\ +< \n#:retry command={/system/package/update check-for-updates without-paging\ +< \_as-value} delay=300ms max=5 on-error={};\r\ +< \n\r\ +< \n#:global arrDeviceInfo ({});\r\ +< \n#:local arrDeviceInfo ({\"section\":{\"key\":\"\"; \"value\":\"\";};});\ +< \r\ +< \n#:set (\$arrDeviceInfo->\"RouterBoard\") [[ :parse \"/system/routerboard\ +< /get\" ]];\r\ +< \n#:retry command={:set (\$arrDeviceInfo->\"Updates\") [[ :parse \"/system\ +< /package/update/get\" ]]} delay=500ms max=5 on-error={:log error (\"Error\ +< \")};\r\ +< \n# [:toarray {\"section\"={\"key\"=\"\"; \"value\"=\"\";} }];\r\ +< \n# [:toarray \"\"];\r\ +< \n:local arrDeviceInfo ({});\r\ +< \n\r\ +< \n:set (\$arrDeviceInfo->\"devUpdates\") {\"channel\"; \"stable\";};\r\ +< \n#:do {:set (arrDeviceInfo->\"Updates\") [[ :parse \"/system/package/upda\ +< te/get\" ]]} on-error={:log error (\$error)}\r\ +< \n\$InspectVar \$arrDeviceInfo;\r\ +< \n" +< add dont-require-permissions=no name=AM-setup owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< \_RouterOS Setup Script: AM-setup\r\ +< \n# \r\ +< \n# Copyright (c) 2005-2026 Vados \r\ +< \n#\r\ +< \n#\r\ +< \n# requires RouterOS, version=7.19\r\ +< \n# requires device-mode, fetch\r\ +< \n\r\ +< \n## Additional commands:\r\ +< \n#\r\ +< \n# For scripts:\r\ +< \n#:if ([ :len [ /system/script/find where name=\$ScriptName ]] = 0 ) do={\ +< \r\ +< \n# :local ScriptName [ :jobname ];\r\ +< \n# :global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ +< \n# /system/script/add name=\$ScriptName owner=\$ScriptName source=([ /too\ +< l/fetch check-certificate=yes-without-crl (\$GlobalScriptsUrl . \$ScriptNa\ +< me . \".rsc\") output=user as-value ]->\"data\");\r\ +< \n#}\r\ +< \n# For run from terminal:\r\ +< \n# /system/script/add name=AM-setup owner=AM-Setup source=([ /tool/fetch \ +< check-certificate=yes-without-crl \"https://ros.vados.ru/AM-setup.rsc\" ou\ +< tput=user as-value ]->\"data\");\r\ +< \n#\r\ +< \n# /system/script/set source=[ :tocrlf [ get \$ScriptName source ] ] \$Sc\ +< riptName;\r\ +< \n:local ScriptName [ :jobname ];\r\ +< \n\r\ +< \n:local RemoveThisScript false;\r\ +< \n\r\ +< \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ +< \n\r\ +< \n{\r\ +< \n :local ScriptName;\r\ +< \n :local RemoveThisScript;\r\ +< \n :global GlobalScriptsUrl;\r\ +< \n :local AllDone;\r\ +< \n :local CertCommonName \"Root YE\";\r\ +< \n :local CertFileName \"Root-YE.pem\";\r\ +< \n :local CertFingerprint \"e14ffcad5b0025731006caa43a121a22d8e9700f4fb9c\ +< f852f02a708aa5d5666\";\r\ +< \n\r\ +< \n :local CertSettings [ /certificate/settings/get ];\r\ +< \n :if (!(((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" || \ +< \\\r\ +< \n (\$CertSettings->\"builtin-trust-store\") ~ \"fetch\" || \\\r\ +< \n (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\r\ +< \n [ :len [ /certificate/builtin/find where common-name=\$CertComm\ +< onName ] ] > 0)) do={\r\ +< \n :put \"Importing certificate...\";\r\ +< \n:log warning (\"\\n\\\$GlobalScriptsUrl = \" . \$GlobalScriptsUrl);\r\ +< \n /tool/fetch (\$GlobalScriptsUrl . \"certs/\" . \$CertFileName) dst-p\ +< ath=\$CertFileName as-value;\r\ +< \n :delay 1s;\r\ +< \n /certificate/import file-name=\$CertFileName passphrase=\"\";\r\ +< \n :if ([ :len [ /certificate/find where fingerprint=\$CertFingerprint \ +< ] ] != 1) do={\r\ +< \n :error \"Something is wrong with your certificates!\";\r\ +< \n };\r\ +< \n :delay 1s;\r\ +< \n };\r\ +< \n :put \"Renaming AM-GlobalConfig, if exists...\";\r\ +< \n :local ConfOldName (\"AM-GlobalConfig-\" . [ /system/clock/get date ] \ +< . [ /system/clock/get time ] . \".rsc\");\r\ +< \n /system/script/set name=\$ConfOldName [ find where name=\"AM-GlobalCon\ +< fig\" ];\r\ +< \n :foreach Script in={ \"AM-GlobalConfig\"; \"AM-GlobalFunc\" } do={\r\ +< \n :put \"Installing \$Script...\";\r\ +< \n /system/script/remove [ find where name=\$Script ];\r\ +< \n /system/script/add name=\$Script owner=\$Script source=([ /tool/fetc\ +< h check-certificate=yes-without-crl url=(\$GlobalScriptsUrl . \$Script . \ +< \".rsc\") output=user as-value ]->\"data\");\r\ +< \n };\r\ +< \n\r\ +< \n :if ([ :len [ /certificate/find where fingerprint=\$CertFingerprint ] \ +< ] > 0) do={\r\ +< \n :put \"Renaming certificate by its common-name...\";\r\ +< \n :global CertificateNameByCN;\r\ +< \n \$CertificateNameByCN \$CertFingerprint;\r\ +< \n };\r\ +< \n\r\ +< \n :put \"Add Schedulers...\";\r\ +< \n :delay 1;\r\ +< \n :put \"Add Global scheduler...\";\r\ +< \n :local OnEvent \"/system/script { run AM-GlobalConfig; run AM-GlobalFu\ +< nc; }\";\r\ +< \n :local Comment \"Setup Global Environment for scripts\";\r\ +< \n :if ([ :len [ /system/scheduler/find where name=\"AM-SetGlobalEnv\" ] \ +< ] = 0) do={\r\ +< \n /system/scheduler/add name=\"AM-SetGlobalEnv\" comment=\$Comment on-\ +< event=\$OnEvent start-time=startup;\r\ +< \n }\r\ +< \n :if ([ /system/scheduler/get \"AM-SetGlobalEnv\" comment ] != \$Commen\ +< t) do={\r\ +< \n /system/scheduler/set \"AM-SetGlobalEnv\" comment=\$Comment;\r\ +< \n }\r\ +< \n :if ([ /system/scheduler/get \"AM-SetGlobalEnv\" on-event ] != \$OnEve\ +< nt) do={\r\ +< \n /system/scheduler/set \"AM-SetGlobalEnv\" on-event=\$OnEvent;\r\ +< \n }\r\ +< \n :delay 1;\r\ +< \n :put \"Add Update Script scheduler\";\r\ +< \n :set OnEvent \":global ScriptInstallUpdate; \\\$ScriptInstallUpdate;\"\ +< ;\r\ +< \n :set Comment \"Every Day Check For Update Scripts\";\r\ +< \n :if ([ :len [ /system/scheduler/find where name=\"AM-ScriptInstallUpda\ +< te\" ] ] = 0) do={\r\ +< \n /system/scheduler/add name=\"AM-ScriptInstallUpdate\" comment=\$Commen\ +< t start-time=startup interval=1d on-event=\$OnEvent;\r\ +< \n }\r\ +< \n\r\ +< \n :delay 1;\r\ +< \n :put \"Loading configuration and functions...\";\r\ +< \n :do { \r\ +< \n /system/script { run AM-GlobalConfig; run AM-GlobalFunc; };\r\ +< \n :global ScriptInstallUpdate; \$ScriptInstallUpdate;\r\ +< \n :set AllDone true;\r\ +< \n } on-error={\r\ +< \n :set AllDone false;\r\ +< \n :local ErrorMsg \"Loading configuration and functions error!\";\r\ +< \n :log error (\$ScriptName . \$ErrorMsg . :error);\r\ +< \n :error \$ErrorMsg;\r\ +< \n }\r\ +< \n\r\ +< \n :delay 5s;\r\ +< \n :if (\$AllDone = true && \$RemoveThisScript = true) do={\r\ +< \n :put \"Add Scheduler for remove this script...\";\r\ +< \n :set OnEvent \":delay 30s; /system/script/remove [ find where name=\$S\ +< criptName ]; :delay5s; /system/scheduler/remove [ find where name=\\\"_Rem\ +< oveSetup\\\" ];\";\r\ +< \n :set Comment \"_RemoveSetup tmp scheduler for remove setup script.\";\ +< \r\ +< \n /system/scheduler/add name=\"_RemoveSetup\" comment=\$Comment start-ti\ +< me=startup interval=30s on-event=\$OnEvent;\r\ +< \n :log warning (\$ScriptName . \"\\nI've done everything, and now I'm ti\ +< red... I'm leaving. ))\\nThere will be an error below, this is normal.\");\ +< \r\ +< \n }\r\ +< \n};\r\ +< \n" +< add dont-require-permissions=no name=fetchCustom owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="\ +< \r\ +< \n#root.mnuc.backuper\r\ +< \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ +< \n#/tool/fetch mode=https url=(\$GlobalScriptsUrl . \".bak/mikro_bak_rsa@1\ +< 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 ch\ +< eck-certificate=yes-without-crl url=(\$GlobalScriptsUrl . \$Script . \".rs\ +< c\") output=user as-value ]->\"data\");\r\ +< \n#/usb1/mikro_bak_rsa.pub" +< add comment="Global functions" dont-require-permissions=no name=AM-GlobalFunc \ +< owner=AM-GlobalFunc policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< !rsc by Vados\r\ +< \n# RouterOS script: AM-GglobalFunc\r\ +< \n# Script comment: Global functions\r\ +< \n# Copyright (c) 2005-2026 Vados \r\ +< \n#\r\ +< \n#\r\ +< \n# requires RouterOS, version=7.19\r\ +< \n# requires device-mode, fetch, scheduler\r\ +< \n:local ExitOK false;\r\ +< \n:local ScriptName [ :jobname ];\r\ +< \n#:global checkRunJob \$SriptName;\r\ +< \n#:global fixCRLF;\r\ +< \n#:if (\$fixCRLF != false) do={\r\ +< \n#:foreach fixScript in=([ /system/script/find where name~\"*\" ]) do={/s\ +< ystem/script/set source=[ :tocrlf [ get \$fixScript source ] ] \$fixScript\ +< }\r\ +< \n#:if (\$fixCRLF != \"LF\") do={ /system/script/set source=[ :tocrlf [ g\ +< et \$fixScript source ] ] \$fixScript};};\r\ +< \n#}\r\ +< \n:global GlobalFuncReady false;\r\ +< \n\r\ +< \n# Git commit id & info, expected configuration version\r\ +< \n:global CommitId \"main/226/e1cd7257\";\r\ +< \n:global CommitTAG \"unknown\";\r\ +< \n:global CommitInfo \"Autocommit in repo: ros.vados.ru, generated by owne\ +< r: root, in 09:45:02 01.04.2026.\";\r\ +< \n\r\ +< \n# The variables are received right here.\r\ +< \n:global GlobalConfVersion 138;\r\ +< \n\r\ +< \n:global SumsDirAndFileName \"tmp/checksums.json\";\r\ +< \n\r\ +< \n:global Identity [/system/identity/get name];\r\ +< \n:global IdentityShort [:pick \$Identity 0 18];\r\ +< \n\r\ +< \n:global devBoardName [/system/resource/get board-name];\r\ +< \n:global devMode [/system/device-mode/get mode];\r\ +< \n:global devCurArch [/system/resource/get architecture-name];\r\ +< \n:global devCurVersion [/system/resource/get version];\r\ +< \n\r\ +< \n# Variables defined in AM-GlobalConfig.rsc\r\ +< \n:global TerminalColorOutput;\r\ +< \n:global CommentsInScripts;\r\ +< \n:global DetectIpAddrDefault;\r\ +< \n:global DetectIpAddrFallback;\r\ +< \n:global updateChannel;\r\ +< \n:global Domain;\r\ +< \n:global EmailGeneralTo;\r\ +< \n:global BackupAndUpdateMode;\r\ +< \n\r\ +< \n# Single functions, without nested functions.\r\ +< \n:global GlobalEnvRemove;\r\ +< \n:global MiniDateTimeStamp;\r\ +< \n\r\ +< \n# Include globals \$PrintDebug and \$PrintDebugOverride\r\ +< \n:global LogPrint;\r\ +< \n\r\ +< \n# DeviceInfo and Updates\r\ +< \n:global IsCheckUpdates;\r\ +< \n:global WaitCheckUpdates;\r\ +< \n:global GetPubIp;\r\ +< \n\r\ +< \n:global GetArrDeviceInfo;\r\ +< \n:global WaitArrDeviceInfo;\r\ +< \n\r\ +< \n:global devModel;\r\ +< \n:global devRunningMode;\r\ +< \n\r\ +< \n:global devRbRevision;\r\ +< \n:global devRbSerialNumber;\r\ +< \n:global devRbVerAvail;\r\ +< \n\r\ +< \n:global runningChannelVersion;\r\ +< \n:global runningChannel;\r\ +< \n:global runningVersion;\r\ +< \n\r\ +< \n:global devBuildTime;\r\ +< \n#:global ROsVerAvail;\r\ +< \n:global PkgUpdStatus;\r\ +< \n:global currentUpdateChannel;\r\ +< \n\r\ +< \n:global ScriptInstallUpdate;\r\ +< \n\r\ +< \n:global DeviceInfo;\r\ +< \n\r\ +< \n:global OldMode;\r\ +< \n\r\ +< \n:global ParseKeyValueStore;\r\ +< \n:global RandomDelay;\r\ +< \n:global GetRandomNumber;\r\ +< \n:global EscapeForRegEx;\r\ +< \n:global ExitError;\r\ +< \n:global CharacterMultiply;\r\ +< \n:global CharacterReplace;\r\ +< \n:global CleanFilePath;\r\ +< \n:global CleanName;\r\ +< \n\r\ +< \n:global CommitBrief;\r\ +< \n\r\ +< \n:global EitherOr;\r\ +< \n:global FormatLine;\r\ +< \n:global GetRandom20CharAlNum;\r\ +< \n:global Grep;\r\ +< \n:global IfThenElse;\r\ +< \n:global MAX;\r\ +< \n:global MIN;\r\ +< \n:global HumanReadableNum;\r\ +< \n\r\ +< \n:global IsFullyConnected;\r\ +< \n:global IsDNSResolving;\r\ +< \n:global IsTimeSync;\r\ +< \n:global IsTimeSyncCached;\r\ +< \n:global IsTimeSyncResetNtp;\r\ +< \n\r\ +< \n:global WaitDNSResolving;\r\ +< \n:global WaitFullyConnected;\r\ +< \n:global WaitTimeSync;\r\ +< \n:global MkDir;\r\ +< \n:global RmDir;\r\ +< \n:global RmFile;\r\ +< \n:global FileGet;\r\ +< \n:global Unix2Dos;\r\ +< \n:global UrlEncode;\r\ +< \n:global WaitForFile;\r\ +< \n:global ScriptLock;\r\ +< \n:global SendTelegram;\r\ +< \n:global NotificationFunctions;\r\ +< \n:global SendNotification;\r\ +< \n:global SendNotification2;\r\ +< \n:global SymbolForNotification;\r\ +< \n:global SymbolByUnicodeName;\r\ +< \n:global ValidateSyntax;\r\ +< \n:global CheckSumsVerify;\r\ +< \n:global GlobalConfChanges;\r\ +< \n:global GlobalConfMigration;\r\ +< \n:global VersionToNum;\r\ +< \n:global RequiredRouterOS;\r\ +< \n:global FetchLargeFiles;\r\ +< \n:global FetchUserAgentStr;\r\ +< \n:global CertificateAvailable;\r\ +< \n:global CertificateDownload;\r\ +< \n:global CertificateNameByCN;\r\ +< \n:global CharacterMultiply;\r\ +< \n\r\ +< \n:global InspectVar;\r\ +< \n:global InspectVarRet;\r\ +< \n:global ParseCustom;\r\ +< \n\r\ +< \n:set IsCheckUpdates do={\r\ +< \n :local isInfo [:tobool \$1];\r\ +< \n :global LogPrint;\r\ +< \n :global updateChannel;\r\ +< \n :global PkgUpdStatus;\r\ +< \n \$LogPrint debug \$0 (\"\\\$isInfo = \" . \$isInfo); \r\ +< \n :local CurrentChannel [ /system/package/update/get channel ];\r\ +< \n :if (\$CurrentChannel != \$updateChannel) do={\r\ +< \n :retry command={/system/package/update set channel=\$updateChannel} \ +< \_delay=300ms max=5 on-error={};\r\ +< \n \$LogPrint debug \$0 (\"Set updates channel to: \$updateChannel\");\ +< \r\ +< \n }\r\ +< \n\r\ +< \n :local Update [ /system/package/update/get ];\r\ +< \n :local Channel (\$Update->\"channel\");\r\ +< \n \$LogPrint debug \$0 (\"Update Channel: \" . \$Channel . \".\");\r\ +< \n\r\ +< \n :local StatusPkg \"undefined\";\r\ +< \n \$LogPrint debug \$0 (\"Checking for updates...\");\r\ +< \n :retry command={:set \$StatusPkg ([/system/package/update/check-for-up\ +< dates without-paging as-value]->\"status\")} \\\r\ +< \n delay=300ms max=5 on-error={};\r\ +< \n \$LogPrint debug \$0 (\"\\\$StatusPkg = \" . \$StatusPkg);\r\ +< \n :if (\$StatusPkg = \"New version is available\") do={ :set PkgUpdStatu\ +< s true; } else={ :set PkgUpdStatus false; }\r\ +< \n \$LogPrint debug \$0 (\"\\\$PkgUpdStatus = \" . \$PkgUpdStatus);\r\ +< \n :if (\$isInfo != false || \$PkgUpdStatus = true) do={\r\ +< \n \$LogPrint debug \$0 (\"\\\$PkgUpdStatus = \" . \$PkgUpdStatus);\r\ +< \n :if ([:len \$arrDeviceInfo] = 0) do={\r\ +< \n :global arrDeviceInfo ({});\r\ +< \n :local arrDeviceInfo ({\"section\":{\"key\":\"\"; \"value\":\"\";};}\ +< );\r\ +< \n }\r\ +< \n # else={:local arrDeviceInfo ({})}\r\ +< \n :retry command={:set (\$arrDeviceInfo->\"devUpdates\") [[ :parse \"/\ +< system/package/update/get\" ]]} delay=500ms max=5 on-error={:log error (\"\ +< Error\")};\r\ +< \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentChannel\"; \$Cu\ +< rrentChannel;};\r\ +< \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentVersion\"; (\$U\ +< pdate->\"installed-version\");};\r\ +< \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentChannelVersion\ +< \"; [/system/resource/get version];};\r\ +< \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devUpdateChannel\"; [\$up\ +< dateChannel];};\r\ +< \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devUpdateVersion\"; (\$Up\ +< date->\"latest-version\");};\r\ +< \n } else={\r\ +< \n :return \$PkgUpdStatus;\r\ +< \n }\r\ +< \n}\r\ +< \n\r\ +< \n:set WaitArrDeviceInfo do={\r\ +< \n :global GetArrDeviceInfo;\r\ +< \n :while ([ \$GetArrDeviceInfo ] = false) do={\r\ +< \n :delay 1s;\r\ +< \n }\r\ +< \n}\r\ +< \n\r\ +< \n:set GetArrDeviceInfo do={\r\ +< \n :global LogPrint;\r\ +< \n\r\ +< \n :global devBoardName;\r\ +< \n :global devModel;\r\ +< \n\r\ +< \n :global arrDeviceInfo [:toarray {\"section\"={\"key\"=\"\"; \"value\"\ +< =\"\";} }];\r\ +< \n #:do {:set (\$arrDeviceInfo->\"Updates\") [[ :parse \"/system/package\ +< /update/get\" ]]} on-error={}\r\ +< \n :global devRbRevision;\r\ +< \n :global devRbSerialNumber;\r\ +< \n :global devRbCurrentFw;\r\ +< \n :global devRbUpgradeFw;\r\ +< \n\r\ +< \n :global devRunning;\r\ +< \n :global devCurArch;\r\ +< \n :global ROsVerCurrent;\r\ +< \n :global ROsChannelCurrent;\r\ +< \n :global ROsVerAvail;\r\ +< \n\r\ +< \n :global ParseCustom;\r\ +< \n :global runningChannelVersion;\r\ +< \n :global runningChannel;\r\ +< \n :global runningVersion;\r\ +< \n :global devBuildTime;\r\ +< \n :global GetPubIp;\r\ +< \n\r\ +< \n :local License [/system/license/get];\r\ +< \n :local Resource [/system/resource/get];\r\ +< \n :set devBuildTime (\$Resource->\"build-time\");\r\ +< \n :set runningChannelVersion (\$Resource->\"version\");\r\ +< \n :set runningChannel [\$ParseCustom \$runningChannelVersion \"(\" \")\ +< \" 1];\r\ +< \n :set runningVersion [\$ParseCustom \$runningChannelVersion \" \"];\r\ +< \n\r\ +< \n :do {\r\ +< \n :if ([:pick \$devBoardName 0 3] != \"CHR\" or [:pick \$devBoardName 0\ +< \_3] != \"x86\") do={\r\ +< \n :local RouterBoard;\r\ +< \n :do {:set RouterBoard [[ :parse \"/system/routerboard/get\" ]]} on\ +< -error={}\r\ +< \n :set devModel (\$RouterBoard->\"model\");\r\ +< \n :set devRbRevision (\$RouterBoard->\"revision\");\r\ +< \n :set devRbSerialNumber (\$RouterBoard->\"serial-number\");\r\ +< \n #:set devRbCurrentFw (\$RouterBoard->\"current-firmware\");\r\ +< \n #:set devRbUpgradeFw (\$RouterBoard->\"upgrade-firmware\");\r\ +< \n :if (\$devCurArch = \"mipsbe\" || \$devCurArch = \"arm\") do={\r\ +< \n :global devRunning [ /system/device-mode/get mode ];\r\ +< \n } else={\r\ +< \n :global devRunning [/system/device-mode/get running];}\r\ +< \n } else={\r\ +< \n :set devModel \$devBoardName;\r\ +< \n \r\ +< \n :set devRbRevision false;\r\ +< \n :set devRbSerialNumber false;\r\ +< \n# :set devRbCurrentFw false;\r\ +< \n# :set devRbUpgradeFw false;\r\ +< \n #:set devCurrentFw \$runningVersion;#:set devUpgradeFw \$ROsVerAvail\ +< ;\r\ +< \n :set devRunning [/system/device-mode/get running];\r\ +< \n }\r\ +< \n } on-error={\r\ +< \n \$LogPrint error \$0 (\"Error in Function getDevice!\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n:return true;\r\ +< \n}\r\ +< \n\r\ +< \n:set DeviceInfo do={\r\ +< \n :global WaitArrDeviceInfo;\r\ +< \n # \$WaitDeviceInfo;\r\ +< \n :global devBoardName;\r\ +< \n :global devCurArch;\r\ +< \n :global devModel;\r\ +< \n :global devRunning;\r\ +< \n :global devRbRevision;\r\ +< \n :global devRbSerialNumber;\r\ +< \n :global PiblicIpAddress;\r\ +< \n\r\ +< \n :global GlobalConfVersion;\r\ +< \n :global Identity;\r\ +< \n :global IfThenElse;\r\ +< \n :global FormatLine;\r\ +< \n :local Return;\r\ +< \n :local License [/system/license/get];\r\ +< \n :local Resource [/system/resource/get];\r\ +< \n :local Snmp [ /snmp/get ];\r\ +< \n :local Update [ /system/package/update/get ];\r\ +< \n\r\ +< \n :set Return ([ \$FormatLine \"Hostname:\" \$Identity ] . \"\\n\" . \\\ +< \r\ +< \n [ \$IfThenElse ([ :len (\$Snmp->\"location\") ] > 0) \\\r\ +< \n ([ \$FormatLine \"Location:\" (\$Snmp->\"location\") ] . \"\\n\") \ +< ] . \\\r\ +< \n [ \$IfThenElse ([ :len (\$Snmp->\"contact\") ] > 0) \\\r\ +< \n ([ \$FormatLine \"Contact:\" (\$Snmp->\"contact\") ] . \"\\n\") ] \ +< . \\\r\ +< \n \"Hardware:\\n\" . \\\r\ +< \n [ \$FormatLine \" Board:\" . \$devBoardName ] . \"\\n\" . \\\r\ +< \n [ \$FormatLine \" Arch:\" . \$devCurArch ] . \"\\n\" . \\\r\ +< \n [ \$FormatLine \" Model:\" \$devModel ] . \\\r\ +< \n [ \$IfThenElse ([ :len \$devRbRevision ] > 0) \\\r\ +< \n (\" \" . \$devRbRevision) ] . \"\\n\" . \\\r\ +< \n [ \$IfThenElse ([ :len \$devRbSerialNumber ] > 0) \\\r\ +< \n ([ \$FormatLine \" Serial:\" . \$devRbSerialNumber ] . \"\\n\"\ +< ) ] . \\\r\ +< \n [ \$IfThenElse ([ :len (\$License->\"nlevel\") ] > 0) \\\r\ +< \n ([ \$FormatLine \" License:\" (\"level \" . (\$License->\"nleve\ +< l\")) ] . \"\\n\") ] . \"RouterOS:\\n\" . \\\r\ +< \n [ \$IfThenElse ([ :len (\$License->\"level\") ] > 0) \\\r\ +< \n ([ \$FormatLine \" License:\" (\"level \" . (\$License->\"level\ +< \")) ] . \"\\n\") ] . \\\r\ +< \n [ \$FormatLine \"Running Channel\" \$runningChannel ] . \"\\n\" . \\\ +< \r\ +< \n [ \$FormatLine \" Installed:\" (\$Update->\"installed-version\") \ +< ] . \"\\n\" . \\\r\ +< \n [ \$IfThenElse ([ :typeof (\$Update->\"latest-version\") ] != \"noth\ +< ing\" && \\\r\ +< \n \$Update->\"installed-version\" != \$Update->\"latest-version\")\ +< \_\\\r\ +< \n ([ \$FormatLine \" Available\" (\$Update->\"latest-version\") ]\ +< \_. \"\\n\") ] . \\\r\ +< \n [ \$IfThenElse (\$RouterBoard->\"routerboard\" = true && \\\r\ +< \n \$RouterBoard->\"current-firmware\" != \$RouterBoard->\"upgrade-\ +< firmware\") \\\r\ +< \n ([ \$FormatLine \" Firmware\" (\$RouterBoard->\"current-firmwar\ +< e\") ] . \"\\n\") ] . \\ \r\ +< \n \"RouterOS-Scripts:\\n\" . \\\r\ +< \n [ \$FormatLine \" Commit\" [ \$CommitBrief ] ] . \"\\n\" . \\\r\ +< \n [ \$FormatLine \" Version\" \$GlobalConfVersion ]);\r\ +< \n}\r\ +< \n\r\ +< \n:if ([ :typeof \$NotificationFunctions ] != \"array\") do={:set Notifica\ +< tionFunctions ({})}\r\ +< \n:set GetRandom20CharAlNum do={\r\ +< \n :global EitherOr;\r\ +< \n :return [ :rndstr length=[ \$EitherOr [ :tonum \$1 ] 20 ] from=\"ABCDE\ +< FGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\" ];\r\ +< \n}\r\ +< \n\r\ +< \n:global checkRunJob;\r\ +< \n:set checkRunJob do={\r\ +< \n :local Script [ :tostr \$1 ];\r\ +< \n :global ScriptLock; \r\ +< \n :if ([ \$ScriptLock \$Script ] = false) do={:return false}\r\ +< \n :foreach Job in=[ /system/script/job/find where script=\$Script ] do={\ +< :set Job [ /system/script/job/get \$Job ];\r\ +< \n :while ([ :typeof (\$Job->\"parent\") ] = \"id\") do={:set Job [ /sy\ +< stem/script/job/get [ find where .id=(\$Job->\"parent\") ] ]}\r\ +< \n :if ((\$Job->\"type\") = \"login\") do={:return true};}; :return fa\ +< lse; \r\ +< \n}\r\ +< \n\r\ +< \n:set InspectVar do={\r\ +< \n :global InspectVarRet;\r\ +< \n :put [ :tocrlf [ \$InspectVarRet \$1 ] ];\r\ +< \n}\r\ +< \n\r\ +< \n:set CommitBrief do={\r\ +< \n :global CommitId;\r\ +< \n :global CommitInfo;\r\ +< \n :if (\$CommitId = \"unknown\") do={\r\ +< \n :return \"unknown\";\r\ +< \n }\r\ +< \n :return (\$CommitInfo . \"/\" . [ :pick \$CommitId 0 8 ]);\r\ +< \n}\r\ +< \n\r\ +< \n:set InspectVarRet do={\r\ +< \n :local Input \$1;\r\ +< \n :local Level (0 + [ :tonum \$2 ]);\r\ +< \n :global CharacterReplace;\r\ +< \n :global IfThenElse;\r\ +< \n :global InspectVarRet;\r\ +< \n :local IndentReturn do={\r\ +< \n :local Prefix [ :tostr \$1 ];\r\ +< \n :local Value [ :tostr \$2 ];\r\ +< \n :local Level [ :tonum \$3 ];\r\ +< \n :global CharacterMultiply;\r\ +< \n :return ([ \$CharacterMultiply \" \" (\$Level * 2) ] . \"-\" . \$Pre\ +< fix . \"-> \" . \$Value);\r\ +< \n }\r\ +< \n :local TypeOf [ :typeof \$Input ];\r\ +< \n :local Len [ :len \$Input ];\r\ +< \n :local Return [ \$IndentReturn \"type\" \$TypeOf \$Level ];\r\ +< \n :if (\$TypeOf = \"array\") do={\r\ +< \n :foreach Key,Value in=\$Input do={\r\ +< \n :set \$Return (\$Return . \"\\n\" . \\\r\ +< \n [ \$IndentReturn \"key\" \$Key (\$Level + 1) ] . \"\\n\" . \\\r\ +< \n [ \$InspectVarRet \$Value (\$Level + 2) ]);\r\ +< \n }\r\ +< \n } else={\r\ +< \n :if (\$TypeOf = \"str\") do={\r\ +< \n :set \$Return (\$Return . \"\\n\" . \\\r\ +< \n [ \$IndentReturn \"len\" \$Len \$Level ]);\r\ +< \n :if ([ :typeof [ :find \$Input (\"\\r\") ] ] = \"num\") do={\r\ +< \n :set Input [ \$CharacterReplace \$Input (\"\\r\") \"\" ];\r\ +< \n }\r\ +< \n :if ([ :typeof [ :find \$Input (\"\\n\") ] ] = \"num\") do={\r\ +< \n :set Input [ \$CharacterReplace \$Input (\"\\n\") \" \" ];\r\ +< \n }\r\ +< \n }\r\ +< \n :if (\$TypeOf != \"nothing\") do={\r\ +< \n :set \$Return (\$Return . \"\\n\" . \\\r\ +< \n [ \$IndentReturn \"value\" [ \$IfThenElse ([ :len \$Input ] > 80)\ +< \_\\\r\ +< \n ([ :pick \$Input 0 77 ] . \"...\") \$Input ] \$Level ]);\r\ +< \n }\r\ +< \n }\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n\r\ +< \n# !!! The function is not ready !!!\r\ +< \n:global FetchHttpInfo do={\r\ +< \n :local Mac [ :tostr \$1 ];\r\ +< \n :global CertificateAvailable;\r\ +< \n :global IsMacLocallyAdministered;\r\ +< \n :global LogPrint;\r\ +< \n :local Url \"https://api.macvendors.com/\";\r\ +< \n :if ([ \$IsMacLocallyAdministered \$Mac ] = true) do={:return \"locall\ +< y administered\";}\r\ +< \n :do {\r\ +< \n :if ([ \$CertificateAvailable \"GTS Root R4\" \"fetch\" ] = false) d\ +< o={\r\ +< \n \$LogPrint warning \$0 (\"Downloading required certificate failed.\ +< \");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n :local Vendor ([ /tool/fetch \r\ +< \n (\$Url . [ :pick \$Mac 0 8 ]) output=user as-value ]->\"data\");\r\ +< \n :return \$Vendor;\r\ +< \n } on-error={\r\ +< \n :onerror Err {\r\ +< \n /tool/fetch check-certificate=yes-without-crl (\$Url) output=none \ +< as-value;\r\ +< \n \$LogPrint debug \$0 (\"The mac vendor is not known in database.\"\ +< );\r\ +< \n } do={ \$LogPrint warning \$0 (\"Failed getting mac vendor: \" . \$E\ +< rr); }\r\ +< \n :return \"unknown vendor\";\r\ +< \n }\r\ +< \n}\r\ +< \n\r\ +< \n:set GetPubIp do={\r\ +< \n :global DetectIpAddrDefault;\r\ +< \n :global DetectIpAddrFallback;\r\ +< \n :global LogPrint;\r\ +< \n \r\ +< \n :local PubIpAddr false;\r\ +< \n :local Url \$DetectIpAddrDefault;\r\ +< \n\r\ +< \n# :retry command={abc} delay=1 max=2 on-error={:put \"got error\"} \r\ +< \n :do {\r\ +< \n \$LogPrint debug \$0 (\"Trying to detect public IP using default s\ +< ervice: \" . \$Url . \"...\");\r\ +< \n :retry command={:set PubIpAddr ([ /tool/fetch http-method=\"get\"\ +< \_check-certificate=yes-without-crl \$Url output=user as-value ]->\"data\"\ +< )} \\\r\ +< \n delay=50ms max=5 on-error={\$LogPrint error [ :jobname ] (\"Fail\ +< ed to detect public IP using default service: \" . \$Url . \".\")}\r\ +< \n #:error \"Failed to detect public IP using default service: \$Url\ +< .\"};\r\ +< \n } on-error={\r\ +< \n \$LogPrint error \$0 (\"Failed to detect public IP using default s\ +< ervice: \" . \$Url . \".\");\r\ +< \n :set Url \$DetectIpAddrFallBack;\r\ +< \n \$LogPrint debug \$0 (\"Trying to detect public IP using fallback \ +< service: \" . \$Url . \"...\");\r\ +< \n :retry command={:set PubIpAddr ([ /tool/fetch http-method=\"get\"\ +< \_check-certificate=yes-without-crl \$Url output=user as-value ]->\"data\"\ +< )} \\\r\ +< \n delay=200ms max=5 on-error={\$LogPrint error [ :jobname ] (\"Fai\ +< led to detect public IP using fallback service: \" . \$Url . \".\")}\r\ +< \n };\r\ +< \n :if (\$PubIpAddr = false) do={\r\ +< \n :set PubIpAddr \"not-detected\";\r\ +< \n } else={\r\ +< \n :set PubIpAddr [ :pick \$PubIpAddr 0 15];\r\ +< \n }\r\ +< \n :return \$PubIpAddr;\r\ +< \n}\r\ +< \n\r\ +< \n:set FormatLine do={\r\ +< \n :local Key [ :tostr \$1 ];\r\ +< \n :local Value [ :tostr \$2 ];\r\ +< \n :local Indent [ :tonum \$3 ];\r\ +< \n :local Spaces;\r\ +< \n :local Return \"\";\r\ +< \n :global CharacterMultiply;\r\ +< \n :global EitherOr;\r\ +< \n :set Indent [ \$EitherOr \$Indent 16 ];\r\ +< \n :local Spaces [ \$CharacterMultiply \" \" \$Indent ];\r\ +< \n :if ([ :len \$Key ] > 0) do={ :set Return (\$Key . \":\")}\r\ +< \n :if ([ :len \$Key ] > (\$Indent - 2)) do={:set Return (\$Return . \"\\\ +< n\" . [ :pick \$Spaces 0 \$Indent ] . \$Value);\r\ +< \n } else={:set Return (\$Return . [ :pick \$Spaces 0 (\$Indent - [ :len \ +< \$Return ]) ] . \$Value)}\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n\r\ +< \n:set ParseCustom do={\r\ +< \n :local Str [ :tostr \$1 ];\r\ +< \n :local Start [:find [ \$Str ] [:tostr \$2]];\r\ +< \n :local End [ :tostr \$3 ];\r\ +< \n :local Num [ :tonum \$4 ];\r\ +< \n :local Return;\r\ +< \n :if ([:len \$Num] = 0) do={:set Num \"0\"}\r\ +< \n :local rest [:pick \$Str (\$Start+\$Num) [:len \$Str]]; \r\ +< \n :if ([:len \$End ] = 0) do={:set Return [:pick \$Str \$Num \$Start]} e\ +< lse={\r\ +< \n :set End [:find \$rest \$End];\r\ +< \n :set Return [:pick \$rest 0 \$End];\r\ +< \n }\r\ +< \n:return \$Return;\r\ +< \n}\r\ +< \n\r\ +< \n:set LogPrint do={\r\ +< \n :local Severity [ :tostr \$1 ];\r\ +< \n :local Name [ :tostr \$2 ];\r\ +< \n :local Message [ :tostr \$3 ];\r\ +< \n :global PrintDebug;\r\ +< \n :global PrintDebugOverride;\r\ +< \n :global EitherOr;\r\ +< \n :local Debug [ \$EitherOr (\$PrintDebugOverride->\$Name) \$PrintDebug \ +< ];\r\ +< \n :local PrintSeverity do={\r\ +< \n :global TerminalColorOutput;\r\ +< \n :if (\$TerminalColorOutput != true) do={:return \$1}\r\ +< \n :local Color { debug=96; info=97; warning=93; error=91 };\r\ +< \n :return (\"\\1B[\" . \$Color->\$1 . \"m\" . \$1 . \"\\1B[0m\");\r\ +< \n}\r\ +< \n :local Log ([ \$EitherOr \$Name \"\" ] . \": \" . \$Message);\ +< \r\ +< \n :if (\$Severity ~ (\"^(custom|debug|error|info)\\\$\")) do={\r\ +< \n :if (\$Severity = \"debug\") do={:log debug \$Log}\r\ +< \n :if (\$Severity = \"error\") do={:log error \$Log}\r\ +< \n :if (\$Severity = \"info\" ) do={:log info \$Log}\r\ +< \n } else={:log warning \$Log; :set Severity \"warning\"}\r\ +< \n :if (\$Severity != \"debug\" || \$Debug = true) do={:put ([ \$PrintSev\ +< erity \$Severity ] . \": \" . \$Message)}\r\ +< \n}\r\ +< \n\r\ +< \n:set CertificateAvailable do={\r\ +< \n :local CommonName [ :tostr \$1 ];\r\ +< \n :local UseFor [ :tostr \$2 ];\r\ +< \n :global CertificateDownload;\r\ +< \n :global EitherOr;\r\ +< \n :global LogPrint;\r\ +< \n :global ParseKeyValueStore;\r\ +< \n :set UseFor [ \$EitherOr \$UseFor \"undefined\" ];\r\ +< \n :if ([ /system/resource/get free-hdd-space ] < 8388608 && \\\r\ +< \n [ /certificate/settings/get crl-download ] = true && \\\r\ +< \n [ /certificate/settings/get crl-store ] = \"system\") do={\r\ +< \n \$LogPrint warning \$0 (\"This system has low free flash space but \ +< \" . \\\r\ +< \n \"is configured to download certificate CRLs to system!\");\r\ +< \n }\r\ +< \n :if ([ :len \$CommonName ] = 0) do={\r\ +< \n \$LogPrint warning \$0 (\"No CommonName given!\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local CertSettings [ /certificate/settings/get ];\r\ +< \n :if (((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" || \\\ +< \r\ +< \n (\$CertSettings->\"builtin-trust-store\") ~ \$UseFor || \\\r\ +< \n (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\r\ +< \n [ :len [ /certificate/builtin/find where common-name=\$CommonName\ +< \_] ] > 0) do={\r\ +< \n :return true;\r\ +< \n }\r\ +< \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] = 0\ +< ) do={\r\ +< \n \$LogPrint info \$0 (\"Certificate with CommonName '\" . \$CommonNam\ +< e . \"' not available.\");\r\ +< \n :if ([ \$CertificateDownload \$CommonName ] = false) do={:return fal\ +< se}\r\ +< \n }\r\ +< \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] > 1\ +< ) do={\r\ +< \n \$LogPrint info \$0 (\"There are \" . \$CertCount . \" Certificates \ +< with CommonName '\" . \$CommonName . \"'. Should be ok.\");\r\ +< \n :return true;\r\ +< \n }\r\ +< \n :local CertVal [ /certificate/get [ find where common-name=\$CommonNam\ +< e ] ];\r\ +< \n :while ((\$CertVal->\"akid\") != \"\" && (\$CertVal->\"akid\") != (\$C\ +< ertVal->\"skid\")) do={\r\ +< \n :if ([ :len [ /certificate/find where skid=(\$CertVal->\"akid\") ] ]\ +< \_= 0) do={\r\ +< \n :local IssuerCN ([ \$ParseKeyValueStore (\$CertVal->\"issuer\") ]-\ +< >\"CN\");\r\ +< \n \$LogPrint info \$0 (\"Certificate chain for '\" . \$CommonName . \ +< \"' is incomplete, missing '\" . \$IssuerCN . \"'.\");\r\ +< \n :if ([ \$CertificateDownload \$IssuerCN ] = false) do={:return fal\ +< se}\r\ +< \n }\r\ +< \n :set CertVal [ /certificate/get [ find where skid=(\$CertVal->\"akid\ +< \") ] ];\r\ +< \n }\r\ +< \n :return true;\r\ +< \n}\r\ +< \n\r\ +< \n:set CertificateDownload do={\r\ +< \n :local CommonName [ :tostr \$1 ];\r\ +< \n :global GlobalScriptsUrl;\r\ +< \n :global GlobalScriptsUrlSuffix;\r\ +< \n :global CertificateNameByCN;\r\ +< \n :global CleanName;\r\ +< \n :global FetchUserAgentStr;\r\ +< \n :global LogPrint;\r\ +< \n :global RmFile;\r\ +< \n :global WaitForFile;\r\ +< \n \r\ +< \n \$LogPrint info \$0 (\"Downloading and importing certificate with Comm\ +< onName '\" . \$CommonName . \"'.\");\r\ +< \n \r\ +< \n :local FileName ([ \$CleanName \$CommonName ] . \".pem\");\r\ +< \n :do {\r\ +< \n /tool/fetch check-certificate=yes-without-crl http-header-field=({ [\ +< \_\$FetchUserAgentStr \$0 ] }) \\\r\ +< \n (\$GlobalScriptsUrl . \"certs/\" . \$FileName . \$GlobalScriptsUrl\ +< Suffix) dst-path=\$FileName as-value;\r\ +< \n \$WaitForFile \$FileName;\r\ +< \n } on-error={\r\ +< \n \$LogPrint warning \$0 (\"Failed downloading certificate with Common\ +< Name '\" . \$CommonName . \\\r\ +< \n \"' from repository! Trying fallback to mkcert.org...\");\r\ +< \n :do {\r\ +< \n :if ([ :len [ /certificate/find where common-name=\"ISRG Root X1\"\ +< \_] ] = 0) do={\r\ +< \n \$LogPrint error \$0 (\"Required certificate is not available.\"\ +< );\r\ +< \n :return false;\r\ +< \n }\r\ +< \n /tool/fetch check-certificate=yes-without-crl http-header-field=({\ +< \_[ \$FetchUserAgentStr \$0 ] }) \\\r\ +< \n \"https://mkcert.org/generate/\" http-data=[ :serialize to=json \ +< ({ \$CommonName }) ] \\\r\ +< \n dst-path=\$FileName as-value;\r\ +< \n \$WaitForFile \$FileName;\r\ +< \n :if ([ /file/get \$FileName size ] = 0) do={\r\ +< \n \$RmFile \$FileName;\r\ +< \n :error false;\r\ +< \n }\r\ +< \n } on-error={\r\ +< \n \$LogPrint warning \$0 (\"Failed downloading certificate with Comm\ +< onName '\" . \$CommonName . \"'!\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n }\r\ +< \n\r\ +< \n /certificate/import file-name=\$FileName passphrase=\"\" as-value;\r\ +< \n :delay 1s;\r\ +< \n \$RmFile \$FileName;\r\ +< \n\r\ +< \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] = 0\ +< ) do={\r\ +< \n /certificate/remove [ find where name~(\"^\" . \$FileName . \"_[0-9]\ +< +\\\$\") ];\r\ +< \n \$LogPrint warning \$0 (\"Certificate with CommonName '\" . \$Common\ +< Name . \"' still unavailable!\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :foreach Cert in=[ /certificate/find where name~(\"^\" . \$FileName . \ +< \"_[0-9]+\\\$\") ] do={\r\ +< \n \$CertificateNameByCN [ /certificate/get \$Cert common-name ];\r\ +< \n }\r\ +< \n :return true;\r\ +< \n}\r\ +< \n\r\ +< \n:set CertificateNameByCN do={\r\ +< \n :local Match [ :tostr \$1 ];\r\ +< \n :global CleanName;\r\ +< \n :global LogPrint;\r\ +< \n :local Cert ([ /certificate/find where (common-name=\$Match or fingerp\ +< rint=\$Match or name=\$Match) ]->0);\r\ +< \n :if ([ :len \$Cert ] = 0) do={\r\ +< \n \$LogPrint warning \$0 (\"No matching certificate found.\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local CommonName [ /certificate/get \$Cert common-name ];\r\ +< \n /certificate/set \$Cert name=[ \$CleanName \$CommonName ];\r\ +< \n :return true;\r\ +< \n}\r\ +< \n\r\ +< \n:set CharacterMultiply do={\r\ +< \n :local Str [ :tostr \$1 ];\r\ +< \n :local Num [ :tonum \$2 ];\r\ +< \n :if (\$Num = 0) do={:return \"\"}\r\ +< \n :local Return \"\";\r\ +< \n :for I from=1 to=\$Num do={:set Return (\$Return . \$Str)}\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n\r\ +< \n:set FetchUserAgentStr do={\r\ +< \n :local Caller [ :tostr \$1 ];\r\ +< \n :global IfThenElse;\r\ +< \n :local Resource [ /system/resource/get ];\r\ +< \n :return (\"User-Agent: Mikrotik/\" . \$Resource->\"version\" . \" \" .\ +< \_\$Resource->\"architecture-name\" . \\\r\ +< \n \" \" . \$Caller . \"/Fetch (https://amster.vados.ru/; main/3419/3ee\ +< 19780)\");\r\ +< \n}\r\ +< \n\r\ +< \n:set Grep do={\r\ +< \n :local Input ([ :tostr \$1 ] . \"\\n\");\r\ +< \n :local Pattern [ :tostr \$2 ];\r\ +< \n :if ([ :typeof [ :find \$Input \$Pattern ] ] = \"nil\") do={:return []\ +< }\r\ +< \n :do {\r\ +< \n :local Line [ :pick \$Input 0 [ :find \$Input \"\\n\" ] ];\r\ +< \n :if ([ :typeof [ :find \$Line \$Pattern ] ] = \"num\") do={:return \ +< \$Line}\r\ +< \n :set Input [ :pick \$Input ([ :find \$Input \"\\n\" ] + 1) [ :len \$\ +< Input ] ];\r\ +< \n } while=([ :len \$Input ] > 0);\r\ +< \n :return [];\r\ +< \n}\r\ +< \n\r\ +< \n:set HumanReadableNum do={\r\ +< \n :local Input [ :tonum \$1 ];\r\ +< \n :local Base [ :tonum \$2 ];\r\ +< \n :global EitherOr;\r\ +< \n :global IfThenElse;\r\ +< \n :local Prefix \"kMGTPE\";\r\ +< \n :local Pow 1;\r\ +< \n :set Base [ \$EitherOr \$Base 1024 ];\r\ +< \n :local Bin [ \$IfThenElse (\$Base = 1024) \"i\" \"\" ];\r\ +< \n :if (\$Input < \$Base) do={:return \$Input}\r\ +< \n :for I from=0 to=[ :len \$Prefix ] do={\r\ +< \n :set Pow (\$Pow * \$Base);\r\ +< \n :if (\$Input / \$Base < \$Pow) do={\r\ +< \n :set Prefix [ :pick \$Prefix \$I ];\r\ +< \n :local Tmp1 (\$Input * 100 / \$Pow);\r\ +< \n :local Tmp2 (\$Tmp1 / 100);\r\ +< \n :if (\$Tmp2 >= 100) do={:return (\$Tmp2 . \$Prefix . \$Bin)}\r\ +< \n :return (\$Tmp2 . \".\" . \\\r\ +< \n [ :pick \$Tmp1 [ :len \$Tmp2 ] ([ :len \$Tmp1 ] - [ :len \$Tmp\ +< 2 ] + 1) ] . \\\r\ +< \n \$Prefix . \$Bin);\r\ +< \n }\r\ +< \n }\r\ +< \n}\r\ +< \n\r\ +< \n:set CleanName do={\r\ +< \n :local Input [ :tostr \$1 ];\r\ +< \n :local Return \"\";\r\ +< \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ +< \n :local Char [ :pick \$Input \$I ];\r\ +< \n :if ([ :typeof [ find \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr\ +< stuvwxyz0123456789\" \$Char ] ] = \"nil\") do={\r\ +< \n :do {:if ([ :len \$Return ] = 0) do={:error true};\r\ +< \n :if ([ :pick \$Return ([ :len \$Return ] - 1) ] = \"-\") do={:er\ +< ror true}; :set Char \"-\"} on-error={:set Char \"\"}; \r\ +< \n };\r\ +< \n :set Return (\$Return . \$Char)};\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n\r\ +< \n:set GetRandomNumber do={\r\ +< \n :global EitherOr;\r\ +< \n :return [ :rndnum from=0 to=[ \$EitherOr [ :tonum \$1 ] 4294967295 ] ]\ +< \r\ +< \n}\r\ +< \n\r\ +< \n:set RandomDelay do={\r\ +< \n :local Time [ :tonum \$1 ];\r\ +< \n :local Unit [ :tostr \$2 ];\r\ +< \n :global EitherOr;\r\ +< \n :global GetRandomNumber;\r\ +< \n :global MAX;\r\ +< \n :if (\$Time = 0) do={:return false}\r\ +< \n :delay ([ \$MAX 10 [ \$GetRandomNumber ([ :tonsec [ :totime (\$Time . \ +< [ \$EitherOr \$Unit \"s\" ]) ] ] / 1000000) ] ] . \"ms\");\r\ +< \n}\r\ +< \n\r\ +< \n:set EscapeForRegEx do={\r\ +< \n :local Input [ :tostr \$1 ];\r\ +< \n :if ([ :len \$Input ] = 0) do={:return \"\"}\r\ +< \n :local Return \"\";\r\ +< \n :local Chars (\"^.[]\\\$()|*+\?{}\\\\\");\r\ +< \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ +< \n :local Char [ :pick \$Input \$I ];\r\ +< \n :if ([ :find \$Chars \$Char ]) do={:set Char (\"\\\\\" . \$Char)}\r\ +< \n :set Return (\$Return . \$Char);\r\ +< \n }\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n:set ExitError do={\r\ +< \n :local ExitOK [ :tostr \$1 ];\r\ +< \n :local Name [ :tostr \$2 ];\r\ +< \n :local Error [ :tostr \$3 ];\r\ +< \n :global IfThenElse;\r\ +< \n :global LogPrint;\r\ +< \n :if (\$ExitOK = \"false\") do={\r\ +< \n \$LogPrint error \$Name ([ \$IfThenElse ([ :pick \$Name 0 1 ] = \"\\\ +< \$\") \\\r\ +< \n \"Function\" \"Script\" ] . \" '\" . \$Name . \"' exited with er\ +< ror\" . \\\r\ +< \n [ \$IfThenElse (!(\$Error ~ \"^(|true|false)\\\$\")) (\": \" . \ +< \$Error) \".\" ]);\r\ +< \n }\r\ +< \n}\r\ +< \n\r\ +< \n:set MiniDateTimeStamp do={\r\ +< \n /system/clock;\r\ +< \n :local vdate [get date];\r\ +< \n :local vtime [get time];\r\ +< \n :local vdoff [:toarray \"0,4,5,7,8,10\"];\r\ +< \n :local MM [:pick \$vdate (\$vdoff->2) (\$vdoff->3)];\r\ +< \n :local M [:tonum \$MM];\r\ +< \n :if (\$vdate ~ \".../../....\") do={\r\ +< \n :set vdoff [:toarray \"7,11,1,3,4,6\"];\r\ +< \n :set M ([:find \"xxanebarprayunulugepctovecANEBARPRAYUNULUGE\ +< PCTOVEC\" [:pick \$vdate (\$vdoff->2) (\$vdoff->3)] -1] / 2);\r\ +< \n :if (\$M>12) do={:set M (\$M - 12)}\r\ +< \n :set MM [:pick (100 + \$M) 1 3];\r\ +< \n }\r\ +< \n :local yyyy [:pick \$vdate (\$vdoff->0) (\$vdoff->1)];\r\ +< \n :local dd [:pick \$vdate (\$vdoff->4) (\$vdoff->5)];\r\ +< \n :local HH [:pick \$vtime 0 2];\r\ +< \n :local mm [:pick \$vtime 3 5];\r\ +< \n :local ss [:pick \$vtime 6 8];\r\ +< \n :return ([\$yyyy] . [\$MM] . [\$dd] . [\$HH] . [\$mm] . [\$ss]);\r\ +< \n}\r\ +< \n\r\ +< \n:set WaitForFile do={\r\ +< \n :local FileName [ :tostr \$1 ];\r\ +< \n :local WaitTime [ :totime \$2 ];\r\ +< \n :global CleanFilePath;\r\ +< \n :global EitherOr;\r\ +< \n :global MAX;\r\ +< \n :set FileName [ \$CleanFilePath \$FileName ];\r\ +< \n :local Delay ([ \$MAX [ \$EitherOr \$WaitTime 2s ] 100ms ] / 9);\r\ +< \n :do {\r\ +< \n :retry {\r\ +< \n /file/get \$FileName;\r\ +< \n :return true;\r\ +< \n } delay=\$Delay max=10;\r\ +< \n } on-error={ }\r\ +< \n :while ([ :len [ /file/find where name=\$FileName ] ] > 0) do={\r\ +< \n :do {\r\ +< \n /file/get \$FileName;\r\ +< \n :return true;\r\ +< \n } on-error={ }\r\ +< \n :delay \$Delay;\r\ +< \n :set Delay (\$Delay * 3 / 2);\r\ +< \n }\r\ +< \n :return false;\r\ +< \n}\r\ +< \n\r\ +< \n:set FileGet do={\r\ +< \n :local FileName [ :tostr \$1 ];\r\ +< \n :global WaitForFile;\r\ +< \n :if ([ \$WaitForFile \$FileName 0s ] = false) do={:return false}\r\ +< \n :local FileVal false;\r\ +< \n :do {:set FileVal [ /file/get \$FileName ];\r\ +< \n } on-error={ }\r\ +< \n :return \$FileVal;\r\ +< \n}\r\ +< \n\r\ +< \n:set RmDir do={\r\ +< \n :local DirName [ :tostr \$1 ];\r\ +< \n :global FileGet;\r\ +< \n :global LogPrint;\r\ +< \n \$LogPrint debug \$0 (\"Removing directory: \". \$DirName);\r\ +< \n :local DirVal [ \$FileGet \$DirName ];\r\ +< \n :if (\$DirVal = false) do={\$LogPrint debug \$0 (\"... which does not \ +< exist.\"); :return true};\r\ +< \n :if (\$DirVal->\"type\" != \"directory\") do={\$LogPrint error \$0 (\"\ +< Directory '\" . \$DirName . \"' is not a directory.\"); :return false};\r\ +< \n :onerror Err {/file/remove \$DirName} do={\$LogPrint error \$0 (\"Remo\ +< ving directory '\" . \$DirName . \"' failed: \" . \$Err); :return false};\ +< \r\ +< \n :return true;\r\ +< \n}\r\ +< \n\r\ +< \n:set RmFile do={\r\ +< \n :local FileName [ :tostr \$1 ];\r\ +< \n :global FileGet;\r\ +< \n :global LogPrint;\r\ +< \n \$LogPrint debug \$0 (\"Removing file: \". \$FileName);\r\ +< \n :local FileVal [ \$FileGet \$FileName ];\r\ +< \n :if (\$FileVal = false) do={\$LogPrint debug \$0 (\"... which does not\ +< \_exist.\"); :return true}\r\ +< \n :if (\$FileVal->\"type\" = \"directory\" || \$FileVal->\"type\" = \"di\ +< sk\") do={\r\ +< \n \$LogPrint error \$0 (\"File '\" . \$FileName . \"' is not a file.\"\ +< ); :return false}\r\ +< \n :onerror Err {\r\ +< \n /file/remove \$FileName;\r\ +< \n } do={\$LogPrint error \$0 (\"Removing file '\" . \$FileName . \"' fai\ +< led: \" . \$Err); :return false}\r\ +< \n :return true;\r\ +< \n}\r\ +< \n\r\ +< \n:set MkDir do={\r\ +< \n :local Path [ :tostr \$1 ];\r\ +< \n :global CleanFilePath;\r\ +< \n :global FileGet;\r\ +< \n :global RmDir;\r\ +< \n :global WaitForFile;\r\ +< \n :global LogPrint;\r\ +< \n :local MkTmpfs do={\r\ +< \n :global WaitForFile;\r\ +< \n :local TmpFs [ /disk/find where slot=tmpfs type=tmpfs ];\r\ +< \n :if ([ :len \$TmpFs ] = 1) do={\r\ +< \n :if ([ /disk/get \$TmpFs disabled ] = true) do={\r\ +< \n \$LogPrint info \$0 (\"The tmpfs is disabled, enabling.\");\r\ +< \n /disk/enable \$TmpFs;\r\ +< \n }\r\ +< \n :return true;\r\ +< \n }\r\ +< \n \$LogPrint info \$0 (\"Creating disk of type tmpfs.\");\r\ +< \n \$RmDir \"tmpfs\";\r\ +< \n :onerror Err {\r\ +< \n /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource\ +< /get total-memory ] / 3);\r\ +< \n \$WaitForFile \"tmpfs\";\r\ +< \n } do={\r\ +< \n \$LogPrint warning \$0 (\"Creating disk of type tmpfs failed: \" .\ +< \_\$Err);\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :return true;\r\ +< \n }\r\ +< \n :set Path [ \$CleanFilePath \$Path ];\r\ +< \n :if (\$Path = \"\") do={\r\ +< \n :return true;\r\ +< \n }\r\ +< \n \$LogPrint debug \$0 (\"Making directory: \" . \$Path);\r\ +< \n :local PathVal [ \$FileGet \$Path ];\r\ +< \n :if (\$PathVal->\"type\" = \"directory\") do={\r\ +< \n \$LogPrint debug \$0 (\"... which already exists.\");\r\ +< \n :return true;\r\ +< \n }\r\ +< \n :if ([ :pick \$Path 0 5 ] = \"tmpfs\") do={\r\ +< \n :if ([ \$MkTmpfs ] = false) do={\r\ +< \n :return false;\r\ +< \n }\r\ +< \n }\r\ +< \n :onerror Err {\r\ +< \n /file/add type=\"directory\" name=\$Path;\r\ +< \n \$WaitForFile \$Path;\r\ +< \n } do={\r\ +< \n \$LogPrint warning \$0 (\"Making directory '\" . \$Path . \"' failed\ +< : \" . \$Err);\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :return true;\r\ +< \n}\r\ +< \n\r\ +< \n:set MAX do={:if (\$1 > \$2) do={:return \$1}\r\ +< \n :return \$2;\r\ +< \n}\r\ +< \n:set MIN do={:if (\$1 < \$2) do={:return \$1}\r\ +< \n :return \$2;\r\ +< \n}\r\ +< \n\r\ +< \n:set CharacterMultiply do={\r\ +< \n :local Str [ :tostr \$1 ];\r\ +< \n :local Num [ :tonum \$2 ];\r\ +< \n :if (\$Num = 0) do={:return \"\"}\r\ +< \n :local Return \"\";\r\ +< \n :for I from=1 to=\$Num do={:set Return (\$Return . \$Str)}\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n\r\ +< \n:set CharacterReplace do={\r\ +< \n :local String [ :tostr \$1 ];\r\ +< \n :local ReplaceFrom [ :tostr \$2 ];\r\ +< \n :local ReplaceWith [ :tostr \$3 ];\r\ +< \n :local Return \"\";\r\ +< \n :if (\$ReplaceFrom = \"\") do={:return \$String}\r\ +< \n :while ([ :typeof [ :find \$String \$ReplaceFrom ] ] != \"nil\") do={\ +< \r\ +< \n :local Pos [ :find \$String \$ReplaceFrom ];\r\ +< \n :set Return (\$Return . [ :pick \$String 0 \$Pos ] . \$ReplaceWith);\ +< \r\ +< \n :set String [ :pick \$String (\$Pos + [ :len \$ReplaceFrom ]) [ :len\ +< \_\$String ] ];\r\ +< \n }\r\ +< \n :return (\$Return . \$String);\r\ +< \n}\r\ +< \n\r\ +< \n:set CleanFilePath do={\r\ +< \n :local Path [ :tostr \$1 ];\r\ +< \n :global CharacterReplace;\r\ +< \n :while (\$Path ~ \"//\") do={:set \$Path [ \$CharacterReplace \$Path \ +< \"//\" \"/\" ]};\r\ +< \n :if ([ :pick \$Path 0 ] = \"/\") do={:set Path [ :pick \$Path 1 [ :len\ +< \_\$Path ] ]};\r\ +< \n :if ([ :pick \$Path ([ :len \$Path ] - 1) ] = \"/\") do={:set Path [ :\ +< pick \$Path 0 ([ :len \$Path ] - 1) ]};\r\ +< \n :return \$Path;\r\ +< \n}\r\ +< \n\r\ +< \n:set IfThenElse do={\r\ +< \n :if ([ :tostr \$1 ] = \"true\" || [ :tobool \$1 ] = true) do={:return \ +< \$2};\r\ +< \n :return \$3;\r\ +< \n}\r\ +< \n\r\ +< \n:set EitherOr do={\r\ +< \n :global IfThenElse;\r\ +< \n :if ([ :typeof \$1 ] = \"num\") do={:return [ \$IfThenElse (\$1 != 0) \ +< \$1 \$2 ]}\r\ +< \n :if ([ :typeof \$1 ] = \"time\") do={:return [ \$IfThenElse (\$1 > 0s)\ +< \_\$1 \$2 ]}\r\ +< \n# this works for boolean values, literal ones with parentheses\r\ +< \n :return [ \$IfThenElse ([ :len [ :tostr \$1 ] ] > 0) \$1 \$2 ];\r\ +< \n}\r\ +< \n\r\ +< \n:set ParseKeyValueStore do={\r\ +< \n :local Source \$1;\r\ +< \n :if ([ :pick \$Source 0 1 ] = \"{\") do={\r\ +< \n :do {\r\ +< \n :return [ :deserialize from=json \$Source ];\r\ +< \n } on-error={ }\r\ +< \n } \r\ +< \n :if ([ :typeof \$Source ] != \"array\") do={:set Source [ :tostr \$1 ]\ +< }\r\ +< \n :local Result ({});\r\ +< \n :foreach KeyValue in=[ :toarray \$Source ] do={\r\ +< \n :if ([ :find \$KeyValue \"=\" ]) do={\r\ +< \n :local Key [ :pick \$KeyValue 0 [ :find \$KeyValue \"=\" ] ];\r\ +< \n :local Value [ :pick \$KeyValue ([ :find \$KeyValue \"=\" ] + 1) [\ +< \_:len \$KeyValue ] ];\r\ +< \n :if (\$Value=\"true\") do={:set Value true}\r\ +< \n :if (\$Value=\"false\") do={:set Value false}\r\ +< \n :set (\$Result->\$Key) \$Value;\r\ +< \n } else={:set (\$Result->\$KeyValue) true}\r\ +< \n }\r\ +< \n :return \$Result;\r\ +< \n}\r\ +< \n:set RequiredRouterOS do={\r\ +< \n :local Caller [ :tostr \$1 ];\r\ +< \n :local Required [ :tostr \$2 ];\r\ +< \n :local Warn [ :tostr \$3 ];\r\ +< \n :global IfThenElse;\r\ +< \n :global LogPrint;\r\ +< \n :global VersionToNum;\r\ +< \n :if (!(\$Required ~ \"^\\\\d+\\\\.\\\\d+((alpha|beta|rc|\\\\.)\\\\d+|)\ +< \\\$\")) do={\r\ +< \n \$LogPrint error \$0 (\"No valid RouterOS version: \" . \$Required);\ +< \r\ +< \n :return false;\r\ +< \n }\r\ +< \n :if ([ \$VersionToNum \$Required ] > [ \$VersionToNum [ /system/packag\ +< e/update/get installed-version ] ]) do={\r\ +< \n :if (\$Warn = \"true\") do={\r\ +< \n \$LogPrint warning \$0 (\"This \" . [ \$IfThenElse ([ :pick \$Call\ +< er 0 ] = (\"\\\$\")) \"function\" \"script\" ] . \\\r\ +< \n \" '\" . \$Caller . \"' (at least specific functionality) requir\ +< es RouterOS \" . \$Required . \". Please update!\");\r\ +< \n }\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :return true;\r\ +< \n}\r\ +< \n:set VersionToNum do={\r\ +< \n :local Input [ :tostr \$1 ];\r\ +< \n :local Multi 0x1000000;\r\ +< \n :local Return 0;\r\ +< \n :global CharacterReplace;\r\ +< \n :set Input [ \$CharacterReplace \$Input \".\" \",\" ];\r\ +< \n :foreach I in={ \"zero\"; \"alpha\"; \"beta\"; \"rc\" } do={\r\ +< \n :set Input [ \$CharacterReplace \$Input \$I (\",\" . \$I . \",\") ];\ +< \r\ +< \n }\r\ +< \n :foreach Value in=([ :toarray \$Input ], 0) do={\r\ +< \n :local Num [ :tonum \$Value ];\r\ +< \n :if (\$Multi = 0x100) do={\r\ +< \n :if ([ :typeof \$Num ] = \"num\") do={\r\ +< \n :set Return (\$Return + 0xff00);\r\ +< \n :set Multi (\$Multi / 0x100);\r\ +< \n } else={\r\ +< \n :if (\$Value = \"zero\") do={ }\r\ +< \n :if (\$Value = \"alpha\") do={ :set Return (\$Return + 0x3f00); \ +< }\r\ +< \n :if (\$Value = \"beta\") do={ :set Return (\$Return + 0x5f00); }\ +< \r\ +< \n :if (\$Value = \"rc\") do={ :set Return (\$Return + 0x7f00); }\r\ +< \n }\r\ +< \n }\r\ +< \n :if ([ :typeof \$Num ] = \"num\") do={ :set Return (\$Return + (\$Va\ +< lue * \$Multi)); }\r\ +< \n :set Multi (\$Multi / 0x100);\r\ +< \n }\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n:set ScriptLock do={\r\ +< \n :local Script [ :tostr \$1 ];\r\ +< \n :local WaitMax [ :totime \$2 ];\r\ +< \n :global GetRandom20CharAlNum;\r\ +< \n :global IfThenElse;\r\ +< \n :global LogPrint;\r\ +< \n :global ScriptLockOrder;\r\ +< \n :if ([ :typeof \$ScriptLockOrder ] = \"nothing\") do={\r\ +< \n :set ScriptLockOrder ({});\r\ +< \n }\r\ +< \n :if ([ :typeof (\$ScriptLockOrder->\$Script) ] = \"nothing\") do={\r\ +< \n :set (\$ScriptLockOrder->\$Script) ({});\r\ +< \n }\r\ +< \n :local JobCount do={\r\ +< \n :local Script [ :tostr \$1 ];\r\ +< \n :return [ :len [ /system/script/job/find where script=\$Script ] ];\ +< \r\ +< \n }\r\ +< \n :local TicketCount do={\r\ +< \n :local Script [ :tostr \$1 ];\r\ +< \n :global ScriptLockOrder;\r\ +< \n :local Count 0;\r\ +< \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ +< \n :if ([ :typeof \$Ticket ] != \"nothing\") do={:set Count (\$Count \ +< + 1)}\r\ +< \n }\r\ +< \n :return \$Count;\r\ +< \n }\r\ +< \n :local IsFirstTicket do={\r\ +< \n :local Script [ :tostr \$1 ];\r\ +< \n :local Check [ :tostr \$2 ];\r\ +< \n :global ScriptLockOrder;\r\ +< \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ +< \n :if (\$Ticket = \$Check) do={:return true}\r\ +< \n :if ([ :typeof \$Ticket ] != \"nothing\" && \$Ticket != \$Check) d\ +< o={:return false}\r\ +< \n }\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local AddTicket do={\r\ +< \n :local Script [ :tostr \$1 ];\r\ +< \n :local Add [ :tostr \$2 ];\r\ +< \n :global ScriptLockOrder;\r\ +< \n :while (true) do={\r\ +< \n :local Pos [ :len (\$ScriptLockOrder->\$Script) ];\r\ +< \n :set (\$ScriptLockOrder->\$Script->\$Pos) \$Add;\r\ +< \n :delay 10ms;\r\ +< \n :if ((\$ScriptLockOrder->\$Script->\$Pos) = \$Add) do={:return tru\ +< e}\r\ +< \n }\r\ +< \n }\r\ +< \n :local RemoveTicket do={\r\ +< \n :local Script [ :tostr \$1 ];\r\ +< \n :local Remove [ :tostr \$2 ];\r\ +< \n :global ScriptLockOrder;\r\ +< \n :foreach Id,Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ +< \n :while ((\$ScriptLockOrder->\$Script->\$Id) = \$Remove) do={\r\ +< \n :set (\$ScriptLockOrder->\$Script->\$Id);\r\ +< \n :delay 10ms;\r\ +< \n }\r\ +< \n }\r\ +< \n }\r\ +< \n :local CleanupTickets do={\r\ +< \n :local Script [ :tostr \$1 ];\r\ +< \n :global ScriptLockOrder;\r\ +< \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ +< \n :if ([ :typeof \$Ticket ] != \"nothing\") do={:return false}\r\ +< \n }\r\ +< \n :set (\$ScriptLockOrder->\$Script) ({});\r\ +< \n }\r\ +< \n :if ([ :typeof \$WaitMax ] = \"nil\" ) do={:set WaitMax 0s}\r\ +< \n :if ([ :len [ /system/script/find where name=\$Script ] ] = 0) do={\r\ +< \n \$LogPrint error \$0 (\"A script named '\" . \$Script . \"' does not\ +< \_exist!\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n :if ([ \$JobCount \$Script ] = 0) do={\r\ +< \n \$LogPrint error \$0 (\"No script '\" . \$Script . \"' is running!\"\ +< );\r\ +< \n :error false;\r\ +< \n }\r\ +< \n :if ([ \$TicketCount \$Script ] >= [ \$JobCount \$Script ]) do={\r\ +< \n \$LogPrint error \$0 (\"More tickets than running scripts '\" . \$Sc\ +< ript . \"', resetting!\");\r\ +< \n :set (\$ScriptLockOrder->\$Script) ({});\r\ +< \n /system/script/job/remove [ find where script=\$Script ];\r\ +< \n }\r\ +< \n :local MyTicket [ \$GetRandom20CharAlNum 6 ];\r\ +< \n \$AddTicket \$Script \$MyTicket;\r\ +< \n :local WaitInterval (\$WaitMax / 20);\r\ +< \n :local WaitTime \$WaitMax;\r\ +< \n :while (\$WaitTime > 0 && \\\r\ +< \n ([ \$IsFirstTicket \$Script \$MyTicket ] = false || \\\r\ +< \n [ \$TicketCount \$Script ] < [ \$JobCount \$Script ])) do={\r\ +< \n :set WaitTime (\$WaitTime - \$WaitInterval);\r\ +< \n :delay \$WaitInterval;\r\ +< \n }\r\ +< \n :if ([ \$IsFirstTicket \$Script \$MyTicket ] = true && \\\r\ +< \n [ \$TicketCount \$Script ] = [ \$JobCount \$Script ]) do={\r\ +< \n \$RemoveTicket \$Script \$MyTicket;\r\ +< \n \$CleanupTickets \$Script;\r\ +< \n :return true;\r\ +< \n }\r\ +< \n \$RemoveTicket \$Script \$MyTicket;\r\ +< \n \$LogPrint debug \$0 (\"Script '\" . \$Script . \"' started more than \ +< once\" . \\\r\ +< \n [ \$IfThenElse (\$WaitTime < \$WaitMax) \" and timed out waiting for\ +< \_lock\" \"\" ] . \"...\");\r\ +< \n :return false;\r\ +< \n}\r\ +< \n:set SendNotification do={ :onerror Err {\r\ +< \n :global SendNotification2;\r\ +< \n \$SendNotification2 ({ origin=\$0; subject=\$1; message=\$2; link=\$3;\ +< \_silent=\$4 });\r\ +< \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err}\r\ +< \n}\r\ +< \n:set SendNotification2 do={\r\ +< \n :local Notification \$1;\r\ +< \n :global NotificationFunctions;\r\ +< \n :foreach FunctionName,Discard in=\$NotificationFunctions do={\r\ +< \n (\$NotificationFunctions->\$FunctionName) (\"\\\$NotificationFunctio\ +< ns->\\\"\" . \$FunctionName . \"\\\"\") \$Notification;\r\ +< \n }\r\ +< \n}\r\ +< \n:set SymbolByUnicodeName do={\r\ +< \n :local Name [ :tostr \$1 ];\r\ +< \n :global EitherOr;\r\ +< \n :global LogPrint;\r\ +< \n :global SymbolsExtra;\r\ +< \n :local Symbols ({\r\ +< \n \"abacus\"=\"\\F0\\9F\\A7\\AE\";\r\ +< \n \"alarm-clock\"=\"\\E2\\8F\\B0\";\r\ +< \n \"arrow-down\"=\"\\E2\\AC\\87\";\r\ +< \n \"arrow-up\"=\"\\E2\\AC\\86\";\r\ +< \n \"calendar\"=\"\\F0\\9F\\93\\85\";\r\ +< \n \"card-file-box\"=\"\\F0\\9F\\97\\83\";\r\ +< \n \"chart-decreasing\"=\"\\F0\\9F\\93\\89\";\r\ +< \n \"chart-increasing\"=\"\\F0\\9F\\93\\88\";\r\ +< \n \"cloud\"=\"\\E2\\98\\81\";\r\ +< \n \"cross-mark\"=\"\\E2\\9D\\8C\";\r\ +< \n \"earth\"=\"\\F0\\9F\\8C\\8D\";\r\ +< \n \"fire\"=\"\\F0\\9F\\94\\A5\";\r\ +< \n \"floppy-disk\"=\"\\F0\\9F\\92\\BE\";\r\ +< \n \"gear\"=\"\\E2\\9A\\99\";\r\ +< \n \"heart\"=\"\\E2\\99\\A5\";\r\ +< \n \"high-voltage-sign\"=\"\\E2\\9A\\A1\";\r\ +< \n \"incoming-envelope\"=\"\\F0\\9F\\93\\A8\";\r\ +< \n \"information\"=\"\\E2\\84\\B9\";\r\ +< \n \"large-orange-circle\"=\"\\F0\\9F\\9F\\A0\";\r\ +< \n \"large-red-circle\"=\"\\F0\\9F\\94\\B4\";\r\ +< \n \"link\"=\"\\F0\\9F\\94\\97\";\r\ +< \n \"lock-with-ink-pen\"=\"\\F0\\9F\\94\\8F\";\r\ +< \n \"memo\"=\"\\F0\\9F\\93\\9D\";\r\ +< \n \"mobile-phone\"=\"\\F0\\9F\\93\\B1\";\r\ +< \n \"pushpin\"=\"\\F0\\9F\\93\\8C\";\r\ +< \n \"scissors\"=\"\\E2\\9C\\82\";\r\ +< \n \"scroll\"=\"\\F0\\9F\\93\\9C\";\r\ +< \n \"smiley-partying-face\"=\"\\F0\\9F\\A5\\B3\";\r\ +< \n \"smiley-smiling-face\"=\"\\E2\\98\\BA\";\r\ +< \n \"smiley-winking-face-with-tongue\"=\"\\F0\\9F\\98\\9C\";\r\ +< \n \"sparkles\"=\"\\E2\\9C\\A8\";\r\ +< \n \"speech-balloon\"=\"\\F0\\9F\\92\\AC\";\r\ +< \n \"star\"=\"\\E2\\AD\\90\";\r\ +< \n \"warning-sign\"=\"\\E2\\9A\\A0\";\r\ +< \n \"white-heavy-check-mark\"=\"\\E2\\9C\\85\"\r\ +< \n }, \$SymbolsExtra);\r\ +< \n :local Magic [ :pick [ /system/clock/get date ] 4 10 ];\r\ +< \n :local Special {\r\ +< \n \"information-04-01\"=\"\\F0\\9F\\9A\\BB\";\r\ +< \n \"large-orange-circle-04-01\"=\"\\F0\\9F\\8D\\8A\";\r\ +< \n \"large-orange-circle-10-31\"=\"\\F0\\9F\\8E\\83\";\r\ +< \n \"large-red-circle-04-01\"=\"\\F0\\9F\\8D\\92\" };\r\ +< \n :if ([ :len (\$Symbols->\$Name) ] = 0) do={\r\ +< \n \$LogPrint warning \$0 (\"No symbol available for name '\" . \$Name \ +< . \"'!\");\r\ +< \n :return \"\";\r\ +< \n }\r\ +< \n :return ([ \$EitherOr (\$Special->(\$Name . \$Magic)) (\$Symbols->\$Na\ +< me) ] . \"\\EF\\B8\\8F\");\r\ +< \n}\r\ +< \n:set SymbolForNotification do={\r\ +< \n :global NotificationsWithSymbols;\r\ +< \n :global SymbolByUnicodeName;\r\ +< \n :global IfThenElse;\r\ +< \n :if (\$NotificationsWithSymbols != true) do={:return [ \$IfThenElse ([\ +< \_:len \$2 ] > 0) ([ :tostr \$2 ] . \" \") \"\" ]}\r\ +< \n :local Return \"\";\r\ +< \n :foreach Symbol in=[ :toarray \$1 ] do={:set Return (\$Return . [ \$Sy\ +< mbolByUnicodeName \$Symbol ])}\r\ +< \n :return (\$Return . \" \");\r\ +< \n}\r\ +< \n:set Unix2Dos do={:return [ :tocrlf [ :tostr \$1 ] ]}\r\ +< \n:set UrlEncode do={\r\ +< \n :local Input [ :tostr \$1 ];\r\ +< \n :if ([ :len \$Input ] = 0) do={:return \"\"}\r\ +< \n :local Return \"\";\r\ +< \n :local Chars (\"\\n\\r !\\\"#\\\$%&'()*+,:;<=>\?@[\\\\]^`{|}~\");\r\ +< \n :local Subs { \"%0A\"; \"%0D\"; \"%20\"; \"%21\"; \"%22\"; \"%23\"; \"\ +< %24\"; \"%25\"; \"%26\"; \"%27\";\r\ +< \n \"%28\"; \"%29\"; \"%2A\"; \"%2B\"; \"%2C\"; \"%3A\"; \"%3B\"; \ +< \"%3C\"; \"%3D\"; \"%3E\"; \"%3F\";\r\ +< \n \"%40\"; \"%5B\"; \"%5C\"; \"%5D\"; \"%5E\"; \"%60\"; \"%7B\"; \ +< \"%7C\"; \"%7D\"; \"%7E\" };\r\ +< \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ +< \n :local Char [ :pick \$Input \$I ];\r\ +< \n :local Replace [ :find \$Chars \$Char ];\r\ +< \n :if ([ :typeof \$Replace ] = \"num\") do={:set Char (\$Subs->\$Repla\ +< ce)}\r\ +< \n :set Return (\$Return . \$Char);\r\ +< \n }\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n:set ValidateSyntax do={\r\ +< \n :local Code [ :tostr \$1 ];\r\ +< \n :global LogPrint;\r\ +< \n :onerror Err {\r\ +< \n [ :parse (\":local Validate do={\\n\" . \$Code . \"\\n}\") ];\r\ +< \n } do={\r\ +< \n \$LogPrint debug \$0 (\"Valdation failed: \" . \$Err);\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :return true;\r\ +< \n}\r\ +< \n:set IsDNSResolving do={\r\ +< \n :do {:resolve \"api.telegram.org\"} on-error={:return false}\r\ +< \n :return true;\r\ +< \n}\r\ +< \n:set IsFullyConnected do={\r\ +< \n :global IsDNSResolving;\r\ +< \n :global IsTimeSync;\r\ +< \n :if ([ \$IsDNSResolving ] = false) do={:return false};\r\ +< \n :if ([ \$IsTimeSync ] = false) do={:return false};\r\ +< \n :return true;\r\ +< \n}\r\ +< \n:set IsTimeSync do={\r\ +< \n :global IsTimeSyncCached;\r\ +< \n :global IsTimeSyncResetNtp;\r\ +< \n :if (\$IsTimeSyncCached = true) do={:return true}\r\ +< \n :if ([ /system/ntp/client/get enabled ] = true) do={\r\ +< \n :if ([ /system/ntp/client/get status ] = \"synchronized\") do={\r\ +< \n :set IsTimeSyncCached true;\r\ +< \n :return true;\r\ +< \n }\r\ +< \n :local Uptime [ /system/resource/get uptime ];\r\ +< \n :if ([ :typeof \$IsTimeSyncResetNtp ] = \"nothing\") do={\r\ +< \n :set IsTimeSyncResetNtp \$Uptime;\r\ +< \n }\r\ +< \n :if (\$Uptime - \$IsTimeSyncResetNtp < 3m) do={:return false}\r\ +< \n :log warning \"\$0 The ntp client is configured, but did not sync.\"\ +< ;\r\ +< \n :set IsTimeSyncResetNtp \$Uptime;\r\ +< \n /system/ntp/client/set enabled=no;\r\ +< \n :delay 20ms;\r\ +< \n /system/ntp/client/set enabled=yes;\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :if ([ /system/license/get ]->\"level\" = \"free\" || \\\r\ +< \n [ /system/resource/get ]->\"board-name\" = \"x86\") do={\r\ +< \n :log debug \"\$0 No ntp client configured, relying on RTC for CHR fr\ +< ee license and x86.\";\r\ +< \n :return true;\r\ +< \n }\r\ +< \n :if ([ /ip/cloud/get update-time ] = true) do={\r\ +< \n :if ([ :typeof [ /ip/cloud/get public-address ] ] = \"ip\") do={\r\ +< \n :set IsTimeSyncCached true;\r\ +< \n :return true;\r\ +< \n }\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :log debug \"\$0 No time source configured! Returning gracefully...\";\ +< \r\ +< \n :return true;\r\ +< \n}\r\ +< \n\r\ +< \n# read parts of a large file\r\ +< \n:set FetchLargeFiles do={\r\ +< \n :local ScriptName [:tostr \$1];\r\ +< \n :local fetchUrl [:tostr \$2];\r\ +< \n :local CheckCert [:tostr \$3];\r\ +< \n :local fetchMode [:tostr \$4];\r\ +< \n :local fetchMethod [:tostr \$5];\r\ +< \n :local FetchString \"undefined\";\r\ +< \n \r\ +< \n :global CleanName;\r\ +< \n :global FetchUserAgentStr;\r\ +< \n :global GetRandom20CharAlNum;\r\ +< \n :global IfThenElse;\r\ +< \n :global LogPrint;\r\ +< \n :global MkDir;\r\ +< \n :global RmDir;\r\ +< \n :global RmFile;\r\ +< \n :global WaitForFile;\r\ +< \n\r\ +< \n :set CheckCert [ \$IfThenElse (\$CheckCert = \"false\") \"no\" \"yes-w\ +< ithout-crl\" ];\r\ +< \n #:set fetchMode [ \$IfThenElse (\$fetchMode != \"false\") [:tostr (\"m\ +< ode=\" . \$fetchMode)] ];\r\ +< \n #:set fetchMethod [\$IfThenElse (\$fetchMethod != \"false\") [:tostr (\ +< \"http-method=\\\"\" . \$fetchMethod . \"\\\"\") ]];\r\ +< \n \r\ +< \n :local DirName (\"tmpfs/\" . [ \$CleanName \$ScriptName ]);\r\ +< \n :if ([ \$MkDir \$DirName ] = false) do={\r\ +< \n \$LogPrint error \$0 (\"Failed creating directory!\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local FileName (\$DirName . \"/\" . [ \$CleanName \$0 ] . \"-\" . [ \ +< \$GetRandom20CharAlNum ]);\r\ +< \n #/tool/fetch check-certificate=\$CheckCert \$Url dst-path=\$FileName h\ +< ttp-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] }) as-value;\r\ +< \n #:log warning (\"\\\$fUrl =\" . \$2 . ({[ \$fMode ]}));\r\ +< \n :onerror Err {\r\ +< \n :set FetchString (\"/tool/fetch \" . \\\r\ +< \n [\$IfThenElse ([\$fetchMethod] != \"false\") (\"http-method=\\\"\"\ +< \_. \$fetchMethod . \"\\\" \")] . \\\r\ +< \n \"check-certificate=\" . \$CheckCert . \" url=(\\\"\" . \$fetchUrl\ +< \_. \"\\\") \" . \\\r\ +< \n [\$IfThenElse ([\$fetchMode] != \"false\") (\"mode=\" . \$fetchMod\ +< e . \" \")] . \\\r\ +< \n http-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] }) as-va\ +< lue);\r\ +< \n :log warning (\"\\\$FetchSring = \" . \$FetchString);\r\ +< \n :put [\$FetchString];\r\ +< \n #:put [/tool/fetch \$fetchMode check-certificate=\$CheckCert url=(\$\ +< fetchUrl) dst-path=(\$FileName) http-header-field=({ [ \$FetchUserAgentStr\ +< \_\$ScriptName ] }) as-value];\r\ +< \n } do={\r\ +< \n :if ([ \$WaitForFile \$FileName 500ms ] = true) do={\r\ +< \n \$RmFile \$FileName;\r\ +< \n }\r\ +< \n \$LogPrint debug \$0 (\"Failed downloading from \" . \$fetchUrl . \"\ +< \_- \" . \$Err);\r\ +< \n \$RmDir \$DirName;\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :if ([ \$WaitForFile \$FileName 5s ] = false) do={\r\ +< \n \$LogPrint debug \$0 (\"The file downloaded from \" . \$fetchUrl . \ +< \" did not show up.\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local FileSize [ /file/get \$FileName size ];\r\ +< \n :local Return \"\";\r\ +< \n :local VarSize 0;\r\ +< \n :while (\$VarSize != \$FileSize) do={\r\ +< \n :set Return (\$Return . ([ /file/read offset=\$VarSize chunk-size=32\ +< 768 file=\$FileName as-value ]->\"data\"));\r\ +< \n :set FileSize [ /file/get \$FileName size ];\r\ +< \n :set VarSize [ :len \$Return ];\r\ +< \n :if (\$VarSize > \$FileSize) do={\r\ +< \n :delay 100ms;\r\ +< \n }\r\ +< \n }\r\ +< \n \$RmDir \$DirName;\r\ +< \n :return \$Return;\r\ +< \n}\r\ +< \n\r\ +< \n:set ScriptInstallUpdate do={ :onerror Err {\r\ +< \n :local Scripts [ :toarray \$1 ];\r\ +< \n :local NewComment [ :tostr \$2 ];\r\ +< \n :global InitSetup;\r\ +< \n\r\ +< \n :global CommitId;\r\ +< \n :global ScriptUpdatesCRLF;\r\ +< \n :global GlobalConfVersion;\r\ +< \n :global Identity;\r\ +< \n :global CertificateAvailable;\r\ +< \n :global CheckSumsVerify;\r\ +< \n :global GlobalScriptsUrl;\r\ +< \n :global SumsDirAndFileName;\r\ +< \n :global GlobalScriptsUrlSuffix;\r\ +< \n :global EitherOr;\r\ +< \n :global FetchUserAgentStr;\r\ +< \n :global Grep;\r\ +< \n :global IfThenElse;\r\ +< \n :global LogPrint;\r\ +< \n :global ParseKeyValueStore;\r\ +< \n :global RequiredRouterOS;\r\ +< \n :global SendNotification2;\r\ +< \n :global SymbolForNotification;\r\ +< \n :global ValidateSyntax;\r\ +< \n :global CommentsInScripts;\r\ +< \n\r\ +< \n :if ([ \$CertificateAvailable \"Root YE\" \"fetch\" ] = false) do={\r\ +< \n \$LogPrint warning \$0 (\"Downloading certificate failed, trying wit\ +< hout.\");\r\ +< \n }\r\ +< \n\r\ +< \n :foreach Script in=\$Scripts do={\r\ +< \n :if ([ :len [ /system/script/find where name=\$Script ] ] = 0) do={\ +< \r\ +< \n \$LogPrint info \$0 (\"Adding new script: \" . \$Script);\r\ +< \n /system/script/add name=\$Script owner=\$Script source=\"#!rsc by \ +< Vados\\n\" comment=\$NewComment;\r\ +< \n }\r\ +< \n }\r\ +< \n\r\ +< \n :local CommitIdBefore \$CommitId;\r\ +< \n :local GlobalConfVersionBefore \$GlobalConfVersion;\r\ +< \n :local ReloadGlobal false;\r\ +< \n :local DeviceMode [ /system/device-mode/get ];\r\ +< \n\r\ +< \n :if (\$CheckSumsVerify = true) do={\r\ +< \n :local CheckSums ({});\r\ +< \n :do {\r\ +< \n :local Url (\$GlobalScriptsUrl . \$SumsDirAndFileName . \$GlobalScr\ +< iptsUrlSuffix);\r\ +< \n \$LogPrint debug \$0 (\"Fetching checksums from url: \" . \$Url);\ +< \r\ +< \n :set CheckSums [ :deserialize from=json ([ /tool/fetch check-certi\ +< ficate=yes-without-crl \\\r\ +< \n http-header-field=({ [ \$FetchUserAgentStr \$0 ] }) \$Url output\ +< =user as-value ]->\"data\") ];\r\ +< \n } on-error={ \$LogPrint warning \$0 (\"Err = \" . \$Err); }\r\ +< \n }\r\ +< \n\r\ +< \n :foreach Script in=[ /system/script/find where source~\"^#!rsc by Vado\ +< s\" ] do={\r\ +< \n :local ScriptVal [ /system/script/get \$Script ];\r\ +< \n :local ScriptInfo [ \$ParseKeyValueStore (\$ScriptVal->\"comment\") \ +< ];\r\ +< \n :local SourceNew;\r\ +< \n\r\ +< \n :foreach Scheduler in=[ /system/scheduler/find where on-event~(\"\\\ +< \\b\" . \$ScriptVal->\"name\" . \"\\\\b\") ] do={\r\ +< \n :local SchedulerVal [ /system/scheduler/get \$Scheduler ];\r\ +< \n :if (\$ScriptVal->\"policy\" != \$SchedulerVal->\"policy\") do={\r\ +< \n \$LogPrint warning \$0 (\"Policies differ for script '\" . \$Scr\ +< iptVal->\"name\" . \"' and its scheduler '\" . \$SchedulerVal->\"name\" . \ +< \"'!\");\r\ +< \n }\r\ +< \n }\r\ +< \n :do {\r\ +< \n :if (\$ScriptInfo->\"ignore\" = true) do={\r\ +< \n \$LogPrint debug \$0 (\"Ignoring script '\" . \$ScriptVal->\"nam\ +< e\" . \"', as requested.\");\r\ +< \n :error true;\r\ +< \n }\r\ +< \n :if (\$CheckSumsVerify = true) do={\r\ +< \n :local CheckSum (\$CheckSums->(\$ScriptVal->\"name\"));\r\ +< \n :if ([ :len (\$ScriptInfo->\"base-url\") ] = 0 && [ :len (\$Scri\ +< ptInfo->\"url-suffix\") ] = 0 && \\\r\ +< \n [ :convert transform=md5 to=hex [ :tolf (\$ScriptVal->\"sou\ +< rce\") ] ] = \$CheckSum) do={\r\ +< \n \$LogPrint debug \$0 (\"Checksum for script '\" . \$ScriptVal-\ +< >\"name\" . \"' matches, ignoring.\");\r\ +< \n :error true;\r\ +< \n }\r\ +< \n }\r\ +< \n :if ([ :len (\$ScriptInfo->\"certificate\") ] > 0) do={\r\ +< \n :if ([ \$CertificateAvailable (\$ScriptInfo->\"certificate\") \"\ +< fetch\" ] = false) do={\r\ +< \n \$LogPrint warning \$0 (\"Downloading certificate failed, tryi\ +< ng without.\");\r\ +< \n }\r\ +< \n }\r\ +< \n :onerror Err {\r\ +< \n :local BaseUrl [ \$EitherOr (\$ScriptInfo->\"base-url\") \$Globa\ +< lScriptsUrl ];\r\ +< \n :local UrlSuffix [ \$EitherOr (\$ScriptInfo->\"url-suffix\") \$G\ +< lobalScriptsUrlSuffix ];\r\ +< \n :local Url (\$BaseUrl . \$ScriptVal->\"name\" . \".rsc\" . \$Url\ +< Suffix);\r\ +< \n \$LogPrint warning \$0 (\"Fetching script '\" . (\$ScriptVal->\"\ +< name\") . \"' from url: \" . \$Url);\r\ +< \n :local Result [ /tool/fetch check-certificate=yes-without-crl \\\ +< \r\ +< \n http-header-field=({ [ \$FetchUserAgentStr \$0 ] }) \$Url outp\ +< ut=user as-value ];\r\ +< \n :if (\$Result->\"status\" = \"finished\") do={\r\ +< \n :set SourceNew [ :tolf (\$Result->\"data\") ];\r\ +< \n } \r\ +< \n } do={\r\ +< \n \$LogPrint warning \$0 (\"Failed fetching script '\" . \$ScriptV\ +< al->\"name\" . \"': \" . \$Err);\r\ +< \n :if (\$Err != \"Fetch failed with status 404\") do={\r\ +< \n :error false;\r\ +< \n }\r\ +< \n :if (\$ScriptVal->\"source\" = \"#!rsc by Vados\") do={\r\ +< \n \$LogPrint warning \$0 (\"Removing dummy. Typo on installation\ +< \?\");\r\ +< \n /system/script/remove \$Script;\r\ +< \n :error false;\r\ +< \n }\r\ +< \n :if (\$CheckSumsVerify = true) do={\r\ +< \n :if ([ :len (\$ScriptInfo->\"base-url\") ] = 0 && [ :len (\$Sc\ +< riptInfo->\"url-suffix\") ] = 0 && \\\r\ +< \n [ :len \$CheckSum ] = 0) do={\r\ +< \n \$LogPrint warning \$0 (\"Added the script manually\? Skip u\ +< pdates with 'ignore=true' in comment.\");\r\ +< \n }\r\ +< \n }\r\ +< \n :error false;\r\ +< \n }\r\ +< \n\r\ +< \n :if ([ :len \$SourceNew ] = 0) do={\r\ +< \n \$LogPrint debug \$0 (\"No update for script '\" . (\$ScriptVal-\ +< >\"name\") . \"'.\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n\r\ +< \n :local SourceCRLF [ :tocrlf \$SourceNew ];\r\ +< \n :if (\$InitSetup != true && ((\$ScriptVal->\"name\") != \"AM-Globa\ +< lConfig\" || (\$ScriptVal->\"name\") != \"AM-GlobalFunc\")) do={\r\ +< \n :if (\$SourceNew = (\$ScriptVal->\"source\") || \$SourceCRLF = (\ +< \$ScriptVal->\"source\")) do={\r\ +< \n \$LogPrint debug \$0 (\"Script '\" . (\$ScriptVal->\"name\") \ +< . \"' source did not change. End of lines set to CRLF.\");\r\ +< \n if (\$ScriptUpdatesCRLF = false) do={\r\ +< \n :put [ :tolf \$SourceNew ];\r\ +< \n \$LogPrint debug \$0 (\"Script '\" . (\$ScriptVal->\"name\"\ +< ) . \"' source update end of lines to LF.\");\r\ +< \n }\r\ +< \n :error false;\r\ +< \n }\r\ +< \n }\r\ +< \n\r\ +< \n :if ([ :pick \$SourceNew 0 14 ] != \"#!rsc by Vados\") do={\r\ +< \n \$LogPrint warning \$0 (\"Looks like new script '\" . \$ScriptVa\ +< l->\"name\" . \"' is not valid (missing shebang = '\$shebang') Ignoring!\"\ +< );\r\ +< \n :error false;\r\ +< \n }\r\ +< \n\r\ +< \n :if (\$CommentsInScripts = true) do={\r\ +< \n :local CommentLine [ \$Grep \$SourceNew (\"\\23 Script comment:\ +< \_\") ];\r\ +< \n :if ([ :len \$CommentLine ] = 0) do={\r\ +< \n \$LogPrint debug \$0 (\"The search in new script '\" . (\$Scr\ +< iptVal->\"name\") . \"' for comment in script body, is not found result Ig\ +< noring!\");\r\ +< \n :error false;\r\ +< \n } else={\r\ +< \n :if ([ :len (\$ScriptVal->\"comment\")] = 0 || [ :len (\$Scri\ +< ptVal->\"comment\")] != [ :pick \$CommentLine ([ :find \$CommentLine \":\"\ +< ] + 2) [ :len \$CommentLine] ]) do={\r\ +< \n \$LogPrint debug \$0 (\"Exsiting comment for script '\" . (\ +< \$ScriptVal->\"name\") . \"' is '\" . (\$ScriptVal->\"comment\") . \"'.\")\ +< ;\r\ +< \n :set (\$ScriptVal->\"comment\") [ :pick \$CommentLine ([ :f\ +< ind \$CommentLine \":\"] + 2) [ :len \$CommentLine] ];\r\ +< \n \$LogPrint debug \$0 (\"New comment (\" . (\$ScriptVal->\"c\ +< omment\") . \") for script '\" . (\$ScriptVal->\"name\") . \"' has been ad\ +< ded!\");\r\ +< \n } else={\r\ +< \n \$LogPrint debug \$0 (\"Comment for script '\" . (\$ScriptV\ +< al->\"name\") . \"' did not change.\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n } \r\ +< \n }\r\ +< \n\r\ +< \n :local RequiredROS ([ \$ParseKeyValueStore [ \$Grep \$SourceNew (\ +< \"\\23 requires RouterOS, \") ] ]->version);\r\ +< \n :if ([ \$RequiredRouterOS \$0 [ \$EitherOr \$RequiredROS \"0.0\" ]\ +< \_false ] = false) do={\r\ +< \n \$LogPrint warning \$0 (\"The script '\" . (\$ScriptVal->\"name\ +< \") . \"' requires RouterOS \" . \\\r\ +< \n \$RequiredROS . \", which is not met by your installation. I\ +< gnoring!\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n :local RequiredDM [ \$ParseKeyValueStore [ \$Grep \$SourceNew (\"\ +< \\23 requires device-mode, \") ] ];\r\ +< \n :local MissingDM ({});\r\ +< \n :foreach Feature,Value in=\$RequiredDM do={\r\ +< \n :if ([ :typeof (\$DeviceMode->\$Feature) ] = \"bool\" && (\$Devi\ +< ceMode->\$Feature) = false) do={\r\ +< \n :set MissingDM (\$MissingDM, \$Feature);\r\ +< \n }\r\ +< \n }\r\ +< \n :if ([ :len \$MissingDM ] > 0) do={\r\ +< \n \$LogPrint warning \$0 (\"The script '\" . (\$ScriptVal->\"name\ +< \") . \"' requires disabled \" . \\\r\ +< \n \"device-mode features (\" . [ :tostr \$MissingDM ] . \"). I\ +< gnoring!\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n\r\ +< \n :if ([ \$ValidateSyntax \$SourceNew ] = false) do={\r\ +< \n \$LogPrint warning \$0 (\"Syntax validation for script '\" . (\$\ +< ScriptVal->\"name\") . \"' failed! Ignoring!\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n \r\ +< \n :log info (\"Updating script: \" . (\$ScriptVal->\"name\") . \" Sc\ +< ript comment: \" . (\$ScriptVal->\"comment\"));\r\ +< \n\r\ +< \n /system/script/set owner=(\$ScriptVal->\"name\") comment=(\$Script\ +< Val->\"comment\") \\\r\ +< \n source=[ \$IfThenElse (\$ScriptUpdatesCRLF = true) \$SourceCRL\ +< F \$SourceNew ] \$Script;\r\ +< \n :if (\$ScriptVal->\"name\" = \"AM-GlobalConfig\" || \\\r\ +< \n \$ScriptVal->\"name\" = \"AM-GlobalFunc\" || \\\r\ +< \n \$ScriptVal->\"name\" ~ (\"^(AM-GlobalFunc\\\\.d|mod)/.\")) d\ +< o={\r\ +< \n :set ReloadGlobal true;\r\ +< \n }\r\ +< \n } on-error={ }\r\ +< \n }\r\ +< \n :if (\$ReloadGlobal = true) do={\r\ +< \n \$LogPrint info \$0 (\"Reloading global configuration and functions.\ +< \");\r\ +< \n :onerror Err {\r\ +< \n :global InitSetup (a);\r\ +< \n /system/script {run AM-GlobalConfig; run AM-GlobalFunc;};\r\ +< \n } do={\$LogPrint error \$0 (\"Reloading global configuration and fun\ +< ctions failed! \" . \$Err)}\r\ +< \n }\r\ +< \n :if (\$GlobalConfVersionBefore > \$GlobalConfVersion) do={\r\ +< \n \$LogPrint warning \$0 (\"The configuration version decreased from \ +< \" . \\\r\ +< \n \$GlobalConfVersionBefore . \" to \" . \$GlobalConfVersion . \\\r\ +< \n \". Installed an older version\?\");\r\ +< \n }\r\ +< \n :if (\$GlobalConfVersionBefore < \$GlobalConfVersion) do={\r\ +< \n :global GlobalConfChanges;\r\ +< \n :global GlobalConfMigration;\r\ +< \n :local ChangeLogCode;\r\ +< \n :if ([ :len \$ChangeLogCode ] > 0) do={\r\ +< \n :if ([ \$ValidateSyntax \$ChangeLogCode ] = true) do={\r\ +< \n :onerror Err {\r\ +< \n [ :parse \$ChangeLogCode ];\r\ +< \n } do={\$LogPrint warning \$0 (\"The changelog failed to run: \" \ +< . \$Err)}\r\ +< \n } else={\$LogPrint warning \$0 (\"The changelog failed syntax vali\ +< dation!\")}\r\ +< \n }\r\ +< \n :if ([ :len \$GlobalConfMigration ] > 0) do={\r\ +< \n :for I from=(\$GlobalConfVersionBefore + 1) to=\$GlobalConfVersion\ +< \_do={\r\ +< \n :local Migration (\$GlobalConfMigration->[ :tostr \$I ]);\r\ +< \n :do {\r\ +< \n :if ([ :typeof \$Migration ] != \"str\") do={\r\ +< \n \$LogPrint debug \$0 (\"Migration code for change \" . \$I .\ +< \_\" is not available.\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n :if ([ \$ValidateSyntax \$Migration ] = false) do={\r\ +< \n \$LogPrint warning \$0 (\"Migration code for change \" . \$I\ +< \_. \" failed syntax validation!\");\r\ +< \n :error false}\r\ +< \n \$LogPrint info \$0 (\"Applying migration for change \" . \$I \ +< . \": \" . \$Migration);\r\ +< \n :onerror Err {\r\ +< \n [ :parse \$Migration ];\r\ +< \n } do={\$LogPrint warning \$0 (\"Migration code for change \" .\ +< \_\$I . \" failed to run: \" . \$Err)}\r\ +< \n } on-error={ }\r\ +< \n }\r\ +< \n }\r\ +< \n :local NotificationMessage (\"The configuration version on \" . \$Id\ +< entity . \" increased \" . \\\r\ +< \n \"to \" . \$GlobalConfVersion . \", current configuration may nee\ +< d modification. \" . \\\r\ +< \n \"Please review and update global-config-overlay, then re-run glo\ +< bal-config.\");\r\ +< \n \$LogPrint info \$0 (\$NotificationMessage);\r\ +< \n :if ([ :len \$GlobalConfChanges ] > 0) do={\r\ +< \n :set NotificationMessage (\$NotificationMessage . \"\\n\\nChanges:\ +< \");\r\ +< \n :for I from=(\$GlobalConfVersionBefore + 1) to=\$GlobalConfVersion\ +< \_do={\r\ +< \n :local Change (\$GlobalConfChanges->[ :tostr \$I ]);\r\ +< \n :set NotificationMessage (\$NotificationMessage . \"\\n \" . \\\ +< \r\ +< \n [ \$SymbolForNotification \"pushpin\" \"*\" ] . \$Change);\r\ +< \n \$LogPrint info \$0 (\"Change \" . \$I . \": \" . \$Change);\r\ +< \n }\r\ +< \n } else={:set NotificationMessage (\$NotificationMessage . \"\\n\\nNe\ +< ws and changes are not available.\")}\r\ +< \n\r\ +< \n :set GlobalConfChanges;\r\ +< \n :set GlobalConfMigration;\r\ +< \n }\r\ +< \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err}\r\ +< \n}\r\ +< \n\r\ +< \n# Global Environment clear. Use: \"\$GlobalEnvRemove True;\".\r\ +< \n:set GlobalEnvRemove do={\r\ +< \n :local doRmEnv [ :tostr \$1 ];\r\ +< \n :global GlobalScriptsUrl;\r\ +< \n :local ScriptsUrl;\r\ +< \n :global LogPrint;\r\ +< \n :if (\$doRmEnv != \"True\") do={\r\ +< \n \$LogPrint error \"GlobalEnvRemove\" (\"This script is needed \\\"T\ +< rue\\\" for confirm to remove global environment variables!\");\r\ +< \n :return [];\r\ +< \n :error true; \r\ +< \n } else={\r\ +< \n :set ScriptsUrl \$GlobalScriptsUrl;\r\ +< \n :delay 5;\r\ +< \n :foreach var in=[/system/script/environment print as-value] do={/sy\ +< stem/script/environment remove (\$var->\".id\")}\r\ +< \n :delay 5;\r\ +< \n :global GlobalScriptsUrl \$ScriptsUrl;\r\ +< \n \$LogPrint warning \"GlobalEnvRemove\" (\"Done!\");\r\ +< \n :return [];\r\ +< \n :error false;\r\ +< \n }\r\ +< \n}\r\ +< \n\r\ +< \n# Add and fix global scheduler\r\ +< \n:put \"Add or/and fix Global scheduler...\";\r\ +< \n:local OnEvent \"/system/script { run AM-GlobalConfig; run AM-GlobalFunc\ +< ; }\";\r\ +< \n:local Comment \"Setup Global Environment for scripts\";\r\ +< \n:if ([ :len [ /system/scheduler/find where name=\"AM-SetGlobalEnv\" ] ] \ +< = 0) do={\r\ +< \n /system/scheduler/add name=\"AM-SetGlobalEnv\" comment=\$Comment on-ev\ +< ent=\$OnEvent start-time=startup;\r\ +< \n}\r\ +< \n:if ([ /system/scheduler/get \"AM-SetGlobalEnv\" comment ] != \$Comment)\ +< \_do={\r\ +< \n /system/scheduler/set \"AM-SetGlobalEnv\" comment=\$Comment;\r\ +< \n}\r\ +< \n:if ([ /system/scheduler/get \"AM-SetGlobalEnv\" on-event ] != \$OnEvent\ +< ) do={\r\ +< \n /system/scheduler/set \"AM-SetGlobalEnv\" on-event=\$OnEvent;\r\ +< \n}\r\ +< \n# Add Update Script scheduler\r\ +< \n:put \"Add or/and fix Update Script scheduler\";\r\ +< \n:set OnEvent \":global ScriptInstallUpdate; \\\$ScriptInstallUpdate;\";\ +< \r\ +< \n:set Comment \"Every Day Check For Update Scripts\";\r\ +< \n:if ([ :len [ /system/scheduler/find where name=\"AM-ScriptInstallUpdate\ +< \" ] ] = 0) do={\r\ +< \n/system/scheduler/add name=\"AM-ScriptInstallUpdate\" comment=\$Comment \ +< start-time=startup interval=1d on-event=\$OnEvent;\r\ +< \n}\r\ +< \n\r\ +< \n#:local Resource [ /system/resource/get ];\r\ +< \n#:log info (\$ScriptName . \" Loaded on \" . \$Resource->\"board-name\" \ +< . \" with RouterOS \" . \$Resource->\"version\" . \" and Architecture \" .\ +< \".\");\r\ +< \n\r\ +< \n:onerror Err {\r\ +< \n :global GlobalConfReady;\r\ +< \n :retry { :if (\$GlobalConfReady != true) do={ :error (\"Global configs\ +< \_not ready.\"); }; } delay=100ms max=5;\r\ +< \n\r\ +< \n# signal we are ready\r\ +< \n:set GlobalFuncReady true;\r\ +< \n:set ExitOK true;\r\ +< \n:log warning (\"This script \$ScriptName Loaded \" . \\\r\ +< \n [ \$IfThenElse (\$CommitId != \"unknown\") ([ \$CommitBrief ] . \" \ +< \") ] . \\\r\ +< \n \"on \" . \$devBoardName . \"\\nRouterOS: \" . \$devCurVersion . \"\ +< \\nArchitecture: \" . \$devCurArch . \"\\nIdentity: \" . \$Identity);\r\ +< \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err;}\r\ +< \n\r\ +< \n#} do={:global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err}\r\ +< \n# log the successful load of the script, or an error if it failed\r\ +< \n#:if ([\$GlobalFuncReady] = true && [\$GlobalConfReady] = true) do={\r\ +< \n" +< add comment="Import ssh keys for public key authentication" \ +< dont-require-permissions=no name=AM-SshKeysImport owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< !rsc by Vados\r\ +< \n# RouterOS script: AM-SshKeysImport\r\ +< \n# Script comment: Import ssh keys for public key authentication\r\ +< \n# Copyright (c) 2005-2026 Vados \r\ +< \n#\r\ +< \n# requires RouterOS, version=7.19\r\ +< \n#\r\ +< \n:local ExitOK false;\r\ +< \n:onerror Err {\r\ +< \n :global GlobalConfReady; :global GlobalFuncReady;\r\ +< \n :retry { :if (\$GlobalConfReady != true || \$GlobalFuncReady != true) \ +< \\\r\ +< \n do={ :error (\"Global configs or functions not ready.\"); }; } del\ +< ay=500ms max=50;\r\ +< \n :local ScriptName [ :jobname ];\r\ +< \n\r\ +< \n:global SSHKeysImport;\r\ +< \n:global SSHKeysImportFile;\r\ +< \n\r\ +< \n# import single key passed as string\r\ +< \n:set SSHKeysImport do={ :onerror Err {\r\ +< \n :local Key [ :tostr \$1 ];\r\ +< \n :local User [ :tostr \$2 ];\r\ +< \n :global GetRandom20CharAlNum;\r\ +< \n :global LogPrint;\r\ +< \n :global MkDir;\r\ +< \n :global RmDir;\r\ +< \n :global WaitForFile;\r\ +< \n :if ([ :len \$Key ] = 0 || [ :len \$User ] = 0) do={\r\ +< \n \$LogPrint warning \$0 (\"Missing argument(s), please pass key and u\ +< ser!\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :if ([ :len [ /user/find where name=\$User ] ] = 0) do={\r\ +< \n \$LogPrint warning \$0 (\"User '\" . \$User . \"' does not exist.\")\ +< ;\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local KeyVal ([ :deserialize \$Key delimiter=\" \" from=dsv options=d\ +< sv.plain ]->0);\r\ +< \n :if (!(\$KeyVal->0 = \"ssh-ed25519\" || \$KeyVal->0 = \"ssh-rsa\")) do\ +< ={\r\ +< \n \$LogPrint warning \$0 (\"SSH key of type '\" . \$KeyVal->0 . \"' is\ +< \_not supported.\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local FingerPrintMD5 [ :convert from=base64 transform=md5 to=hex (\$K\ +< eyVal->1) ];\r\ +< \n :local RegEx (\"\\\\bmd5=\" . \$FingerPrintMD5 . \"\\\\b\");\r\ +< \n :if ([ :len [ /user/ssh-keys/find where user=\$User \\\r\ +< \n (key-owner~\$RegEx or info~\$RegEx) ] ] > 0) do={\r\ +< \n \$LogPrint warning \$0 (\"The ssh public key (MD5:\" . \$FingerPrint\ +< MD5 . \\\r\ +< \n \") is already available for user '\" . \$User . \"'.\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :if ([ \$MkDir \"tmpfs/ssh-keys-import\" ] = false) do={\r\ +< \n \$LogPrint warning \$0 (\"Creating directory 'tmpfs/ssh-keys-import'\ +< \_failed!\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local FileName (\"tmpfs/ssh-keys-import/key-\" . [ \$GetRandom20CharA\ +< lNum 6 ] . \".pub\");\r\ +< \n /file/add name=\$FileName contents=(\$Key . \", md5=\" . \$FingerPrint\ +< MD5);\r\ +< \n \$WaitForFile \$FileName;\r\ +< \n :onerror Err {\r\ +< \n /user/ssh-keys/import public-key-file=\$FileName user=\$User;\r\ +< \n \$LogPrint info \$0 (\"Imported ssh public key (\" . \$KeyVal->2 . \ +< \", \" . \$KeyVal->0 . \", \" . \\\r\ +< \n \"MD5:\" . \$FingerPrintMD5 . \") for user '\" . \$User . \"'.\");\ +< \r\ +< \n \$RmDir \"tmpfs/ssh-keys-import\";\r\ +< \n } do={\r\ +< \n \$LogPrint warning \$0 (\"Failed importing key: \" . \$Err);\r\ +< \n \$RmDir \"tmpfs/ssh-keys-import\";\r\ +< \n :return false;\r\ +< \n }\r\ +< \n} do={\r\ +< \n :global ExitOnError; \$ExitOnError \$0 \$Err;\r\ +< \n} }\r\ +< \n\r\ +< \n# import keys from a file\r\ +< \n:set SSHKeysImportFile do={ :onerror Err {\r\ +< \n :local FileName [ :tostr \$1 ];\r\ +< \n :local User [ :tostr \$2 ];\r\ +< \n :global EitherOr;\r\ +< \n :global FileExists;\r\ +< \n :global LogPrint;\r\ +< \n :global ParseKeyValueStore;\r\ +< \n :global SSHKeysImport;\r\ +< \n :if ([ :len \$FileName ] = 0 || [ :len \$User ] = 0) do={\r\ +< \n \$LogPrint warning \$0 (\"Missing argument(s), please pass file name\ +< \_and user!\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :if ([ \$FileExists \$FileName ] = false) do={\r\ +< \n \$LogPrint warning \$0 (\"File '\" . \$FileName . \"' does not exist\ +< .\");\r\ +< \n :return false;\r\ +< \n }\r\ +< \n :local Keys [ :tolf [ /file/get \$FileName contents ] ];\r\ +< \n :foreach KeyVal in=[ :deserialize \$Keys delimiter=\" \" from=dsv opti\ +< ons=dsv.plain ] do={\r\ +< \n :local Continue false;\r\ +< \n :if (\$KeyVal->0 = \"ssh-ed25519\" || \$KeyVal->0 = \"ssh-rsa\") do=\ +< {\r\ +< \n :if ([ \$SSHKeysImport (\$KeyVal->0 . \" \" . \$KeyVal->1 . \" \" \ +< . \$KeyVal->2) \$User ] = false) do={\r\ +< \n \$LogPrint warning \$0 (\"Failed importing key for user '\" . \$\ +< User . \"'.\");\r\ +< \n }\r\ +< \n :set Continue true;\r\ +< \n }\r\ +< \n :if (\$Continue = false && \$KeyVal->0 = \"#\") do={\r\ +< \n :set User [ \$EitherOr ([ \$ParseKeyValueStore (\$KeyVal->1) ]->\"\ +< user\") \$User ];\r\ +< \n :set Continue true;\r\ +< \n }\r\ +< \n :if (\$Continue = false && [ :len (\$KeyVal->0) ] > 0) do={\r\ +< \n \$LogPrint warning \$0 (\"SSH key of type '\" . \$KeyVal->0 . \"' \ +< is not supported.\");\r\ +< \n }\r\ +< \n }\r\ +< \n} do={\r\ +< \n :global ExitOnError; \$ExitOnError \$0 \$Err;\r\ +< \n} }\r\ +< \n} do={:global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err}\r\ +< \n" +< add comment="Enable or disable ip addresses based on bridge port state" \ +< dont-require-permissions=no name=mod/AM-IPbridge owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< !rsc by Vados\r\ +< \n# RouterOS script: mod/AM-IPbridge\r\ +< \n# Script comment: Enable or disable ip addresses based on bridge port st\ +< ate\r\ +< \n# Copyright (c) 2005-2026 Vados \r\ +< \n#\r\ +< \n#\r\ +< \n# requires RouterOS, version=7.19\r\ +< \n# requires device-mode, fetch\r\ +< \n#\r\ +< \n:local ScriptName [ :jobname ];\r\ +< \n\r\ +< \n# Add this Script scheduler\r\ +< \n:if ([ :len [ /system/scheduler/find where name=\$ScriptName ] ] = 0) do\ +< ={\r\ +< \n:log warning (\"SystemScheduler for script: \" . \$ScriptName . \" is NO\ +< T SET! Fix It Now!\");\r\ +< \n:local OnEvent \"/system/script/run \$ScriptName;\";\r\ +< \n:local Comment \"Every Day Check For Fake Bridges\";\r\ +< \n/system/scheduler/add name=\$ScriptName comment=\$Comment start-time=sta\ +< rtup interval=1d on-event=\$OnEvent;\r\ +< \n}\r\ +< \n\r\ +< \n:foreach Bridge in=[ /interface/bridge/find ] do={\r\ +< \n :local BrName [ /interface/bridge/get \$Bridge name ];\r\ +< \n :if ([ :len [ /interface/bridge/port/find where bridge=\$BrName ] ] > \ +< 0) do={\r\ +< \n :if ([ :len [ /interface/bridge/port/find where bridge=\$BrName and \ +< inactive=no ] ] = 0) do={\r\ +< \n /ip/address/disable [ find where !dynamic interface=\$BrName ];\r\ +< \n } else={\r\ +< \n /ip/address/enable [ find where !dynamic interface=\$BrName ];\r\ +< \n }\r\ +< \n }\r\ +< \n}\r\ +< \n" +< add comment="Check for certificates validity" dont-require-permissions=no \ +< name=AM-CheckCerts owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< !rsc by Vados\r\ +< \n# RouterOS script: AM-CheckCerts\r\ +< \n# Script comment: Check for certificates validity\r\ +< \n# Copyright (c) 2005-2026 Vados \r\ +< \n#\r\ +< \n#\r\ +< \n# requires RouterOS, version=7.19\r\ +< \n# requires device-mode, fetch\r\ +< \n\r\ +< \n:local ExitOK false;\r\ +< \n:onerror Err {\r\ +< \n :global GlobalConfReady; :global GlobalFuncReady;\r\ +< \n :retry { :if (\$GlobalConfReady != true || \$GlobalFuncReady != true) \ +< \\\r\ +< \n do={ :error (\"Global config and/or functions not ready.\"); }; } \ +< delay=500ms max=50;\r\ +< \n :local ScriptName [ :jobname ];\r\ +< \n\r\ +< \n :global CertRenewTime;\r\ +< \n :global CertRenewUrl;\r\ +< \n :global CertWarnTime;\r\ +< \n :global Identity;\r\ +< \n\r\ +< \n :global CertificateAvailable;\r\ +< \n :global EscapeForRegEx;\r\ +< \n :global IfThenElse;\r\ +< \n :global LogPrint;\r\ +< \n :global ParseKeyValueStore;\r\ +< \n :global ScriptLock;\r\ +< \n :global SendNotification2;\r\ +< \n :global SymbolForNotification;\r\ +< \n :global UrlEncode;\r\ +< \n# :global WaitFullyConnected;\r\ +< \n\r\ +< \n# Add this Script scheduler\r\ +< \n:if ([ :len [ /system/scheduler/find where name=\$ScriptName ] ] = 0) do\ +< ={\r\ +< \n:log warning (\"System Scheduler for script: \" . \$ScriptName . \" is N\ +< OT SET! Fix It Now!\");\r\ +< \n:local OnEvent \"/system/script/run \$ScriptName;\";\r\ +< \n:local Comment \"Every Day Check For Renew Certificates\";\r\ +< \n/system/scheduler/add name=\$ScriptName comment=\$Comment start-time=sta\ +< rtup interval=1d on-event=\$OnEvent;\r\ +< \n}\r\ +< \n\r\ +< \n\r\ +< \n :local CheckCertificatesDownloadImport do={\r\ +< \n :local ScriptName [ :tostr \$1 ];\r\ +< \n :local CertName [ :tostr \$2 ];\r\ +< \n :local FetchName [ :tostr \$3 ];\r\ +< \n\r\ +< \n :global CertRenewUrl;\r\ +< \n :global CertRenewPass;\r\ +< \n\r\ +< \n :global CertificateNameByCN;\r\ +< \n :global EscapeForRegEx;\r\ +< \n :global FetchUserAgentStr;\r\ +< \n :global LogPrint;\r\ +< \n :global RmFile;\r\ +< \n :global UrlEncode;\r\ +< \n :global WaitForFile;\r\ +< \n\r\ +< \n :foreach Type in={ \"p12\"; \"pem\" } do={\r\ +< \n :local CertFileName ([ \$UrlEncode \$FetchName ] . \".\" . \$Type)\ +< ;\r\ +< \n \$LogPrint debug \$ScriptName (\"Trying type '\" . \$Type . \"' fo\ +< r '\" . \$CertName . \\\r\ +< \n \"' (file '\" . \$CertFileName . \"')...\");\r\ +< \n\r\ +< \n :do {\r\ +< \n :onerror Err {\r\ +< \n /tool/fetch check-certificate=yes-without-crl \\\r\ +< \n http-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] \ +< }) \\\r\ +< \n (\$CertRenewUrl . \$CertFileName) dst-path=\$CertFileName \ +< as-value;\r\ +< \n } do={\r\ +< \n :if (!(\$Err ~ \"[Ss]tatus 404\")) do={\r\ +< \n \$LogPrint warning \$0 (\"Failed fetching certificate: \" . \ +< \$Err);\r\ +< \n }\r\ +< \n :error false;\r\ +< \n }\r\ +< \n \$WaitForFile \$CertFileName; \r\ +< \n\r\ +< \n :local DecryptionFailed true;\r\ +< \n :foreach I,PassPhrase in=\$CertRenewPass do={\r\ +< \n :do {\r\ +< \n \$LogPrint debug \$ScriptName (\"Trying \" . \$I . \". passp\ +< hrase... \");\r\ +< \n :local Result [ /certificate/import file-name=\$CertFileName\ +< \_passphrase=\$PassPhrase as-value ];\r\ +< \n :if (\$Result->\"decryption-failures\" = 0) do={\r\ +< \n \$LogPrint debug \$ScriptName (\"Success!\");\r\ +< \n :set DecryptionFailed false;\r\ +< \n }\r\ +< \n } on-error={ }\r\ +< \n }\r\ +< \n \$RmFile \$CertFileName;\r\ +< \n\r\ +< \n :if (\$DecryptionFailed = true) do={\r\ +< \n \$LogPrint warning \$ScriptName (\"Decryption failed for certi\ +< ficate file '\" . \$CertFileName . \"'.\");\r\ +< \n }\r\ +< \n\r\ +< \n :foreach CertInChain in=[ /certificate/find where common-name!=\ +< \$CertName !private-key \\\r\ +< \n name~(\"^\" . [ \$EscapeForRegEx \$CertFileName ] . \"_[0-9]\ +< +\\\$\") \\\r\ +< \n !(subject-alt-name~(\"(^|\\\\W)(DNS|IP):\" . [ \$EscapeForRe\ +< gEx \$CertName ] . \"(\\\\W|\\\$)\")) \\\r\ +< \n !(common-name=[]) ] do={\r\ +< \n \$CertificateNameByCN [ /certificate/get \$CertInChain common-\ +< name ];\r\ +< \n }\r\ +< \n\r\ +< \n :return true;\r\ +< \n } on-error={\r\ +< \n \$LogPrint debug \$ScriptName (\"Could not download certificate \ +< file '\" . \$CertFileName . \"'.\");\r\ +< \n }\r\ +< \n }\r\ +< \n\r\ +< \n :return false;\r\ +< \n }\r\ +< \n\r\ +< \n :local FormatInfo do={\r\ +< \n :local Cert \$1;\r\ +< \n\r\ +< \n :global FormatLine;\r\ +< \n :global FormatMultiLines;\r\ +< \n :global IfThenElse;\r\ +< \n\r\ +< \n :local FormatExpire do={\r\ +< \n :global CharacterReplace;\r\ +< \n :return [ \$CharacterReplace [ \$CharacterReplace [ :tostr \$1 ] \ +< \"w\" \"w \" ] \"d\" \"d \" ];\r\ +< \n }\r\ +< \n\r\ +< \n :local FormatCertChain do={\r\ +< \n :local Cert \$1;\r\ +< \n\r\ +< \n :global ParseKeyValueStore;\r\ +< \n\r\ +< \n :local CertVal [ /certificate/get \$Cert ];\r\ +< \n\r\ +< \n :if ([ :typeof (\$CertVal->\"issuer\") ] = \"nothing\") do={\r\ +< \n :return \"self-signed\";\r\ +< \n }\r\ +< \n\r\ +< \n :local Return \"\";\r\ +< \n :for I from=0 to=5 do={\r\ +< \n :set Return (\$Return . [ \$ParseKeyValueStore (\$CertVal->\"iss\ +< uer\") ]->\"CN\");\r\ +< \n :if ([ :len [ /certificate/builtin/find where skid=(\$CertVal->\ +< \"akid\") ] ] > 0) do={\r\ +< \n :return \$Return;\r\ +< \n }\r\ +< \n :do {\r\ +< \n :set CertVal [ /certificate/get [ find where skid=(\$CertVal->\ +< \"akid\") ] ];\r\ +< \n } on-error={\r\ +< \n :return (\$Return . \" (possibly incomplete!)\");\r\ +< \n }\r\ +< \n :if ((\$CertVal->\"akid\") = \"\" || (\$CertVal->\"akid\") = (\$\ +< CertVal->\"skid\")) do={\r\ +< \n :return \$Return;\r\ +< \n }\r\ +< \n :set Return (\$Return . \" -> \");\r\ +< \n }\r\ +< \n :return (\$Return . \"...\");\r\ +< \n }\r\ +< \n\r\ +< \n :local CertVal [ /certificate/get \$Cert ];\r\ +< \n\r\ +< \n :return ( \\\r\ +< \n [ \$FormatLine \"Name\" (\$CertVal->\"name\") ] . \"\\n\" . \\\r\ +< \n [ \$IfThenElse ([ :len (\$CertVal->\"common-name\") ] > 0) ([ \$Fo\ +< rmatLine \"CommonName\" (\$CertVal->\"common-name\") ] . \"\\n\") ] . \\\r\ +< \n [ \$IfThenElse ([ :len (\$CertVal->\"subject-alt-name\") ] > 0) ([\ +< \_\$FormatMultiLines \"SubjectAltNames\" (\$CertVal->\"subject-alt-name\")\ +< \_] . \"\\n\") ] . \\\r\ +< \n [ \$FormatLine \"Private key\" [ \$IfThenElse ((\$CertVal->\"priva\ +< te-key\") = true) \"available\" \"missing\" ] ] . \"\\n\" . \\\r\ +< \n [ \$FormatLine \"Fingerprint\" (\$CertVal->\"fingerprint\") ] . \"\ +< \\n\" . \\\r\ +< \n [ \$IfThenElse ([ :len (\$CertVal->\"ca\") ] > 0) [ \$FormatLine \ +< \"Issuer\" (\$CertVal->\"ca\") ] [ \$FormatLine \"Issuer chain\" [ \$Forma\ +< tCertChain \$Cert ] ] ] . \"\\n\" . \\\r\ +< \n \"Validity:\\n\" . \\\r\ +< \n [ \$FormatLine \" days\" (\$CertVal->\"days-valid\") ] . \"\\n\ +< \" . \\\r\ +< \n [ \$FormatLine \" from\" (\$CertVal->\"invalid-before\") ] . \"\ +< \\n\" . \\\r\ +< \n [ \$FormatLine \" to\" (\$CertVal->\"invalid-after\") ] . \"\\n\ +< \" . \\\r\ +< \n [ \$FormatLine \" time left\" [ \$IfThenElse ((\$CertVal->\"exp\ +< ired\") = true) \"expired\" [ \$FormatExpire (\$CertVal->\"expires-after\"\ +< ) ] ] ]);\r\ +< \n }\r\ +< \n\r\ +< \n :if ([ \$ScriptLock \$ScriptName ] = false) do={\r\ +< \n :set ExitOK true;\r\ +< \n :error false;\r\ +< \n }\r\ +< \n# \$WaitFullyConnected;\r\ +< \n\r\ +< \n :foreach Cert in=[ /certificate/find where !revoked !ca !scep-url expi\ +< res-after<\$CertRenewTime ] do={\r\ +< \n :local CertVal [ /certificate/get \$Cert ];\r\ +< \n :local LastName;\r\ +< \n :local FetchName;\r\ +< \n\r\ +< \n :do {\r\ +< \n :if ([ :len \$CertRenewUrl ] = 0) do={\r\ +< \n \$LogPrint info \$ScriptName (\"No CertRenewUrl given.\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n \$LogPrint info \$ScriptName (\"Attempting to renew certificate '\ +< \" . (\$CertVal->\"name\") . \"'.\");\r\ +< \n\r\ +< \n :local ImportSuccess false;\r\ +< \n :if ([ :len (\$CertVal->\"common-name\") ] > 0) do={\r\ +< \n :set LastName (\$CertVal->\"common-name\");\r\ +< \n :set FetchName \$LastName;\r\ +< \n :set ImportSuccess [ \$CheckCertificatesDownloadImport \$ScriptN\ +< ame \$LastName \$FetchName ];\r\ +< \n }\r\ +< \n :foreach SAN in=(\$CertVal->\"subject-alt-name\") do={\r\ +< \n :if (\$ImportSuccess = false) do={\r\ +< \n :set LastName [ :pick \$SAN ([ :find \$SAN \":\" ] + 1) [ :len\ +< \_\$SAN ] ];\r\ +< \n :set FetchName \$LastName;\r\ +< \n :set ImportSuccess [ \$CheckCertificatesDownloadImport \$Scrip\ +< tName \$LastName \$FetchName ];\r\ +< \n :if (\$ImportSuccess = false && [ :pick \$LastName 0 2 ] = \"*\ +< .\") do={\r\ +< \n :set FetchName (\"star.\" . [ :pick \$LastName 2 [ :len \$La\ +< stName ] ]);\r\ +< \n :set ImportSuccess [ \$CheckCertificatesDownloadImport \$Scr\ +< iptName \$LastName \$FetchName ];\r\ +< \n }\r\ +< \n }\r\ +< \n }\r\ +< \n :if (\$ImportSuccess = false) do={ :error false; }\r\ +< \n\r\ +< \n :if ([ :len (\$CertVal->\"fingerprint\") ] > 0 && \$CertVal->\"fin\ +< gerprint\" != [ /certificate/get \$Cert fingerprint ]) do={\r\ +< \n \$LogPrint debug \$ScriptName (\"Certificate '\" . \$CertVal->\"\ +< name\" . \"' was updated in place.\");\r\ +< \n :set CertVal [ /certificate/get \$Cert ];\r\ +< \n } else={\r\ +< \n \$LogPrint debug \$ScriptName (\"Certificate '\" . \$CertVal->\"\ +< name\" . \"' was not updated, but replaced.\");\r\ +< \n\r\ +< \n :local CertNew [ /certificate/find where name~(\"^\" . [ \$Escap\ +< eForRegEx [ \$UrlEncode \$FetchName ] ] . \"\\\\.(p12|pem)_[0-9]+\\\$\") \ +< \\\r\ +< \n (common-name=(\$CertVal->\"common-name\") or subject-alt-name~\ +< (\"(^|\\\\W)(DNS|IP):\" . [ \$EscapeForRegEx \$LastName ] . \"(\\\\W|\\\$)\ +< \")) \\\r\ +< \n fingerprint!=[ :tostr (\$CertVal->\"fingerprint\") ] ];\r\ +< \n :local CertNewVal [ /certificate/get \$CertNew ];\r\ +< \n\r\ +< \n :if ((\$CertVal->\"expires-after\") > (\$CertNewVal->\"expires-a\ +< fter\")) do={\r\ +< \n /certificate/remove \$CertNew;\r\ +< \n \$LogPrint warning \$ScriptName (\"Old certificate is newer th\ +< an the new one. Aborting renew.\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n\r\ +< \n :if ((\$CertVal->\"private-key\") = true && (\$CertVal->\"privat\ +< e-key\") != (\$CertNewVal->\"private-key\")) do={\r\ +< \n /certificate/remove \$CertNew;\r\ +< \n \$LogPrint warning \$ScriptName (\"Old certificate '\" . (\$Ce\ +< rtVal->\"name\") . \"' has a private key, new certificate does not. Aborti\ +< ng renew.\");\r\ +< \n :error false;\r\ +< \n }\r\ +< \n\r\ +< \n :if ([ \$CertificateAvailable ([ \$ParseKeyValueStore (\$CertNew\ +< Val->\"issuer\") ]->\"CN\") \"fetch\" ] = false) do={\r\ +< \n \$LogPrint warning \$ScriptName (\"The certificate chain is no\ +< t available!\");\r\ +< \n }\r\ +< \n\r\ +< \n /ip/service/set certificate=(\$CertNewVal->\"name\") [ find wher\ +< e certificate=(\$CertVal->\"name\") ];\r\ +< \n\r\ +< \n /ip/ipsec/identity/set certificate=(\$CertNewVal->\"name\") [ fi\ +< nd where certificate=(\$CertVal->\"name\") ];\r\ +< \n /ip/ipsec/identity/set remote-certificate=(\$CertNewVal->\"name\ +< \") [ find where remote-certificate=(\$CertVal->\"name\") ];\r\ +< \n\r\ +< \n /ip/hotspot/profile/set ssl-certificate=(\$CertNewVal->\"name\")\ +< \_[ find where ssl-certificate=(\$CertVal->\"name\") ];\r\ +< \n\r\ +< \n /certificate/remove \$Cert;\r\ +< \n /certificate/set \$CertNew name=(\$CertVal->\"name\");\r\ +< \n :set Cert \$CertNew;\r\ +< \n :set CertVal [ /certificate/get \$CertNew ];\r\ +< \n }\r\ +< \n\r\ +< \n \$SendNotification2 ({ origin=\$ScriptName; silent=true; \\\r\ +< \n subject=([ \$SymbolForNotification \"lock-with-ink-pen\" ] . \"C\ +< ertificate renewed: \" . (\$CertVal->\"name\")); \\\r\ +< \n message=(\"A certificate on \" . \$Identity . \" has been renewe\ +< d.\\n\\n\" . [ \$FormatInfo \$Cert ]) });\r\ +< \n \$LogPrint info \$ScriptName (\"The certificate '\" . (\$CertVal->\ +< \"name\") . \"' has been renewed.\");\r\ +< \n } on-error={\r\ +< \n \$LogPrint debug \$ScriptName (\"Could not renew certificate '\" .\ +< \_(\$CertVal->\"name\") . \"'.\");\r\ +< \n }\r\ +< \n }\r\ +< \n\r\ +< \n :foreach Cert in=[ /certificate/find where !revoked !scep-url !(expire\ +< s-after=[]) \\\r\ +< \n expires-after<\$CertWarnTime !(fingerprint=[]) ] do\ +< ={\r\ +< \n :local CertVal [ /certificate/get \$Cert ];\r\ +< \n\r\ +< \n :if ([ :len [ /certificate/scep-server/find where ca-cert=(\$CertVal\ +< ->\"ca\") ] ] > 0) do={\r\ +< \n \$LogPrint debug \$ScriptName (\"Certificate '\" . (\$CertVal->\"n\ +< ame\") . \"' is handled by SCEP, skipping.\");\r\ +< \n } else={\r\ +< \n :local State [ \$IfThenElse ((\$CertVal->\"expired\") = true) \"ex\ +< pired\" \"is about to expire\" ];\r\ +< \n\r\ +< \n \$SendNotification2 ({ origin=\$ScriptName; \\\r\ +< \n subject=([ \$SymbolForNotification \"lock-with-ink-pen,warning-s\ +< ign\" ] . \"Certificate warning: \" . (\$CertVal->\"name\")); \\\r\ +< \n message=(\"A certificate on \" . \$Identity . \" \" . \$State . \ +< \".\\n\\n\" . [ \$FormatInfo \$Cert ]) });\r\ +< \n \$LogPrint info \$ScriptName (\"The certificate '\" . (\$CertVal->\ +< \"name\") . \"' \" . \$State . \\\r\ +< \n \", it is invalid after \" . (\$CertVal->\"invalid-after\") . \ +< \".\");\r\ +< \n }\r\ +< \n }\r\ +< \n} do={\r\ +< \n :global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err;\r\ +< \n}\r\ +< \n" +< add comment="Global Config Script" dont-require-permissions=no name=\ +< AM-GlobalConfig owner=vados policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< !rsc by Vados\ +< \n# RouterOS script: AM-GlobalConfig\ +< \n# Script comment: Global Config Script\ +< \n# Copyright (c) 2007-2026 Vados \ +< \n#\ +< \n#\ +< \n# Warning: Dont touch this line!\ +< \n:global GlobalConfReady false;\ +< \n#\ +< \n#\ +< \n# Global Url For Amster scripts to fetch\ +< \n# most be defined in AM-Init-Script or AM-setup scripts\ +< \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\ +< \n:global ScriptsUrlSuffix \"\";\ +< \n:global CheckSumsVerify true;\ +< \n\ +< \n:global ScriptUpdatesCRLF true;\ +< \n:global CommentsInScripts true;\ +< \n\ +< \n# Debug output:\ +< \n:global PrintDebug true; #false;\ +< \n\ +< \n# Debug output for specific script:\ +< \n:set (\$PrintDebugOverride->\"AM-GlobalFunc\") true;\ +< \n\ +< \n# Debug logs\ +< \n# Other actions (disk, email, remote or support) can be used as well.\ +< \n# I do not recommend using echo - use debug output instead (https://rsc.\ +< eworm.de/main/DEBUG.html#debug-output).\ +< \n#/system/logging/add topics=script,debug action=memory;\ +< \n\ +< \n:global MikrotikUpgradeUrl \"https://upgrade.mikrotik.com/routeros\";\ +< \n:global Domain \"WORKGROUP\";\ +< \n\ +< \n:global EmailGeneralTo \"vados@vados.ru\";\ +< \n#:global EmailGeneralCc \"\";\ +< \n\ +< \n# \$ScriptInstallUpdate mod/notification-telegram\ +< \n:global TelegramTokenId \"8390868324:AAG3_d1hfVR2M6pGAgDK6ZvhOe4J97nyopw\ +< \";\ +< \n:global TelegramChatId \"-1003631309063\"; #\"454403445\";\ +< \n# Use this to send notifications to a specific topic in group.\ +< \n#:global TelegramThreadId \"30\";\ +< \n# Using telegram-chat you have to define trusted chat ids (not group ids\ +< !)\ +< \n# or user names. Groups allow to chat with devices simultaneously.\ +< \n:global TelegramChatIdsTrusted {\ +< \n \"454403445\"\ +< \n \"-1003631309063\"\ +< \n \"-5124482807\"\ +< \n \"1087968824\";\ +< \n};\ +< \n# \"-5294757340\";\ +< \n\ +< \n:global TelegramChatGroups \"(all)\";\ +< \n#:global TelegramChatGroups \"(all|home|office)\";\ +< \n\ +< \n:global NotificationFunctions {\ +< \n \"email\"\ +< \n \"telegram\";\ +< \n};\ +< \n# Toggle this to disable symbols in notifications.\ +< \n:global NotificationsWithSymbols true;\ +< \n:global TerminalColorOutput true;\ +< \n\ +< \n:global DetectIpAddrDefault \"https://ipv4.mikrotik.ovh/\";\ +< \n:global DetectIpAddrFallback \"https://api.ipify.org/\";\ +< \n\ +< \n## Update channel. Possible values: stable, long-term, testing, developm\ +< ent\ +< \n:global updateChannel \"stable\";\ +< \n\ +< \n:global CertRenewUrl (\$GlobalScriptsUrl . \"certs/\");\ +< \n:global CertRenewTime 2w;\ +< \n:global CertRenewPass {\ +< \n \"\";\ +< \n# \"v3ry-s3cr3t\";\ +< \n# \"4n0th3r-s3cr3t\";\ +< \n};\ +< \n:global CertWarnTime 1w;\ +< \n:global CertIssuedExportPass {\ +< \n \"\";\ +< \n# \"cert1-cn\"=\"v3ry-s3cr3t\";\ +< \n# \"cert2-cn\"=\"4n0th3r-s3cr3t\";\ +< \n};\ +< \n\ +< \n# Script BackupAndUpdate mode, possible values: backup,\ +< \n# updateOnce - Update once as \"osnotify\" and back \"osnotify\" mode (i\ +< n terminal run :set OSUpdateMode updateOnce; \$OSUpdateMode;). \ +< \n# osupdate - Update if available and creates backups before/after update\ +< \_(ignores `forceBackup`)\ +< \n# Set `forceBackup` to true to always create backups, even\ +< \_without updates\ +< \n# osnotify - Set `forceBackup` to always create backups on every run\ +< \n:global DevInfoIncludeIP true;\ +< \n:global BackupAndUpdateMode \"osnotify\"\ +< \n\ +< \n:global forceBackup true;\ +< \n:global BackupPassword \"Peskar55\";\ +< \n\ +< \n# SFTP Backup Variables\ +< \n:global BackupRandomDelay 0;\ +< \n:global BackupUploadUrl \"sftp://amster.vados.ru/upload/\";\ +< \n:global BackupUploadUser \$Identity;\ +< \n:global BackupUploadPass \"root.mnuc.backuper\";\ +< \n\ +< \n:global BackupSendBinary true;\ +< \n:global BackupSendExport true;\ +< \n:global BackupSendGlobalConfig true;\ +< \n:global BackupSendScripts true;\ +< \n\ +< \n# Remove local file after uploading if no errors\ +< \n:global BackupRmLocal true;\ +< \n\ +< \n# Local Backups Root Directory \ +< \n:global BackupLocalRoot \"tmpfs\";\ +< \n\ +< \n# Encrypt Backup\ +< \n:global BackupEncrypt true;\ +< \n\ +< \n# Sensitive information in Backups\ +< \n:global BackupSens true;\ +< \n\ +< \n# User Export\ +< \n:global BackupUser true;\ +< \n\ +< \n# License Export (not for CHR, will silently skip)\ +< \n:global BackupLicense false;\ +< \n\ +< \n# SSH Keys\ +< \n:global BackupSshKeys true;\ +< \n\ +< \n# Certificate Export\ +< \n:global BackupCerts true;\ +< \n\ +< \n# Certificate Password\ +< \n:global BackupCertsPasswd \"\";\ +< \n\ +< \n# User-Manager Export\ +< \n:global BackupUserMan false;\ +< \n\ +< \n# The Dude Export\ +< \n:global BackupDude false;\ +< \n\ +< \n# User Files to export, comma-separated string or array of strings\ +< \n# User Files are not removed on backup\ +< \n# Any directory paths will be removed (/ -> _) on remote file\ +< \n# Nonpresent files are silently skipped\ +< \n:global BackupUserList \"autosupout.rif,autosupout.old.rif\";\ +< \n\ +< \n# load functions and any custom scripts\ +< \n# [ /system/script/find where name=\"global-config-ov\ +< erlay\" ], \\\ +< \n# [ /system/script/find where name~\"^global-config-o\ +< verlay\\\\.d/.\" ]\ +< \n#\ +< \n#:foreach Script in=([ /system/script/find where name=\"Amster-TGglobalV\ +< ars\" ], [ /system/script/find where name=\"Amster-TGglobalFunc\" ]) do={\ +< \n# :onerror Err {\ +< \n# /system/script/run \$Script;\ +< \n# } do={\ +< \n# :log error (\"Loading configuration from configs and functions\"\ +< \_. [ /system/script/get \$Script name ] . \" failed: \" . \$Err);\ +< \n# }\ +< \n#}\ +< \n#:log info \"\\ndevMode = \$devMode\";\ +< \n#:log info \"\\ndevRunning = \$devRunning\";\ +< \n:foreach Script in=[ /system/script/find where source~\"^#!rsc by Vados \ +< GlobalRUN\\r\?\\n\" ] do={\ +< \n :onerror Err {\ +< \n /system/script/run \$Script;\ +< \n } do={\ +< \n :log error (\"Run script \" . [ /system/script/get \$Script name \ +< ] . \" width marker \\\" GlobalRUN\\\" failed: \" . \$Err);\ +< \n }\ +< \n}\ +< \n\ +< \n# signal we are ready\ +< \n:set GlobalConfReady true;\ +< \n:while (\$GlobalConfReady != true) do={:delay 500ms};\ +< \n" +< add comment="Renew locally issued certificates" dont-require-permissions=no \ +< name=AM-CertsRenew owner=AM-CertsRenew policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ +< !rsc by Vados\r\ +< \n# RouterOS script: AM-CertsRenew\r\ +< \n# Script comment: Renew locally issued certificates\r\ +< \n# Copyright (c) 2005-2026 Vados \r\ +< \n#\r\ +< \n#\r\ +< \n# requires RouterOS, version=7.19\r\ +< \n#\r\ +< \n:local ExitOK false;\r\ +< \n:onerror Err {\r\ +< \n :global GlobalConfReady; :global GlobalFuncReady;\r\ +< \n :retry { :if (\$GlobalConfReady != true || \$GlobalFuncReady != true) \ +< \\\r\ +< \n do={ :error (\"Global config and/or functions not ready.\"); }; } \ +< delay=500ms max=50;\r\ +< \n :local ScriptName [ :jobname ];\r\ +< \n\r\ +< \n :global CertIssuedExportPass;\r\ +< \n\r\ +< \n :global LogPrint;\r\ +< \n :global MkDir;\r\ +< \n :global ScriptLock;\r\ +< \n\r\ +< \n# Add this Script scheduler\r\ +< \n:if ([ :len [ /system/scheduler/find where name=\$ScriptName ] ] = 0) do\ +< ={\r\ +< \n:log warning (\"System Scheduler for script: \" . \$ScriptName . \" is N\ +< OT SET! Fix It Now!\");\r\ +< \n:local OnEvent \"/system/script/run \$ScriptName;\";\r\ +< \n:local Comment \"Every Day Check For Update Local Issued Certificates.\"\ +< ;\r\ +< \n#/system/scheduler/add name=\$ScriptName comment=\$Comment start-time=st\ +< artup interval=1d on-event=\$OnEvent;\r\ +< \n}\r\ +< \n\r\ +< \n :if ([ \$ScriptLock \$ScriptName ] = false) do={\r\ +< \n :set ExitOK true;\r\ +< \n :error false;\r\ +< \n }\r\ +< \n\r\ +< \n :foreach Cert in=[ /certificate/find where issued expires-after<3w ] d\ +< o={\r\ +< \n :local CertVal [ /certificate/get \$Cert ];\r\ +< \n /certificate/issued-revoke \$Cert;\r\ +< \n /certificate/set name=(\$CertVal->\"name\" . \"-revoked-\" . [ /syst\ +< em/clock/get date ]) \$Cert;\r\ +< \n /certificate/add name=(\$CertVal->\"name\") common-name=(\$CertVal->\ +< \"common-name\") \\\r\ +< \n key-usage=(\$CertVal->\"key-usage\") subject-alt-name=(\$CertVal\ +< ->\"subject-alt-name\");\r\ +< \n /certificate/sign (\$CertVal->\"name\") ca=(\$CertVal->\"ca\");\r\ +< \n :if ([ :typeof (\$CertIssuedExportPass->(\$CertVal->\"common-name\")\ +< ) ] = \"str\") do={\r\ +< \n :if ([ \$MkDir \"cert-issued\" ] = true) do={\r\ +< \n /certificate/export-certificate (\$CertVal->\"name\") type=pkcs1\ +< 2 \\\r\ +< \n file-name=(\"cert-issued/\" . \$CertVal->\"common-name\") \\\ +< \r\ +< \n export-passphrase=(\$CertIssuedExportPass->(\$CertVal->\"com\ +< mon-name\"));\r\ +< \n \$LogPrint info \$ScriptName (\"Issued a new certificate for '\"\ +< \_. \$CertVal->\"common-name\" . \\\r\ +< \n \"', exported to 'cert-issued/\" . \$CertVal->\"common-name\" \ +< . \".p12'.\");\r\ +< \n } else={\r\ +< \n \$LogPrint warning \$ScriptName (\"Failed creating directory, no\ +< t exporting certificate.\");\r\ +< \n }\r\ +< \n } else={\r\ +< \n \$LogPrint info \$ScriptName (\"Issued a new certificate for '\" .\ +< \_\$CertVal->\"common-name\" . \"'.\");\r\ +< \n }\r\ +< \n }\r\ +< \n} do={\r\ +< \n :global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err;\r\ +< \n}\r\ +< \n" +< /user group +< add name=backup policy="telnet,ssh,ftp,read,write,policy,test,sniff,sensitive,\ +< !local,!reboot,!winbox,!password,!web,!api,!romon,!rest-api" +< /caps-man provisioning +< add action=create-dynamic-enabled hw-supported-modes=gn master-configuration=\ +< cfg-2ghz name-format=prefix-identity name-prefix=2ghz +< add action=create-dynamic-enabled hw-supported-modes=ac master-configuration=\ +< cfg-5ghz-ac name-format=prefix-identity name-prefix=5ghz-ac +< add action=create-dynamic-enabled hw-supported-modes=an master-configuration=\ +< cfg-5ghz-an name-format=prefix-identity name-prefix=5ghz-an +< /certificate settings +< set builtin-trust-store=fetch +< /disk settings +< set auto-media-interface=lo default-mount-point-template="[tmpfs]" +< /ip smb +< set comment=MikroVados domain=WORKGROUP enabled=yes interfaces=Bridge-LAN +< /interface bridge port +< add bridge=Bridge-LAN ingress-filtering=no interface=ether2 \ +< internal-path-cost=10 path-cost=10 +< add bridge=Bridge-LAN comment=LEN ingress-filtering=no interface=ether3 \ +< internal-path-cost=10 path-cost=10 +< add bridge=Bridge-LAN comment=NUC ingress-filtering=no interface=ether4 \ +< internal-path-cost=10 path-cost=10 +< add bridge=Bridge-LAN ingress-filtering=no interface=ether5 \ +< internal-path-cost=10 path-cost=10 +< /ip firewall connection tracking +< set udp-timeout=10s +< /ip neighbor discovery-settings +< set discover-interface-list=LAN +< /ip settings +< set max-neighbor-entries=8192 secure-redirects=no +< /ipv6 settings +< set disable-ipv6=yes max-neighbor-entries=8192 +< /interface detect-internet +< set detect-interface-list=WAN internet-interface-list=WAN lan-interface-list=\ +< LAN wan-interface-list=WAN +< /interface l2tp-server server +< set authentication=mschap2 use-ipsec=yes +< /interface list member +< add comment=WAN interface="ether1 - Unet" list=WAN +< add interface=Bridge-LAN list=LAN +< /interface ovpn-server server +< add auth=sha1,md5 mac-address=FE:82:A5:78:8E:84 name=ovpn-server1 +< /interface wifi cap +< set caps-man-addresses=10.30.30.10 certificate=request discovery-interfaces=\ +< wlan1,wlan2 lock-to-caps-man=no slaves-static=no +< /interface wifi capsman +< set package-path="" require-peer-certificate=no upgrade-policy=none +< /interface wifi provisioning +< add action=create-dynamic-enabled disabled=no master-configuration=2G-N \ +< name-format=2G-%I slave-configurations=2G-G supported-bands=\ +< 2ghz-n,2ghz-g,2ghz-g +< add action=create-dynamic-enabled disabled=no master-configuration=5G-AC \ +< name-format=5G-%I supported-bands=5ghz-ac,5ghz-ac +< /interface wireguard peers +< add allowed-address=10.8.0.2/32,0.0.0.0/0 client-allowed-address=0.0.0.0/0 \ +< endpoint-address=89.110.101.17 endpoint-port=29185 interface=WG name=\ +< MikroVados persistent-keepalive=10s public-key=\ +< "64Y25EUZQQt8EIeAJYD8qWt+te8qvGEepnswdBgmzlY=" +< /interface wireless cap +< # +< set bridge=Bridge-LAN caps-man-addresses=10.30.30.10 \ +< caps-man-certificate-common-names=CAPsMAN-51B25E507D07 certificate=\ +< CAP-18FD746E5814 discovery-interfaces=Bridge-LAN enabled=yes interfaces=\ +< wlan1,wlan2 lock-to-caps-man=yes +< /interface wireless sniffer +< set file-name=24g +< /ip address +< add address=10.30.30.81/24 interface=Bridge-LAN network=10.30.30.0 +< add address=10.8.0.2/24 interface=WG network=10.8.0.0 +< /ip dhcp-client +< add add-default-route=special-classless default-route-distance=2 \ +< default-route-tables=main interface="ether1 - Unet" name="ether1 - Unet" \ +< use-peer-dns=no +< /ip dhcp-server config +< set accounting=no +< /ip dhcp-server lease +< add address=10.30.30.101 client-id=1:48:8f:5a:8e:ee:a8 mac-address=\ +< 48:8F:5A:8E:EE:A8 server=masterDHCP +< add address=10.30.30.107 client-id=1:f0:de:f1:91:d:1e mac-address=\ +< F0:DE:F1:91:0D:1E server=masterDHCP +< add address=10.30.30.83 client-id=1:0:80:77:ec:43:86 mac-address=\ +< 00:80:77:EC:43:86 server=masterDHCP +< add address=10.30.30.70 dhcp-option=domain-search-list,HostName \ +< dhcp-option-set=HP1505n mac-address=00:1E:0B:1A:88:8D server=masterDHCP +< add address=10.30.30.50 client-id=1:4:7c:16:36:f5:37 mac-address=\ +< 04:7C:16:36:F5:37 server=masterDHCP +< add address=10.30.30.71 client-id=1:10:2d:41:2c:20:c2 mac-address=\ +< 10:2D:41:2C:20:C2 server=masterDHCP +< add address=10.30.30.61 client-id=1:10:8:c1:81:59:5f mac-address=\ +< 10:08:C1:81:59:5F server=masterDHCP +< add address=10.30.30.72 client-id=1:10:38:1f:d2:5f:13 mac-address=\ +< 10:38:1F:D2:5F:13 server=masterDHCP +< add address=10.30.30.99 client-id=1:10:b1:df:e9:d0:d5 mac-address=\ +< 10:B1:DF:E9:D0:D5 server=masterDHCP +< add address=10.30.30.111 client-id=1:fe:2:52:be:3f:16 mac-address=\ +< FE:02:52:BE:3F:16 server=masterDHCP +< add address=10.30.30.93 client-id=1:7e:8b:1e:cb:b8:cb mac-address=\ +< CC:42:10:12:46:94 server=masterDHCP +< add address=10.30.30.94 client-id=1:50:cc:f8:85:96:a mac-address=\ +< 50:CC:F8:85:96:0A server=masterDHCP +< add address=10.30.30.82 client-id=1:e4:18:6b:58:34:ab mac-address=\ +< E4:18:6B:58:34:AB server=masterDHCP +< add address=10.30.30.77 dhcp-option=HostName dhcp-option-set=StartLife1 \ +< mac-address=C4:82:E1:03:49:10 server=masterDHCP +< add address=10.30.30.73 client-id=1:10:38:1f:82:81:f2 mac-address=\ +< 10:38:1F:82:81:F2 server=masterDHCP +< add address=10.30.30.95 client-id=1:88:ae:dd:60:39:54 dhcp-option=HostName \ +< dhcp-option-set=VADOS-NUC mac-address=88:AE:DD:60:39:54 server=masterDHCP +< add address=10.30.30.98 client-id=1:c8:5b:76:d8:cc:bf dhcp-option=HostName \ +< dhcp-option-set=VADOS-LEN mac-address=C8:5B:76:D8:CC:BF server=masterDHCP +< add address=10.30.30.96 client-id=iPhone mac-address=4A:91:ED:0E:1F:39 \ +< server=masterDHCP +< add address=10.30.30.74 client-id=1:20:72:a9:d3:34:36 dhcp-option=HostName \ +< dhcp-option-set=MiTV mac-address=20:72:A9:D3:34:36 server=masterDHCP \ +< use-src-mac=yes +< add address=10.30.30.30 dhcp-option=HostName dhcp-option-set=miller \ +< mac-address=F0:75:5D:1E:5F:71 server=masterDHCP +< add address=10.30.30.100 client-id=iVados dhcp-option=HostName \ +< dhcp-option-set="=\"Client ID\"" mac-address=DE:4D:72:F3:1A:9F server=\ +< masterDHCP +< add address=10.30.30.86 dhcp-option=HostName dhcp-option-set=MikroYellow \ +< mac-address=48:8F:5A:8E:1A:C2 server=masterDHCP +< /ip dhcp-server network +< add address=10.30.30.0/24 caps-manager=10.30.30.10 dhcp-option=\ +< domain-search-list dhcp-option-set=domain-search-set dns-server=\ +< 10.30.30.81 domain=WORKGROUP gateway=10.30.30.81 netmask=24 ntp-server=\ +< 10.30.30.81,10.30.30.10 wins-server=10.30.30.95,10.30.30.98 +< /ip dns +< set allow-remote-requests=yes cache-max-ttl=1d doh-max-concurrent-queries=100 \ +< doh-max-server-connections=20 servers=8.8.8.8,8.8.4.4 verify-doh-cert=yes +< /ip dns static +< add address=10.30.30.33 name=amster-nuc type=A +< add address=10.30.30.33 comment=AMSTER name=amster.vados.ru type=A +< add address=10.30.30.33 name=amster type=A +< add address=10.30.30.33 name=amster-reg type=A +< add address=10.30.30.33 name=mng.vados.ru type=A +< add address=10.30.30.33 name=mgr.vados.ru type=A +< add address=10.30.30.33 name=prt.vados.ru type=A +< add address=10.30.30.33 name=git.vados.ru type=A +< add address=10.30.30.33 name=reg.vados.ru type=A +< add address=10.30.30.33 match-subdomain=yes name=ros.vados.ru type=A +< add address=10.30.30.33 match-subdomain=yes name=mikrots.vados.ru type=A +< add address=10.30.30.33 name=oxidized.vados.ru type=A +< add address=8.8.4.4 comment="Google-dns IPv4 2" name=dns.google type=A +< add address=8.8.8.8 comment="Google-dns IPv4 1" name=dns.google type=A +< add address=10.30.30.30 comment=MILLER name=miller.vados.ru type=A +< add address=10.30.30.30 name=MILLER-LEN type=A +< add address=10.30.30.30 name=miller type=A +< add address=1.1.1.1 comment="CloudFlare-doh IPv4 1" name=\ +< security.cloudflare-dns.com type=A +< add address=1.0.0.1 comment="CloudFlare-doh IPv4 2" name=\ +< security.cloudflare-dns.com type=A +< add address=9.9.9.9 comment="Cuad9-dns IPv4 1" disabled=yes name=\ +< dns.quad9.net type=A +< add address=149.112.112.112 comment="Cuad9-dns IPv4 2" disabled=yes name=\ +< dns.quad9.net type=A +< add address=91.192.189.2 comment=Unet-DNS disabled=yes name=ns1.unet.ws type=\ +< A +< add address=10.30.30.81 comment=LocalNet name=MikroVados type=A +< add address=10.30.30.10 name=MikroNUC type=A +< add address=10.30.30.86 name=MikroYellow type=A +< add address=10.30.30.85 name=MikroMic type=A +< add address=10.30.30.95 name=VADOS-NUC type=A +< add address=10.30.30.98 name=VADOS-LEN type=A +< add address=10.30.30.20 name=garage type=A +< add address=2606:4700:4700::1111 disabled=yes name=\ +< security.cloudflare-dns.com type=AAAA +< add address=2606:4700:4700::1001 disabled=yes name=\ +< security.cloudflare-dns.com type=AAAA +< /ip firewall address-list +< add address=91.215.120.206 list=TRUSTED +< add address=185.71.70.78 disabled=yes list=TRUSTED +< add address=176.53.203.171 disabled=yes list=TRUSTED +< add address=176.53.203.170 disabled=yes list=TRUSTED +< add address=176.53.202.194 disabled=yes list=TRUSTED +< add address=10.30.30.100-255 list=KIDS +< add address=8.8.4.0/24 list=YouTube +< add address=8.8.8.0/24 list=YouTube +< add address=8.34.208.0/20 list=YouTube +< add address=8.35.192.0/20 list=YouTube +< add address=23.236.48.0/20 list=YouTube +< add address=23.251.128.0/19 list=YouTube +< add address=34.0.0.0/15 list=YouTube +< add address=34.2.0.0/16 list=YouTube +< add address=34.3.0.0/23 list=YouTube +< add address=34.3.3.0/24 list=YouTube +< add address=34.3.4.0/24 list=YouTube +< add address=34.3.8.0/21 list=YouTube +< add address=34.3.16.0/20 list=YouTube +< add address=34.3.32.0/19 list=YouTube +< add address=34.3.64.0/18 list=YouTube +< add address=34.4.0.0/14 list=YouTube +< add address=34.8.0.0/13 list=YouTube +< add address=34.16.0.0/12 list=YouTube +< add address=34.32.0.0/11 list=YouTube +< add address=34.64.0.0/10 list=YouTube +< add address=34.128.0.0/10 list=YouTube +< add address=35.184.0.0/13 list=YouTube +< add address=35.192.0.0/14 list=YouTube +< add address=35.196.0.0/15 list=YouTube +< add address=35.198.0.0/16 list=YouTube +< add address=35.199.0.0/17 list=YouTube +< add address=35.199.128.0/18 list=YouTube +< add address=35.200.0.0/13 list=YouTube +< add address=35.208.0.0/12 list=YouTube +< add address=35.224.0.0/12 list=YouTube +< add address=35.240.0.0/13 list=YouTube +< add address=57.140.192.0/18 list=YouTube +< add address=64.15.112.0/20 list=YouTube +< add address=64.233.160.0/19 list=YouTube +< add address=66.22.228.0/23 list=YouTube +< add address=66.102.0.0/20 list=YouTube +< add address=66.249.64.0/19 list=YouTube +< add address=70.32.128.0/19 list=YouTube +< add address=72.14.192.0/18 list=YouTube +< add address=74.125.0.0/16 list=YouTube +< add address=104.154.0.0/15 list=YouTube +< add address=104.196.0.0/14 list=YouTube +< add address=104.237.160.0/19 list=YouTube +< add address=107.167.160.0/19 list=YouTube +< add address=107.178.192.0/18 list=YouTube +< add address=108.59.80.0/20 list=YouTube +< add address=108.170.192.0/18 list=YouTube +< add address=108.177.0.0/17 list=YouTube +< add address=130.211.0.0/16 list=YouTube +< add address=136.22.160.0/20 list=YouTube +< add address=136.22.176.0/21 list=YouTube +< add address=136.22.184.0/23 list=YouTube +< add address=136.22.186.0/24 list=YouTube +< add address=142.250.0.0/15 list=YouTube +< add address=146.148.0.0/17 list=YouTube +< add address=152.65.208.0/22 list=YouTube +< add address=152.65.214.0/23 list=YouTube +< add address=152.65.218.0/23 list=YouTube +< add address=152.65.222.0/23 list=YouTube +< add address=152.65.224.0/19 list=YouTube +< add address=162.120.128.0/17 list=YouTube +< add address=162.216.148.0/22 list=YouTube +< add address=162.222.176.0/21 list=YouTube +< add address=172.110.32.0/21 list=YouTube +< add address=172.217.0.0/16 list=YouTube +< add address=172.253.0.0/16 list=YouTube +< add address=173.194.0.0/16 list=YouTube +< add address=173.255.112.0/20 list=YouTube +< add address=192.158.28.0/22 list=YouTube +< add address=192.178.0.0/15 list=YouTube +< add address=193.186.4.0/24 list=YouTube +< add address=199.36.154.0/23 list=YouTube +< add address=199.36.156.0/24 list=YouTube +< add address=199.192.112.0/22 list=YouTube +< add address=199.223.232.0/21 list=YouTube +< add address=207.223.160.0/20 list=YouTube +< add address=208.65.152.0/22 list=YouTube +< add address=208.68.108.0/22 list=YouTube +< add address=208.81.188.0/22 list=YouTube +< add address=208.117.224.0/19 list=YouTube +< add address=209.85.128.0/17 list=YouTube +< add address=216.58.192.0/19 list=YouTube +< add address=216.73.80.0/20 list=YouTube +< add address=216.239.32.0/19 list=YouTube +< add address=2ip.ru list=Test +< add address=157.240.247.174 list=Instagram +< add address=46.53.178.107 list=Instagram +< add address=179.60.195.174 list=Instagram +< add address=157.240.205.174 list=Instagram +< add address=31.13.24.0/21 list=Instagram +< add address=31.13.64.0/18 list=Instagram +< add address=45.64.40.0/22 list=Instagram +< add address=66.220.144.0/20 list=Instagram +< add address=69.63.176.0/20 list=Instagram +< add address=69.171.224.0/19 list=Instagram +< add address=74.119.76.0/22 list=Instagram +< add address=103.4.96.0/22 list=Instagram +< add address=129.134.0.0/16 list=Instagram +< add address=157.240.0.0/16 list=Instagram +< add address=173.252.64.0/18 list=Instagram +< add address=179.60.192.0/22 list=Instagram +< add address=185.60.216.0/22 list=Instagram +< add address=204.15.20.0/22 list=Instagram +< add address=157.240.200.63 list=Instagram +< add address=185.60.219.63 list=Instagram +< add address=129.134.31.12 list=Instagram +< add address=66.81.203.132 list=Instagram +< add address=185.89.218.12 list=Instagram +< add address=31.13.66.63 list=Instagram +< add address=84.15.65.162 list=Instagram +< add address=68.66.224.28 list=Instagram +< add address=157.240.253.63 list=Instagram +< add address=83.174.11.224 list=Instagram +< add address=157.240.9.52 list=Instagram +< add address=157.240.252.174 list=Instagram +< add address=157.240.195.63 list=Instagram +< add address=31.13.71.52 list=Instagram +< add address=57.144.110.192 list=Instagram +< add address=157.240.252.17 list=Instagram +< add address=84.15.66.97 list=Instagram +< add address=217.168.6.33 list=Instagram +< add address=31.13.83.52 list=Instagram +< add address=157.240.241.63 list=Instagram +< add address=129.134.30.12 list=Instagram +< add address=185.89.219.12 list=Instagram +< add address=157.240.252.10 list=Instagram +< add address=157.240.201.63 list=Instagram +< add address=66.81.203.197 list=Instagram +< add address=179.60.195.52 list=Instagram +< add address=66.81.203.7 list=Instagram +< add address=216.40.34.41 list=Instagram +< add address=157.240.202.63 list=Instagram +< add address=157.240.229.63 list=Instagram +< add address=157.240.252.63 list=Instagram +< add address=31.13.72.53 list=Instagram +< add address=124.108.16.224 list=Instagram +< add address=157.240.205.63 list=Instagram +< add address=92.46.37.96 list=Instagram +< add address=157.240.247.63 list=Instagram +< add address=157.240.234.63 list=Instagram +< add address=157.240.235.63 list=Instagram +< add address=87.245.208.97 list=Instagram +< add address=216.58.192.0/19 list=Instagram +< add address=209.85.128.0/17 list=Instagram +< add address=198.105.240.0/20 list=Instagram +< add address=173.194.0.0/16 list=Instagram +< add address=172.217.0.0/16 list=Instagram +< add address=142.250.0.0/15 list=Instagram +< add address=108.177.0.0/17 list=Instagram +< add address=87.245.197.140 list=Instagram +< add address=74.125.0.0/16 list=Instagram +< add address=64.233.160.0/19 list=Instagram +< add address=157.240.0.1 list=Instagram +< add address=157.240.238.63 list=Instagram +< add address=157.240.238.174 list=Instagram +< add address=157.240.0.63 list=Instagram +< add address=157.240.224.63 list=Instagram +< add address=157.240.224.174 list=Instagram +< add address=157.240.251.36 list=Instagram +< add address=157.240.253.12 list=Instagram +< add address=157.240.253.35 list=Instagram +< add address=157.240.238.13 list=Instagram +< add address=157.240.238.56 list=Instagram +< add address=157.240.238.175 list=Instagram +< add address=57.144.112.141 list=Instagram +< add address=157.240.251.60 list=Instagram +< add address=157.240.251.128 list=Instagram +< add address=157.240.238.5 list=Instagram +< add address=157.240.253.13 list=Instagram +< add address=157.240.253.5 list=Instagram +< add address=157.240.238.2 list=Instagram +< add address=157.240.238.37 list=Instagram +< add address=157.240.251.5 list=Instagram +< add address=157.240.251.34 list=Instagram +< add address=57.144.112.1 list=Instagram +< add address=157.240.238.54 list=Instagram +< add address=129.134.26.123 list=Instagram +< add address=157.240.252.3 list=Instagram +< add address=31.13.84.4 list=Instagram +< add address=157.240.224.12 list=Instagram +< add address=157.240.238.4 list=Instagram +< add address=157.240.0.13 list=Instagram +< add address=3.33.139.32 list=Instagram +< add address=157.240.0.35 list=Instagram +< add address=157.240.238.14 list=Instagram +< add address=157.240.238.60 list=Instagram +< add address=57.144.112.145 list=Instagram +< add address=157.240.251.35 list=Instagram +< add address=151.101.84.159 list=Twitter +< add address=pbs.twimg.com list=Twitter +< add address=89.110.101.17 comment=VDSIna list=TRUSTED +< add address=10.8.0.0/24 comment="WG VDSIna" list=TRUSTED +< add address=ikus.pesc.ru comment=ikus.pesc.ru list=NoVdsina +< add address=love.ru comment=love.ru list=NoVdsina +< add address=gosuslugi.ru comment=gosuslugi.ru list=NoVdsina +< add address=pochta.ru comment=pochta.ru list=NoVdsina +< add address=vdsina.com list=NoVdsina +< add address=vdsina.ru list=NoVdsina +< add address=youla.ru list=NoVdsina +< add address=kupiprodai.ru list=NoVdsina +< add address=myip.ru list=Test +< add address=geoip.co list=NoVdsina +< add address=x.com list=Twitter +< add address=facebook.com list=facebook +< add address=fbcd.net list=facebook +< add address=comp-lenta.ru list=NoVdsina +< add address=128.85.102.70 comment=update.microsoft.com list=\ +< windowsupdateslist +< add address=wu-b-net.trafficmanager.net. comment=\ +< ctldl.windowsupdate.com.delivery.microsoft.com list=windowsupdateslist +< add address=ctldl.windowsupdate.com.delivery.microsoft.com. comment=\ +< ctldl.windowsupdate.com list=windowsupdateslist +< add address=redir.update.msft.com.trafficmanager.net. comment=\ +< update.microsoft.com list=windowsupdateslist +< add address=geo.prod.do.dsp.trafficmanager.net. comment=\ +< geo.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +< add address=13.74.139.29 comment=array605.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=kv801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ +< kv801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +< add address=e12437.d.akamaiedge.net. comment=\ +< kv801.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist +< add address=displaycatalog-rp.md.mp.microsoft.com.akadns.net. comment=\ +< displaycatalog.mp.microsoft.com list=windowsupdateslist +< add address=rp-consumer-prod-displaycatalog-geomap.trafficmanager.net. \ +< comment=displaycatalog-rp.md.mp.microsoft.com.akadns.net list=\ +< windowsupdateslist +< add address=sls.update.microsoft.com. comment=slscr.update.microsoft.com \ +< list=windowsupdateslist +< add address=glb.sls.prod.dcat.dsp.trafficmanager.net. comment=\ +< sls.update.microsoft.com list=windowsupdateslist +< add address=fe3.delivery.mp.microsoft.com. comment=\ +< fe3cr.delivery.mp.microsoft.com list=windowsupdateslist +< add address=glb.cws.prod.dcat.dsp.trafficmanager.net. comment=\ +< fe3.delivery.mp.microsoft.com list=windowsupdateslist +< add address=fe2cr.update.msft.com.trafficmanager.net. comment=\ +< fe2cr.update.microsoft.com list=windowsupdateslist +< add address=download.windowsupdate.com.delivery.microsoft.com. comment=\ +< download.windowsupdate.com list=windowsupdateslist +< add address=wu-f-net.trafficmanager.net. comment=\ +< download.windowsupdate.com.delivery.microsoft.com list=windowsupdateslist +< add address=tsfe.trafficmanager.net. comment=\ +< tsfe.trafficshaping.dsp.mp.microsoft.com list=windowsupdateslist +< add address=edge.ds-c7110-microsoft.global.dns.qwilted-cds.cqloud.com. \ +< comment=9.au.download.windowsupdate.com list=windowsupdateslist +< add address=52.158.227.125 comment=array812.prod.do.dsp.mp.microsoft.com \ +< list=windowsupdateslist +< add address=au.download.windowsupdate.com.delivery.microsoft.com. comment=\ +< au.download.windowsupdate.com list=windowsupdateslist +< add address=a767.dspw65.akamai.net. comment=\ +< download.windowsupdate.com.edgesuite.net list=windowsupdateslist +< add address=52.151.58.88 comment=array810.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=consumer-licensing-aks2aks.md.mp.microsoft.com.akadns.net. \ +< comment=licensing.mp.microsoft.com list=windowsupdateslist +< add address=licensing-prod-frontdoor-geomap.trafficmanager.net. comment=\ +< consumer-licensing-aks2aks.md.mp.microsoft.com.akadns.net list=\ +< windowsupdateslist +< add address=star.f.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ +< comment=msedge.f.dl.delivery.mp.microsoft.com list=windowsupdateslist +< add address=cdp-f-nlu-net.trafficmanager.net. comment=\ +< star.f.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=star.b.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ +< comment=msedge.b.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist +< add address=cdp-f-tlu-net.trafficmanager.net. comment=\ +< star.b.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=storeedgefd.xbetservices.akadns.net. comment=\ +< storeedgefd.dsx.mp.microsoft.com list=windowsupdateslist +< add address=\ +< storeedgefd.dsx.mp.microsoft.com.edgekey.net.globalredir.akadns.net. \ +< comment=storeedgefd.dsx.mp.microsoft.com.edgekey.net list=\ +< windowsupdateslist +< add address=e16646.dscg.akamaiedge.net. comment=\ +< storeedgefd.dsx.mp.microsoft.com.edgekey.net.globalredir.akadns.net list=\ +< windowsupdateslist +< add address=40.69.76.189 comment=array621.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=bg.microsoft.map.fastly.net. comment=\ +< 3.au.download.windowsupdate.com list=windowsupdateslist +< add list=windowsupdateslist +< add address=40.69.75.33 comment=array613.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=star.sf.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ +< comment=msedgeextensions.sf.tlu.dl.delivery.mp.microsoft.com list=\ +< windowsupdateslist +< add address=cdp-f-ssl-tlu-net.trafficmanager.net. comment=\ +< star.sf.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=a2033.dscd.akamai.net. comment=\ +< star.sb.tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=\ +< windowsupdateslist +< add address=13.74.138.242 comment=array602.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=dl.delivery.mp.microsoft.com.delivery.microsoft.com. comment=\ +< dl.delivery.mp.microsoft.com list=windowsupdateslist +< add address=dcat-f-nlu-net.trafficmanager.net. comment=\ +< dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=1d.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ +< comment=1D.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist +< add address=dcat-b-tlu-net.trafficmanager.net. comment=\ +< 1d.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=a122.dscg3.akamai.net. comment=\ +< tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=windowsupdateslist +< add address=geover.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ +< geover.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +< add address=e10370.d.akamaiedge.net. comment=\ +< geover.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist +< add address=52.232.182.21 comment=array511.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=40.70.77.95 comment=array519.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=a1683.dscd.akamai.net. comment=\ +< dl.delivery.mp.microsoft.com-c.edgesuite.net list=windowsupdateslist +< add address=consumer-collections-aks2eap.md.mp.microsoft.com.akadns.net. \ +< comment=collections.mp.microsoft.com list=windowsupdateslist +< add address=a1847.dscd.akamai.net. comment=\ +< wildcard.f.tlu.dl.delivery.mp.microsoft.com.edgesuite.net list=\ +< windowsupdateslist +< add address=13.74.142.6 comment=array607.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=au.download.windowsupdate.com.edgesuite.net. comment=\ +< 2.au.download.windowsupdate.com list=windowsupdateslist +< add address=a767.dscg3.akamai.net. comment=\ +< au.download.windowsupdate.com.edgesuite.net list=windowsupdateslist +< add address=52.156.123.84 comment=array818.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=40.69.78.254 comment=array610.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=4.au.download.windowsupdate.com.delivery.microsoft.com. comment=\ +< 4.au.download.windowsupdate.com list=windowsupdateslist +< add address=cl-glcb907925.gcdn.co. comment=\ +< 4.au.download.windowsupdate.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=52.167.167.111 comment=array510.prod.do.dsp.mp.microsoft.com \ +< list=windowsupdateslist +< add address=40.69.70.43 comment=array623.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=tsfe.trafficshaping.dsp.mp.microsoft.com.delivery.microsoft.com. \ +< comment=tsfe.trafficshaping.dsp.mp.microsoft.com list=windowsupdateslist +< add address=ts-frontend.trafficmanager.net. comment=\ +< tsfe.trafficshaping.dsp.mp.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=40.69.75.248 comment=array616.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=40.69.74.84 comment=array615.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=sds.trafficmanager.net. comment=software-download.microsoft.com \ +< list=windowsupdateslist +< add address=40.69.74.80 comment=array611.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.175.242.182 comment=array804.prod.do.dsp.mp.microsoft.com \ +< list=windowsupdateslist +< add address=dlc-shim.trafficmanager.net. comment=download.microsoft.com list=\ +< windowsupdateslist +< add address=e12671.dscd.akamaiedge.net. comment=\ +< download.microsoft.com.edgekey.net list=windowsupdateslist +< add address=20.187.55.34 comment=array808.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.167.167.231 comment=array513.prod.do.dsp.mp.microsoft.com \ +< list=windowsupdateslist +< add address=52.167.222.13 comment=array518.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=kv601.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ +< kv601.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +< add address=e12358.d.akamaiedge.net. comment=\ +< kv601.prod.do.dsp.mp.microsoft.com.edgekey.net list=windowsupdateslist +< add address=tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. comment=\ +< tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist +< add address=dcat-f-tlu-net.trafficmanager.net. comment=\ +< tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=a1856.dspw65.akamai.net. comment=\ +< tlu.dl.delivery.mp.microsoft.com-c.edgesuite.net list=windowsupdateslist +< add address=52.167.164.252 comment=array506.prod.do.dsp.mp.microsoft.com \ +< list=windowsupdateslist +< add address=13.74.137.54 comment=array601.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=kv501.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ +< kv501.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +< add address=collections-prod-frontdoor-geomap.trafficmanager.net. comment=\ +< consumer-collections-aks2eap.md.mp.microsoft.com.akadns.net list=\ +< windowsupdateslist +< add address=52.167.160.173 comment=array509.prod.do.dsp.mp.microsoft.com \ +< list=windowsupdateslist +< add address=40.70.77.148 comment=array516.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.167.200.126 comment=array507.prod.do.dsp.mp.microsoft.com \ +< list=windowsupdateslist +< add address=52.167.167.59 comment=array508.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=40.69.76.172 comment=array620.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=82.202.162.184 comment=comp-lenta.ru list=NoWG +< add address=smtp.mail.me.com.akadns.net. comment=smtp.mail.me.com list=NoWG +< add address=17.57.155.37 comment=smtp.mail.me.com.akadns.net list=NoWG +< add address=smtp.mail.me.com comment=smtp.mail.me.com list=NoVdsina +< add address=40.70.76.5 comment=array514.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=13.74.186.119 comment=array618.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.177.176.186 comment=array520.prod.do.dsp.mp.microsoft.com \ +< list=windowsupdateslist +< add address=40.70.76.27 comment=array515.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.167.160.43 comment=array503.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.110 comment=array817.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=13.74.142.8 comment=array614.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=13.74.138.254 comment=array603.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.167.167.96 comment=array501.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=40.69.76.215 comment=array622.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=13.74.143.200 comment=array606.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.111 comment=array818.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.112 comment=array819.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=13.74.137.53 comment=array608.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.98 comment=array805.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.96 comment=array803.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.104 comment=array811.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.101 comment=array808.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.99 comment=array806.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.17 comment=array802.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.97 comment=array804.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.103 comment=array810.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.16 comment=array801.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=40.70.77.177 comment=array517.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.167.164.84 comment=array512.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.105 comment=array812.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.107 comment=array814.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.232.161.82 comment=array502.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.108 comment=array815.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=52.167.161.91 comment=array505.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.102 comment=array809.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.109 comment=array816.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.106 comment=array813.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.117 comment=array622.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.107 comment=array612.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.108 comment=array613.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.105 comment=array610.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.113 comment=array618.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.116 comment=array621.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.98 comment=array603.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.114 comment=array619.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.111 comment=array616.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.97 comment=array602.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.106 comment=array611.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.110 comment=array615.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.119 comment=array624.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.135 comment=array514.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.97 comment=array503.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.99 comment=array604.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.61 comment=array504.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.131 comment=array510.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.132 comment=array511.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.96 comment=array601.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.104 comment=array609.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.138 comment=array517.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.60 comment=array501.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.139 comment=array518.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.118 comment=array623.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.113 comment=array820.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.103 comment=array608.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.154.7.100 comment=array807.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.129 comment=array508.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.134 comment=array513.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.62 comment=array505.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.137 comment=array516.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.101 comment=array606.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.96 comment=array502.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.130 comment=array509.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.112 comment=array617.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.100 comment=array605.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.115 comment=array620.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.136 comment=array515.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=purchase.md.mp.microsoft.com.akadns.net. comment=\ +< purchase.mp.microsoft.com list=windowsupdateslist +< add address=e110219.a.akamaiedge.net. comment=\ +< purchase.mp.microsoft.com.edgekey.net list=windowsupdateslist +< add address=72.153.5.140 comment=array519.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.141 list=windowsupdateslist +< add address=72.153.5.63 comment=array506.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.128 comment=array507.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.102 comment=array607.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=storesdk.xbetservices.akadns.net. comment=\ +< storesdk.dsx.mp.microsoft.com list=windowsupdateslist +< add address=e16646.g.akamaiedge.net. comment=\ +< storesdk.dsx.mp.microsoft.com.edgekey.net list=windowsupdateslist +< add address=software-download.microsoft.com.delivery.microsoft.com. comment=\ +< software-download.microsoft.com list=windowsupdateslist +< add address=download.prss.microsoft.com.akamaized.net. comment=\ +< software-download.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=72.145.35.109 comment=array614.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=72.153.5.133 comment=array512.prod.do.dsp.mp.microsoft.com list=\ +< windowsupdateslist +< add address=213.180.192.0/19 comment=YandexDisk list=NoVdsina +< add address=87.250.250.50 comment=YandexDisk list=NoVdsina +< add address=consumer-prod-bcfd-v7-afd.trafficmanager.net. comment=\ +< displaycatalog.mp.microsoft.com list=windowsupdateslist +< add address=purchase-europeeap.md.mp.microsoft.com.akadns.net. comment=\ +< purchase.md.mp.microsoft.com.akadns.net list=windowsupdateslist +< add address=ne-az-conspurchase-mp.trafficmanager.net. comment=\ +< purchase-europeeap.md.mp.microsoft.com.akadns.net list=windowsupdateslist +< add address=storeedgefd.dsx.mp.microsoft.com.edgekey.net. comment=\ +< cdn.storeedgefd.dsx.mp.microsoft.com list=windowsupdateslist +< add address=star.f.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ +< comment=msedge.f.tlu.dl.delivery.mp.microsoft.com list=windowsupdateslist +< add address=a1996.dscd.akamai.net. comment=\ +< wildcard.f.dl.delivery.mp.microsoft.com.edgesuite.net list=\ +< windowsupdateslist +< add address=cp801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ +< cp801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +< add address=glb.tas02.sls-prod.dcat.dsp.mp.microsoft.com. comment=\ +< tas02.sls.update.microsoft.com list=windowsupdateslist +< add address=cp601.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ +< cp601.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +< add address=star.sb.tlu.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ +< comment=msedgeextensions.sb.tlu.dl.delivery.mp.microsoft.com list=\ +< windowsupdateslist +< add address=star.sf.dl.delivery.mp.microsoft.com.delivery.microsoft.com. \ +< comment=msedge.sf.dl.delivery.mp.microsoft.com list=windowsupdateslist +< add address=cdp-f-ssl-nlu-net.trafficmanager.net. comment=\ +< star.sf.dl.delivery.mp.microsoft.com.delivery.microsoft.com list=\ +< windowsupdateslist +< add address=tm-pifd-prod-gbl-weight.trafficmanager.net. comment=\ +< paymentinstruments.mp.microsoft.com list=windowsupdateslist +< add address=10.30.30.33 comment=amster-nuc list=NoWG +< add address=10.30.30.11 comment=MikroNUC list=NoWG +< add address=89.110.101.17 comment=!!!VDSINA!!!! list=NoWG +< add address=89.110.101.17 list=VPN-Server +< add address=80.85.244.9 list=TRUSTED +< add address=8.8.8.8 list=TRUSTED +< add address=8.8.4.4 list=TRUSTED +< add address=disc801.prod.do.dsp.mp.microsoft.com.edgekey.net. comment=\ +< disc801.prod.do.dsp.mp.microsoft.com list=windowsupdateslist +< add address=10.30.30.95 comment=NUC list=NoWG +< add address=glb.tas02.cws-prod.dcat.dsp.mp.microsoft.com. comment=\ +< tas02.cws.update.microsoft.com list=windowsupdateslist +< /ip firewall filter +< add action=add-src-to-address-list address-list="Honeypot Hacker" \ +< address-list-timeout=12h chain=input comment="block honeypot DNS" \ +< connection-state=new dst-port=53 in-interface="ether1 - Unet" protocol=\ +< udp +< add action=add-src-to-address-list address-list="Honeypot Hacker" \ +< address-list-timeout=4w2d chain=input connection-state=new dst-port=53 \ +< in-interface="ether1 - Unet" protocol=tcp +< add action=add-src-to-address-list address-list="Honeypot Hacker" \ +< address-list-timeout=4w2d chain=input comment=\ +< "block honeypot ssh rdp winbox" connection-state=new dst-port=\ +< 22,8291,2222 in-interface="ether1 - Unet" protocol=tcp src-address-list=\ +< !TRUSTED +< add action=add-src-to-address-list address-list="Honeypot Hacker" \ +< address-list-timeout=4w2d chain=input comment="block honeypot asterisk" \ +< connection-state=new dst-port=5060 in-interface="ether1 - Unet" protocol=\ +< udp +< add action=add-src-to-address-list address-list="Honeypot Hacker" \ +< address-list-timeout=5d chain=input comment="block honeypot NTP" \ +< connection-state=new dst-port=123 in-interface="ether1 - Unet" protocol=\ +< udp src-address=!10.30.30.0/24 +< add action=accept chain=input comment=\ +< "accept NTP clients on local area network" dst-port=123 in-interface=\ +< Bridge-LAN in-interface-list=LAN protocol=udp +< add action=accept chain=input comment="accept WireGuard" dst-port=13231 \ +< in-interface="ether1 - Unet" protocol=udp src-address-list=VPN-Server +< add action=accept chain=input disabled=yes dst-port=443 in-interface=\ +< "ether1 - Unet" protocol=tcp +< add action=accept chain=output disabled=yes protocol=tcp src-port=443 +< add action=fasttrack-connection chain=forward comment=\ +< "FastTrack for non-VPN connections" connection-mark=!VPN_No_FastTrack \ +< connection-state=established,related,new disabled=yes +< add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \ +< connection-state=established,related,new disabled=yes routing-mark=\ +< !To-VPN +< add action=accept chain=input comment=\ +< "defconf: accept established,related,untracked" connection-state=\ +< established,related,untracked +< add action=drop chain=input comment="defconf: drop invalid" connection-state=\ +< invalid +< add action=accept chain=input comment="defconf: accept ICMP" disabled=yes \ +< protocol=icmp +< add action=accept chain=input comment=\ +< "defconf: accept to local loopback (for CAPsMAN)" disabled=yes \ +< dst-address=127.0.0.1 +< add action=accept chain=output disabled=yes src-address=127.0.0.1 +< add action=accept chain=forward comment="defconf: accept in ipsec policy" \ +< ipsec-policy=in,ipsec +< add action=accept chain=forward comment="defconf: accept out ipsec policy" \ +< ipsec-policy=out,ipsec +< add action=accept chain=forward comment=\ +< "defconf: accept established,related, untracked" connection-state=\ +< established,related,untracked +< add action=drop chain=forward comment="defconf: drop invalid" \ +< connection-state=invalid disabled=yes +< add action=drop chain=forward comment=\ +< "defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \ +< connection-state=new in-interface="ether1 - Unet" +< add action=accept chain=input connection-state=established disabled=yes +< add action=accept chain=input connection-state=related disabled=yes +< add action=drop chain=input disabled=yes in-interface-list=!LAN +< add action=drop chain=forward comment=\ +< "Filter Rule to block FB address LIST : )" disabled=yes dst-address-list=\ +< facebook +< add action=drop chain=forward comment=\ +< "Filter Rule to block YOUTUBE address LIST : )" disabled=yes \ +< dst-address-list=YouTube +< /ip firewall mangle +< add action=mark-connection chain=prerouting comment=\ +< "Mark VPN connections to exclude from FastTrack" in-interface=WG \ +< log-prefix=Mark-VPN-FT new-connection-mark=VPN_No_FastTrack +< add action=mark-routing chain=prerouting comment="Test sites" disabled=yes \ +< dst-address=!10.30.30.0/24 dst-address-list=Test new-routing-mark=To-VPN \ +< passthrough=no src-address=10.30.30.0/24 +< add action=mark-routing chain=prerouting comment=Instagram dst-address=\ +< !10.30.30.0/24 dst-address-list=Instagram new-routing-mark=To-VPN \ +< src-address=10.30.30.0/24 src-address-list=!NoWG +< add action=mark-routing chain=prerouting comment=Twitter dst-address=\ +< !10.30.30.0/24 dst-address-list=Twitter new-routing-mark=To-VPN \ +< src-address=10.30.30.0/24 src-address-list=!NoWG +< add action=mark-routing chain=prerouting comment=YouTube dst-address=\ +< !10.30.30.0/24 dst-address-list=YouTube new-routing-mark=To-VPN \ +< src-address=10.30.30.0/24 src-address-list=!NoWG +< add action=mark-routing chain=prerouting comment=facebook dst-address=\ +< !10.30.30.0/24 dst-address-list=facebook new-routing-mark=To-VPN \ +< src-address=10.30.30.0/24 src-address-list=!NoWG +< add action=mark-routing chain=prerouting comment="VDSIna for All sites" \ +< dst-address=!10.30.30.0/24 dst-address-list=!NoVdsina log-prefix=VPN-all \ +< new-routing-mark=To-VPN src-address=10.30.30.0/24 src-address-list=!NoWG +< add action=change-mss chain=forward comment="MSS on WG" new-mss=1380 \ +< out-interface=WG protocol=tcp tcp-flags=syn tcp-mss=1381-65535 +< add action=mark-routing chain=prerouting comment="VPN Network" dst-address=\ +< 10.8.0.0/24 dst-address-list=!NoVdsina log=yes log-prefix=VPN-Net \ +< new-routing-mark=To-VPN src-address=10.30.30.0/24 src-address-list=!NoWG +< /ip firewall nat +< add action=redirect chain=dstnat comment=\ +< "FORCE DNS TO LOCAL MIKROTIK DNS SERVER" dst-port=53 protocol=tcp \ +< src-address=10.30.30.0/24 to-ports=53 +< add action=redirect chain=dstnat dst-port=53 protocol=udp src-address=\ +< 10.30.30.0/24 to-ports=53 +< add action=masquerade chain=srcnat comment="masquerade Default" ipsec-policy=\ +< out,none out-interface="ether1 - Unet" routing-mark=!To-VPN +< add action=masquerade chain=srcnat comment=WG dst-address-list=!NoVdsina \ +< in-interface=Bridge-LAN log-prefix=WG-nat out-interface=WG routing-mark=\ +< To-VPN +< add action=dst-nat chain=dstnat comment=npm disabled=yes dst-port=81 \ +< in-interface="ether1 - Unet" protocol=tcp to-addresses=10.30.30.33 \ +< to-ports=81 +< add action=dst-nat chain=dstnat comment=amster.vados.ruhttps disabled=yes \ +< dst-port=443 in-interface="ether1 - Unet" protocol=tcp to-addresses=\ +< 10.30.30.33 to-ports=443 +< add action=dst-nat chain=dstnat comment="amster.vados.ru For Certbot HTTP" \ +< disabled=yes dst-port=80 in-interface="ether1 - Unet" protocol=tcp \ +< to-addresses=10.30.30.33 to-ports=80 +< add action=dst-nat chain=dstnat disabled=yes dst-port=80 in-interface=\ +< "ether1 - Unet" protocol=tcp to-addresses=10.30.30.33 to-ports=80 +< add action=dst-nat chain=dstnat comment="Yandex.DNS Family" disabled=yes \ +< dst-port=53 in-interface=Bridge-LAN protocol=udp src-address-list=KIDS \ +< time=6h-15m,sun,mon,tue,wed,thu,fri,sat to-addresses=77.88.8.3 +< add action=dst-nat chain=dstnat disabled=yes dst-port=53 in-interface=\ +< Bridge-LAN protocol=tcp src-address-list=KIDS time=\ +< 6h-15m,sun,mon,tue,wed,thu,fri,sat to-addresses=77.88.8.3 +< add action=dst-nat chain=dstnat dst-address=146.120.64.211 dst-port=32000 \ +< in-interface="ether1 - Unet" protocol=tcp to-addresses=10.30.30.95 \ +< to-ports=32000 +< add action=dst-nat chain=dstnat dst-address=146.120.64.211 dst-port=32000 \ +< in-interface="ether1 - Unet" protocol=udp to-addresses=10.30.30.95 \ +< to-ports=32000 +< add action=dst-nat chain=dstnat dst-port=32000 protocol=tcp routing-mark=\ +< To-VPN to-addresses=10.30.30.95 to-ports=32000 +< add action=dst-nat chain=dstnat dst-port=32000 protocol=udp routing-mark=\ +< To-VPN to-addresses=10.30.30.95 to-ports=32000 +< /ip firewall raw +< add action=drop chain=prerouting comment="Drop Honeypot Hackers" \ +< in-interface="ether1 - Unet" src-address-list="Honeypot Hacker" +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=\ +< extras.getpagespeed.com content=extras.getpagespeed.com disabled=yes +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=linux.duke.edu \ +< content=linux.duke.edu disabled=yes +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=vk.com \ +< content=vk.com +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=ok.ru content=\ +< ok.ru +< add action=add-dst-to-address-list address-list=Instagram \ +< address-list-timeout=none-dynamic chain=prerouting comment=Instagram \ +< content=instagram.com +< add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\ +< none-dynamic chain=prerouting comment=Twitter content=twimg.com +< add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\ +< none-dynamic chain=prerouting content=x.com +< add action=add-dst-to-address-list address-list=Twitter address-list-timeout=\ +< none-dynamic chain=prerouting content=twitter.com +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting comment=YouTube content=youtube.com +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting content=googleapis.com +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting content=ggpht.com +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting content=youtu.be +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting content=ytimg.com +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting content=googlevideo.com +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting content=gstatic.com +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting content=googleusercontent.com +< add action=add-dst-to-address-list address-list=YouTube address-list-timeout=\ +< none-dynamic chain=prerouting content=nhacmp3youtube.com +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=rutube.ru \ +< content=rutube.ru +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=me.com \ +< content=me.com +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=icloud.com \ +< content=icloud.com +< add action=add-dst-to-address-list address-list=facebook \ +< address-list-timeout=none-dynamic chain=prerouting comment=facebook \ +< content=fbcd.net +< add action=add-dst-to-address-list address-list=facebook \ +< address-list-timeout=none-dynamic chain=prerouting content=facebook.com +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=comp-lenta.ru \ +< content=comp-lenta.ru +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=\ +< smtp.mail.me.com content=smtp.mail.me.com log=yes +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=gov.ru \ +< content=gov.ru +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=\ +< r78.fssp.gov.ru content=r78.fssp.gov.ru +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=api.db-ip.com \ +< content=api.db-ip.com +< add action=add-dst-to-address-list address-list=NoVdsina \ +< address-list-timeout=none-dynamic chain=prerouting comment=\ +< api.telegram.org content=api.telegram.org +< /ip firewall service-port +< set ftp disabled=yes +< set tftp disabled=yes +< set irc disabled=no +< set sip disabled=yes +< set pptp disabled=yes +< set rtsp disabled=no +< /ip hotspot walled-garden +< add server=*1 +< /ip ipsec settings +< set accounting=no +< /ip ipsec policy +< set 0 disabled=yes dst-address=0.0.0.0/0 src-address=0.0.0.0/0 +< /ip ipsec profile +< set [ find default=yes ] dpd-interval=2m dpd-maximum-failures=5 +< /ip proxy +< set cache-administrator="" max-cache-size=none port=80,443 src-address=\ +< 0.0.0.0 +< /ip route +< add disabled=no distance=3 dst-address=192.168.0.0/24 gateway=l2tp-vpn +< add disabled=no distance=4 dst-address=192.168.5.0/24 gateway=l2tp-vpn +< add disabled=no distance=3 dst-address=192.168.0.0/24 gateway=l2tp-vpn +< add disabled=no distance=4 dst-address=192.168.5.0/24 gateway=l2tp-vpn +< add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=WG routing-table=\ +< To-VPN scope=30 target-scope=10 +< add disabled=yes distance=2 dst-address=0.0.0.0/0 gateway=146.120.64.209 \ +< routing-table=main scope=30 target-scope=10 +< /ip service +< set ftp disabled=yes +< set telnet disabled=yes +< set ssh address=10.30.30.0/24 port=2222 +< set winbox address=10.30.30.0/24 +< set api address=10.30.30.0/24 disabled=yes +< set api-ssl address=10.30.30.0/24 +< set www-ssl port=18443 +< set www address=10.30.30.0/24 disabled=yes port=18880 +< /ip service webserver +< set acme-plain=no crl-plain=no graphs-plain=no graphs-secure=no index-plain=\ +< no index-secure=no rest-plain=no rest-secure=no scep-plain=no \ +< webfig-plain=no webfig-secure=no +< /ip ssh +< set forwarding-enabled=both publickey-authentication-options=verify-required \ +< strong-crypto=yes +< /ip upnp +< set enabled=yes +< /ip upnp interfaces +< add interface=Bridge-LAN type=internal +< add interface="ether1 - Unet" type=external +< /ipv6 firewall address-list +< add address=::/128 comment="defconf: unspecified address" list=bad_ipv6 +< add address=::1/128 comment="defconf: lo" list=bad_ipv6 +< add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6 +< add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6 +< add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6 +< add address=100::/64 comment="defconf: discard only " list=bad_ipv6 +< add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6 +< add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6 +< add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6 +< /ipv6 firewall filter +< add action=add-src-to-address-list address-list=bad_ipv6 \ +< address-list-timeout=none-dynamic chain=input comment=\ +< "defconf: accept established,related,untracked" connection-state=\ +< established,related,untracked in-interface=WG in-interface-list=WAN \ +< src-address-list="" +< add action=drop chain=input comment="defconf: drop invalid" connection-state=\ +< invalid +< add action=accept chain=input comment="defconf: accept ICMPv6" protocol=\ +< icmpv6 +< add action=accept chain=input comment="defconf: accept UDP traceroute" \ +< dst-port=33434-33534 protocol=udp +< add action=accept chain=input comment=\ +< "defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\ +< udp src-address=fe80::/10 +< add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \ +< protocol=udp +< add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\ +< ipsec-ah +< add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\ +< ipsec-esp +< add action=accept chain=input comment=\ +< "defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec +< add action=drop chain=input comment=\ +< "defconf: drop everything else not coming from LAN" in-interface-list=\ +< !LAN +< add action=accept chain=forward comment=\ +< "defconf: accept established,related,untracked" connection-state=\ +< established,related,untracked +< add action=drop chain=forward comment="defconf: drop invalid" \ +< connection-state=invalid +< add action=drop chain=forward comment=\ +< "defconf: drop packets with bad src ipv6" src-address-list=bad_ipv6 +< add action=drop chain=forward comment=\ +< "defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6 +< add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \ +< hop-limit=equal:1 protocol=icmpv6 +< add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\ +< icmpv6 +< add action=accept chain=forward comment="defconf: accept HIP" protocol=139 +< add action=accept chain=forward comment="defconf: accept IKE" dst-port=\ +< 500,4500 protocol=udp +< add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\ +< ipsec-ah +< add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\ +< ipsec-esp +< add action=accept chain=forward comment=\ +< "defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec +< add action=drop chain=forward comment=\ +< "defconf: drop everything else not coming from LAN" in-interface-list=\ +< !LAN +< /ipv6 nd +< set [ find default=yes ] advertise-dns=yes +< /ppp secret +< add local-address=192.168.60.1 name=vados remote-address=192.168.60.2 \ +< service=l2tp +< /routing bfd configuration +< add disabled=no +< /snmp +< set contact=@AmsterNL enabled=yes engine-id-suffix=MikroMaster location=NL \ +< src-address=10.30.30.81 trap-interfaces=Bridge-LAN,WG trap-target=\ +< 10.30.30.10 +< /system clock +< set time-zone-autodetect=no time-zone-name=Europe/Moscow +< /system clock manual +< set time-zone=+03:00 +< /system identity +< set name=MikroMaster +< /system logging +< add action=email disabled=yes regex="* added|changed|removed *" topics=\ +< system,info +< /system ntp client +< set enabled=yes +< /system ntp server +< set enabled=yes manycast=yes multicast=yes use-local-clock=yes +< /system ntp client servers +< add address=0.ru.pool.ntp.org +< add address=1.ru.pool.ntp.org +< add address=2.ru.pool.ntp.org +< add address=3.ru.pool.ntp.org +< add address=time.google.com disabled=yes +< /system scheduler +< add comment="Windows Update script" interval=2d5m name=WU-script-run-schedule \ +< on-event=WU-add-to-list policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-date=2014-02-11 start-time=00:00:00 +< add comment="Backup Every Week" disabled=yes interval=1w name=BackupEveryWeek \ +< on-event=BackupAndUpdate policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-date=2025-07-07 start-time=03:41:27 +< add comment="DoH Cache Flush" interval=1d name="DNS Cache Flush" on-event=\ +< DNS_Flush_Cache policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-date=2019-12-06 start-time=05:30:00 +< add comment="Create mkdir function on startup" name=\ +< create_mkdir_function_on_startup on-event=\ +< "/system script run create_mkdir_function;" policy=read,write,policy,test \ +< start-time=startup +< add comment="Scheduler for Update Certificates CloudFlare Quad9" interval=1w \ +< name="Update Certificates CloudFlare Quad9" on-event=\ +< "/system/script { run Update-Certificates; }" policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-date=2025-11-28 start-time=05:45:40 +< add comment="Scheduler for Amster-Backup-UpdateEmail" disabled=yes interval=\ +< 1w name=Amster-Backup-UpdateEmail on-event=\ +< "/system/script { run Amster-Backup-UpdateEmail; }" policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-date=2026-02-13 start-time=03:41:27 +< add comment="Setup Global Environment for scripts" name=AM-SetGlobalEnv \ +< on-event="/system/script { run AM-GlobalConfig; run AM-GlobalFunc; }" \ +< policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-time=startup +< add comment="Every Day Check For Update Scripts" interval=1d name=\ +< AM-ScriptInstallUpdate on-event=\ +< ":global ScriptInstallUpdate; \$ScriptInstallUpdate;" policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-time=startup +< add comment="Every Day Check For Fake Bridges" interval=1d name=\ +< mod/AM-IPbridge on-event="/system/script/run mod/AM-IPbridge;" policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-time=startup +< add comment="Every Day Check For Renew Certificates" interval=1d name=\ +< AM-CheckCerts on-event="/system/script/run AM-CheckCerts;" policy=\ +< ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ +< start-time=startup +< /system watchdog +< set watchdog-timer=no +< /tool e-mail +< set certificate-verification=no from=MikroVados port=587 \ +< server=smtp.mail.me.com tls=starttls user=vadossio@icloud.com +< /tool mac-server +< set allowed-interface-list=LAN +< /tool mac-server mac-winbox +< set allowed-interface-list=LAN +< /tool netwatch +< add comment="doh, doh-url=https://security.cloudflare-dns.com/dns-query, notif\ +< y, name=CloudFlare-doh IPv4 1" disabled=yes down-script="" host=1.1.1.1 \ +< http-codes="" test-script="" type=simple up-script="" +< add check-certificate=no comment="doh-fallback, doh-url=https://security.cloud\ +< flare-dns.com/dns-query, doh-cert=DigiCert Global Root CA, notify, name=Cl\ +< oudFlare-doh IPv4" disabled=yes down-script="" host=1.0.0.1 http-codes="" \ +< port=443 test-script="" type=simple up-script="" +< add comment="dns-fallback, notify, name=Google-DNS IPv4" disabled=yes \ +< down-script="" host=8.8.8.8 http-codes="" test-script="" type=simple \ +< up-script="" +< add comment="doh-fallback, doh-url=https://dns.google/dns-query, doh-cert=GTS \ +< Root R1, notify, name=Google-DOH IPv4" disabled=yes down-script="" host=\ +< 8.8.4.4 http-codes="" test-script="" type=simple up-script="" +< add comment="dns, notify, name=Cuad9-DOH IPv4" disabled=yes down-script="" \ +< host=9.9.9.9 http-codes="" test-script="" type=simple up-script="" +< add comment="doh-fallback, doh-url=https://dns.quad9.net/dns-query, name=Cuad9\ +< -DOH IPv4" disabled=yes down-script="" host=149.112.112.112 http-codes="" \ +< test-script="" type=simple up-script="" +< add comment="dns-fallback, notify, name=ns1.unet.ws" disabled=yes \ +< down-script="" host=91.192.189.2 http-codes="" test-script="" type=simple \ +< up-script="" +< /tool sniffer +< set filter-interface=Bridge-LAN filter-src-ip-address=10.30.30.50/32 +< /user aaa +< set accounting=no diff --git a/MikroNUC/20260405/20260405035444-Config.rsc b/MikroNUC/20260405/20260405035444-Config.rsc new file mode 100644 index 0000000..77fef34 --- /dev/null +++ b/MikroNUC/20260405/20260405035444-Config.rsc @@ -0,0 +1,2916 @@ +# 2026-04-05 03:54:44 by RouterOS 7.22.1 +# system id = NmJcEM+8XAP +# +/caps-man channel +add band=2ghz-g/n extension-channel=disabled frequency=2422 name=2G-3 \ + reselect-interval=20m save-selected=yes +add band=5ghz-a/n/ac extension-channel=XXXX frequency=5660 name=5G-5660 \ + save-selected=yes +add band=5ghz-a/n/ac extension-channel=XXXXXXXX frequency=5160,5200,5280 \ + name=5G-5160-5280 reselect-interval=30m save-selected=yes +add band=5ghz-n/ac extension-channel=XXXX frequency=5180 name=5G-36 \ + reselect-interval=30m save-selected=yes +add band=5ghz-n/ac extension-channel=XXXX frequency=5200 name=5G-40 \ + reselect-interval=30m save-selected=yes +add band=5ghz-n/ac extension-channel=XXXX frequency=5220 name=5G-44 \ + reselect-interval=30m save-selected=yes +add band=5ghz-n/ac extension-channel=XXXX frequency=5240 name=5G-48 \ + reselect-interval=30m save-selected=yes +add band=2ghz-g/n extension-channel=disabled frequency=2442 name=2G-7 \ + reselect-interval=20m save-selected=yes +add band=2ghz-g/n extension-channel=disabled frequency=2462 name=2G-11 \ + reselect-interval=20m save-selected=yes +/interface bridge +add name=Bridge-DOC +add name=Bridge-LAN port-cost-mode=short +/interface ethernet +set [ find default-name=ether1 ] disable-running-check=no name=ether2 +/interface veth +add address=172.18.20.6/30 container-mac-address=00:00:00:00:00:00 dhcp=no \ + gateway=172.18.20.5 gateway6="" name=docker-xray-vless-veth +add address=10.10.10.10/24 container-mac-address=5C:26:FE:05:6F:12 dhcp=no \ + gateway=10.10.10.1 gateway6="" mac-address=5C:26:FE:05:6F:11 name=veth1 +/caps-man datapath +add bridge=Bridge-LAN client-to-client-forwarding=yes local-forwarding=yes \ + name=xs-DataPath +add bridge=Bridge-LAN client-to-client-forwarding=yes local-forwarding=yes \ + name=DataPath +/caps-man security +add authentication-types=wpa2-psk encryption=aes-ccm group-encryption=aes-ccm \ + group-key-update=30m name=xs-Sec +add authentication-types=wpa2-psk encryption=aes-ccm group-encryption=aes-ccm \ + group-key-update=30m name=WPA2 +/caps-man configuration +add channel.band=2ghz-b/g/n country=no_country_set datapath=xs-DataPath mode=\ + ap name=xs-2G rx-chains=0,1,2,3 security=xs-Sec ssid=vados tx-chains=\ + 0,1,2,3 +add channel.band=5ghz-a/n/ac country=no_country_set datapath=xs-DataPath \ + installation=any mode=ap name=xs-5G rx-chains=0,1,2,3 security=xs-Sec \ + ssid=vados5g tx-chains=0,1,2,3 +add channel.band=2ghz-b/g/n .control-channel-width=20mhz .extension-channel=\ + XX .frequency=2422,2442,2462 .reselect-interval=20m country=belarus \ + datapath=DataPath datapath.client-to-client-forwarding=yes \ + .local-forwarding=yes hw-protection-mode=rts-cts installation=any name=2G \ + rx-chains=0,1,2,3 security=WPA2 ssid=vados tx-chains=0,1,2,3 +add channel.band=5ghz-a/n/ac .control-channel-width=20mhz .extension-channel=\ + XXXX .frequency=5180,5200,5220,5240,5260 .reselect-interval=20m \ + .skip-dfs-channels=yes country=belarus datapath=DataPath \ + datapath.client-to-client-forwarding=yes .local-forwarding=yes \ + hw-protection-mode=rts-cts installation=any name=5G security=WPA2 ssid=\ + vados5g +/disk +add slot=tmpfs tmpfs-max-size=715827882 type=tmpfs +/interface list +add include=dynamic,static name=LAN +/interface wireless security-profiles +set [ find default=yes ] supplicant-identity=MikroMIC +/ip dhcp-server option +add code=12 name=HostName +add code=119 force=yes name=domain-search-list value="0x03'WORKGROUP'0x00" +/ip dhcp-server option sets +add name=P1505n options=HostName +add name=StartLife1 options=HostName +add name=amsterDev options=HostName +add name=MiTV options=HostName +add name=miller options=HostName +add name=amster options=HostName +add name=garage options=HostName +add name=domain-search-set options=domain-search-list +/ip pool +add name=dhcp ranges=10.30.30.150-10.30.30.200 +/system logging action +add email-start-tls=yes email-to=vados@vados.ru name=email target=email +/system script +add dont-require-permissions=no name=test owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + \r\ + \n#:local ScriptName [ :jobname ];\r\ + \n:local expSrc;\r\ + \n:local FileName;\r\ + \n:local FilePath;\r\ + \n:local DirPath \"tmpfs/\";\r\ + \n:global WaitForFile;\r\ + \n:global IfThenElse;\r\ + \n\r\ + \n:foreach Script in=([ /system/script find where name~\"Amster-GlobalConf\ + *\" ]) do={\r\ + \n:local ScriptVal [ /system/script/get \$Script ];\r\ + \n\r\ + \n:local expName [ (\$ScriptVal->\"name\") ];\r\ + \n#[/system/script get \$expScript name];\r\ + \n:delay 2s;\r\ + \n\r\ + \n:set expSrc [/system/script print where name=\$expName];\r\ + \n/system/script print where name=\$expName;\r\ + \n#[:put [/system/script get \$expScript source]];\r\ + \n:put [\$expSrc];\r\ + \n:delay 2s;\r\ + \n:set FileName \$expName;\r\ + \n:set FilePath (\$DirPath . \$FileName);\r\ + \n\r\ + \n#:log warning \"\\n----------------------\\n\\\$expSrc = \$expSrc\\n____\ + ______________________________\";\r\ + \n:log info \"\\n\\\$FileName = '\$FileName'\";\r\ + \n:log info \"\\n\\\$FilePath = \$FilePath\";\r\ + \n#:log warning {/system/script/get source=[/system/script/get \$expScript\ + \_source];};\r\ + \n\r\ + \n#\$[/system script get [/system script find name=\"\$FileName\"] source]\ + \r\ + \n\r\ + \n#:local gettingScript \"\$FileName\";\r\ + \n#:execute script=\"[[:parse \\\"[:parse { :put (\"\$[/system script get \ + [/system script find name=\$FileName] source]\"); } \\\"]]\"; \\\r\ + \n\r\ + \n#:execute script={:put \"[:parse \\\"[:parse [/system/script get [/syste\ + m/script find name=\$gettingScript] source];\\\"]]\";} \\\r\ + \n# file=(\$FilePath . \".rsc\\00\");\r\ + \n:do {\r\ + \n:local fName (\$FilePath . \".rsc\");\r\ + \n#:delay 3s;\r\ + \n#/file add name=\$fName;\r\ + \n:put [:tostr [\$expSrc]];\r\ + \n/file set \$fName contents=[:put [\$expSrc]];\r\ + \n:delay 3s;\r\ + \n\$WaitForFile \$fName;\r\ + \n(\$FilePath . \".rsc\");\r\ + \n#:delay 2s;\r\ + \n\r\ + \n} on-error={\r\ + \n:log error \"\\nERROR \\\$FilePath = \$FilePath\";\r\ + \n}\r\ + \n#\$WaitForFile (\$FilePath . \".rsc\");\r\ + \n#:execute script={ :put [/system/script get [:put \$FileName] source]; }\ + ;\r\ + \n#/system/script export \$Sscript file=\$FilePath;\r\ + \n#/system/script/export [:put [/system/script/get \$expScript source]] fi\ + le=\$FilePath;\r\ + \n#:execute script={ :put [/system/script/get \$expScript source]; } \\\r\ + \n\r\ + \n#:log warning \"\\n\\\$expScript = \$expScript\";\r\ + \n# \\\r\ + \n# file=(\$FilePath . \".rsc\\00\");\r\ + \n#script={:put [/system/script/get \$FileName source];} file=(\$FilePath\ + \_. \".rsc\\00\");\r\ + \n#/system script export \$src file=(\$FilePath . \$FileName);\r\ + \n}\r\ + \n\r\ + \n:log warning \"\\nComplete!\";\r\ + \n\r\ + \n # :execute script={ :put [ /system/script/get Amster-GlobalConfig sou\ + rce ]; } \\\r\ + \n # file=(\$FilePath . \".conf\\00\");\r\ + \n # \$WaitForFile (\$FilePath . \".conf\");\r\ + \n # :onerror Err {\r\ + \n # /tool/fetch upload=yes url=(\$BackupUploadUrl . \"/\" . \$FileName\ + \_. \".conf\") \\\r\ + \n # user=\$BackupUploadUser password=\$BackupUploadPass src-path=(\ + \$FilePath . \".conf\");\r\ + \n # :set ConfigFile [ /file/get (\$FilePath . \".conf\") ];\r\ + \n # :set (\$ConfigFile->\"name\") (\$FileName . \".conf\");\r\ + \n " +add dont-require-permissions=no name=test1 owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="\ + \r\ + \n#:local runningVer [:find [/system/resource/get version] \"(\"];\r\ + \n\r\ + \n:local runningChannel;\r\ + \n:local runningVersion;\r\ + \n:local ParseCustom;\r\ + \n\r\ + \n:set ParseCustom do={\r\ + \n :local Str [ :tostr \$1 ];\r\ + \n :local Start [:find [ \$Str ] [:tostr \$2]];\r\ + \n :local End [ :tostr \$3 ];\r\ + \n :local Num [ :tonum \$4 ];\r\ + \n :local Return;\r\ + \n\r\ + \n :if ([:len \$Num] = 0) do={:set Num \"0\"}\r\ + \n :local rest [:pick \$Str (\$Start+\$Num) [:len \$Str]]; \r\ + \n :if ([:len \$End ] = 0) do={:set Return [:pick \$Str \$Num \$Start]} e\ + lse={\r\ + \n :set End [:find \$rest \$End];\r\ + \n :set Return [:pick \$rest 0 \$End];\r\ + \n }\r\ + \n:return \$Return;\r\ + \n}\r\ + \n \r\ + \n:global runningChannel [\$ParseCustom [/system/resource/get version] \"(\ + \" \")\" 1];\r\ + \n:log warning [\$runningChannel];\r\ + \n:set runningVersion [\$ParseCustom [/system/resource/get version] \" \" \ + \")\" 2];\r\ + \n:log warning [\$runningVersion];\r\ + \n\r\ + \n\r\ + \n\r\ + \n# :if ([:len \$open] = 0) do={\r\ + \n# :log error \"\$SMP Could not extract installed OS channel from vers\ + ion string: `\$runningOsAndChannel`.\";\r\ + \n# :error \"\$SMP error, check logs\";\r\ + \n# }\r\ + \n# :local rest [:pick \$runningOsAndChannel (\$open+1) [:len \$runningOs\ + AndChannel]];\r\ + \n# :local close [:find \$rest \")\"];\r\ + \n# :local channel [:pick \$rest 0 \$close];\r\ + \n# :return \$channel;\r\ + \n#}" +add dont-require-permissions=no name=01-Amster-Init-Script owner=vados \ + policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + source="# Amster Initial Script\r\ + \n#\r\ + \n#:global GlobalEnvRemove true; /system/script {run Amster-GlobalEnvRemov\ + e; };\r\ + \n#:delay 1s;\r\ + \n:#global ReloadGlobal true; \r\ + \n\r\ + \n:global AmScriptsUrl \"https://ros.vados.ru/\";\r\ + \n:global defOwner \"vados\";\r\ + \n:global AmFirstRun;\r\ + \n\r\ + \n:set AmFirstRun do={\r\ + \n :global AmScriptsUrl;\r\ + \n :global defOwner;\r\ + \n #:global ParseKeyValueStore;\r\ + \n #:local AmUpdCRLF true;\r\ + \n #:local IfThenElse;\r\ + \n #:set IfThenElse do={:if ([ :tostr \$1 ] = \"true\" || [ :tobool \$1\ + \_] = true) do={:return \$2}; :return \$3}\r\ + \n #/certificate/settings/set builtin-trust-store=fetch;\r\ + \n #/tool/fetch \"\$scriptsUrl/certs/Root-YE.pem\" dst-path=\"root-ye.p\ + em\";\r\ + \n #/certificate/import file-name=\"root-ye.pem\" passphrase=\"\";\r\ + \n # For basic verification we rename the certificate and print it by f\ + ingerprint. Make sure exactly this one certificate (\"Root-YE\") is shown.\ + \r\ + \n #/certificate/set name=\"Root-YE\" [ find where common-name=\"Root Y\ + E\" ];\r\ + \n #/certificate/print proplist=name,fingerprint where fingerprint=\"e1\ + 4ffcad5b0025731006caa43a121a22d8e9700f4fb9cf852f02a708aa5d5666\";\r\ + \n #:log info \"\\nAmScriptsUrl = \$AmScriptsUrl\";\r\ + \n :local Scripts {\r\ + \n \"Amster-GlobalConfig\"\r\ + \n \"Amster-GlobalFunc\";\r\ + \n# \"Amster-SFTP-backup\"\r\ + \n# \"Amster-BkpEmail-and-upd\";\r\ + \n };\r\ + \n# /system/script/set owner=(\$ScriptVal->\"name\") \\\r\ + \n# source=[ \$IfThenElse (\$ScriptUpdatesCRLF = true) \$SourceCRLF \$S\ + ourceNew ] \$Script;\r\ + \n :foreach Script in=\$Scripts do={\r\ + \n :put \"Installing \$Script...\";\r\ + \n /system/script/remove [ find where name=\$Script ];\r\ + \n /system/script/add name=\$Script owner=\$defOwner source=([ /too\ + l/fetch (\"\$AmScriptsUrl\" . \$Script . \".rsc\") output=user as-value ]-\ + >\"data\");\r\ + \n /system/script/set source=[ :tocrlf [ get \$Script source ] ] \$\ + Script;\r\ + \n };\r\ + \n /system/script { run Amster-GlobalConfig; run Amster-GlobalFunc; }\r\ + \n}\r\ + \n:global AmUpdRun;\r\ + \n:set AmUpdRun do={\r\ + \n #:local UpdScript [ :tostr \$1 ];\r\ + \n #:global ParseKeyValueStore;\r\ + \n :global AmScriptsUrl;\r\ + \n :global defOwner;\r\ + \n :local Scripts {\r\ + \n# \"Amster-GlobalConfig\"\r\ + \n# \"Amster-GlobalFunc\"\r\ + \n# \"Amster-GlobalRemove\"\r\ + \n \"Amster-backup-SFTP\"\r\ + \n \"Amster-SFTP-backup\"\r\ + \n \"Amster-BkpEmail-and-upd\"\r\ + \n \"Amster-TG-Bot\"\r\ + \n \"Amster-TG-Notification\";\r\ + \n };\r\ + \n :foreach Script in=\$Scripts do={\r\ + \n :put \"updating \$Script...\";\r\ + \n /system/script/remove [ find where name=\$Script ];\r\ + \n /system/script/add name=\$Script owner=\$defOwner source=([ /too\ + l/fetch (\"\$AmScriptsUrl\" . \$Script . \".rsc\") output=user as-value ]-\ + >\"data\");\r\ + \n /system/script/set source=[ :tocrlf [ get \$Script source ] ] \$\ + Script;\r\ + \n };\r\ + \n# /system/script/add name=\$Script owner=\$AmOwner source=([ /tool/fe\ + tch check-certificate=yes-without-crl (\"\$AmScriptsUrl\" . \$Script . \".\ + rsc\") output=user as-value ]->\"data\"); };\r\ + \n}\r\ + \n\r\ + \n\$AmFirstRun;\r\ + \n#\$AmUpdRun;\r\ + \n\r\ + \n#\$setUpdExist;\r\ + \n#:global setUpdExist;\r\ + \n#:global ParseKeyValueStore;\r\ + \n#:set setUpdExist do={\r\ + \n#:do {\r\ + \n#:global ParseKeyValueStore;\r\ + \n# :foreach Script in=[ /system/script/find where source~\"^#!rsc by Vad\ + os\\r\?\\n#comment=*\" ] do={\r\ + \n# :local ScriptVal [ /system/script/get \$Script ];\r\ + \n# :local ScriptInfo [ \$ParseKeyValueStore (\$ScriptVal->\"#comment\"\ + ) ];\r\ + \n# :local scriptName (\$ScriptVal->\"name\");\r\ + \n#:log warning (\"\\n\\\$scriptName = \". \$scriptName);\r\ + \n#: log warning (\"\\n\\\$ScriptInfo = \". \$ScriptInfo);\r\ + \n# }\r\ + \n#} on-error={}\r\ + \n#}\r\ + \n#\$name;\$owner;\$policy;\$dont-require-permissions;\$last-started;\$run\ + -count;\$source;\$invalid;\$comment;\$.id;\$.nextid;\$.dead;\$.about;\r\ + \n#;(evl / (evl /docommand=;(evl / (evl /foreachcounter=\$Script;do=;(evl \ + / (evl /localname=\$ScriptVal;value=(evl (evl /system/script/getnumber=\$S\ + cript))) (evl /localname=\$ScriptInfo;value=(evl (<%% \$ParseKeyValueStore\ + \_(> \$ParseKeyValueStore);(-> \$ScriptVal comment)))) (evl /localname=\$s\ + criptName) (evl /setname=\$scriptName;value=(-> #\$ScriptVal name)) (evl /\ + log/errormessage=(. \r\ + \n# \$ ScriptInfo = \$ScriptInfo)));in=(evl (evl /system/script/findwhere\ + =\$name;\$owner;\$policy;\$dont-require-permissions;\$last-started;\$run-c\ + ount;\$source;\$invalid;\$comment;\$.id;\$.nextid;\$.dead;\$.about;(~ \$so\ + urce (. ^#!rsc by Vados \r\ + \n# \? \r\ + \n#));5))));on-error=;(evl /)))\r\ + \n" +add dont-require-permissions=no name="Download cAP's Packages" owner=vados \ + policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + source="# +------------------------------+\r\ + \n# | |\r\ + \n# | Mikrotik RouterOS Scripts |\r\ + \n# | _Download cAP's Packages_ |\r\ + \n# | |\r\ + \n# +------------------------------+\r\ + \n# https://github.com/sebastian13/mikrotik-routeros-scripts\r\ + \n#\r\ + \n\r\ + \n# Set a directory path providing the required space\r\ + \n# Add a microSD card https://wiki.mikrotik.com/wiki/Manual:System/Disks\ + \r\ + \n# or setup a RAM-Disk via '/disk/add type=tmpfs tmpfs-max-size=20M slot=\ + ram'\r\ + \n:local dir \"/tmpfs/capsman-packages\";\r\ + \n\r\ + \n\r\ + \n# Set Package Path if required, set policy to none if using 'upgrade-cap\ + s' script\r\ + \n/interface/wifi/capsman/set package-path=\$dir upgrade-policy=none;\r\ + \n/caps-man/manager/set package-path=\$dir upgrade-policy=none;\r\ + \n#require-same-version;\r\ + \n\r\ + \n:local installed [/system package get value-name=version [find where nam\ + e=\"routeros\"]]\r\ + \n\r\ + \n# Delete old downloads\r\ + \n# /file/remove [ find type=package name~\"capsman*\" ]\r\ + \n\r\ + \n# Starting from RouterOS version 7.13, drivers for older wireless and 60\ + GHz interfaces are\r\ + \n# part of the separate \"wireless\" package. The existing \"wifiwave2\" \ + package has been divided\r\ + \n# into distinct packages: \"wifi-qcom\" and \"wifi-qcom-ac\".\r\ + \n# RouterOS >=7.12 is required to upgrade to 7.13.\r\ + \n# https://forum.mikrotik.com/viewtopic.php\?t=202423\r\ + \n\r\ + \n:foreach architecture in={ \"arm\";\r\ + \n# \"arm64\";\r\ + \n \"x86_64\";\r\ + \n \"mipsbe\"} do={\r\ + \n :foreach package in={ \"routeros\";\r\ + \n# \"wifi-qcom-ac\";\r\ + \n# \"wifi-qcom\";\r\ + \n \"wireless\"} do={ :do {\r\ + \n :put \"\"\r\ + \n :put \"Download \$package \$installed for \$architecture\"\r\ + \n /tool fetch mode=https \\\r\ + \n url=\"https://download.mikrotik.com/routeros/\$installed/\$packa\ + ge-\$installed-\$architecture.npk\" \\\r\ + \n dst-path=\"\$dir/\$package-\$installed-\$architecture.npk\"\r\ + \n } on-error={ :put \"Error downloading the file. On a 404, note t\ + hat the package may not exist for the specified architecture!\" }\r\ + \n }\r\ + \n}\r\ + \n" +add comment="Script for setup routeros scrypt system" \ + dont-require-permissions=no name=AM-setup owner=AM-setup policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\r\ + \n# RouterOS script: AM-setup\r\ + \n# Script comment: Script for setup routeros scrypt system\r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n# requires device-mode, fetch\r\ + \n#\r\ + \n# :local ScriptName [ :jobname ];\r\ + \n# Additional commands:\r\ + \n#\r\ + \n# For scripts:\r\ + \n#:global NewScript \"script_name\"; \r\ + \n#:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ + \n#/system/script/add name=\$NewScript owner=\$NewScript source=([/tool/fe\ + tch check-certificate=yes-without-crl (\$GlobalScriptsUrl . \$ScriptAdd . \ + \".rsc\") output=user as-value ]->\"data\");\r\ + \n#:global NewScript (a);\r\ + \n#:global ScriptInstallUpdate; \$ScriptInstallUpdate;\r\ + \n#\r\ + \n# For run from terminal:\r\ + \n#/system/script/add name=AM-setup owner=AM-Setup source=([/tool/fetch ch\ + eck-certificate=yes-without-crl \"https://ros.vados.ru/AM-setup.rsc\" outp\ + ut=user as-value ]->\"data\");\r\ + \n#\r\ + \n\r\ + \n:global ScriptUpdatesCRLF \"LF\";\r\ + \n#:if (\$ScriptUpdatesCRLF != false) do={\r\ + \n# :foreach Script in=[ /system/script/find where source~\"^#!rsc by Vad\ + os\" ] do={\r\ + \n# if (\$ScriptUpdatesCRLF = true) do={\r\ + \n# /system/script/set source=[ :tocrlf [ get \$Script source ] ] \$S\ + cript;\r\ + \n# } else={\r\ + \n# /system/script/set source=[ :tolf [ get \$Script source ] ] \$Scr\ + ipt;\r\ + \n# }\r\ + \n# }\r\ + \n#}\r\ + \n\r\ + \n# /import verbose=no \$ScriptName\r\ + \n:global SetupScript [ :jobname ];\r\ + \n:global RemoveMe;\r\ + \n:global RunOnce;\r\ + \n:global InitSetup true;\r\ + \n:global tmpfs true;\r\ + \n\r\ + \n{\r\ + \n :local RmMe [:tobool \$1];\r\ + \n\r\ + \n :global GlobalScriptsUrl;\r\ + \n :global SetupScript;\r\ + \n :global RemoveMe;\r\ + \n :global InitSetup;\r\ + \n :global tmpfs;\r\ + \n \r\ + \n :local CertCommonName \"Root YE\";\r\ + \n :local CertFileName \"Root-YE.pem\";\r\ + \n :local CertFingerprint \"e14ffcad5b0025731006caa43a121a22d8e9700f4fb9c\ + f852f02a708aa5d5666\";\r\ + \n\r\ + \n :if (\$SetupScript = false) do={\r\ + \n :global SetupScript \"AM-setup\";\r\ + \n }\r\ + \n :if (\$RemoveMe != false) do={\r\ + \n :set RemoveMe true;\r\ + \n }\r\ + \n\r\ + \n :log warning (\"\\n\\\$GlobalScriptsUrl = \" . \$GlobalScriptsUrl);\r\ + \n \r\ + \n :local CertSettings [ /certificate/settings/get ];\r\ + \n :if (!(((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" || \ + \\\r\ + \n (\$CertSettings->\"builtin-trust-store\") ~ \"fetch\" || \\\r\ + \n (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\r\ + \n [ :len [ /certificate/builtin/find where common-name=\$CertComm\ + onName ] ] > 0)) do={\r\ + \n :put \"Importing certificate...\";\r\ + \n \r\ + \n /tool/fetch (\$GlobalScriptsUrl . \"certs/\" . \$CertFileName) dst-p\ + ath=\$CertFileName as-value;\r\ + \n :delay 1s;\r\ + \n /certificate/import file-name=\$CertFileName passphrase=\"\";\r\ + \n :if ([ :len [ /certificate/find where fingerprint=\$CertFingerprint \ + ] ] != 1) do={\r\ + \n :error \"Something is wrong with your certificates!\";\r\ + \n };\r\ + \n :delay 1s;\r\ + \n };\r\ + \n\r\ + \n:local MkTmpfs do={\r\ + \n :local TmpFs [ /disk/find where slot=tmpfs type=tmpfs ];\r\ + \n :if ([ :len \$TmpFs ] = 1) do={\r\ + \n :if ([ /disk/get \$TmpFs disabled ] = true) do={\r\ + \n :log info (\"The tmpfs is disabled, enabling.\");\r\ + \n /disk/enable \$TmpFs;\r\ + \n }\r\ + \n :return true;\r\ + \n }\r\ + \n :log info (\"Try to removing directory 'tmpfs'.\");\r\ + \n :do {\r\ + \n :retry {\r\ + \n /file/remove tmpfs;\r\ + \n :return true;\r\ + \n } delay=100ms max=10;\r\ + \n } on-error={ }\r\ + \n# \$RmDir \"tmpfs\";\r\ + \n :onerror Err {\r\ + \n /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource/g\ + et total-memory ] / 3);\r\ + \n :do {\r\ + \n :retry {\r\ + \n /file/get tmpfs;\r\ + \n :return true;\r\ + \n } delay=222ms max=10;\r\ + \n } on-error={ }\r\ + \n } do={\r\ + \n :log warning (\"Creating disk of type tmpfs failed: \" . \$Err);\r\ + \n :return false;\r\ + \n }\r\ + \n# :return true;\r\ + \n}\r\ + \n:if (\$tmpfs = true) do={\r\ + \n :put \"Tmpfs variable is true. Checking for tmpfs/scripts directory...\ + \";\r\ + \n :if ([/file find name=\"tmpfs/scripts\"] != \"\") do={\r\ + \n :log info (\$0 . \"Directory tmpfs/scripts exsist.\");\r\ + \n :return \$true;\r\ + \n } else={\r\ + \n :log warning (\$0 . \"Directory tmpfs/scripts does't exsist.\");\r\ + \n :if ([ \$MkTmpfs ] = false) do={\r\ + \n :log error (\$0 . \"Directory tmpfs is not created!\");\r\ + \n :return false;\r\ + \n } else={\r\ + \n :onerror Err {\r\ + \n /file/add type=\"directory\" name=/tmpfs/scripts;\r\ + \n :do {\r\ + \n :retry {\r\ + \n /file/get /tmpfs/scripts;\r\ + \n :return true;\r\ + \n } delay=100ms max=10;\r\ + \n } on-error={ }\r\ + \n } do={\r\ + \n :log warning (\$0 . \"Making directory 'scripts' failed: \" . \$\ + Err);\r\ + \n :return false;\r\ + \n }\r\ + \n# :return true;\r\ + \n# [ /file/get \$FileName ]\r\ + \n }\r\ + \n# :log error (\$0 . \"Directory tmpfs/scripts does not exsist. Remove\ + \_global variable tmpfs!\");\r\ + \n# :global tmpfs (a);\r\ + \n# return false;\r\ + \n }\r\ + \n}\r\ + \n :put \"Renaming AM-GlobalConfig, if exists...\";\r\ + \n :local ConfOldName (\"AM-GlobalConfig-\" . [ /system/clock/get date ] \ + . [ /system/clock/get time ] . \".rsc\");\r\ + \n /system/script/set name=\$ConfOldName [ find where name=\"AM-GlobalCon\ + fig\" ];\r\ + \n :foreach Script in={ \"AM-GlobalConfig\"; \"AM-GlobalFunc\" } do={\r\ + \n :put \"Installing \$Script...\";\r\ + \n /system/script/remove [ find where name=\$Script ];\r\ + \n /system/script/add name=\$Script owner=\$Script source=([ /tool/fetc\ + h check-certificate=yes-without-crl url=(\$GlobalScriptsUrl . \$Script . \ + \".rsc\") output=user as-value ]->\"data\");\r\ + \n \r\ + \n /system/script run \$Script;\r\ + \n :delay 2s;\r\ + \n };\r\ + \n\r\ + \n :if ([ :len [ /certificate/find where fingerprint=\$CertFingerprint ] \ + ] > 0) do={\r\ + \n :put \"Renaming certificate by its common-name...\";\r\ + \n :global CertificateNameByCN;\r\ + \n \$CertificateNameByCN \$CertFingerprint;\r\ + \n };\r\ + \n\r\ + \n :if (\$RemoveMe = true) do={\r\ + \n :put \"Add Scheduler for remove this script...\";\r\ + \n :local OnEvent (\":delay 30s;\\n\" . \"/system/script/remove [ find \ + where name=\\\"\$SetupScript\\\" ];\\n\" . \\\r\ + \n \":delay 2s;\\n\" . \"/system/scheduler/remove [ find where name=\\\ + \"_RemoveSetup\\\" ];\\n\" . \\\r\ + \n \":delay 2s;\\n\" . \":global RemoveMe (a);\\n\");\r\ + \n :local Comment \"_RemoveSetup tmp scheduler for remove setup script.\ + \";\r\ + \n /system/scheduler/add name=\"_RemoveSetup\" comment=\$Comment start-\ + time=startup interval=30s on-event=\$OnEvent;\r\ + \n :log warning (\$0 . \"\\nI've done everything, and now I'm tired..\ + . I'm leaving.\\nThere will be an error below, this is normal.\");\r\ + \n }\r\ + \n :delay 1;\r\ + \n :put \"Loading configuration and functions...\";\r\ + \n :do { \r\ + \n :global ScriptInstallUpdate; \$ScriptInstallUpdate;\r\ + \n :put \"Normal removing temporary global environment variables.\";\ + \r\ + \n :global SetupScript (a);\r\ + \n :global InitSetup (a);\r\ + \n :global RemoveMe (a);\r\ + \n } on-error={\r\ + \n :local ErrorMsg \"Loading configuration and functions error!\";\r\ + \n :log error (\$0 . \$ErrorMsg . :error);\r\ + \n :error \$ErrorMsg;\r\ + \n }\r\ + \n}\r\ + \n" +add comment="Global Config Script" dont-require-permissions=no name=\ + AM-GlobalConfig owner=AM-GlobalConfig policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\r\ + \n# RouterOS script: AM-GlobalConfig\r\ + \n# Script comment: Global Config Script\r\ + \n# Copyright (c) 2007-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# Warning: Dont touch this line!\r\ + \n:global GlobalConfReady false;\r\ + \n#\r\ + \n#\r\ + \n# Global Url For Amster scripts to fetch\r\ + \n# most be defined in AM-Init-Script or AM-setup scripts\r\ + \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ + \n:global ScriptsUrlSuffix \"\";\r\ + \n:global CheckSumsVerify true;\r\ + \n\r\ + \n:global ScriptUpdatesCRLF true;\r\ + \n:global CommentsInScripts true;\r\ + \n\r\ + \n# Debug output:\r\ + \n:global PrintDebug true; #false;\r\ + \n\r\ + \n# Debug output for specific script:\r\ + \n:set (\$PrintDebugOverride->\"AM-GlobalFunc\") true;\r\ + \n\r\ + \n# Debug logs\r\ + \n# Other actions (disk, email, remote or support) can be used as well.\r\ + \n# I do not recommend using echo - use debug output instead (https://rsc.\ + eworm.de/main/DEBUG.html#debug-output).\r\ + \n#/system/logging/add topics=script,debug action=memory;\r\ + \n\r\ + \n:global MikrotikUpgradeUrl \"https://upgrade.mikrotik.com/routeros\";\r\ + \n:global Domain \"WORKGROUP\";\r\ + \n\r\ + \n:global EmailGeneralTo \"vados@vados.ru\";\r\ + \n#:global EmailGeneralCc \"\";\r\ + \n\r\ + \n# \$ScriptInstallUpdate mod/notification-telegram\r\ + \n:global TelegramTokenId \"8390868324:AAG3_d1hfVR2M6pGAgDK6ZvhOe4J97nyopw\ + \";\r\ + \n:global TelegramChatId \"-1003631309063\"; #\"454403445\";\r\ + \n# Use this to send notifications to a specific topic in group.\r\ + \n#:global TelegramThreadId \"30\";\r\ + \n# Using telegram-chat you have to define trusted chat ids (not group ids\ + !)\r\ + \n# or user names. Groups allow to chat with devices simultaneously.\r\ + \n:global TelegramChatIdsTrusted {\r\ + \n \"454403445\"\r\ + \n \"-1003631309063\"\r\ + \n \"-5124482807\"\r\ + \n \"1087968824\";\r\ + \n};\r\ + \n# \"-5294757340\";\r\ + \n\r\ + \n:global TelegramChatGroups \"(all)\";\r\ + \n#:global TelegramChatGroups \"(all|home|office)\";\r\ + \n\r\ + \n:global NotificationFunctions {\r\ + \n \"email\"\r\ + \n \"telegram\";\r\ + \n};\r\ + \n# Toggle this to disable symbols in notifications.\r\ + \n:global NotificationsWithSymbols true;\r\ + \n:global TerminalColorOutput true;\r\ + \n\r\ + \n:global DetectIpAddrDefault \"https://ipv4.mikrotik.ovh/\";\r\ + \n:global DetectIpAddrFallback \"https://api.ipify.org/\";\r\ + \n\r\ + \n## Update channel. Possible values: stable, long-term, testing, developm\ + ent\r\ + \n:global updateChannel \"stable\";\r\ + \n\r\ + \n:global CertRenewUrl (\$GlobalScriptsUrl . \"certs/\");\r\ + \n:global CertRenewTime 2w;\r\ + \n:global CertRenewPass {\r\ + \n \"\";\r\ + \n# \"v3ry-s3cr3t\";\r\ + \n# \"4n0th3r-s3cr3t\";\r\ + \n};\r\ + \n:global CertWarnTime 1w;\r\ + \n:global CertIssuedExportPass {\r\ + \n \"\";\r\ + \n# \"cert1-cn\"=\"v3ry-s3cr3t\";\r\ + \n# \"cert2-cn\"=\"4n0th3r-s3cr3t\";\r\ + \n};\r\ + \n\r\ + \n# Script BackupAndUpdate mode, possible values: backup,\r\ + \n# updateOnce - Update once as \"osnotify\" and back \"osnotify\" mode (i\ + n terminal run :set OSUpdateMode updateOnce; \$OSUpdateMode;). \r\ + \n# osupdate - Update if available and creates backups before/after update\ + \_(ignores `forceBackup`)\r\ + \n# Set `forceBackup` to true to always create backups, even\ + \_without updates\r\ + \n# osnotify - Set `forceBackup` to always create backups on every run\r\ + \n:global DevInfoIncludeIP true;\r\ + \n:global BackupAndUpdateMode \"osnotify\"\r\ + \n\r\ + \n:global forceBackup true;\r\ + \n:global BackupPassword \"Peskar55\";\r\ + \n\r\ + \n# SFTP Backup Variables\r\ + \n:global BackupRandomDelay 0;\r\ + \n:global BackupUploadUrl \"sftp://amster.vados.ru/upload/\";\r\ + \n:global BackupUploadUser \$Identity;\r\ + \n:global BackupUploadPass \"root.mnuc.backuper\";\r\ + \n\r\ + \n:global BackupSendBinary true;\r\ + \n:global BackupSendExport true;\r\ + \n:global BackupSendGlobalConfig true;\r\ + \n:global BackupSendScripts true;\r\ + \n\r\ + \n# Remove local file after uploading if no errors\r\ + \n:global BackupRmLocal true;\r\ + \n\r\ + \n# Local Backups Root Directory \r\ + \n:global BackupLocalRoot \"tmpfs\";\r\ + \n\r\ + \n# Encrypt Backup\r\ + \n:global BackupEncrypt true;\r\ + \n\r\ + \n# Sensitive information in Backups\r\ + \n:global BackupSens true;\r\ + \n\r\ + \n# User Export\r\ + \n:global BackupUser true;\r\ + \n\r\ + \n# License Export (not for CHR, will silently skip)\r\ + \n:global BackupLicense false;\r\ + \n\r\ + \n# SSH Keys\r\ + \n:global BackupSshKeys true;\r\ + \n\r\ + \n# Certificate Export\r\ + \n:global BackupCerts true;\r\ + \n\r\ + \n# Certificate Password\r\ + \n:global BackupCertsPasswd \"\";\r\ + \n\r\ + \n# User-Manager Export\r\ + \n:global BackupUserMan false;\r\ + \n\r\ + \n# The Dude Export\r\ + \n:global BackupDude false;\r\ + \n\r\ + \n# User Files to export, comma-separated string or array of strings\r\ + \n# User Files are not removed on backup\r\ + \n# Any directory paths will be removed (/ -> _) on remote file\r\ + \n# Nonpresent files are silently skipped\r\ + \n:global BackupUserList \"autosupout.rif,autosupout.old.rif\";\r\ + \n\r\ + \n# load functions and any custom scripts\r\ + \n# [ /system/script/find where name=\"global-config-ov\ + erlay\" ], \\\r\ + \n# [ /system/script/find where name~\"^global-config-o\ + verlay\\\\.d/.\" ]\r\ + \n#\r\ + \n#:foreach Script in=([ /system/script/find where name=\"Amster-TGglobalV\ + ars\" ], [ /system/script/find where name=\"Amster-TGglobalFunc\" ]) do={\ + \r\ + \n# :onerror Err {\r\ + \n# /system/script/run \$Script;\r\ + \n# } do={\r\ + \n# :log error (\"Loading configuration from configs and functions\"\ + \_. [ /system/script/get \$Script name ] . \" failed: \" . \$Err);\r\ + \n# }\r\ + \n#}\r\ + \n#:log info \"\\ndevMode = \$devMode\";\r\ + \n#:log info \"\\ndevRunning = \$devRunning\";\r\ + \n:foreach Script in=[ /system/script/find where source~\"^#!rsc by Vados \ + GlobalRUN\\r\?\\n\" ] do={\r\ + \n :onerror Err {\r\ + \n /system/script/run \$Script;\r\ + \n } do={\r\ + \n :log error (\"Run script \" . [ /system/script/get \$Script name \ + ] . \" width marker \\\" GlobalRUN\\\" failed: \" . \$Err);\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n# signal we are ready\r\ + \n:set GlobalConfReady true;\r\ + \n:while (\$GlobalConfReady != true) do={:delay 500ms};\r\ + \n" +add comment="Global functions" dont-require-permissions=no name=AM-GlobalFunc \ + owner=AM-GlobalFunc policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="#\ + !rsc by Vados\r\ + \n# RouterOS script: AM-GglobalFunc\r\ + \n# Script comment: Global functions\r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n# requires device-mode, fetch, scheduler\r\ + \n:local ExitOK false;\r\ + \n:local ScriptName [ :jobname ];\r\ + \n#:global checkRunJob \$SriptName;\r\ + \n#:global fixCRLF;\r\ + \n#:if (\$fixCRLF != false) do={\r\ + \n#:foreach fixScript in=([ /system/script/find where name~\"*\" ]) do={/s\ + ystem/script/set source=[ :tocrlf [ get \$fixScript source ] ] \$fixScript\ + }\r\ + \n#:if (\$fixCRLF != \"LF\") do={ /system/script/set source=[ :tocrlf [ g\ + et \$fixScript source ] ] \$fixScript};};\r\ + \n#}\r\ + \n:global GlobalFuncReady false;\r\ + \n\r\ + \n# Git commit id & info, expected configuration version\r\ + \n:global CommitId \"main/226/e1cd7257\";\r\ + \n:global CommitTAG \"unknown\";\r\ + \n:global CommitInfo \"Autocommit in repo: ros.vados.ru, generated by owne\ + r: root, in 09:45:02 01.04.2026.\";\r\ + \n\r\ + \n# The variables are received right here.\r\ + \n:global GlobalConfVersion 138;\r\ + \n\r\ + \n:global SumsDirAndFileName \"tmp/checksums.json\";\r\ + \n\r\ + \n:global Identity [/system/identity/get name];\r\ + \n:global IdentityShort [:pick \$Identity 0 18];\r\ + \n\r\ + \n:global devBoardName [/system/resource/get board-name];\r\ + \n:global devMode [/system/device-mode/get mode];\r\ + \n:global devCurArch [/system/resource/get architecture-name];\r\ + \n:global devCurVersion [/system/resource/get version];\r\ + \n\r\ + \n# Variables defined in AM-GlobalConfig.rsc\r\ + \n:global TerminalColorOutput;\r\ + \n:global CommentsInScripts;\r\ + \n:global DetectIpAddrDefault;\r\ + \n:global DetectIpAddrFallback;\r\ + \n:global updateChannel;\r\ + \n:global Domain;\r\ + \n:global EmailGeneralTo;\r\ + \n:global BackupAndUpdateMode;\r\ + \n\r\ + \n# Single functions, without nested functions.\r\ + \n:global GlobalEnvRemove;\r\ + \n:global MiniDateTimeStamp;\r\ + \n\r\ + \n# Include globals \$PrintDebug and \$PrintDebugOverride\r\ + \n:global LogPrint;\r\ + \n\r\ + \n# DeviceInfo and Updates\r\ + \n:global IsCheckUpdates;\r\ + \n:global WaitCheckUpdates;\r\ + \n:global GetPubIp;\r\ + \n\r\ + \n:global GetArrDeviceInfo;\r\ + \n:global WaitArrDeviceInfo;\r\ + \n\r\ + \n:global devModel;\r\ + \n:global devRunningMode;\r\ + \n\r\ + \n:global devRbRevision;\r\ + \n:global devRbSerialNumber;\r\ + \n:global devRbVerAvail;\r\ + \n\r\ + \n:global runningChannelVersion;\r\ + \n:global runningChannel;\r\ + \n:global runningVersion;\r\ + \n\r\ + \n:global devBuildTime;\r\ + \n#:global ROsVerAvail;\r\ + \n:global PkgUpdStatus;\r\ + \n:global currentUpdateChannel;\r\ + \n\r\ + \n:global ScriptInstallUpdate;\r\ + \n\r\ + \n:global DeviceInfo;\r\ + \n\r\ + \n:global OldMode;\r\ + \n\r\ + \n:global ParseKeyValueStore;\r\ + \n:global RandomDelay;\r\ + \n:global GetRandomNumber;\r\ + \n:global EscapeForRegEx;\r\ + \n:global ExitError;\r\ + \n:global CharacterMultiply;\r\ + \n:global CharacterReplace;\r\ + \n:global CleanFilePath;\r\ + \n:global CleanName;\r\ + \n\r\ + \n:global CommitBrief;\r\ + \n\r\ + \n:global EitherOr;\r\ + \n:global FormatLine;\r\ + \n:global GetRandom20CharAlNum;\r\ + \n:global Grep;\r\ + \n:global IfThenElse;\r\ + \n:global MAX;\r\ + \n:global MIN;\r\ + \n:global HumanReadableNum;\r\ + \n\r\ + \n:global IsFullyConnected;\r\ + \n:global IsDNSResolving;\r\ + \n:global IsTimeSync;\r\ + \n:global IsTimeSyncCached;\r\ + \n:global IsTimeSyncResetNtp;\r\ + \n\r\ + \n:global WaitDNSResolving;\r\ + \n:global WaitFullyConnected;\r\ + \n:global WaitTimeSync;\r\ + \n:global MkDir;\r\ + \n:global RmDir;\r\ + \n:global RmFile;\r\ + \n:global FileGet;\r\ + \n:global Unix2Dos;\r\ + \n:global UrlEncode;\r\ + \n:global WaitForFile;\r\ + \n:global ScriptLock;\r\ + \n:global SendTelegram;\r\ + \n:global NotificationFunctions;\r\ + \n:global SendNotification;\r\ + \n:global SendNotification2;\r\ + \n:global SymbolForNotification;\r\ + \n:global SymbolByUnicodeName;\r\ + \n:global ValidateSyntax;\r\ + \n:global CheckSumsVerify;\r\ + \n:global GlobalConfChanges;\r\ + \n:global GlobalConfMigration;\r\ + \n:global VersionToNum;\r\ + \n:global RequiredRouterOS;\r\ + \n:global FetchLargeFiles;\r\ + \n:global FetchUserAgentStr;\r\ + \n:global CertificateAvailable;\r\ + \n:global CertificateDownload;\r\ + \n:global CertificateNameByCN;\r\ + \n:global CharacterMultiply;\r\ + \n\r\ + \n:global InspectVar;\r\ + \n:global InspectVarRet;\r\ + \n:global ParseCustom;\r\ + \n\r\ + \n:set IsCheckUpdates do={\r\ + \n :local isInfo [:tobool \$1];\r\ + \n :global LogPrint;\r\ + \n :global updateChannel;\r\ + \n :global PkgUpdStatus;\r\ + \n \$LogPrint debug \$0 (\"\\\$isInfo = \" . \$isInfo); \r\ + \n :local CurrentChannel [ /system/package/update/get channel ];\r\ + \n :if (\$CurrentChannel != \$updateChannel) do={\r\ + \n :retry command={/system/package/update set channel=\$updateChannel} \ + \_delay=300ms max=5 on-error={};\r\ + \n \$LogPrint debug \$0 (\"Set updates channel to: \$updateChannel\");\ + \r\ + \n }\r\ + \n\r\ + \n :local Update [ /system/package/update/get ];\r\ + \n :local Channel (\$Update->\"channel\");\r\ + \n \$LogPrint debug \$0 (\"Update Channel: \" . \$Channel . \".\");\r\ + \n\r\ + \n :local StatusPkg \"undefined\";\r\ + \n \$LogPrint debug \$0 (\"Checking for updates...\");\r\ + \n :retry command={:set \$StatusPkg ([/system/package/update/check-for-up\ + dates without-paging as-value]->\"status\")} \\\r\ + \n delay=300ms max=5 on-error={};\r\ + \n \$LogPrint debug \$0 (\"\\\$StatusPkg = \" . \$StatusPkg);\r\ + \n :if (\$StatusPkg = \"New version is available\") do={ :set PkgUpdStatu\ + s true; } else={ :set PkgUpdStatus false; }\r\ + \n \$LogPrint debug \$0 (\"\\\$PkgUpdStatus = \" . \$PkgUpdStatus);\r\ + \n :if (\$isInfo != false || \$PkgUpdStatus = true) do={\r\ + \n \$LogPrint debug \$0 (\"\\\$PkgUpdStatus = \" . \$PkgUpdStatus);\r\ + \n :if ([:len \$arrDeviceInfo] = 0) do={\r\ + \n :global arrDeviceInfo ({});\r\ + \n :local arrDeviceInfo ({\"section\":{\"key\":\"\"; \"value\":\"\";};}\ + );\r\ + \n }\r\ + \n # else={:local arrDeviceInfo ({})}\r\ + \n :retry command={:set (\$arrDeviceInfo->\"devUpdates\") [[ :parse \"/\ + system/package/update/get\" ]]} delay=500ms max=5 on-error={:log error (\"\ + Error\")};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentChannel\"; \$Cu\ + rrentChannel;};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentVersion\"; (\$U\ + pdate->\"installed-version\");};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devCurrentChannelVersion\ + \"; [/system/resource/get version];};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devUpdateChannel\"; [\$up\ + dateChannel];};\r\ + \n #:set (\$arrDeviceInfo->\"devUpdates\") {\"devUpdateVersion\"; (\$Up\ + date->\"latest-version\");};\r\ + \n } else={\r\ + \n :return \$PkgUpdStatus;\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set WaitArrDeviceInfo do={\r\ + \n :global GetArrDeviceInfo;\r\ + \n :while ([ \$GetArrDeviceInfo ] = false) do={\r\ + \n :delay 1s;\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set GetArrDeviceInfo do={\r\ + \n :global LogPrint;\r\ + \n\r\ + \n :global devBoardName;\r\ + \n :global devModel;\r\ + \n\r\ + \n :global arrDeviceInfo [:toarray {\"section\"={\"key\"=\"\"; \"value\"\ + =\"\";} }];\r\ + \n #:do {:set (\$arrDeviceInfo->\"Updates\") [[ :parse \"/system/package\ + /update/get\" ]]} on-error={}\r\ + \n :global devRbRevision;\r\ + \n :global devRbSerialNumber;\r\ + \n :global devRbCurrentFw;\r\ + \n :global devRbUpgradeFw;\r\ + \n\r\ + \n :global devRunning;\r\ + \n :global devCurArch;\r\ + \n :global ROsVerCurrent;\r\ + \n :global ROsChannelCurrent;\r\ + \n :global ROsVerAvail;\r\ + \n\r\ + \n :global ParseCustom;\r\ + \n :global runningChannelVersion;\r\ + \n :global runningChannel;\r\ + \n :global runningVersion;\r\ + \n :global devBuildTime;\r\ + \n :global GetPubIp;\r\ + \n\r\ + \n :local License [/system/license/get];\r\ + \n :local Resource [/system/resource/get];\r\ + \n :set devBuildTime (\$Resource->\"build-time\");\r\ + \n :set runningChannelVersion (\$Resource->\"version\");\r\ + \n :set runningChannel [\$ParseCustom \$runningChannelVersion \"(\" \")\ + \" 1];\r\ + \n :set runningVersion [\$ParseCustom \$runningChannelVersion \" \"];\r\ + \n\r\ + \n :do {\r\ + \n :if ([:pick \$devBoardName 0 3] != \"CHR\" or [:pick \$devBoardName 0\ + \_3] != \"x86\") do={\r\ + \n :local RouterBoard;\r\ + \n :do {:set RouterBoard [[ :parse \"/system/routerboard/get\" ]]} on\ + -error={}\r\ + \n :set devModel (\$RouterBoard->\"model\");\r\ + \n :set devRbRevision (\$RouterBoard->\"revision\");\r\ + \n :set devRbSerialNumber (\$RouterBoard->\"serial-number\");\r\ + \n #:set devRbCurrentFw (\$RouterBoard->\"current-firmware\");\r\ + \n #:set devRbUpgradeFw (\$RouterBoard->\"upgrade-firmware\");\r\ + \n :if (\$devCurArch = \"mipsbe\" || \$devCurArch = \"arm\") do={\r\ + \n :global devRunning [ /system/device-mode/get mode ];\r\ + \n } else={\r\ + \n :global devRunning [/system/device-mode/get running];}\r\ + \n } else={\r\ + \n :set devModel \$devBoardName;\r\ + \n \r\ + \n :set devRbRevision false;\r\ + \n :set devRbSerialNumber false;\r\ + \n# :set devRbCurrentFw false;\r\ + \n# :set devRbUpgradeFw false;\r\ + \n #:set devCurrentFw \$runningVersion;#:set devUpgradeFw \$ROsVerAvail\ + ;\r\ + \n :set devRunning [/system/device-mode/get running];\r\ + \n }\r\ + \n } on-error={\r\ + \n \$LogPrint error \$0 (\"Error in Function getDevice!\");\r\ + \n :return false;\r\ + \n }\r\ + \n:return true;\r\ + \n}\r\ + \n\r\ + \n:set DeviceInfo do={\r\ + \n :global WaitArrDeviceInfo;\r\ + \n # \$WaitDeviceInfo;\r\ + \n :global devBoardName;\r\ + \n :global devCurArch;\r\ + \n :global devModel;\r\ + \n :global devRunning;\r\ + \n :global devRbRevision;\r\ + \n :global devRbSerialNumber;\r\ + \n :global PiblicIpAddress;\r\ + \n\r\ + \n :global GlobalConfVersion;\r\ + \n :global Identity;\r\ + \n :global IfThenElse;\r\ + \n :global FormatLine;\r\ + \n :local Return;\r\ + \n :local License [/system/license/get];\r\ + \n :local Resource [/system/resource/get];\r\ + \n :local Snmp [ /snmp/get ];\r\ + \n :local Update [ /system/package/update/get ];\r\ + \n\r\ + \n :set Return ([ \$FormatLine \"Hostname:\" \$Identity ] . \"\\n\" . \\\ + \r\ + \n [ \$IfThenElse ([ :len (\$Snmp->\"location\") ] > 0) \\\r\ + \n ([ \$FormatLine \"Location:\" (\$Snmp->\"location\") ] . \"\\n\") \ + ] . \\\r\ + \n [ \$IfThenElse ([ :len (\$Snmp->\"contact\") ] > 0) \\\r\ + \n ([ \$FormatLine \"Contact:\" (\$Snmp->\"contact\") ] . \"\\n\") ] \ + . \\\r\ + \n \"Hardware:\\n\" . \\\r\ + \n [ \$FormatLine \" Board:\" . \$devBoardName ] . \"\\n\" . \\\r\ + \n [ \$FormatLine \" Arch:\" . \$devCurArch ] . \"\\n\" . \\\r\ + \n [ \$FormatLine \" Model:\" \$devModel ] . \\\r\ + \n [ \$IfThenElse ([ :len \$devRbRevision ] > 0) \\\r\ + \n (\" \" . \$devRbRevision) ] . \"\\n\" . \\\r\ + \n [ \$IfThenElse ([ :len \$devRbSerialNumber ] > 0) \\\r\ + \n ([ \$FormatLine \" Serial:\" . \$devRbSerialNumber ] . \"\\n\"\ + ) ] . \\\r\ + \n [ \$IfThenElse ([ :len (\$License->\"nlevel\") ] > 0) \\\r\ + \n ([ \$FormatLine \" License:\" (\"level \" . (\$License->\"nleve\ + l\")) ] . \"\\n\") ] . \"RouterOS:\\n\" . \\\r\ + \n [ \$IfThenElse ([ :len (\$License->\"level\") ] > 0) \\\r\ + \n ([ \$FormatLine \" License:\" (\"level \" . (\$License->\"level\ + \")) ] . \"\\n\") ] . \\\r\ + \n [ \$FormatLine \"Running Channel\" \$runningChannel ] . \"\\n\" . \\\ + \r\ + \n [ \$FormatLine \" Installed:\" (\$Update->\"installed-version\") \ + ] . \"\\n\" . \\\r\ + \n [ \$IfThenElse ([ :typeof (\$Update->\"latest-version\") ] != \"noth\ + ing\" && \\\r\ + \n \$Update->\"installed-version\" != \$Update->\"latest-version\")\ + \_\\\r\ + \n ([ \$FormatLine \" Available\" (\$Update->\"latest-version\") ]\ + \_. \"\\n\") ] . \\\r\ + \n [ \$IfThenElse (\$RouterBoard->\"routerboard\" = true && \\\r\ + \n \$RouterBoard->\"current-firmware\" != \$RouterBoard->\"upgrade-\ + firmware\") \\\r\ + \n ([ \$FormatLine \" Firmware\" (\$RouterBoard->\"current-firmwar\ + e\") ] . \"\\n\") ] . \\ \r\ + \n \"RouterOS-Scripts:\\n\" . \\\r\ + \n [ \$FormatLine \" Commit\" [ \$CommitBrief ] ] . \"\\n\" . \\\r\ + \n [ \$FormatLine \" Version\" \$GlobalConfVersion ]);\r\ + \n}\r\ + \n\r\ + \n:if ([ :typeof \$NotificationFunctions ] != \"array\") do={:set Notifica\ + tionFunctions ({})}\r\ + \n:set GetRandom20CharAlNum do={\r\ + \n :global EitherOr;\r\ + \n :return [ :rndstr length=[ \$EitherOr [ :tonum \$1 ] 20 ] from=\"ABCDE\ + FGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\" ];\r\ + \n}\r\ + \n\r\ + \n:global checkRunJob;\r\ + \n:set checkRunJob do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :global ScriptLock; \r\ + \n :if ([ \$ScriptLock \$Script ] = false) do={:return false}\r\ + \n :foreach Job in=[ /system/script/job/find where script=\$Script ] do={\ + :set Job [ /system/script/job/get \$Job ];\r\ + \n :while ([ :typeof (\$Job->\"parent\") ] = \"id\") do={:set Job [ /sy\ + stem/script/job/get [ find where .id=(\$Job->\"parent\") ] ]}\r\ + \n :if ((\$Job->\"type\") = \"login\") do={:return true};}; :return fa\ + lse; \r\ + \n}\r\ + \n\r\ + \n:set InspectVar do={\r\ + \n :global InspectVarRet;\r\ + \n :put [ :tocrlf [ \$InspectVarRet \$1 ] ];\r\ + \n}\r\ + \n\r\ + \n:set CommitBrief do={\r\ + \n :global CommitId;\r\ + \n :global CommitInfo;\r\ + \n :if (\$CommitId = \"unknown\") do={\r\ + \n :return \"unknown\";\r\ + \n }\r\ + \n :return (\$CommitInfo . \"/\" . [ :pick \$CommitId 0 8 ]);\r\ + \n}\r\ + \n\r\ + \n:set InspectVarRet do={\r\ + \n :local Input \$1;\r\ + \n :local Level (0 + [ :tonum \$2 ]);\r\ + \n :global CharacterReplace;\r\ + \n :global IfThenElse;\r\ + \n :global InspectVarRet;\r\ + \n :local IndentReturn do={\r\ + \n :local Prefix [ :tostr \$1 ];\r\ + \n :local Value [ :tostr \$2 ];\r\ + \n :local Level [ :tonum \$3 ];\r\ + \n :global CharacterMultiply;\r\ + \n :return ([ \$CharacterMultiply \" \" (\$Level * 2) ] . \"-\" . \$Pre\ + fix . \"-> \" . \$Value);\r\ + \n }\r\ + \n :local TypeOf [ :typeof \$Input ];\r\ + \n :local Len [ :len \$Input ];\r\ + \n :local Return [ \$IndentReturn \"type\" \$TypeOf \$Level ];\r\ + \n :if (\$TypeOf = \"array\") do={\r\ + \n :foreach Key,Value in=\$Input do={\r\ + \n :set \$Return (\$Return . \"\\n\" . \\\r\ + \n [ \$IndentReturn \"key\" \$Key (\$Level + 1) ] . \"\\n\" . \\\r\ + \n [ \$InspectVarRet \$Value (\$Level + 2) ]);\r\ + \n }\r\ + \n } else={\r\ + \n :if (\$TypeOf = \"str\") do={\r\ + \n :set \$Return (\$Return . \"\\n\" . \\\r\ + \n [ \$IndentReturn \"len\" \$Len \$Level ]);\r\ + \n :if ([ :typeof [ :find \$Input (\"\\r\") ] ] = \"num\") do={\r\ + \n :set Input [ \$CharacterReplace \$Input (\"\\r\") \"\" ];\r\ + \n }\r\ + \n :if ([ :typeof [ :find \$Input (\"\\n\") ] ] = \"num\") do={\r\ + \n :set Input [ \$CharacterReplace \$Input (\"\\n\") \" \" ];\r\ + \n }\r\ + \n }\r\ + \n :if (\$TypeOf != \"nothing\") do={\r\ + \n :set \$Return (\$Return . \"\\n\" . \\\r\ + \n [ \$IndentReturn \"value\" [ \$IfThenElse ([ :len \$Input ] > 80)\ + \_\\\r\ + \n ([ :pick \$Input 0 77 ] . \"...\") \$Input ] \$Level ]);\r\ + \n }\r\ + \n }\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n# !!! The function is not ready !!!\r\ + \n:global FetchHttpInfo do={\r\ + \n :local Mac [ :tostr \$1 ];\r\ + \n :global CertificateAvailable;\r\ + \n :global IsMacLocallyAdministered;\r\ + \n :global LogPrint;\r\ + \n :local Url \"https://api.macvendors.com/\";\r\ + \n :if ([ \$IsMacLocallyAdministered \$Mac ] = true) do={:return \"locall\ + y administered\";}\r\ + \n :do {\r\ + \n :if ([ \$CertificateAvailable \"GTS Root R4\" \"fetch\" ] = false) d\ + o={\r\ + \n \$LogPrint warning \$0 (\"Downloading required certificate failed.\ + \");\r\ + \n :error false;\r\ + \n }\r\ + \n :local Vendor ([ /tool/fetch \r\ + \n (\$Url . [ :pick \$Mac 0 8 ]) output=user as-value ]->\"data\");\r\ + \n :return \$Vendor;\r\ + \n } on-error={\r\ + \n :onerror Err {\r\ + \n /tool/fetch check-certificate=yes-without-crl (\$Url) output=none \ + as-value;\r\ + \n \$LogPrint debug \$0 (\"The mac vendor is not known in database.\"\ + );\r\ + \n } do={ \$LogPrint warning \$0 (\"Failed getting mac vendor: \" . \$E\ + rr); }\r\ + \n :return \"unknown vendor\";\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set GetPubIp do={\r\ + \n :global DetectIpAddrDefault;\r\ + \n :global DetectIpAddrFallback;\r\ + \n :global LogPrint;\r\ + \n \r\ + \n :local PubIpAddr false;\r\ + \n :local Url \$DetectIpAddrDefault;\r\ + \n\r\ + \n# :retry command={abc} delay=1 max=2 on-error={:put \"got error\"} \r\ + \n :do {\r\ + \n \$LogPrint debug \$0 (\"Trying to detect public IP using default s\ + ervice: \" . \$Url . \"...\");\r\ + \n :retry command={:set PubIpAddr ([ /tool/fetch http-method=\"get\"\ + \_check-certificate=yes-without-crl \$Url output=user as-value ]->\"data\"\ + )} \\\r\ + \n delay=50ms max=5 on-error={\$LogPrint error [ :jobname ] (\"Fail\ + ed to detect public IP using default service: \" . \$Url . \".\")}\r\ + \n #:error \"Failed to detect public IP using default service: \$Url\ + .\"};\r\ + \n } on-error={\r\ + \n \$LogPrint error \$0 (\"Failed to detect public IP using default s\ + ervice: \" . \$Url . \".\");\r\ + \n :set Url \$DetectIpAddrFallBack;\r\ + \n \$LogPrint debug \$0 (\"Trying to detect public IP using fallback \ + service: \" . \$Url . \"...\");\r\ + \n :retry command={:set PubIpAddr ([ /tool/fetch http-method=\"get\"\ + \_check-certificate=yes-without-crl \$Url output=user as-value ]->\"data\"\ + )} \\\r\ + \n delay=200ms max=5 on-error={\$LogPrint error [ :jobname ] (\"Fai\ + led to detect public IP using fallback service: \" . \$Url . \".\")}\r\ + \n };\r\ + \n :if (\$PubIpAddr = false) do={\r\ + \n :set PubIpAddr \"not-detected\";\r\ + \n } else={\r\ + \n :set PubIpAddr [ :pick \$PubIpAddr 0 15];\r\ + \n }\r\ + \n :return \$PubIpAddr;\r\ + \n}\r\ + \n\r\ + \n:set FormatLine do={\r\ + \n :local Key [ :tostr \$1 ];\r\ + \n :local Value [ :tostr \$2 ];\r\ + \n :local Indent [ :tonum \$3 ];\r\ + \n :local Spaces;\r\ + \n :local Return \"\";\r\ + \n :global CharacterMultiply;\r\ + \n :global EitherOr;\r\ + \n :set Indent [ \$EitherOr \$Indent 16 ];\r\ + \n :local Spaces [ \$CharacterMultiply \" \" \$Indent ];\r\ + \n :if ([ :len \$Key ] > 0) do={ :set Return (\$Key . \":\")}\r\ + \n :if ([ :len \$Key ] > (\$Indent - 2)) do={:set Return (\$Return . \"\\\ + n\" . [ :pick \$Spaces 0 \$Indent ] . \$Value);\r\ + \n } else={:set Return (\$Return . [ :pick \$Spaces 0 (\$Indent - [ :len \ + \$Return ]) ] . \$Value)}\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set ParseCustom do={\r\ + \n :local Str [ :tostr \$1 ];\r\ + \n :local Start [:find [ \$Str ] [:tostr \$2]];\r\ + \n :local End [ :tostr \$3 ];\r\ + \n :local Num [ :tonum \$4 ];\r\ + \n :local Return;\r\ + \n :if ([:len \$Num] = 0) do={:set Num \"0\"}\r\ + \n :local rest [:pick \$Str (\$Start+\$Num) [:len \$Str]]; \r\ + \n :if ([:len \$End ] = 0) do={:set Return [:pick \$Str \$Num \$Start]} e\ + lse={\r\ + \n :set End [:find \$rest \$End];\r\ + \n :set Return [:pick \$rest 0 \$End];\r\ + \n }\r\ + \n:return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set LogPrint do={\r\ + \n :local Severity [ :tostr \$1 ];\r\ + \n :local Name [ :tostr \$2 ];\r\ + \n :local Message [ :tostr \$3 ];\r\ + \n :global PrintDebug;\r\ + \n :global PrintDebugOverride;\r\ + \n :global EitherOr;\r\ + \n :local Debug [ \$EitherOr (\$PrintDebugOverride->\$Name) \$PrintDebug \ + ];\r\ + \n :local PrintSeverity do={\r\ + \n :global TerminalColorOutput;\r\ + \n :if (\$TerminalColorOutput != true) do={:return \$1}\r\ + \n :local Color { debug=96; info=97; warning=93; error=91 };\r\ + \n :return (\"\\1B[\" . \$Color->\$1 . \"m\" . \$1 . \"\\1B[0m\");\r\ + \n}\r\ + \n :local Log ([ \$EitherOr \$Name \"\" ] . \": \" . \$Message);\ + \r\ + \n :if (\$Severity ~ (\"^(custom|debug|error|info)\\\$\")) do={\r\ + \n :if (\$Severity = \"debug\") do={:log debug \$Log}\r\ + \n :if (\$Severity = \"error\") do={:log error \$Log}\r\ + \n :if (\$Severity = \"info\" ) do={:log info \$Log}\r\ + \n } else={:log warning \$Log; :set Severity \"warning\"}\r\ + \n :if (\$Severity != \"debug\" || \$Debug = true) do={:put ([ \$PrintSev\ + erity \$Severity ] . \": \" . \$Message)}\r\ + \n}\r\ + \n\r\ + \n:set CertificateAvailable do={\r\ + \n :local CommonName [ :tostr \$1 ];\r\ + \n :local UseFor [ :tostr \$2 ];\r\ + \n :global CertificateDownload;\r\ + \n :global EitherOr;\r\ + \n :global LogPrint;\r\ + \n :global ParseKeyValueStore;\r\ + \n :set UseFor [ \$EitherOr \$UseFor \"undefined\" ];\r\ + \n :if ([ /system/resource/get free-hdd-space ] < 8388608 && \\\r\ + \n [ /certificate/settings/get crl-download ] = true && \\\r\ + \n [ /certificate/settings/get crl-store ] = \"system\") do={\r\ + \n \$LogPrint warning \$0 (\"This system has low free flash space but \ + \" . \\\r\ + \n \"is configured to download certificate CRLs to system!\");\r\ + \n }\r\ + \n :if ([ :len \$CommonName ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"No CommonName given!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local CertSettings [ /certificate/settings/get ];\r\ + \n :if (((\$CertSettings->\"builtin-trust-anchors\") = \"trusted\" || \\\ + \r\ + \n (\$CertSettings->\"builtin-trust-store\") ~ \$UseFor || \\\r\ + \n (\$CertSettings->\"builtin-trust-store\") = \"all\") && \\\r\ + \n [ :len [ /certificate/builtin/find where common-name=\$CommonName\ + \_] ] > 0) do={\r\ + \n :return true;\r\ + \n }\r\ + \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] = 0\ + ) do={\r\ + \n \$LogPrint info \$0 (\"Certificate with CommonName '\" . \$CommonNam\ + e . \"' not available.\");\r\ + \n :if ([ \$CertificateDownload \$CommonName ] = false) do={:return fal\ + se}\r\ + \n }\r\ + \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] > 1\ + ) do={\r\ + \n \$LogPrint info \$0 (\"There are \" . \$CertCount . \" Certificates \ + with CommonName '\" . \$CommonName . \"'. Should be ok.\");\r\ + \n :return true;\r\ + \n }\r\ + \n :local CertVal [ /certificate/get [ find where common-name=\$CommonNam\ + e ] ];\r\ + \n :while ((\$CertVal->\"akid\") != \"\" && (\$CertVal->\"akid\") != (\$C\ + ertVal->\"skid\")) do={\r\ + \n :if ([ :len [ /certificate/find where skid=(\$CertVal->\"akid\") ] ]\ + \_= 0) do={\r\ + \n :local IssuerCN ([ \$ParseKeyValueStore (\$CertVal->\"issuer\") ]-\ + >\"CN\");\r\ + \n \$LogPrint info \$0 (\"Certificate chain for '\" . \$CommonName . \ + \"' is incomplete, missing '\" . \$IssuerCN . \"'.\");\r\ + \n :if ([ \$CertificateDownload \$IssuerCN ] = false) do={:return fal\ + se}\r\ + \n }\r\ + \n :set CertVal [ /certificate/get [ find where skid=(\$CertVal->\"akid\ + \") ] ];\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set CertificateDownload do={\r\ + \n :local CommonName [ :tostr \$1 ];\r\ + \n :global GlobalScriptsUrl;\r\ + \n :global GlobalScriptsUrlSuffix;\r\ + \n :global CertificateNameByCN;\r\ + \n :global CleanName;\r\ + \n :global FetchUserAgentStr;\r\ + \n :global LogPrint;\r\ + \n :global RmFile;\r\ + \n :global WaitForFile;\r\ + \n \r\ + \n \$LogPrint info \$0 (\"Downloading and importing certificate with Comm\ + onName '\" . \$CommonName . \"'.\");\r\ + \n \r\ + \n :local FileName ([ \$CleanName \$CommonName ] . \".pem\");\r\ + \n :do {\r\ + \n /tool/fetch check-certificate=yes-without-crl http-header-field=({ [\ + \_\$FetchUserAgentStr \$0 ] }) \\\r\ + \n (\$GlobalScriptsUrl . \"certs/\" . \$FileName . \$GlobalScriptsUrl\ + Suffix) dst-path=\$FileName as-value;\r\ + \n \$WaitForFile \$FileName;\r\ + \n } on-error={\r\ + \n \$LogPrint warning \$0 (\"Failed downloading certificate with Common\ + Name '\" . \$CommonName . \\\r\ + \n \"' from repository! Trying fallback to mkcert.org...\");\r\ + \n :do {\r\ + \n :if ([ :len [ /certificate/find where common-name=\"ISRG Root X1\"\ + \_] ] = 0) do={\r\ + \n \$LogPrint error \$0 (\"Required certificate is not available.\"\ + );\r\ + \n :return false;\r\ + \n }\r\ + \n /tool/fetch check-certificate=yes-without-crl http-header-field=({\ + \_[ \$FetchUserAgentStr \$0 ] }) \\\r\ + \n \"https://mkcert.org/generate/\" http-data=[ :serialize to=json \ + ({ \$CommonName }) ] \\\r\ + \n dst-path=\$FileName as-value;\r\ + \n \$WaitForFile \$FileName;\r\ + \n :if ([ /file/get \$FileName size ] = 0) do={\r\ + \n \$RmFile \$FileName;\r\ + \n :error false;\r\ + \n }\r\ + \n } on-error={\r\ + \n \$LogPrint warning \$0 (\"Failed downloading certificate with Comm\ + onName '\" . \$CommonName . \"'!\");\r\ + \n :return false;\r\ + \n }\r\ + \n }\r\ + \n\r\ + \n /certificate/import file-name=\$FileName passphrase=\"\" as-value;\r\ + \n :delay 1s;\r\ + \n \$RmFile \$FileName;\r\ + \n\r\ + \n :if ([ :len [ /certificate/find where common-name=\$CommonName ] ] = 0\ + ) do={\r\ + \n /certificate/remove [ find where name~(\"^\" . \$FileName . \"_[0-9]\ + +\\\$\") ];\r\ + \n \$LogPrint warning \$0 (\"Certificate with CommonName '\" . \$Common\ + Name . \"' still unavailable!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :foreach Cert in=[ /certificate/find where name~(\"^\" . \$FileName . \ + \"_[0-9]+\\\$\") ] do={\r\ + \n \$CertificateNameByCN [ /certificate/get \$Cert common-name ];\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set CertificateNameByCN do={\r\ + \n :local Match [ :tostr \$1 ];\r\ + \n :global CleanName;\r\ + \n :global LogPrint;\r\ + \n :local Cert ([ /certificate/find where (common-name=\$Match or fingerp\ + rint=\$Match or name=\$Match) ]->0);\r\ + \n :if ([ :len \$Cert ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"No matching certificate found.\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local CommonName [ /certificate/get \$Cert common-name ];\r\ + \n /certificate/set \$Cert name=[ \$CleanName \$CommonName ];\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set CharacterMultiply do={\r\ + \n :local Str [ :tostr \$1 ];\r\ + \n :local Num [ :tonum \$2 ];\r\ + \n :if (\$Num = 0) do={:return \"\"}\r\ + \n :local Return \"\";\r\ + \n :for I from=1 to=\$Num do={:set Return (\$Return . \$Str)}\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set FetchUserAgentStr do={\r\ + \n :local Caller [ :tostr \$1 ];\r\ + \n :global IfThenElse;\r\ + \n :local Resource [ /system/resource/get ];\r\ + \n :return (\"User-Agent: Mikrotik/\" . \$Resource->\"version\" . \" \" .\ + \_\$Resource->\"architecture-name\" . \\\r\ + \n \" \" . \$Caller . \"/Fetch (https://amster.vados.ru/; main/3419/3ee\ + 19780)\");\r\ + \n}\r\ + \n\r\ + \n:set Grep do={\r\ + \n :local Input ([ :tostr \$1 ] . \"\\n\");\r\ + \n :local Pattern [ :tostr \$2 ];\r\ + \n :if ([ :typeof [ :find \$Input \$Pattern ] ] = \"nil\") do={:return []\ + }\r\ + \n :do {\r\ + \n :local Line [ :pick \$Input 0 [ :find \$Input \"\\n\" ] ];\r\ + \n :if ([ :typeof [ :find \$Line \$Pattern ] ] = \"num\") do={:return \ + \$Line}\r\ + \n :set Input [ :pick \$Input ([ :find \$Input \"\\n\" ] + 1) [ :len \$\ + Input ] ];\r\ + \n } while=([ :len \$Input ] > 0);\r\ + \n :return [];\r\ + \n}\r\ + \n\r\ + \n:set HumanReadableNum do={\r\ + \n :local Input [ :tonum \$1 ];\r\ + \n :local Base [ :tonum \$2 ];\r\ + \n :global EitherOr;\r\ + \n :global IfThenElse;\r\ + \n :local Prefix \"kMGTPE\";\r\ + \n :local Pow 1;\r\ + \n :set Base [ \$EitherOr \$Base 1024 ];\r\ + \n :local Bin [ \$IfThenElse (\$Base = 1024) \"i\" \"\" ];\r\ + \n :if (\$Input < \$Base) do={:return \$Input}\r\ + \n :for I from=0 to=[ :len \$Prefix ] do={\r\ + \n :set Pow (\$Pow * \$Base);\r\ + \n :if (\$Input / \$Base < \$Pow) do={\r\ + \n :set Prefix [ :pick \$Prefix \$I ];\r\ + \n :local Tmp1 (\$Input * 100 / \$Pow);\r\ + \n :local Tmp2 (\$Tmp1 / 100);\r\ + \n :if (\$Tmp2 >= 100) do={:return (\$Tmp2 . \$Prefix . \$Bin)}\r\ + \n :return (\$Tmp2 . \".\" . \\\r\ + \n [ :pick \$Tmp1 [ :len \$Tmp2 ] ([ :len \$Tmp1 ] - [ :len \$Tmp\ + 2 ] + 1) ] . \\\r\ + \n \$Prefix . \$Bin);\r\ + \n }\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set CleanName do={\r\ + \n :local Input [ :tostr \$1 ];\r\ + \n :local Return \"\";\r\ + \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ + \n :local Char [ :pick \$Input \$I ];\r\ + \n :if ([ :typeof [ find \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr\ + stuvwxyz0123456789\" \$Char ] ] = \"nil\") do={\r\ + \n :do {:if ([ :len \$Return ] = 0) do={:error true};\r\ + \n :if ([ :pick \$Return ([ :len \$Return ] - 1) ] = \"-\") do={:er\ + ror true}; :set Char \"-\"} on-error={:set Char \"\"}; \r\ + \n };\r\ + \n :set Return (\$Return . \$Char)};\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set GetRandomNumber do={\r\ + \n :global EitherOr;\r\ + \n :return [ :rndnum from=0 to=[ \$EitherOr [ :tonum \$1 ] 4294967295 ] ]\ + \r\ + \n}\r\ + \n\r\ + \n:set RandomDelay do={\r\ + \n :local Time [ :tonum \$1 ];\r\ + \n :local Unit [ :tostr \$2 ];\r\ + \n :global EitherOr;\r\ + \n :global GetRandomNumber;\r\ + \n :global MAX;\r\ + \n :if (\$Time = 0) do={:return false}\r\ + \n :delay ([ \$MAX 10 [ \$GetRandomNumber ([ :tonsec [ :totime (\$Time . \ + [ \$EitherOr \$Unit \"s\" ]) ] ] / 1000000) ] ] . \"ms\");\r\ + \n}\r\ + \n\r\ + \n:set EscapeForRegEx do={\r\ + \n :local Input [ :tostr \$1 ];\r\ + \n :if ([ :len \$Input ] = 0) do={:return \"\"}\r\ + \n :local Return \"\";\r\ + \n :local Chars (\"^.[]\\\$()|*+\?{}\\\\\");\r\ + \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ + \n :local Char [ :pick \$Input \$I ];\r\ + \n :if ([ :find \$Chars \$Char ]) do={:set Char (\"\\\\\" . \$Char)}\r\ + \n :set Return (\$Return . \$Char);\r\ + \n }\r\ + \n :return \$Return;\r\ + \n}\r\ + \n:set ExitError do={\r\ + \n :local ExitOK [ :tostr \$1 ];\r\ + \n :local Name [ :tostr \$2 ];\r\ + \n :local Error [ :tostr \$3 ];\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :if (\$ExitOK = \"false\") do={\r\ + \n \$LogPrint error \$Name ([ \$IfThenElse ([ :pick \$Name 0 1 ] = \"\\\ + \$\") \\\r\ + \n \"Function\" \"Script\" ] . \" '\" . \$Name . \"' exited with er\ + ror\" . \\\r\ + \n [ \$IfThenElse (!(\$Error ~ \"^(|true|false)\\\$\")) (\": \" . \ + \$Error) \".\" ]);\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n:set MiniDateTimeStamp do={\r\ + \n /system/clock;\r\ + \n :local vdate [get date];\r\ + \n :local vtime [get time];\r\ + \n :local vdoff [:toarray \"0,4,5,7,8,10\"];\r\ + \n :local MM [:pick \$vdate (\$vdoff->2) (\$vdoff->3)];\r\ + \n :local M [:tonum \$MM];\r\ + \n :if (\$vdate ~ \".../../....\") do={\r\ + \n :set vdoff [:toarray \"7,11,1,3,4,6\"];\r\ + \n :set M ([:find \"xxanebarprayunulugepctovecANEBARPRAYUNULUGE\ + PCTOVEC\" [:pick \$vdate (\$vdoff->2) (\$vdoff->3)] -1] / 2);\r\ + \n :if (\$M>12) do={:set M (\$M - 12)}\r\ + \n :set MM [:pick (100 + \$M) 1 3];\r\ + \n }\r\ + \n :local yyyy [:pick \$vdate (\$vdoff->0) (\$vdoff->1)];\r\ + \n :local dd [:pick \$vdate (\$vdoff->4) (\$vdoff->5)];\r\ + \n :local HH [:pick \$vtime 0 2];\r\ + \n :local mm [:pick \$vtime 3 5];\r\ + \n :local ss [:pick \$vtime 6 8];\r\ + \n :return ([\$yyyy] . [\$MM] . [\$dd] . [\$HH] . [\$mm] . [\$ss]);\r\ + \n}\r\ + \n\r\ + \n:set WaitForFile do={\r\ + \n :local FileName [ :tostr \$1 ];\r\ + \n :local WaitTime [ :totime \$2 ];\r\ + \n :global CleanFilePath;\r\ + \n :global EitherOr;\r\ + \n :global MAX;\r\ + \n :set FileName [ \$CleanFilePath \$FileName ];\r\ + \n :local Delay ([ \$MAX [ \$EitherOr \$WaitTime 2s ] 100ms ] / 9);\r\ + \n :do {\r\ + \n :retry {\r\ + \n /file/get \$FileName;\r\ + \n :return true;\r\ + \n } delay=\$Delay max=10;\r\ + \n } on-error={ }\r\ + \n :while ([ :len [ /file/find where name=\$FileName ] ] > 0) do={\r\ + \n :do {\r\ + \n /file/get \$FileName;\r\ + \n :return true;\r\ + \n } on-error={ }\r\ + \n :delay \$Delay;\r\ + \n :set Delay (\$Delay * 3 / 2);\r\ + \n }\r\ + \n :return false;\r\ + \n}\r\ + \n\r\ + \n:set FileGet do={\r\ + \n :local FileName [ :tostr \$1 ];\r\ + \n :global WaitForFile;\r\ + \n :if ([ \$WaitForFile \$FileName 0s ] = false) do={:return false}\r\ + \n :local FileVal false;\r\ + \n :do {:set FileVal [ /file/get \$FileName ];\r\ + \n } on-error={ }\r\ + \n :return \$FileVal;\r\ + \n}\r\ + \n\r\ + \n:set RmDir do={\r\ + \n :local DirName [ :tostr \$1 ];\r\ + \n :global FileGet;\r\ + \n :global LogPrint;\r\ + \n \$LogPrint debug \$0 (\"Removing directory: \". \$DirName);\r\ + \n :local DirVal [ \$FileGet \$DirName ];\r\ + \n :if (\$DirVal = false) do={\$LogPrint debug \$0 (\"... which does not \ + exist.\"); :return true};\r\ + \n :if (\$DirVal->\"type\" != \"directory\") do={\$LogPrint error \$0 (\"\ + Directory '\" . \$DirName . \"' is not a directory.\"); :return false};\r\ + \n :onerror Err {/file/remove \$DirName} do={\$LogPrint error \$0 (\"Remo\ + ving directory '\" . \$DirName . \"' failed: \" . \$Err); :return false};\ + \r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set RmFile do={\r\ + \n :local FileName [ :tostr \$1 ];\r\ + \n :global FileGet;\r\ + \n :global LogPrint;\r\ + \n \$LogPrint debug \$0 (\"Removing file: \". \$FileName);\r\ + \n :local FileVal [ \$FileGet \$FileName ];\r\ + \n :if (\$FileVal = false) do={\$LogPrint debug \$0 (\"... which does not\ + \_exist.\"); :return true}\r\ + \n :if (\$FileVal->\"type\" = \"directory\" || \$FileVal->\"type\" = \"di\ + sk\") do={\r\ + \n \$LogPrint error \$0 (\"File '\" . \$FileName . \"' is not a file.\"\ + ); :return false}\r\ + \n :onerror Err {\r\ + \n /file/remove \$FileName;\r\ + \n } do={\$LogPrint error \$0 (\"Removing file '\" . \$FileName . \"' fai\ + led: \" . \$Err); :return false}\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set MkDir do={\r\ + \n :local Path [ :tostr \$1 ];\r\ + \n :global CleanFilePath;\r\ + \n :global FileGet;\r\ + \n :global RmDir;\r\ + \n :global WaitForFile;\r\ + \n :global LogPrint;\r\ + \n :local MkTmpfs do={\r\ + \n :global WaitForFile;\r\ + \n :local TmpFs [ /disk/find where slot=tmpfs type=tmpfs ];\r\ + \n :if ([ :len \$TmpFs ] = 1) do={\r\ + \n :if ([ /disk/get \$TmpFs disabled ] = true) do={\r\ + \n \$LogPrint info \$0 (\"The tmpfs is disabled, enabling.\");\r\ + \n /disk/enable \$TmpFs;\r\ + \n }\r\ + \n :return true;\r\ + \n }\r\ + \n \$LogPrint info \$0 (\"Creating disk of type tmpfs.\");\r\ + \n \$RmDir \"tmpfs\";\r\ + \n :onerror Err {\r\ + \n /disk/add slot=tmpfs type=tmpfs tmpfs-max-size=([ /system/resource\ + /get total-memory ] / 3);\r\ + \n \$WaitForFile \"tmpfs\";\r\ + \n } do={\r\ + \n \$LogPrint warning \$0 (\"Creating disk of type tmpfs failed: \" .\ + \_\$Err);\r\ + \n :return false;\r\ + \n }\r\ + \n :return true;\r\ + \n }\r\ + \n :set Path [ \$CleanFilePath \$Path ];\r\ + \n :if (\$Path = \"\") do={\r\ + \n :return true;\r\ + \n }\r\ + \n \$LogPrint debug \$0 (\"Making directory: \" . \$Path);\r\ + \n :local PathVal [ \$FileGet \$Path ];\r\ + \n :if (\$PathVal->\"type\" = \"directory\") do={\r\ + \n \$LogPrint debug \$0 (\"... which already exists.\");\r\ + \n :return true;\r\ + \n }\r\ + \n :if ([ :pick \$Path 0 5 ] = \"tmpfs\") do={\r\ + \n :if ([ \$MkTmpfs ] = false) do={\r\ + \n :return false;\r\ + \n }\r\ + \n }\r\ + \n :onerror Err {\r\ + \n /file/add type=\"directory\" name=\$Path;\r\ + \n \$WaitForFile \$Path;\r\ + \n } do={\r\ + \n \$LogPrint warning \$0 (\"Making directory '\" . \$Path . \"' failed\ + : \" . \$Err);\r\ + \n :return false;\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n:set MAX do={:if (\$1 > \$2) do={:return \$1}\r\ + \n :return \$2;\r\ + \n}\r\ + \n:set MIN do={:if (\$1 < \$2) do={:return \$1}\r\ + \n :return \$2;\r\ + \n}\r\ + \n\r\ + \n:set CharacterMultiply do={\r\ + \n :local Str [ :tostr \$1 ];\r\ + \n :local Num [ :tonum \$2 ];\r\ + \n :if (\$Num = 0) do={:return \"\"}\r\ + \n :local Return \"\";\r\ + \n :for I from=1 to=\$Num do={:set Return (\$Return . \$Str)}\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set CharacterReplace do={\r\ + \n :local String [ :tostr \$1 ];\r\ + \n :local ReplaceFrom [ :tostr \$2 ];\r\ + \n :local ReplaceWith [ :tostr \$3 ];\r\ + \n :local Return \"\";\r\ + \n :if (\$ReplaceFrom = \"\") do={:return \$String}\r\ + \n :while ([ :typeof [ :find \$String \$ReplaceFrom ] ] != \"nil\") do={\ + \r\ + \n :local Pos [ :find \$String \$ReplaceFrom ];\r\ + \n :set Return (\$Return . [ :pick \$String 0 \$Pos ] . \$ReplaceWith);\ + \r\ + \n :set String [ :pick \$String (\$Pos + [ :len \$ReplaceFrom ]) [ :len\ + \_\$String ] ];\r\ + \n }\r\ + \n :return (\$Return . \$String);\r\ + \n}\r\ + \n\r\ + \n:set CleanFilePath do={\r\ + \n :local Path [ :tostr \$1 ];\r\ + \n :global CharacterReplace;\r\ + \n :while (\$Path ~ \"//\") do={:set \$Path [ \$CharacterReplace \$Path \ + \"//\" \"/\" ]};\r\ + \n :if ([ :pick \$Path 0 ] = \"/\") do={:set Path [ :pick \$Path 1 [ :len\ + \_\$Path ] ]};\r\ + \n :if ([ :pick \$Path ([ :len \$Path ] - 1) ] = \"/\") do={:set Path [ :\ + pick \$Path 0 ([ :len \$Path ] - 1) ]};\r\ + \n :return \$Path;\r\ + \n}\r\ + \n\r\ + \n:set IfThenElse do={\r\ + \n :if ([ :tostr \$1 ] = \"true\" || [ :tobool \$1 ] = true) do={:return \ + \$2};\r\ + \n :return \$3;\r\ + \n}\r\ + \n\r\ + \n:set EitherOr do={\r\ + \n :global IfThenElse;\r\ + \n :if ([ :typeof \$1 ] = \"num\") do={:return [ \$IfThenElse (\$1 != 0) \ + \$1 \$2 ]}\r\ + \n :if ([ :typeof \$1 ] = \"time\") do={:return [ \$IfThenElse (\$1 > 0s)\ + \_\$1 \$2 ]}\r\ + \n# this works for boolean values, literal ones with parentheses\r\ + \n :return [ \$IfThenElse ([ :len [ :tostr \$1 ] ] > 0) \$1 \$2 ];\r\ + \n}\r\ + \n\r\ + \n:set ParseKeyValueStore do={\r\ + \n :local Source \$1;\r\ + \n :if ([ :pick \$Source 0 1 ] = \"{\") do={\r\ + \n :do {\r\ + \n :return [ :deserialize from=json \$Source ];\r\ + \n } on-error={ }\r\ + \n } \r\ + \n :if ([ :typeof \$Source ] != \"array\") do={:set Source [ :tostr \$1 ]\ + }\r\ + \n :local Result ({});\r\ + \n :foreach KeyValue in=[ :toarray \$Source ] do={\r\ + \n :if ([ :find \$KeyValue \"=\" ]) do={\r\ + \n :local Key [ :pick \$KeyValue 0 [ :find \$KeyValue \"=\" ] ];\r\ + \n :local Value [ :pick \$KeyValue ([ :find \$KeyValue \"=\" ] + 1) [\ + \_:len \$KeyValue ] ];\r\ + \n :if (\$Value=\"true\") do={:set Value true}\r\ + \n :if (\$Value=\"false\") do={:set Value false}\r\ + \n :set (\$Result->\$Key) \$Value;\r\ + \n } else={:set (\$Result->\$KeyValue) true}\r\ + \n }\r\ + \n :return \$Result;\r\ + \n}\r\ + \n:set RequiredRouterOS do={\r\ + \n :local Caller [ :tostr \$1 ];\r\ + \n :local Required [ :tostr \$2 ];\r\ + \n :local Warn [ :tostr \$3 ];\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global VersionToNum;\r\ + \n :if (!(\$Required ~ \"^\\\\d+\\\\.\\\\d+((alpha|beta|rc|\\\\.)\\\\d+|)\ + \\\$\")) do={\r\ + \n \$LogPrint error \$0 (\"No valid RouterOS version: \" . \$Required);\ + \r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ \$VersionToNum \$Required ] > [ \$VersionToNum [ /system/packag\ + e/update/get installed-version ] ]) do={\r\ + \n :if (\$Warn = \"true\") do={\r\ + \n \$LogPrint warning \$0 (\"This \" . [ \$IfThenElse ([ :pick \$Call\ + er 0 ] = (\"\\\$\")) \"function\" \"script\" ] . \\\r\ + \n \" '\" . \$Caller . \"' (at least specific functionality) requir\ + es RouterOS \" . \$Required . \". Please update!\");\r\ + \n }\r\ + \n :return false;\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n:set VersionToNum do={\r\ + \n :local Input [ :tostr \$1 ];\r\ + \n :local Multi 0x1000000;\r\ + \n :local Return 0;\r\ + \n :global CharacterReplace;\r\ + \n :set Input [ \$CharacterReplace \$Input \".\" \",\" ];\r\ + \n :foreach I in={ \"zero\"; \"alpha\"; \"beta\"; \"rc\" } do={\r\ + \n :set Input [ \$CharacterReplace \$Input \$I (\",\" . \$I . \",\") ];\ + \r\ + \n }\r\ + \n :foreach Value in=([ :toarray \$Input ], 0) do={\r\ + \n :local Num [ :tonum \$Value ];\r\ + \n :if (\$Multi = 0x100) do={\r\ + \n :if ([ :typeof \$Num ] = \"num\") do={\r\ + \n :set Return (\$Return + 0xff00);\r\ + \n :set Multi (\$Multi / 0x100);\r\ + \n } else={\r\ + \n :if (\$Value = \"zero\") do={ }\r\ + \n :if (\$Value = \"alpha\") do={ :set Return (\$Return + 0x3f00); \ + }\r\ + \n :if (\$Value = \"beta\") do={ :set Return (\$Return + 0x5f00); }\ + \r\ + \n :if (\$Value = \"rc\") do={ :set Return (\$Return + 0x7f00); }\r\ + \n }\r\ + \n }\r\ + \n :if ([ :typeof \$Num ] = \"num\") do={ :set Return (\$Return + (\$Va\ + lue * \$Multi)); }\r\ + \n :set Multi (\$Multi / 0x100);\r\ + \n }\r\ + \n :return \$Return;\r\ + \n}\r\ + \n:set ScriptLock do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :local WaitMax [ :totime \$2 ];\r\ + \n :global GetRandom20CharAlNum;\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global ScriptLockOrder;\r\ + \n :if ([ :typeof \$ScriptLockOrder ] = \"nothing\") do={\r\ + \n :set ScriptLockOrder ({});\r\ + \n }\r\ + \n :if ([ :typeof (\$ScriptLockOrder->\$Script) ] = \"nothing\") do={\r\ + \n :set (\$ScriptLockOrder->\$Script) ({});\r\ + \n }\r\ + \n :local JobCount do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :return [ :len [ /system/script/job/find where script=\$Script ] ];\ + \r\ + \n }\r\ + \n :local TicketCount do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :local Count 0;\r\ + \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ + \n :if ([ :typeof \$Ticket ] != \"nothing\") do={:set Count (\$Count \ + + 1)}\r\ + \n }\r\ + \n :return \$Count;\r\ + \n }\r\ + \n :local IsFirstTicket do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :local Check [ :tostr \$2 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ + \n :if (\$Ticket = \$Check) do={:return true}\r\ + \n :if ([ :typeof \$Ticket ] != \"nothing\" && \$Ticket != \$Check) d\ + o={:return false}\r\ + \n }\r\ + \n :return false;\r\ + \n }\r\ + \n :local AddTicket do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :local Add [ :tostr \$2 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :while (true) do={\r\ + \n :local Pos [ :len (\$ScriptLockOrder->\$Script) ];\r\ + \n :set (\$ScriptLockOrder->\$Script->\$Pos) \$Add;\r\ + \n :delay 10ms;\r\ + \n :if ((\$ScriptLockOrder->\$Script->\$Pos) = \$Add) do={:return tru\ + e}\r\ + \n }\r\ + \n }\r\ + \n :local RemoveTicket do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :local Remove [ :tostr \$2 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :foreach Id,Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ + \n :while ((\$ScriptLockOrder->\$Script->\$Id) = \$Remove) do={\r\ + \n :set (\$ScriptLockOrder->\$Script->\$Id);\r\ + \n :delay 10ms;\r\ + \n }\r\ + \n }\r\ + \n }\r\ + \n :local CleanupTickets do={\r\ + \n :local Script [ :tostr \$1 ];\r\ + \n :global ScriptLockOrder;\r\ + \n :foreach Ticket in=(\$ScriptLockOrder->\$Script) do={\r\ + \n :if ([ :typeof \$Ticket ] != \"nothing\") do={:return false}\r\ + \n }\r\ + \n :set (\$ScriptLockOrder->\$Script) ({});\r\ + \n }\r\ + \n :if ([ :typeof \$WaitMax ] = \"nil\" ) do={:set WaitMax 0s}\r\ + \n :if ([ :len [ /system/script/find where name=\$Script ] ] = 0) do={\r\ + \n \$LogPrint error \$0 (\"A script named '\" . \$Script . \"' does not\ + \_exist!\");\r\ + \n :error false;\r\ + \n }\r\ + \n :if ([ \$JobCount \$Script ] = 0) do={\r\ + \n \$LogPrint error \$0 (\"No script '\" . \$Script . \"' is running!\"\ + );\r\ + \n :error false;\r\ + \n }\r\ + \n :if ([ \$TicketCount \$Script ] >= [ \$JobCount \$Script ]) do={\r\ + \n \$LogPrint error \$0 (\"More tickets than running scripts '\" . \$Sc\ + ript . \"', resetting!\");\r\ + \n :set (\$ScriptLockOrder->\$Script) ({});\r\ + \n /system/script/job/remove [ find where script=\$Script ];\r\ + \n }\r\ + \n :local MyTicket [ \$GetRandom20CharAlNum 6 ];\r\ + \n \$AddTicket \$Script \$MyTicket;\r\ + \n :local WaitInterval (\$WaitMax / 20);\r\ + \n :local WaitTime \$WaitMax;\r\ + \n :while (\$WaitTime > 0 && \\\r\ + \n ([ \$IsFirstTicket \$Script \$MyTicket ] = false || \\\r\ + \n [ \$TicketCount \$Script ] < [ \$JobCount \$Script ])) do={\r\ + \n :set WaitTime (\$WaitTime - \$WaitInterval);\r\ + \n :delay \$WaitInterval;\r\ + \n }\r\ + \n :if ([ \$IsFirstTicket \$Script \$MyTicket ] = true && \\\r\ + \n [ \$TicketCount \$Script ] = [ \$JobCount \$Script ]) do={\r\ + \n \$RemoveTicket \$Script \$MyTicket;\r\ + \n \$CleanupTickets \$Script;\r\ + \n :return true;\r\ + \n }\r\ + \n \$RemoveTicket \$Script \$MyTicket;\r\ + \n \$LogPrint debug \$0 (\"Script '\" . \$Script . \"' started more than \ + once\" . \\\r\ + \n [ \$IfThenElse (\$WaitTime < \$WaitMax) \" and timed out waiting for\ + \_lock\" \"\" ] . \"...\");\r\ + \n :return false;\r\ + \n}\r\ + \n:set SendNotification do={ :onerror Err {\r\ + \n :global SendNotification2;\r\ + \n \$SendNotification2 ({ origin=\$0; subject=\$1; message=\$2; link=\$3;\ + \_silent=\$4 });\r\ + \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err}\r\ + \n}\r\ + \n:set SendNotification2 do={\r\ + \n :local Notification \$1;\r\ + \n :global NotificationFunctions;\r\ + \n :foreach FunctionName,Discard in=\$NotificationFunctions do={\r\ + \n (\$NotificationFunctions->\$FunctionName) (\"\\\$NotificationFunctio\ + ns->\\\"\" . \$FunctionName . \"\\\"\") \$Notification;\r\ + \n }\r\ + \n}\r\ + \n:set SymbolByUnicodeName do={\r\ + \n :local Name [ :tostr \$1 ];\r\ + \n :global EitherOr;\r\ + \n :global LogPrint;\r\ + \n :global SymbolsExtra;\r\ + \n :local Symbols ({\r\ + \n \"abacus\"=\"\\F0\\9F\\A7\\AE\";\r\ + \n \"alarm-clock\"=\"\\E2\\8F\\B0\";\r\ + \n \"arrow-down\"=\"\\E2\\AC\\87\";\r\ + \n \"arrow-up\"=\"\\E2\\AC\\86\";\r\ + \n \"calendar\"=\"\\F0\\9F\\93\\85\";\r\ + \n \"card-file-box\"=\"\\F0\\9F\\97\\83\";\r\ + \n \"chart-decreasing\"=\"\\F0\\9F\\93\\89\";\r\ + \n \"chart-increasing\"=\"\\F0\\9F\\93\\88\";\r\ + \n \"cloud\"=\"\\E2\\98\\81\";\r\ + \n \"cross-mark\"=\"\\E2\\9D\\8C\";\r\ + \n \"earth\"=\"\\F0\\9F\\8C\\8D\";\r\ + \n \"fire\"=\"\\F0\\9F\\94\\A5\";\r\ + \n \"floppy-disk\"=\"\\F0\\9F\\92\\BE\";\r\ + \n \"gear\"=\"\\E2\\9A\\99\";\r\ + \n \"heart\"=\"\\E2\\99\\A5\";\r\ + \n \"high-voltage-sign\"=\"\\E2\\9A\\A1\";\r\ + \n \"incoming-envelope\"=\"\\F0\\9F\\93\\A8\";\r\ + \n \"information\"=\"\\E2\\84\\B9\";\r\ + \n \"large-orange-circle\"=\"\\F0\\9F\\9F\\A0\";\r\ + \n \"large-red-circle\"=\"\\F0\\9F\\94\\B4\";\r\ + \n \"link\"=\"\\F0\\9F\\94\\97\";\r\ + \n \"lock-with-ink-pen\"=\"\\F0\\9F\\94\\8F\";\r\ + \n \"memo\"=\"\\F0\\9F\\93\\9D\";\r\ + \n \"mobile-phone\"=\"\\F0\\9F\\93\\B1\";\r\ + \n \"pushpin\"=\"\\F0\\9F\\93\\8C\";\r\ + \n \"scissors\"=\"\\E2\\9C\\82\";\r\ + \n \"scroll\"=\"\\F0\\9F\\93\\9C\";\r\ + \n \"smiley-partying-face\"=\"\\F0\\9F\\A5\\B3\";\r\ + \n \"smiley-smiling-face\"=\"\\E2\\98\\BA\";\r\ + \n \"smiley-winking-face-with-tongue\"=\"\\F0\\9F\\98\\9C\";\r\ + \n \"sparkles\"=\"\\E2\\9C\\A8\";\r\ + \n \"speech-balloon\"=\"\\F0\\9F\\92\\AC\";\r\ + \n \"star\"=\"\\E2\\AD\\90\";\r\ + \n \"warning-sign\"=\"\\E2\\9A\\A0\";\r\ + \n \"white-heavy-check-mark\"=\"\\E2\\9C\\85\"\r\ + \n }, \$SymbolsExtra);\r\ + \n :local Magic [ :pick [ /system/clock/get date ] 4 10 ];\r\ + \n :local Special {\r\ + \n \"information-04-01\"=\"\\F0\\9F\\9A\\BB\";\r\ + \n \"large-orange-circle-04-01\"=\"\\F0\\9F\\8D\\8A\";\r\ + \n \"large-orange-circle-10-31\"=\"\\F0\\9F\\8E\\83\";\r\ + \n \"large-red-circle-04-01\"=\"\\F0\\9F\\8D\\92\" };\r\ + \n :if ([ :len (\$Symbols->\$Name) ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"No symbol available for name '\" . \$Name \ + . \"'!\");\r\ + \n :return \"\";\r\ + \n }\r\ + \n :return ([ \$EitherOr (\$Special->(\$Name . \$Magic)) (\$Symbols->\$Na\ + me) ] . \"\\EF\\B8\\8F\");\r\ + \n}\r\ + \n:set SymbolForNotification do={\r\ + \n :global NotificationsWithSymbols;\r\ + \n :global SymbolByUnicodeName;\r\ + \n :global IfThenElse;\r\ + \n :if (\$NotificationsWithSymbols != true) do={:return [ \$IfThenElse ([\ + \_:len \$2 ] > 0) ([ :tostr \$2 ] . \" \") \"\" ]}\r\ + \n :local Return \"\";\r\ + \n :foreach Symbol in=[ :toarray \$1 ] do={:set Return (\$Return . [ \$Sy\ + mbolByUnicodeName \$Symbol ])}\r\ + \n :return (\$Return . \" \");\r\ + \n}\r\ + \n:set Unix2Dos do={:return [ :tocrlf [ :tostr \$1 ] ]}\r\ + \n:set UrlEncode do={\r\ + \n :local Input [ :tostr \$1 ];\r\ + \n :if ([ :len \$Input ] = 0) do={:return \"\"}\r\ + \n :local Return \"\";\r\ + \n :local Chars (\"\\n\\r !\\\"#\\\$%&'()*+,:;<=>\?@[\\\\]^`{|}~\");\r\ + \n :local Subs { \"%0A\"; \"%0D\"; \"%20\"; \"%21\"; \"%22\"; \"%23\"; \"\ + %24\"; \"%25\"; \"%26\"; \"%27\";\r\ + \n \"%28\"; \"%29\"; \"%2A\"; \"%2B\"; \"%2C\"; \"%3A\"; \"%3B\"; \ + \"%3C\"; \"%3D\"; \"%3E\"; \"%3F\";\r\ + \n \"%40\"; \"%5B\"; \"%5C\"; \"%5D\"; \"%5E\"; \"%60\"; \"%7B\"; \ + \"%7C\"; \"%7D\"; \"%7E\" };\r\ + \n :for I from=0 to=([ :len \$Input ] - 1) do={\r\ + \n :local Char [ :pick \$Input \$I ];\r\ + \n :local Replace [ :find \$Chars \$Char ];\r\ + \n :if ([ :typeof \$Replace ] = \"num\") do={:set Char (\$Subs->\$Repla\ + ce)}\r\ + \n :set Return (\$Return . \$Char);\r\ + \n }\r\ + \n :return \$Return;\r\ + \n}\r\ + \n:set ValidateSyntax do={\r\ + \n :local Code [ :tostr \$1 ];\r\ + \n :global LogPrint;\r\ + \n :onerror Err {\r\ + \n [ :parse (\":local Validate do={\\n\" . \$Code . \"\\n}\") ];\r\ + \n } do={\r\ + \n \$LogPrint debug \$0 (\"Valdation failed: \" . \$Err);\r\ + \n :return false;\r\ + \n }\r\ + \n :return true;\r\ + \n}\r\ + \n:set IsDNSResolving do={\r\ + \n :do {:resolve \"api.telegram.org\"} on-error={:return false}\r\ + \n :return true;\r\ + \n}\r\ + \n:set IsFullyConnected do={\r\ + \n :global IsDNSResolving;\r\ + \n :global IsTimeSync;\r\ + \n :if ([ \$IsDNSResolving ] = false) do={:return false};\r\ + \n :if ([ \$IsTimeSync ] = false) do={:return false};\r\ + \n :return true;\r\ + \n}\r\ + \n:set IsTimeSync do={\r\ + \n :global IsTimeSyncCached;\r\ + \n :global IsTimeSyncResetNtp;\r\ + \n :if (\$IsTimeSyncCached = true) do={:return true}\r\ + \n :if ([ /system/ntp/client/get enabled ] = true) do={\r\ + \n :if ([ /system/ntp/client/get status ] = \"synchronized\") do={\r\ + \n :set IsTimeSyncCached true;\r\ + \n :return true;\r\ + \n }\r\ + \n :local Uptime [ /system/resource/get uptime ];\r\ + \n :if ([ :typeof \$IsTimeSyncResetNtp ] = \"nothing\") do={\r\ + \n :set IsTimeSyncResetNtp \$Uptime;\r\ + \n }\r\ + \n :if (\$Uptime - \$IsTimeSyncResetNtp < 3m) do={:return false}\r\ + \n :log warning \"\$0 The ntp client is configured, but did not sync.\"\ + ;\r\ + \n :set IsTimeSyncResetNtp \$Uptime;\r\ + \n /system/ntp/client/set enabled=no;\r\ + \n :delay 20ms;\r\ + \n /system/ntp/client/set enabled=yes;\r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ /system/license/get ]->\"level\" = \"free\" || \\\r\ + \n [ /system/resource/get ]->\"board-name\" = \"x86\") do={\r\ + \n :log debug \"\$0 No ntp client configured, relying on RTC for CHR fr\ + ee license and x86.\";\r\ + \n :return true;\r\ + \n }\r\ + \n :if ([ /ip/cloud/get update-time ] = true) do={\r\ + \n :if ([ :typeof [ /ip/cloud/get public-address ] ] = \"ip\") do={\r\ + \n :set IsTimeSyncCached true;\r\ + \n :return true;\r\ + \n }\r\ + \n :return false;\r\ + \n }\r\ + \n :log debug \"\$0 No time source configured! Returning gracefully...\";\ + \r\ + \n :return true;\r\ + \n}\r\ + \n\r\ + \n# read parts of a large file\r\ + \n:set FetchLargeFiles do={\r\ + \n :local ScriptName [:tostr \$1];\r\ + \n :local fetchUrl [:tostr \$2];\r\ + \n :local CheckCert [:tostr \$3];\r\ + \n :local fetchMode [:tostr \$4];\r\ + \n :local fetchMethod [:tostr \$5];\r\ + \n :local FetchString \"undefined\";\r\ + \n \r\ + \n :global CleanName;\r\ + \n :global FetchUserAgentStr;\r\ + \n :global GetRandom20CharAlNum;\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global MkDir;\r\ + \n :global RmDir;\r\ + \n :global RmFile;\r\ + \n :global WaitForFile;\r\ + \n\r\ + \n :set CheckCert [ \$IfThenElse (\$CheckCert = \"false\") \"no\" \"yes-w\ + ithout-crl\" ];\r\ + \n #:set fetchMode [ \$IfThenElse (\$fetchMode != \"false\") [:tostr (\"m\ + ode=\" . \$fetchMode)] ];\r\ + \n #:set fetchMethod [\$IfThenElse (\$fetchMethod != \"false\") [:tostr (\ + \"http-method=\\\"\" . \$fetchMethod . \"\\\"\") ]];\r\ + \n \r\ + \n :local DirName (\"tmpfs/\" . [ \$CleanName \$ScriptName ]);\r\ + \n :if ([ \$MkDir \$DirName ] = false) do={\r\ + \n \$LogPrint error \$0 (\"Failed creating directory!\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local FileName (\$DirName . \"/\" . [ \$CleanName \$0 ] . \"-\" . [ \ + \$GetRandom20CharAlNum ]);\r\ + \n #/tool/fetch check-certificate=\$CheckCert \$Url dst-path=\$FileName h\ + ttp-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] }) as-value;\r\ + \n #:log warning (\"\\\$fUrl =\" . \$2 . ({[ \$fMode ]}));\r\ + \n :onerror Err {\r\ + \n :set FetchString (\"/tool/fetch \" . \\\r\ + \n [\$IfThenElse ([\$fetchMethod] != \"false\") (\"http-method=\\\"\"\ + \_. \$fetchMethod . \"\\\" \")] . \\\r\ + \n \"check-certificate=\" . \$CheckCert . \" url=(\\\"\" . \$fetchUrl\ + \_. \"\\\") \" . \\\r\ + \n [\$IfThenElse ([\$fetchMode] != \"false\") (\"mode=\" . \$fetchMod\ + e . \" \")] . \\\r\ + \n http-header-field=({ [ \$FetchUserAgentStr \$ScriptName ] }) as-va\ + lue);\r\ + \n :log warning (\"\\\$FetchSring = \" . \$FetchString);\r\ + \n :put [\$FetchString];\r\ + \n #:put [/tool/fetch \$fetchMode check-certificate=\$CheckCert url=(\$\ + fetchUrl) dst-path=(\$FileName) http-header-field=({ [ \$FetchUserAgentStr\ + \_\$ScriptName ] }) as-value];\r\ + \n } do={\r\ + \n :if ([ \$WaitForFile \$FileName 500ms ] = true) do={\r\ + \n \$RmFile \$FileName;\r\ + \n }\r\ + \n \$LogPrint debug \$0 (\"Failed downloading from \" . \$fetchUrl . \"\ + \_- \" . \$Err);\r\ + \n \$RmDir \$DirName;\r\ + \n :return false;\r\ + \n }\r\ + \n :if ([ \$WaitForFile \$FileName 5s ] = false) do={\r\ + \n \$LogPrint debug \$0 (\"The file downloaded from \" . \$fetchUrl . \ + \" did not show up.\");\r\ + \n :return false;\r\ + \n }\r\ + \n :local FileSize [ /file/get \$FileName size ];\r\ + \n :local Return \"\";\r\ + \n :local VarSize 0;\r\ + \n :while (\$VarSize != \$FileSize) do={\r\ + \n :set Return (\$Return . ([ /file/read offset=\$VarSize chunk-size=32\ + 768 file=\$FileName as-value ]->\"data\"));\r\ + \n :set FileSize [ /file/get \$FileName size ];\r\ + \n :set VarSize [ :len \$Return ];\r\ + \n :if (\$VarSize > \$FileSize) do={\r\ + \n :delay 100ms;\r\ + \n }\r\ + \n }\r\ + \n \$RmDir \$DirName;\r\ + \n :return \$Return;\r\ + \n}\r\ + \n\r\ + \n:set ScriptInstallUpdate do={ :onerror Err {\r\ + \n :local Scripts [ :toarray \$1 ];\r\ + \n :local NewComment [ :tostr \$2 ];\r\ + \n :global InitSetup;\r\ + \n\r\ + \n :global CommitId;\r\ + \n :global ScriptUpdatesCRLF;\r\ + \n :global GlobalConfVersion;\r\ + \n :global Identity;\r\ + \n :global CertificateAvailable;\r\ + \n :global CheckSumsVerify;\r\ + \n :global GlobalScriptsUrl;\r\ + \n :global SumsDirAndFileName;\r\ + \n :global GlobalScriptsUrlSuffix;\r\ + \n :global EitherOr;\r\ + \n :global FetchUserAgentStr;\r\ + \n :global Grep;\r\ + \n :global IfThenElse;\r\ + \n :global LogPrint;\r\ + \n :global ParseKeyValueStore;\r\ + \n :global RequiredRouterOS;\r\ + \n :global SendNotification2;\r\ + \n :global SymbolForNotification;\r\ + \n :global ValidateSyntax;\r\ + \n :global CommentsInScripts;\r\ + \n\r\ + \n :if ([ \$CertificateAvailable \"Root YE\" \"fetch\" ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Downloading certificate failed, trying wit\ + hout.\");\r\ + \n }\r\ + \n\r\ + \n :foreach Script in=\$Scripts do={\r\ + \n :if ([ :len [ /system/script/find where name=\$Script ] ] = 0) do={\ + \r\ + \n \$LogPrint info \$0 (\"Adding new script: \" . \$Script);\r\ + \n /system/script/add name=\$Script owner=\$Script source=\"#!rsc by \ + Vados\\n\" comment=\$NewComment;\r\ + \n }\r\ + \n }\r\ + \n\r\ + \n :local CommitIdBefore \$CommitId;\r\ + \n :local GlobalConfVersionBefore \$GlobalConfVersion;\r\ + \n :local ReloadGlobal false;\r\ + \n :local DeviceMode [ /system/device-mode/get ];\r\ + \n\r\ + \n :if (\$CheckSumsVerify = true) do={\r\ + \n :local CheckSums ({});\r\ + \n :do {\r\ + \n :local Url (\$GlobalScriptsUrl . \$SumsDirAndFileName . \$GlobalScr\ + iptsUrlSuffix);\r\ + \n \$LogPrint debug \$0 (\"Fetching checksums from url: \" . \$Url);\ + \r\ + \n :set CheckSums [ :deserialize from=json ([ /tool/fetch check-certi\ + ficate=yes-without-crl \\\r\ + \n http-header-field=({ [ \$FetchUserAgentStr \$0 ] }) \$Url output\ + =user as-value ]->\"data\") ];\r\ + \n } on-error={ \$LogPrint warning \$0 (\"Err = \" . \$Err); }\r\ + \n }\r\ + \n\r\ + \n :foreach Script in=[ /system/script/find where source~\"^#!rsc by Vado\ + s\" ] do={\r\ + \n :local ScriptVal [ /system/script/get \$Script ];\r\ + \n :local ScriptInfo [ \$ParseKeyValueStore (\$ScriptVal->\"comment\") \ + ];\r\ + \n :local SourceNew;\r\ + \n\r\ + \n :foreach Scheduler in=[ /system/scheduler/find where on-event~(\"\\\ + \\b\" . \$ScriptVal->\"name\" . \"\\\\b\") ] do={\r\ + \n :local SchedulerVal [ /system/scheduler/get \$Scheduler ];\r\ + \n :if (\$ScriptVal->\"policy\" != \$SchedulerVal->\"policy\") do={\r\ + \n \$LogPrint warning \$0 (\"Policies differ for script '\" . \$Scr\ + iptVal->\"name\" . \"' and its scheduler '\" . \$SchedulerVal->\"name\" . \ + \"'!\");\r\ + \n }\r\ + \n }\r\ + \n :do {\r\ + \n :if (\$ScriptInfo->\"ignore\" = true) do={\r\ + \n \$LogPrint debug \$0 (\"Ignoring script '\" . \$ScriptVal->\"nam\ + e\" . \"', as requested.\");\r\ + \n :error true;\r\ + \n }\r\ + \n :if (\$CheckSumsVerify = true) do={\r\ + \n :local CheckSum (\$CheckSums->(\$ScriptVal->\"name\"));\r\ + \n :if ([ :len (\$ScriptInfo->\"base-url\") ] = 0 && [ :len (\$Scri\ + ptInfo->\"url-suffix\") ] = 0 && \\\r\ + \n [ :convert transform=md5 to=hex [ :tolf (\$ScriptVal->\"sou\ + rce\") ] ] = \$CheckSum) do={\r\ + \n \$LogPrint debug \$0 (\"Checksum for script '\" . \$ScriptVal-\ + >\"name\" . \"' matches, ignoring.\");\r\ + \n :error true;\r\ + \n }\r\ + \n }\r\ + \n :if ([ :len (\$ScriptInfo->\"certificate\") ] > 0) do={\r\ + \n :if ([ \$CertificateAvailable (\$ScriptInfo->\"certificate\") \"\ + fetch\" ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Downloading certificate failed, tryi\ + ng without.\");\r\ + \n }\r\ + \n }\r\ + \n :onerror Err {\r\ + \n :local BaseUrl [ \$EitherOr (\$ScriptInfo->\"base-url\") \$Globa\ + lScriptsUrl ];\r\ + \n :local UrlSuffix [ \$EitherOr (\$ScriptInfo->\"url-suffix\") \$G\ + lobalScriptsUrlSuffix ];\r\ + \n :local Url (\$BaseUrl . \$ScriptVal->\"name\" . \".rsc\" . \$Url\ + Suffix);\r\ + \n \$LogPrint warning \$0 (\"Fetching script '\" . (\$ScriptVal->\"\ + name\") . \"' from url: \" . \$Url);\r\ + \n :local Result [ /tool/fetch check-certificate=yes-without-crl \\\ + \r\ + \n http-header-field=({ [ \$FetchUserAgentStr \$0 ] }) \$Url outp\ + ut=user as-value ];\r\ + \n :if (\$Result->\"status\" = \"finished\") do={\r\ + \n :set SourceNew [ :tolf (\$Result->\"data\") ];\r\ + \n } \r\ + \n } do={\r\ + \n \$LogPrint warning \$0 (\"Failed fetching script '\" . \$ScriptV\ + al->\"name\" . \"': \" . \$Err);\r\ + \n :if (\$Err != \"Fetch failed with status 404\") do={\r\ + \n :error false;\r\ + \n }\r\ + \n :if (\$ScriptVal->\"source\" = \"#!rsc by Vados\") do={\r\ + \n \$LogPrint warning \$0 (\"Removing dummy. Typo on installation\ + \?\");\r\ + \n /system/script/remove \$Script;\r\ + \n :error false;\r\ + \n }\r\ + \n :if (\$CheckSumsVerify = true) do={\r\ + \n :if ([ :len (\$ScriptInfo->\"base-url\") ] = 0 && [ :len (\$Sc\ + riptInfo->\"url-suffix\") ] = 0 && \\\r\ + \n [ :len \$CheckSum ] = 0) do={\r\ + \n \$LogPrint warning \$0 (\"Added the script manually\? Skip u\ + pdates with 'ignore=true' in comment.\");\r\ + \n }\r\ + \n }\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :if ([ :len \$SourceNew ] = 0) do={\r\ + \n \$LogPrint debug \$0 (\"No update for script '\" . (\$ScriptVal-\ + >\"name\") . \"'.\");\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :local SourceCRLF [ :tocrlf \$SourceNew ];\r\ + \n :if (\$InitSetup != true && ((\$ScriptVal->\"name\") != \"AM-Globa\ + lConfig\" || (\$ScriptVal->\"name\") != \"AM-GlobalFunc\")) do={\r\ + \n :if (\$SourceNew = (\$ScriptVal->\"source\") || \$SourceCRLF = (\ + \$ScriptVal->\"source\")) do={\r\ + \n \$LogPrint debug \$0 (\"Script '\" . (\$ScriptVal->\"name\") \ + . \"' source did not change. End of lines set to CRLF.\");\r\ + \n if (\$ScriptUpdatesCRLF = false) do={\r\ + \n :put [ :tolf \$SourceNew ];\r\ + \n \$LogPrint debug \$0 (\"Script '\" . (\$ScriptVal->\"name\"\ + ) . \"' source update end of lines to LF.\");\r\ + \n }\r\ + \n :error false;\r\ + \n }\r\ + \n }\r\ + \n\r\ + \n :if ([ :pick \$SourceNew 0 14 ] != \"#!rsc by Vados\") do={\r\ + \n \$LogPrint warning \$0 (\"Looks like new script '\" . \$ScriptVa\ + l->\"name\" . \"' is not valid (missing shebang = '\$shebang') Ignoring!\"\ + );\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :if (\$CommentsInScripts = true) do={\r\ + \n :local CommentLine [ \$Grep \$SourceNew (\"\\23 Script comment:\ + \_\") ];\r\ + \n :if ([ :len \$CommentLine ] = 0) do={\r\ + \n \$LogPrint debug \$0 (\"The search in new script '\" . (\$Scr\ + iptVal->\"name\") . \"' for comment in script body, is not found result Ig\ + noring!\");\r\ + \n :error false;\r\ + \n } else={\r\ + \n :if ([ :len (\$ScriptVal->\"comment\")] = 0 || [ :len (\$Scri\ + ptVal->\"comment\")] != [ :pick \$CommentLine ([ :find \$CommentLine \":\"\ + ] + 2) [ :len \$CommentLine] ]) do={\r\ + \n \$LogPrint debug \$0 (\"Exsiting comment for script '\" . (\ + \$ScriptVal->\"name\") . \"' is '\" . (\$ScriptVal->\"comment\") . \"'.\")\ + ;\r\ + \n :set (\$ScriptVal->\"comment\") [ :pick \$CommentLine ([ :f\ + ind \$CommentLine \":\"] + 2) [ :len \$CommentLine] ];\r\ + \n \$LogPrint debug \$0 (\"New comment (\" . (\$ScriptVal->\"c\ + omment\") . \") for script '\" . (\$ScriptVal->\"name\") . \"' has been ad\ + ded!\");\r\ + \n } else={\r\ + \n \$LogPrint debug \$0 (\"Comment for script '\" . (\$ScriptV\ + al->\"name\") . \"' did not change.\");\r\ + \n :error false;\r\ + \n }\r\ + \n } \r\ + \n }\r\ + \n\r\ + \n :local RequiredROS ([ \$ParseKeyValueStore [ \$Grep \$SourceNew (\ + \"\\23 requires RouterOS, \") ] ]->version);\r\ + \n :if ([ \$RequiredRouterOS \$0 [ \$EitherOr \$RequiredROS \"0.0\" ]\ + \_false ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"The script '\" . (\$ScriptVal->\"name\ + \") . \"' requires RouterOS \" . \\\r\ + \n \$RequiredROS . \", which is not met by your installation. I\ + gnoring!\");\r\ + \n :error false;\r\ + \n }\r\ + \n :local RequiredDM [ \$ParseKeyValueStore [ \$Grep \$SourceNew (\"\ + \\23 requires device-mode, \") ] ];\r\ + \n :local MissingDM ({});\r\ + \n :foreach Feature,Value in=\$RequiredDM do={\r\ + \n :if ([ :typeof (\$DeviceMode->\$Feature) ] = \"bool\" && (\$Devi\ + ceMode->\$Feature) = false) do={\r\ + \n :set MissingDM (\$MissingDM, \$Feature);\r\ + \n }\r\ + \n }\r\ + \n :if ([ :len \$MissingDM ] > 0) do={\r\ + \n \$LogPrint warning \$0 (\"The script '\" . (\$ScriptVal->\"name\ + \") . \"' requires disabled \" . \\\r\ + \n \"device-mode features (\" . [ :tostr \$MissingDM ] . \"). I\ + gnoring!\");\r\ + \n :error false;\r\ + \n }\r\ + \n\r\ + \n :if ([ \$ValidateSyntax \$SourceNew ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Syntax validation for script '\" . (\$\ + ScriptVal->\"name\") . \"' failed! Ignoring!\");\r\ + \n :error false;\r\ + \n }\r\ + \n \r\ + \n :log info (\"Updating script: \" . (\$ScriptVal->\"name\") . \" Sc\ + ript comment: \" . (\$ScriptVal->\"comment\"));\r\ + \n\r\ + \n /system/script/set owner=(\$ScriptVal->\"name\") comment=(\$Script\ + Val->\"comment\") \\\r\ + \n source=[ \$IfThenElse (\$ScriptUpdatesCRLF = true) \$SourceCRL\ + F \$SourceNew ] \$Script;\r\ + \n :if (\$ScriptVal->\"name\" = \"AM-GlobalConfig\" || \\\r\ + \n \$ScriptVal->\"name\" = \"AM-GlobalFunc\" || \\\r\ + \n \$ScriptVal->\"name\" ~ (\"^(AM-GlobalFunc\\\\.d|mod)/.\")) d\ + o={\r\ + \n :set ReloadGlobal true;\r\ + \n }\r\ + \n } on-error={ }\r\ + \n }\r\ + \n :if (\$ReloadGlobal = true) do={\r\ + \n \$LogPrint info \$0 (\"Reloading global configuration and functions.\ + \");\r\ + \n :onerror Err {\r\ + \n :global InitSetup (a);\r\ + \n /system/script {run AM-GlobalConfig; run AM-GlobalFunc;};\r\ + \n } do={\$LogPrint error \$0 (\"Reloading global configuration and fun\ + ctions failed! \" . \$Err)}\r\ + \n }\r\ + \n :if (\$GlobalConfVersionBefore > \$GlobalConfVersion) do={\r\ + \n \$LogPrint warning \$0 (\"The configuration version decreased from \ + \" . \\\r\ + \n \$GlobalConfVersionBefore . \" to \" . \$GlobalConfVersion . \\\r\ + \n \". Installed an older version\?\");\r\ + \n }\r\ + \n :if (\$GlobalConfVersionBefore < \$GlobalConfVersion) do={\r\ + \n :global GlobalConfChanges;\r\ + \n :global GlobalConfMigration;\r\ + \n :local ChangeLogCode;\r\ + \n :if ([ :len \$ChangeLogCode ] > 0) do={\r\ + \n :if ([ \$ValidateSyntax \$ChangeLogCode ] = true) do={\r\ + \n :onerror Err {\r\ + \n [ :parse \$ChangeLogCode ];\r\ + \n } do={\$LogPrint warning \$0 (\"The changelog failed to run: \" \ + . \$Err)}\r\ + \n } else={\$LogPrint warning \$0 (\"The changelog failed syntax vali\ + dation!\")}\r\ + \n }\r\ + \n :if ([ :len \$GlobalConfMigration ] > 0) do={\r\ + \n :for I from=(\$GlobalConfVersionBefore + 1) to=\$GlobalConfVersion\ + \_do={\r\ + \n :local Migration (\$GlobalConfMigration->[ :tostr \$I ]);\r\ + \n :do {\r\ + \n :if ([ :typeof \$Migration ] != \"str\") do={\r\ + \n \$LogPrint debug \$0 (\"Migration code for change \" . \$I .\ + \_\" is not available.\");\r\ + \n :error false;\r\ + \n }\r\ + \n :if ([ \$ValidateSyntax \$Migration ] = false) do={\r\ + \n \$LogPrint warning \$0 (\"Migration code for change \" . \$I\ + \_. \" failed syntax validation!\");\r\ + \n :error false}\r\ + \n \$LogPrint info \$0 (\"Applying migration for change \" . \$I \ + . \": \" . \$Migration);\r\ + \n :onerror Err {\r\ + \n [ :parse \$Migration ];\r\ + \n } do={\$LogPrint warning \$0 (\"Migration code for change \" .\ + \_\$I . \" failed to run: \" . \$Err)}\r\ + \n } on-error={ }\r\ + \n }\r\ + \n }\r\ + \n :local NotificationMessage (\"The configuration version on \" . \$Id\ + entity . \" increased \" . \\\r\ + \n \"to \" . \$GlobalConfVersion . \", current configuration may nee\ + d modification. \" . \\\r\ + \n \"Please review and update global-config-overlay, then re-run glo\ + bal-config.\");\r\ + \n \$LogPrint info \$0 (\$NotificationMessage);\r\ + \n :if ([ :len \$GlobalConfChanges ] > 0) do={\r\ + \n :set NotificationMessage (\$NotificationMessage . \"\\n\\nChanges:\ + \");\r\ + \n :for I from=(\$GlobalConfVersionBefore + 1) to=\$GlobalConfVersion\ + \_do={\r\ + \n :local Change (\$GlobalConfChanges->[ :tostr \$I ]);\r\ + \n :set NotificationMessage (\$NotificationMessage . \"\\n \" . \\\ + \r\ + \n [ \$SymbolForNotification \"pushpin\" \"*\" ] . \$Change);\r\ + \n \$LogPrint info \$0 (\"Change \" . \$I . \": \" . \$Change);\r\ + \n }\r\ + \n } else={:set NotificationMessage (\$NotificationMessage . \"\\n\\nNe\ + ws and changes are not available.\")}\r\ + \n\r\ + \n :set GlobalConfChanges;\r\ + \n :set GlobalConfMigration;\r\ + \n }\r\ + \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err}\r\ + \n}\r\ + \n\r\ + \n# Global Environment clear. Use: \"\$GlobalEnvRemove True;\".\r\ + \n:set GlobalEnvRemove do={\r\ + \n :local doRmEnv [ :tostr \$1 ];\r\ + \n :global GlobalScriptsUrl;\r\ + \n :local ScriptsUrl;\r\ + \n :global LogPrint;\r\ + \n :if (\$doRmEnv != \"True\") do={\r\ + \n \$LogPrint error \"GlobalEnvRemove\" (\"This script is needed \\\"T\ + rue\\\" for confirm to remove global environment variables!\");\r\ + \n :return [];\r\ + \n :error true; \r\ + \n } else={\r\ + \n :set ScriptsUrl \$GlobalScriptsUrl;\r\ + \n :delay 5;\r\ + \n :foreach var in=[/system/script/environment print as-value] do={/sy\ + stem/script/environment remove (\$var->\".id\")}\r\ + \n :delay 5;\r\ + \n :global GlobalScriptsUrl \$ScriptsUrl;\r\ + \n \$LogPrint warning \"GlobalEnvRemove\" (\"Done!\");\r\ + \n :return [];\r\ + \n :error false;\r\ + \n }\r\ + \n}\r\ + \n\r\ + \n# Add and fix global scheduler\r\ + \n:put \"Add or/and fix Global scheduler...\";\r\ + \n:local OnEvent \"/system/script { run AM-GlobalConfig; run AM-GlobalFunc\ + ; }\";\r\ + \n:local Comment \"Setup Global Environment for scripts\";\r\ + \n:if ([ :len [ /system/scheduler/find where name=\"AM-SetGlobalEnv\" ] ] \ + = 0) do={\r\ + \n /system/scheduler/add name=\"AM-SetGlobalEnv\" comment=\$Comment on-ev\ + ent=\$OnEvent start-time=startup;\r\ + \n}\r\ + \n:if ([ /system/scheduler/get \"AM-SetGlobalEnv\" comment ] != \$Comment)\ + \_do={\r\ + \n /system/scheduler/set \"AM-SetGlobalEnv\" comment=\$Comment;\r\ + \n}\r\ + \n:if ([ /system/scheduler/get \"AM-SetGlobalEnv\" on-event ] != \$OnEvent\ + ) do={\r\ + \n /system/scheduler/set \"AM-SetGlobalEnv\" on-event=\$OnEvent;\r\ + \n}\r\ + \n# Add Update Script scheduler\r\ + \n:put \"Add or/and fix Update Script scheduler\";\r\ + \n:set OnEvent \":global ScriptInstallUpdate; \\\$ScriptInstallUpdate;\";\ + \r\ + \n:set Comment \"Every Day Check For Update Scripts\";\r\ + \n:if ([ :len [ /system/scheduler/find where name=\"AM-ScriptInstallUpdate\ + \" ] ] = 0) do={\r\ + \n/system/scheduler/add name=\"AM-ScriptInstallUpdate\" comment=\$Comment \ + start-time=startup interval=1d on-event=\$OnEvent;\r\ + \n}\r\ + \n\r\ + \n#:local Resource [ /system/resource/get ];\r\ + \n#:log info (\$ScriptName . \" Loaded on \" . \$Resource->\"board-name\" \ + . \" with RouterOS \" . \$Resource->\"version\" . \" and Architecture \" .\ + \".\");\r\ + \n\r\ + \n:onerror Err {\r\ + \n :global GlobalConfReady;\r\ + \n :retry { :if (\$GlobalConfReady != true) do={ :error (\"Global configs\ + \_not ready.\"); }; } delay=100ms max=5;\r\ + \n\r\ + \n# signal we are ready\r\ + \n:set GlobalFuncReady true;\r\ + \n:set ExitOK true;\r\ + \n:log warning (\"This script \$ScriptName Loaded \" . \\\r\ + \n [ \$IfThenElse (\$CommitId != \"unknown\") ([ \$CommitBrief ] . \" \ + \") ] . \\\r\ + \n \"on \" . \$devBoardName . \"\\nRouterOS: \" . \$devCurVersion . \"\ + \\nArchitecture: \" . \$devCurArch . \"\\nIdentity: \" . \$Identity);\r\ + \n} do={:global ExitOnError; \$ExitOnError \$0 \$Err;}\r\ + \n\r\ + \n#} do={:global ExitError; \$ExitError \$ExitOK [ :jobname ] \$Err}\r\ + \n# log the successful load of the script, or an error if it failed\r\ + \n#:if ([\$GlobalFuncReady] = true && [\$GlobalConfReady] = true) do={\r\ + \n" +add dont-require-permissions=no name=fetchCustom owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="\ + \r\ + \n\r\ + \n#root.mnuc.backuper\r\ + \n:global GlobalScriptsUrl \"https://ros.vados.ru/\";\r\ + \n/tool/fetch mode=https url=(\$GlobalScriptsUrl . \".bak/mikro_bak_rsa@10\ + .30.30.10.pub\") dst-path=\"/mikro_bak_rsa@10.30.30.10.pub\";\r\ + \n#/usb1/mikro_bak_rsa.pub" +add dont-require-permissions=yes name=MkTmpfs owner=vados policy=\ + ftp,read,write,policy,test,sniff,sensitive source=\ + ":global MkDir;\r\ + \n\r\ + \n\$MkDir /usb1/tmpfs;" +add dont-require-permissions=no name=CreateContainer owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":\ + local contIF \"veth1\";\r\ + \n:local contIP \"10.10.10.10/24\";\r\ + \n:local contGW \"10.10.10.1\";\r\ + \n#/interface/veth/add name=\$contIF address=\$contIP gateway=\$contGW;\r\ + \n:local contBridgeIF \"Bridge-DOC\";\r\ + \n:local contBridgeIP \"10.10.10.1/24\";\r\ + \n/interface/bridge/add name=\$contBridgeIF;\r\ + \n/ip/address/add address=\$contBridgeIP interface=\$contBridgeIF;\r\ + \n/interface/bridge/port/add bridge=\$contBridgeIF interface=\$contIF;\r\ + \n/container/config/set ram-high=768M registry-url=https://registry-1.dock\ + er.io tmpdir=sata1/tmp\r\ + \n" +add dont-require-permissions=no name=carkeeperbot owner=vados policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="/\ + container/mounts/add list=carkeeper_configs/.profile src=sata1/carkeeper/c\ + onfigs/.profile dst=/root/.ashrc;\r\ + \n/container/mounts/add list=carkeeper_configs/php.ini src=sata1/carkeeper\ + /configs/php.ini dst=/etc/php82/php.ini;\r\ + \n#/container/mounts/add list=carkeeper_configs src=sata1/carkeeper/config\ + s dst=/configs;\r\ + \n/container/mounts/add list=carkeeper_app src=sata1/carkeeper/app dst=/ap\ + p;\r\ + \n/container/mounts/add list=carkeeper_scripts src=sata1/carkeeper/scripts\ + \_dst=/scripts;\r\ + \n/container/mounts/add list=carkeeper_configs/sshd_config src=sata1/carke\ + eper/configs/sshd_config dst=/etc/ssh/sshd_config;\r\ + \n\r\ + \n/container/mounts/add list=carkeeper_tmp src=sata1/carkeeper/tmp dst=/va\ + r/tmp;\r\ + \n/container/mounts/add list=carkeeper_sync src=sata1/carkeeper/sync dst=/\ + var/sync;\r\ + \n" +add comment="Enable or disable ip addresses based on bridge port state" \ + dont-require-permissions=no name=mod/AM-IPbridge owner=mod/AM-IPbridge \ + policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + source="#!rsc by Vados\r\ + \n# RouterOS script: mod/AM-IPbridge\r\ + \n# Script comment: Enable or disable ip addresses based on bridge port st\ + ate\r\ + \n# Copyright (c) 2005-2026 Vados \r\ + \n#\r\ + \n#\r\ + \n# requires RouterOS, version=7.19\r\ + \n# requires device-mode, fetch\r\ + \n#\r\ + \n:local ScriptName [ :jobname ];\r\ + \n\r\ + \n# Add this Script scheduler\r\ + \n:if ([ :len [ /system/scheduler/find where name=\$ScriptName ] ] = 0) do\ + ={\r\ + \n:log warning (\"SystemScheduler for script: \" . \$ScriptName . \" is NO\ + T SET! Fix It Now!\");\r\ + \n:local OnEvent \"/system/script/run \$ScriptName;\";\r\ + \n:local Comment \"Every Day Check For Fake Bridges\";\r\ + \n/system/scheduler/add name=\$ScriptName comment=\$Comment start-time=sta\ + rtup interval=1d on-event=\$OnEvent;\r\ + \n}\r\ + \n\r\ + \n:foreach Bridge in=[ /interface/bridge/find ] do={\r\ + \n :local BrName [ /interface/bridge/get \$Bridge name ];\r\ + \n :if ([ :len [ /interface/bridge/port/find where bridge=\$BrName ] ] > \ + 0) do={\r\ + \n :if ([ :len [ /interface/bridge/port/find where bridge=\$BrName and \ + inactive=no ] ] = 0) do={\r\ + \n /ip/address/disable [ find where !dynamic interface=\$BrName ];\r\ + \n } else={\r\ + \n /ip/address/enable [ find where !dynamic interface=\$BrName ];\r\ + \n }\r\ + \n }\r\ + \n}\r\ + \n" +/user group +add name=backup policy="telnet,ssh,ftp,read,write,policy,test,sniff,sensitive,\ + !local,!reboot,!winbox,!password,!web,!api,!romon,!rest-api" +/app settings +set auto-update=yes disk=sata1 lan-bridge=Bridge-LAN registry-mirrors="https:/\ + /reg.vados.ru:5000/:https://reg.vados.ru/,https://registry-1.docker.io" +/caps-man aaa +set called-format=ssid +/caps-man access-list +add action=reject allow-signal-out-of-range=10s disabled=no interface=all \ + signal-range=-120..-80 ssid-regexp="" +add action=accept allow-signal-out-of-range=10s disabled=no interface=all \ + signal-range=-79..120 ssid-regexp="" +/caps-man manager +# bad package path +set ca-certificate=CAPsMAN-CA-51B25E507D07 certificate=CAPsMAN-51B25E507D07 \ + enabled=yes package-path=/tmpfs/capsman-packages +/caps-man manager interface +set [ find default=yes ] forbid=yes +add disabled=no interface=Bridge-LAN +/caps-man provisioning +add action=create-dynamic-enabled hw-supported-modes=g,gn,b \ + master-configuration=2G name-format=prefix-identity name-prefix=2G +add action=create-dynamic-enabled hw-supported-modes=an,ac,a \ + master-configuration=5G name-format=prefix-identity name-prefix=5G +add action=create-dynamic-enabled disabled=yes hw-supported-modes=ac,an,a \ + master-configuration=2G name-format=prefix-identity name-prefix=5ghz-ac +add action=create-dynamic-enabled disabled=yes hw-supported-modes=an \ + master-configuration=5G name-format=prefix-identity name-prefix=5ghz-an +/certificate settings +set builtin-trust-store=fetch crl-download=yes crl-use=yes +/container config +set layer-dir=/sata1 registry-url=https://reg.vados.ru tmpdir=/ramstorage \ + username=amster-dev +/container envs +add key=ENV list=carkeeperbot_envs value=/root/.ashrc +add key=PATH list=carkeeperbot_envs value=\ + /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +add key=PORT list=carkeeperbot_envs value="\${SSH_PORT}" +add key=SSH_PORT list=carkeeperbot_envs value=8222 +/container mounts +add dst=/app list=carkeeper_app src=/sata1/carkeeper/app +add dst=/configs list=carkeeper_configs src=/sata1/carkeeper/configs +add dst=/root/.ashrc list=carkeeper_configs/.profile src=\ + /sata1/carkeeper/configs/.profile +add dst=/etc/php82/php.ini list=carkeeper_configs/php.ini src=\ + /sata1/carkeeper/configs/php.ini +add dst=/etc/ssh/sshd_config list=carkeeper_configs/sshd_config src=\ + /sata1/carkeeper/configs/sshd_config +add dst=/scripts list=carkeeper_scripts src=/sata1/carkeeper/scripts +add dst=/var/sync list=carkeeper_sync src=/sata1/carkeeper/sync +add dst=/var/tmp list=carkeeper_tmp src=/sata1/carkeeper/tmp +/interface bridge port +add bridge=Bridge-LAN interface=ether2 +add bridge=Bridge-DOC interface=veth1 +add bridge=Bridge-LAN interface=LAN +add bridge=Bridge-LAN interface=dynamic +/ipv6 settings +set disable-ipv6=yes disable-link-local-address=yes +/interface detect-internet +set detect-interface-list=LAN internet-interface-list=LAN lan-interface-list=\ + LAN wan-interface-list=LAN +/interface wifi capsman +set package-path=/tmpfs/capsman-packages upgrade-policy=none +/ip address +add address=10.30.30.10/24 interface=Bridge-LAN network=10.30.30.0 +add address=10.10.10.1/24 disabled=yes interface=Bridge-DOC network=\ + 10.10.10.0 +add address=172.18.20.5/30 disabled=yes interface=docker-xray-vless-veth \ + network=172.18.20.4 +/ip dhcp-server +add add-arp=yes address-pool=dhcp always-broadcast=yes bootp-support=none \ + dhcp-option-set=domain-search-set disabled=yes interface=Bridge-LAN \ + lease-script=lease-script lease-time=10m name=nucDHCP server-address=\ + 10.30.30.10 +/ip dns +set allow-remote-requests=yes doh-max-concurrent-queries=100 \ + doh-max-server-connections=20 servers=10.30.30.81 verify-doh-cert=yes +/ip firewall filter +add action=accept chain=input +add action=accept chain=output +add action=accept chain=forward comment="Comment of the rule" disabled=yes +/ip firewall mangle +# docker-xray-vless-veth not ready +add action=change-mss chain=forward new-mss=1360 out-interface=\ + docker-xray-vless-veth protocol=tcp tcp-flags=syn tcp-mss=1420-65535 +/ip firewall nat +# docker-xray-vless-veth not ready +add action=masquerade chain=srcnat out-interface=docker-xray-vless-veth +/ip firewall service-port +set ftp disabled=yes +set tftp disabled=yes +set sip disabled=yes +set pptp disabled=yes +set rtsp disabled=no +/ip route +add disabled=no dst-address=0.0.0.0/0 gateway=10.30.30.81 routing-table=main +/ip service +set ftp disabled=yes +set www disabled=yes +set ssh port=2222 +set www-ssl port=4443 +set api disabled=yes +set api-ssl disabled=yes +/ip service webserver +set acme-plain=no crl-plain=no graphs-plain=no graphs-secure=no index-plain=\ + no index-secure=no rest-plain=no rest-secure=no scep-plain=no \ + webfig-plain=no webfig-secure=no +/ip ssh +set forwarding-enabled=both password-authentication=no \ + publickey-authentication-options=verify-required strong-crypto=yes +/ip upnp +set allow-disable-external-interface=yes enabled=yes +/ipv6 firewall address-list +add address=2400:cb00::/32 list=CLOUDFLARE-IP-Address +add address=2606:4700::/32 list=CLOUDFLARE-IP-Address +add address=2803:f800::/32 list=CLOUDFLARE-IP-Address +add address=2405:b500::/32 list=CLOUDFLARE-IP-Address +add address=2405:8100::/32 list=CLOUDFLARE-IP-Address +add address=2a06:98c0::/29 list=CLOUDFLARE-IP-Address +add address=2c0f:f248::/32 list=CLOUDFLARE-IP-Address +/system clock +set time-zone-autodetect=no time-zone-name=Europe/Moscow +/system gps +set set-system-time=yes +/system identity +set name=MikroNUC +/system note +set show-at-login=no +/system ntp client +set enabled=yes +/system ntp server +set enabled=yes manycast=yes multicast=yes +/system ntp client servers +add address=10.30.30.81 +add address=0.ru.pool.ntp.org +add address=1.ru.pool.ntp.org +add address=2.ru.pool.ntp.org +add address=3.ru.pool.ntp.org +/system scheduler +add comment="Backup Every Week" interval=1w name=BackupEveryWeek on-event=\ + "/system/script { run BackupAndUpdate; }" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-date=2025-07-07 start-time=04:41:27 +add comment="Setup Global Environment for scripts" name=Amster-SetGlobalEnv \ + on-event=\ + "/system/script { run Amster-GlobalConfig; run Amster-GlobalFunc; }" \ + policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +add comment="Every Day Check For Update Scripts" interval=1d name=\ + Amster-GetInstallUpdate on-event=":global getInstUpd; \$getInstUpd;" \ + policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +add comment="Every Day Check For Update Scripts" interval=1d name=\ + ScriptInstallUpdate on-event=\ + ":global ScriptInstallUpdate; \$ScriptInstallUpdate;" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +add comment="Setup Global Environment for scripts" name=AM-SetGlobalEnv \ + on-event="/system/script { run AM-GlobalConfig; run AM-GlobalFunc; }" \ + policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +add comment="Every Day Check For Update Scripts" interval=1d name=\ + AM-ScriptInstallUpdate on-event=\ + ":global ScriptInstallUpdate; \$ScriptInstallUpdate;" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +add comment="Every Day Check For Fake Bridges" interval=1d name=\ + mod/AM-IPbridge on-event="/system/script/run mod/AM-IPbridge;" policy=\ + ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \ + start-time=startup +/tool e-mail +set certificate-verification=no from=MikroNUC port=587 \ + server=smtp.mail.me.com tls=starttls user=vadossio@icloud.com +/tool netwatch +add disabled=yes down-script=\ + ":local msg \"Host MikroYellow is DOWN\";\r\ + \n\$TGSendMessage \$msg;" host=10.30.30.86 http-codes="" interval=10s \ + test-script="" type=simple up-script=\ + ":global TGSendMessage;\r\ + \n\$TGSendMessage \"Host MikroYellow is UP\";" +/user aaa +set accounting=no diff --git a/MikroNUC/tmp/Config.rsc b/MikroNUC/tmp/Config.rsc deleted file mode 100644 index e69de29..0000000