aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/ipcalc.rsc26
-rw-r--r--mod/notification-email.rsc7
-rw-r--r--mod/notification-telegram.rsc6
-rw-r--r--mod/ssh-keys-import.rsc6
4 files changed, 35 insertions, 10 deletions
diff --git a/mod/ipcalc.rsc b/mod/ipcalc.rsc
index eacff6d..d65d472 100644
--- a/mod/ipcalc.rsc
+++ b/mod/ipcalc.rsc
@@ -34,20 +34,34 @@
# calculate and return netmask, network, min host, max host and broadcast
:set IPCalcReturn do={
:local Input [ :tostr $1 ];
- :local Address [ :toip [ :pick $Input 0 [ :find $Input "/" ] ] ];
+
+ :global NetMask4;
+ :global NetMask6;
+
+ :local Address [ :pick $Input 0 [ :find $Input "/" ] ];
:local Bits [ :tonum [ :pick $Input ([ :find $Input "/" ] + 1) [ :len $Input ] ] ];
- :local Mask ((255.255.255.255 << (32 - $Bits)) & 255.255.255.255);
+ :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 Return {
+ :local Return ({
"address"=$Address;
"netmask"=$Mask;
"networkaddress"=($Address & $Mask);
"networkbits"=$Bits;
"network"=(($Address & $Mask) . "/" . $Bits);
- "hostmin"=(($Address & $Mask) | 0.0.0.1);
- "hostmax"=(($Address | ~$Mask) ^ 0.0.0.1);
+ "hostmin"=(($Address & $Mask) | $One);
+ "hostmax"=(($Address | ~$Mask) ^ $One);
"broadcast"=($Address | ~$Mask);
- }
+ });
:return $Return;
}
diff --git a/mod/notification-email.rsc b/mod/notification-email.rsc
index ad9762a..7c3a6ff 100644
--- a/mod/notification-email.rsc
+++ b/mod/notification-email.rsc
@@ -101,8 +101,11 @@
$LogPrint warning $0 ("File '" . $File . "' does not exist, can not attach.");
}
}
- /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") cc=($Message->"cc") \
- subject=($Message->"subject") body=($Message->"body") file=$Attach;
+ :do {
+ /tool/e-mail/send from=[ $EMailGenerateFrom ] to=($Message->"to") \
+ cc=($Message->"cc") subject=($Message->"subject") \
+ body=($Message->"body") file=$Attach;
+ } on-error={ }
:local Wait true;
:do {
:delay 1s;
diff --git a/mod/notification-telegram.rsc b/mod/notification-telegram.rsc
index 2eb90e1..ff9b4da 100644
--- a/mod/notification-telegram.rsc
+++ b/mod/notification-telegram.rsc
@@ -21,6 +21,7 @@
:global TelegramQueue;
:global TelegramMessageIDs;
+ :global CertificateAvailable;
:global IsFullyConnected;
:global LogPrint;
@@ -29,6 +30,11 @@
: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 ];
diff --git a/mod/ssh-keys-import.rsc b/mod/ssh-keys-import.rsc
index 7bdc95d..8bea64e 100644
--- a/mod/ssh-keys-import.rsc
+++ b/mod/ssh-keys-import.rsc
@@ -40,7 +40,9 @@
:local FingerPrintMD5 [ :convert from=base64 transform=md5 to=hex ($KeyVal->1) ];
- :if ([ :len [ /user/ssh-keys/find where user=$User key-owner~("\\bmd5=" . $FingerPrintMD5 . "\\b") ] ] > 0) do={
+ :local RegEx ("\\bmd5=" . $FingerPrintMD5 . "\\b");
+ :if ([ :len [ /user/ssh-keys/find where user=$User \
+ (key-owner~$RegEx or info~$RegEx) ] ] > 0) do={
$LogPrint warning $0 ("The ssh public key (MD5:" . $FingerPrintMD5 . \
") is already available for user '" . $User . "'.");
:return false;
@@ -85,7 +87,7 @@
:return false;
}
- :if ([ $FileExists $FileName ] = true) do={
+ :if ([ $FileExists $FileName ] = false) do={
$LogPrint warning $0 ("File '" . $FileName . "' does not exist.");
:return false;
}