Compare commits

..

3 commits

Author SHA1 Message Date
Christian Hesse
4b30806c07 doc/mod/ssh-keys-import: reverse old and new 2025-10-10 09:11:27 +02:00
Christian Hesse
da466a4680 global-functions: $CertificateAvailable: drop the compatibility workaround...
... and make it depend in RouterOS 7.19 and its builtin certificates.
2025-10-10 09:05:41 +02:00
Christian Hesse
3488c9b9af INITIAL-COMMANDS: drop the compatibility workaround...
... and make it depend in RouterOS 7.19 and its builtin certificates.
2025-10-10 09:05:41 +02:00
4 changed files with 13 additions and 79 deletions

View file

@ -22,12 +22,10 @@
:global EitherOr;
:global FetchHuge;
:global HumanReadableNum;
:global IfThenElse;
:global LogPrint;
:global LogPrintOnce;
:global LogPrintVerbose;
:global NetMask4;
:global NetMask6;
:global MIN;
:global ScriptLock;
:global WaitFullyConnected;
@ -116,13 +114,8 @@
:do {
:local Branch;
:if ($Address ~ "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}(/[0-9]{1,2})?\$") do={
:local Net $Address;
:local CIDR 32;
:local Slash [ :find $Address "/" ];
:if ([ :typeof $Slash ] = "num") do={
:set Net [ :toip [ :pick $Address 0 $Slash ] ]
:set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ];
:set Address [ :tostr (([ :toip $Net ] & [ $NetMask4 $CIDR ]) . [ $IfThenElse ($CIDR < 32) ("/" . $CIDR) ]) ];
:if ($Address ~ "/32\$") do={
:set Address [ :pick $Address 0 ([ :len $Address ] - 3) ];
}
:set Branch [ $GetBranch $Address ];
:set ($IPv4Addresses->$Branch->$Address) $TimeOut;
@ -130,13 +123,13 @@
}
:if ($Address ~ "^[0-9a-zA-Z]*:[0-9a-zA-Z:\\.]+(/[0-9]{1,3})?\$") do={
:local Net $Address;
:local CIDR 128;
:local Cidr 64;
:local Slash [ :find $Address "/" ];
:if ([ :typeof $Slash ] = "num") do={
:set Net [ :toip6 [ :pick $Address 0 $Slash ] ]
:set CIDR [ :pick $Address ($Slash + 1) [ :len $Address ] ];
:set Cidr [ $MIN [ :pick $Address ($Slash + 1) [ :len $Address ] ] 64 ];
}
:set Address (([ :toip6 $Net ] & [ $NetMask6 $CIDR ]) . "/" . $CIDR);
:set Address (([ :toip6 $Net ] & ffff:ffff:ffff:ffff::) . "/" . $Cidr);
:set Branch [ $GetBranch $Address ];
:set ($IPv6Addresses->$Branch->$Address) $TimeOut;
:error true;

View file

@ -61,8 +61,6 @@
:global MAX;
:global MIN;
:global MkDir;
:global NetMask4;
:global NetMask6;
:global NotificationFunctions;
:global ParseDate;
:global ParseKeyValueStore;
@ -467,7 +465,7 @@
:local Error [ :tostr $3 ];
:global IfThenElse;
:global LogPrint;
:global LogPrint;
:if ($ExitOK = "false") do={
$LogPrint error $Name ([ $IfThenElse ([ :pick $Name 0 1 ] = "\$") \
@ -992,43 +990,6 @@
:return true;
}
# return an IPv4 netmask for CIDR
:set NetMask4 do={
:local CIDR [ :tonum $1 ];
:return ((255.255.255.255 << (32 - $CIDR)) & 255.255.255.255);
}
# return an IPv6 netmask for CIDR
:set NetMask6 do={
:local FuncName $0;
:local CIDR [ :tostr $1 ];
:global IfThenElse;
:global MAX;
:global MIN;
:global NetMask6Cache;
:if ([ :typeof ($NetMask6Cache->$CIDR) ] = "ip6") do={
:return ($NetMask6Cache->$CIDR);
}
:if ([ :typeof $NetMask6Cache ] = "nothing") do={
:set NetMask6Cache ({});
}
:local Mask "";
:for I from=0 to=7 do={
:set Mask ($Mask . \
[ :convert from=num to=hex (0xffff - (0xffff >> [ :tonum [ $MIN [ $MAX ($CIDR - (16 * $I)) 0 ] 16 ] ])) ] . \
[ $IfThenElse ($I < 7) ":" ]);
}
:set Mask [ :toip6 $Mask ];
:set ($NetMask6Cache->$CIDR) $Mask;
:return $Mask;
}
# prepare NotificationFunctions array
:if ([ :typeof $NotificationFunctions ] != "array") do={
:set NotificationFunctions ({});

View file

@ -34,34 +34,20 @@
# calculate and return netmask, network, min host, max host and broadcast
:set IPCalcReturn do={
:local Input [ :tostr $1 ];
:global NetMask4;
:global NetMask6;
:local Address [ :pick $Input 0 [ :find $Input "/" ] ];
:local Address [ :toip [ :pick $Input 0 [ :find $Input "/" ] ] ];
:local Bits [ :tonum [ :pick $Input ([ :find $Input "/" ] + 1) [ :len $Input ] ] ];
:local Mask;
:local One;
:if ([ :typeof [ :toip $Address ] ] = "ip") do={
:set Address [ :toip $Address ];
:set Mask [ $NetMask4 $Bits ];
:set One 0.0.0.1;
} else={
:set Address [ :toip6 $Address ];
:set Mask [ $NetMask6 $Bits ];
:set One ::1;
}
:local Mask ((255.255.255.255 << (32 - $Bits)) & 255.255.255.255);
:local Return ({
:local Return {
"address"=$Address;
"netmask"=$Mask;
"networkaddress"=($Address & $Mask);
"networkbits"=$Bits;
"network"=(($Address & $Mask) . "/" . $Bits);
"hostmin"=(($Address & $Mask) | $One);
"hostmax"=(($Address | ~$Mask) ^ $One);
"hostmin"=(($Address & $Mask) | 0.0.0.1);
"hostmax"=(($Address | ~$Mask) ^ 0.0.0.1);
"broadcast"=($Address | ~$Mask);
});
}
:return $Return;
}

View file

@ -21,7 +21,6 @@
:global TelegramQueue;
:global TelegramMessageIDs;
:global CertificateAvailable;
:global IsFullyConnected;
:global LogPrint;
@ -30,11 +29,6 @@
:return false;
}
:if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" ] = false) do={
$LogPrint warning $0 ("Downloading required certificate failed.");
:return false;
}
:local AllDone true;
:local QueueLen [ :len $TelegramQueue ];