aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2023-04-24 21:54:50 +0200
committerGravatar Christian Hesse <mail@eworm.de>2023-04-24 22:26:26 +0200
commit83e57e6aabcd59b453f0e96695e7ceaf31c1ad6b (patch)
tree01f4c9ea7d3751814e808855434748b522b51ba9
parentfb9feea5950caec1c9bd7b9a3188cc312bf61956 (diff)
parent82b5ae174ac15bb6c2b7180980da12c1908de7df (diff)
Merge branch 'FormatLine' into next
-rw-r--r--backup-cloud.rsc7
-rw-r--r--backup-email.rsc7
-rw-r--r--backup-upload.rsc7
-rw-r--r--check-certificates.rsc27
-rw-r--r--check-health.rsc5
-rw-r--r--check-lte-firmware-upgrade.rsc7
-rw-r--r--collect-wireless-mac.capsman.rsc19
-rw-r--r--collect-wireless-mac.local.rsc19
-rw-r--r--collect-wireless-mac.template.rsc19
-rw-r--r--daily-psk.capsman.rsc7
-rw-r--r--daily-psk.local.rsc7
-rw-r--r--daily-psk.template.rsc7
-rw-r--r--global-functions.rsc58
-rw-r--r--mod/ipcalc.rsc13
14 files changed, 120 insertions, 89 deletions
diff --git a/backup-cloud.rsc b/backup-cloud.rsc
index b75d5cb..b6f6025 100644
--- a/backup-cloud.rsc
+++ b/backup-cloud.rsc
@@ -17,6 +17,7 @@
:global Identity;
:global DeviceInfo;
+:global FormatLine;
:global LogPrintExit2;
:global RandomDelay;
:global ScriptFromTerminal;
@@ -47,9 +48,9 @@ $WaitFullyConnected;
subject=([ $SymbolForNotification "floppy-disk,cloud" ] . "Cloud backup"); \
message=("Uploaded backup for " . $Identity . " to cloud.\n\n" . \
[ $DeviceInfo ] . "\n\n" . \
- "Name: " . $Cloud->"name" . "\n" . \
- "Size: " . $Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)\n" . \
- "Download key: " . $Cloud->"secret-download-key"); silent=true });
+ [ $FormatLine "Name" ($Cloud->"name") ] . "\n" . \
+ [ $FormatLine "Size" ($Cloud->"size" . " B (" . ($Cloud->"size" / 1024) . " KiB)") ] . "\n" . \
+ [ $FormatLine "Download key" ($Cloud->"secret-download-key") ]); silent=true });
} on-error={
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "floppy-disk,warning-sign" ] . "Cloud backup failed"); \
diff --git a/backup-email.rsc b/backup-email.rsc
index ba12494..e8837a0 100644
--- a/backup-email.rsc
+++ b/backup-email.rsc
@@ -22,6 +22,7 @@
:global CharacterReplace;
:global DeviceInfo;
+:global FormatLine;
:global LogPrintExit2;
:global MkDir;
:global RandomDelay;
@@ -91,9 +92,9 @@ $SendEMail2 ({ origin=$0; \
message=("See attached files for backup and config export for " . \
$Identity . ".\n\n" . \
[ $DeviceInfo ] . "\n\n" . \
- "Backup file: " . $BackupFile . "\n" . \
- "Export file: " . $ExportFile . "\n" . \
- "Config file: " . $ConfigFile); \
+ [ $FormatLine "Backup file" $BackupFile ] . "\n" . \
+ [ $FormatLine "Export file" $ExportFile ] . "\n" . \
+ [ $FormatLine "Config file" $ConfigFile ]); \
attach=$Attach; remove-attach=true });
# wait for the mail to be sent
diff --git a/backup-upload.rsc b/backup-upload.rsc
index 4c09d4a..9fb35d8 100644
--- a/backup-upload.rsc
+++ b/backup-upload.rsc
@@ -25,6 +25,7 @@
:global CharacterReplace;
:global DeviceInfo;
+:global FormatLine;
:global IfThenElse;
:global LogPrintExit2;
:global MkDir;
@@ -120,9 +121,9 @@ $SendNotification2 ({ origin=$0; \
([ $SymbolForNotification "floppy-disk,up-arrow" ] . "Backup & Config upload") ]; \
message=("Backup and config export upload for " . $Identity . ".\n\n" . \
[ $DeviceInfo ] . "\n\n" . \
- "Backup file: " . $BackupFile . "\n" . \
- "Export file: " . $ExportFile . "\n" . \
- "Config file: " . $ConfigFile); silent=true });
+ [ $FormatLine "Backup file" $BackupFile ] . "\n" . \
+ [ $FormatLine "Export file" $ExportFile ] . "\n" . \
+ [ $FormatLine "Config file" $ConfigFile ]); silent=true });
:if ($Failed = 1) do={
:error "An error occured!";
diff --git a/check-certificates.rsc b/check-certificates.rsc
index 2b76873..7e9fbe2 100644
--- a/check-certificates.rsc
+++ b/check-certificates.rsc
@@ -76,6 +76,7 @@
:local FormatInfo do={
:local CertVal $1;
+ :global FormatLine;
:global IfThenElse;
:global ParseKeyValueStore;
@@ -84,25 +85,15 @@
:return [ $CharacterReplace [ $CharacterReplace [ :tostr $1 ] "w" "w " ] "d" "d " ];
}
- :local FormatSANs do={
- :local SANs $1;
- :local Return "";
-
- :foreach SAN in=$SANs do={
- :set Return ($Return . "\n " . $SAN);
- }
- :return $Return;
- }
-
:return ( \
- "Name: " . ($CertVal->"name") . "\n" . \
- [ $IfThenElse ([ :len ($CertVal->"common-name") ] > 0) ("CommonName: " . ($CertVal->"common-name") . "\n") ] . \
- [ $IfThenElse ([ :len ($CertVal->"subject-alt-name") ] > 0) ("SubjectAltNames:" . [ $FormatSANs ($CertVal->"subject-alt-name") ] . "\n") ] . \
- "Private key: " . [ $IfThenElse (($CertVal->"private-key") = true) "available" "missing" ] . "\n" . \
- "Fingerprint: " . ($CertVal->"fingerprint") . "\n" . \
- "Issuer: " . ($CertVal->"ca") . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN") . "\n" . \
- "Validity: " . ($CertVal->"invalid-before") . " to " . ($CertVal->"invalid-after") . "\n" . \
- "Expires in: " . [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ]);
+ [ $FormatLine "Name" ($CertVal->"name") ] . "\n" . \
+ [ $IfThenElse ([ :len ($CertVal->"common-name") ] > 0) ([ $FormatLine "CommonName" ($CertVal->"common-name") ] . "\n") ] . \
+ [ $IfThenElse ([ :len ($CertVal->"subject-alt-name") ] > 0) ([ $FormatLine "SubjectAltNames" ($CertVal->"subject-alt-name") ] . "\n") ] . \
+ [ $FormatLine "Private key" [ $IfThenElse (($CertVal->"private-key") = true) "available" "missing" ] ] . "\n" . \
+ [ $FormatLine "Fingerprint" ($CertVal->"fingerprint") ] . "\n" . \
+ [ $FormatLine "Issuer" ($CertVal->"ca" . ([ $ParseKeyValueStore ($CertVal->"issuer") ]->"CN")) ] . "\n" . \
+ [ $FormatLine "Validity" ($CertVal->"invalid-before" . " to " . $CertVal->"invalid-after") ] . "\n" . \
+ [ $FormatLine "Expires in" [ $IfThenElse (($CertVal->"expired") = true) "expired" [ $FormatExpire ($CertVal->"expires-after") ] ] ]);
}
$WaitFullyConnected;
diff --git a/check-health.rsc b/check-health.rsc
index e208bac..af0d70b 100644
--- a/check-health.rsc
+++ b/check-health.rsc
@@ -21,6 +21,7 @@
:global CheckHealthVoltagePercent;
:global Identity;
+:global FormatLine;
:global IfThenElse;
:global LogPrintExit2;
:global ScriptLock;
@@ -93,8 +94,8 @@ $ScriptLock $0;
subject=([ $SymbolForNotification ("high-voltage-sign,chart-" . [ $IfThenElse ($NumLast < \
$NumCurr) "in" "de" ] . "creasing") ] . "Health warning: " . $Name); \
message=("The " . $Name . " on " . $Identity . " jumped more than " . $CheckHealthVoltagePercent . "%.\n\n" . \
- "old value: " . ($CheckHealthLast->$Name) . " V\n" . \
- "new value: " . $Value . " V") });
+ [ $FormatLine "old value" ($CheckHealthLast->$Name . " V") ] . "\n" . \
+ [ $FormatLine "new value" ($Value . " V") ]) });
} else={
:if ($NumCurr <= $CheckHealthVoltageLow && $NumLast > $CheckHealthVoltageLow) do={
$SendNotification2 ({ origin=$0; \
diff --git a/check-lte-firmware-upgrade.rsc b/check-lte-firmware-upgrade.rsc
index 02e864b..81bdf9b 100644
--- a/check-lte-firmware-upgrade.rsc
+++ b/check-lte-firmware-upgrade.rsc
@@ -23,6 +23,7 @@
:global SentLteFirmwareUpgradeNotification;
:global CharacterReplace;
+ :global FormatLine;
:global LogPrintExit2;
:global ScriptFromTerminal;
:global SendNotification2;
@@ -71,9 +72,9 @@
subject=([ $SymbolForNotification "sparkles" ] . "LTE firmware upgrade"); \
message=("A new firmware version " . ($Firmware->"latest") . " is available for " . \
"LTE interface " . $IntName . " on " . $Identity . ".\n\n" . \
- "Interface: " . [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] . "\n" . \
- "Installed: " . ($Firmware->"installed") . "\n" . \
- "Available: " . ($Firmware->"latest")); silent=true });
+ [ $FormatLine "Interface" [ $CharacterReplace ($Info->"manufacturer" . " " . $Info->"model") ("\"") "" ] ] . "\n" . \
+ [ $FormatLine "Installed" ($Firmware->"installed") ] . "\n" . \
+ [ $FormatLine "Available" ($Firmware->"latest") ]); silent=true });
:set ($SentLteFirmwareUpgradeNotification->$IntName) ($Firmware->"latest");
}
diff --git a/collect-wireless-mac.capsman.rsc b/collect-wireless-mac.capsman.rsc
index e814fa9..094ffc0 100644
--- a/collect-wireless-mac.capsman.rsc
+++ b/collect-wireless-mac.capsman.rsc
@@ -17,6 +17,7 @@
:global Identity;
:global EitherOr;
+:global FormatLine;
:global GetMacVendor;
:global LogPrintExit2;
:global ScriptLock;
@@ -69,15 +70,15 @@ $ScriptLock $0 false 10;
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
- "Controller: " . $Identity . "\n" . \
- "Interface: " . $RegVal->"interface" . "\n" . \
- "SSID: " . $RegVal->"ssid" . "\n" . \
- "MAC: " . $RegVal->"mac-address" . "\n" . \
- "Vendor: " . $Vendor . "\n" . \
- "Hostname: " . $HostName . "\n" . \
- "Address: " . $Address . "\n" . \
- "DNS name: " . $DnsName . "\n" . \
- "Date: " . $DateTime) });
+ [ $FormatLine "Controller" $Identity ] . "\n" . \
+ [ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \
+ [ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \
+ [ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \
+ [ $FormatLine "Vendor" $Vendor ] . "\n" . \
+ [ $FormatLine "Hostname" $HostName ] . "\n" . \
+ [ $FormatLine "Address" $Address ] . "\n" . \
+ [ $FormatLine "DNS name" $DnsName ] . "\n" . \
+ [ $FormatLine "Date" $DateTime ]) });
}
} else={
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
diff --git a/collect-wireless-mac.local.rsc b/collect-wireless-mac.local.rsc
index ee07f54..23eb9fa 100644
--- a/collect-wireless-mac.local.rsc
+++ b/collect-wireless-mac.local.rsc
@@ -17,6 +17,7 @@
:global Identity;
:global EitherOr;
+:global FormatLine;
:global GetMacVendor;
:global LogPrintExit2;
:global ScriptLock;
@@ -70,15 +71,15 @@ $ScriptLock $0 false 10;
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
- "Controller: " . $Identity . "\n" . \
- "Interface: " . $RegVal->"interface" . "\n" . \
- "SSID: " . $RegVal->"ssid" . "\n" . \
- "MAC: " . $RegVal->"mac-address" . "\n" . \
- "Vendor: " . $Vendor . "\n" . \
- "Hostname: " . $HostName . "\n" . \
- "Address: " . $Address . "\n" . \
- "DNS name: " . $DnsName . "\n" . \
- "Date: " . $DateTime) });
+ [ $FormatLine "Controller" $Identity ] . "\n" . \
+ [ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \
+ [ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \
+ [ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \
+ [ $FormatLine "Vendor" $Vendor ] . "\n" . \
+ [ $FormatLine "Hostname" $HostName ] . "\n" . \
+ [ $FormatLine "Address" $Address ] . "\n" . \
+ [ $FormatLine "DNS name" $DnsName ] . "\n" . \
+ [ $FormatLine "Date" $DateTime ]) });
}
} else={
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
diff --git a/collect-wireless-mac.template.rsc b/collect-wireless-mac.template.rsc
index c315385..a8983d9 100644
--- a/collect-wireless-mac.template.rsc
+++ b/collect-wireless-mac.template.rsc
@@ -18,6 +18,7 @@
:global Identity;
:global EitherOr;
+:global FormatLine;
:global GetMacVendor;
:global LogPrintExit2;
:global ScriptLock;
@@ -71,15 +72,15 @@ $ScriptLock $0 false 10;
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "mobile-phone" ] . $RegVal->"mac-address" . " connected to " . $RegVal->"ssid"); \
message=("A device with unknown MAC address connected to " . $RegVal->"ssid" . " on " . $Identity . ".\n\n" . \
- "Controller: " . $Identity . "\n" . \
- "Interface: " . $RegVal->"interface" . "\n" . \
- "SSID: " . $RegVal->"ssid" . "\n" . \
- "MAC: " . $RegVal->"mac-address" . "\n" . \
- "Vendor: " . $Vendor . "\n" . \
- "Hostname: " . $HostName . "\n" . \
- "Address: " . $Address . "\n" . \
- "DNS name: " . $DnsName . "\n" . \
- "Date: " . $DateTime) });
+ [ $FormatLine "Controller" $Identity ] . "\n" . \
+ [ $FormatLine "Interface" ($RegVal->"interface") ] . "\n" . \
+ [ $FormatLine "SSID" ($RegVal->"ssid") ] . "\n" . \
+ [ $FormatLine "MAC" ($RegVal->"mac-address") ] . "\n" . \
+ [ $FormatLine "Vendor" $Vendor ] . "\n" . \
+ [ $FormatLine "Hostname" $HostName ] . "\n" . \
+ [ $FormatLine "Address" $Address ] . "\n" . \
+ [ $FormatLine "DNS name" $DnsName ] . "\n" . \
+ [ $FormatLine "Date" $DateTime ]) });
}
} else={
$LogPrintExit2 debug $0 ("No mac address available... Ignoring.") false;
diff --git a/daily-psk.capsman.rsc b/daily-psk.capsman.rsc
index 17a09e1..e589991 100644
--- a/daily-psk.capsman.rsc
+++ b/daily-psk.capsman.rsc
@@ -17,6 +17,7 @@
:global DailyPskQrCodeUrl;
:global Identity;
+:global FormatLine;
:global LogPrintExit2;
:global SendNotification2;
:global SymbolForNotification;
@@ -86,9 +87,9 @@ $WaitFullyConnected;
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
- "SSID: " . $Ssid . "\n" . \
- "PSK: " . $NewPsk . "\n" . \
- "Date: " . $Date . "\n\n" . \
+ [ $FormatLine "SSID" $Ssid ] . "\n" . \
+ [ $FormatLine "PSK" $NewPsk ] . "\n" . \
+ [ $FormatLine "Date" $Date ] . "\n\n" . \
"A client device specific rule must not exist!"); link=$Link });
}
}
diff --git a/daily-psk.local.rsc b/daily-psk.local.rsc
index 17a60f7..df17173 100644
--- a/daily-psk.local.rsc
+++ b/daily-psk.local.rsc
@@ -17,6 +17,7 @@
:global DailyPskQrCodeUrl;
:global Identity;
+:global FormatLine;
:global LogPrintExit2;
:global SendNotification2;
:global SymbolForNotification;
@@ -85,9 +86,9 @@ $WaitFullyConnected;
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
- "SSID: " . $Ssid . "\n" . \
- "PSK: " . $NewPsk . "\n" . \
- "Date: " . $Date . "\n\n" . \
+ [ $FormatLine "SSID" $Ssid ] . "\n" . \
+ [ $FormatLine "PSK" $NewPsk ] . "\n" . \
+ [ $FormatLine "Date" $Date ] . "\n\n" . \
"A client device specific rule must not exist!"); link=$Link });
}
}
diff --git a/daily-psk.template.rsc b/daily-psk.template.rsc
index 7e41a1f..5f30ce3 100644
--- a/daily-psk.template.rsc
+++ b/daily-psk.template.rsc
@@ -18,6 +18,7 @@
:global DailyPskQrCodeUrl;
:global Identity;
+:global FormatLine;
:global LogPrintExit2;
:global SendNotification2;
:global SymbolForNotification;
@@ -93,9 +94,9 @@ $WaitFullyConnected;
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "calendar" ] . "daily PSK " . $Ssid); \
message=("This is the daily PSK on " . $Identity . ":\n\n" . \
- "SSID: " . $Ssid . "\n" . \
- "PSK: " . $NewPsk . "\n" . \
- "Date: " . $Date . "\n\n" . \
+ [ $FormatLine "SSID" $Ssid ] . "\n" . \
+ [ $FormatLine "PSK" $NewPsk ] . "\n" . \
+ [ $FormatLine "Date" $Date ] . "\n\n" . \
"A client device specific rule must not exist!"); link=$Link });
}
}
diff --git a/global-functions.rsc b/global-functions.rsc
index e682edc..45fda9f 100644
--- a/global-functions.rsc
+++ b/global-functions.rsc
@@ -29,6 +29,7 @@
:global DownloadPackage;
:global EitherOr;
:global EscapeForRegEx;
+:global FormatLine;
:global GetMacVendor;
:global GetRandom20CharAlNum;
:global GetRandom20CharHex;
@@ -194,6 +195,7 @@
:global Identity;
:global IfThenElse;
+ :global FormatLine;
:local Resource [ /system/resource/get ];
:local RouterBoard;
@@ -204,27 +206,27 @@
:local Update [ /system/package/update/get ];
:return ( \
- "Hostname: " . $Identity . \
- "\nBoard name: " . $Resource->"board-name" . \
- "\nArchitecture: " . $Resource->"architecture-name" . \
+ [ $FormatLine "Hostname" $Identity ] . "\n" . \
+ [ $FormatLine "Board name" ($Resource->"board-name") ] . "\n" . \
+ [ $FormatLine "Architecture" ($Resource->"architecture-name") ] . "\n" . \
[ $IfThenElse ($RouterBoard->"routerboard" = true) \
- ("\nModel: " . $RouterBoard->"model" . \
- [ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \
- (" " . $RouterBoard->"revision") ] . \
- "\nSerial number: " . $RouterBoard->"serial-number") ] . \
+ ([ $FormatLine "Model" ($RouterBoard->"model") ] . \
+ [ $IfThenElse ([ :len ($RouterBoard->"revision") ] > 0) \
+ (" " . $RouterBoard->"revision") ] . "\n" . \
+ [ $FormatLine "Serial number" ($RouterBoard->"serial-number") ] . "\n") ] . \
[ $IfThenElse ([ :len ($License->"level") ] > 0) \
- ("\nLicense: " . $License->"level") ] . \
- "\nRouterOS:" . \
- "\n Channel: " . $Update->"channel" . \
- "\n Installed: " . $Update->"installed-version" . \
+ ([ $FormatLine "License" ($License->"level") ] . "\n") ] . \
+ "RouterOS:\n" . \
+ [ $FormatLine " Channel" ($Update->"channel") ] . "\n" . \
+ [ $FormatLine " Installed" ($Update->"installed-version") ] . "\n" . \
[ $IfThenElse ([ :typeof ($Update->"latest-version") ] != "nothing" && \
$Update->"installed-version" != $Update->"latest-version") \
- ("\n Available: " . $Update->"latest-version") ] . \
+ ([ $FormatLine " Available" ($Update->"latest-version") ] . "\n") ] . \
[ $IfThenElse ($RouterBoard->"routerboard" = true && \
$RouterBoard->"current-firmware" != $RouterBoard->"upgrade-firmware") \
- ("\n Firmware: " . $RouterBoard->"current-firmware") ] . \
- "\nRouterOS-Scripts:" . \
- "\n Version: " . $ExpectedConfigVersion);
+ ([ $FormatLine " Firmware" ($RouterBoard->"current-firmware") ] . "\n") ] . \
+ "RouterOS-Scripts:\n" . \
+ [ $FormatLine " Version" $ExpectedConfigVersion ]);
}
# convert line endings, DOS -> UNIX
@@ -329,6 +331,32 @@
:return $Return;
}
+# format a line for output
+:set FormatLine do={
+ :local Key [ :tostr $1 ];
+ :local Values [ :toarray $2 ];
+ :local Indent [ :tonum $3 ];
+ :local Spaces " ";
+ :local Return "";
+
+ :global EitherOr;
+ :global FormatLine;
+
+ :set Indent [ $EitherOr $Indent 16 ];
+
+ :if ([ :len $Key ] > 0) do={ :set Return ($Key . ":"); }
+ :if ([ :len $Key ] > ($Indent - 2)) do={
+ :set Return ($Return . "\n" . [ :pick $Spaces 0 $Indent ] . ($Values->0));
+ } else={
+ :set Return ($Return . [ :pick $Spaces 0 ($Indent - [ :len $Return ]) ] . ($Values->0));
+ }
+ :foreach Value in=[ :pick $Values 1 [ :len $Values ] ] do={
+ :set Return ($Return . "\n" . [ $FormatLine "" ({$Value}) $Indent ]);
+ }
+
+ :return $Return;
+}
+
# get MAC vendor
:set GetMacVendor do={
:local Mac [ :tostr $1 ];
diff --git a/mod/ipcalc.rsc b/mod/ipcalc.rsc
index ee78378..eaa5c97 100644
--- a/mod/ipcalc.rsc
+++ b/mod/ipcalc.rsc
@@ -13,18 +13,19 @@
:set IPCalc do={
:local Input [ :tostr $1 ];
+ :global FormatLine;
:global IPCalcReturn;
:global PrettyPrint;
:local Values [ $IPCalcReturn $1 ];
$PrettyPrint ( \
- "Address: " . $Values->"address" . "\n" . \
- "Netmask: " . $Values->"netmask" . "\n" . \
- "Network: " . $Values->"network" . "\n" . \
- "HostMin: " . $Values->"hostmin" . "\n" . \
- "HostMax: " . $Values->"hostmax" . "\n" . \
- "Broadcast: " . $Values->"broadcast");
+ [ $FormatLine "Address" ($Values->"address") ] . "\n" . \
+ [ $FormatLine "Netmask" ($Values->"netmask") ] . "\n" . \
+ [ $FormatLine "Network" ($Values->"network") ] . "\n" . \
+ [ $FormatLine "HostMin" ($Values->"hostmin") ] . "\n" . \
+ [ $FormatLine "HostMax" ($Values->"hostmax") ] . "\n" . \
+ [ $FormatLine "Broadcast" ($Values->"broadcast") ]);
}
# calculate and return netmask, network, min host, max host and broadcast