global-functions: move daily psk secrets to global-config

This commit is contained in:
Christian Hesse 2018-10-09 14:12:38 +02:00
parent 7b4bef1a1e
commit 977a5d5f5e
2 changed files with 20 additions and 17 deletions

View file

@ -38,9 +38,23 @@
:global "gre-cert-prefix" "ikev2-"; :global "gre-cert-prefix" "ikev2-";
:global "gre-int-prefix" "gre-"; :global "gre-int-prefix" "gre-";
# Access-list entries matching this comment are updated with daily # Access-list entries matching this comment are updated
# pseudo-random PSK. # with daily pseudo-random PSK.
:global "daily-psk-match-comment" "Daily PSK"; :global "daily-psk-match-comment" "Daily PSK";
:global "daily-psk-secrets" {
{ "Abusive"; "Aggressive"; "Bored"; "Chemical"; "Cold";
"Cruel"; "Curved"; "Delightful"; "Discreet"; "Elite";
"Evasive"; "Faded"; "Flat"; "Future"; "Grandiose";
"Hanging"; "Humorous"; "Interesting"; "Magenta";
"Magnificent"; "Numerous"; "Optimal"; "Pathetic";
"Possessive"; "Remarkable"; "Rightful"; "Ruthless";
"Stale"; "Unusual"; "Useless"; "Various" };
{ "Adhesive"; "Amusing"; "Astonishing"; "Frantic";
"Kindhearted"; "Limping"; "Roasted"; "Robust";
"Staking"; "Thundering"; "Ultra"; "Unusual" };
{ "Belief"; "Button"; "Curtain"; "Edge"; "Jewel";
"String"; "Whistle" }
}
# Run different commands with multiple mode-button presses. # Run different commands with multiple mode-button presses.
:global "mode-button" { :global "mode-button" {

View file

@ -8,20 +8,7 @@
:global GeneratePSK do={ :global GeneratePSK do={
:local date $1; :local date $1;
# 0-30 for days of month :global "daily-psk-secrets";
:local secret1 { "Abusive"; "Aggressive"; "Bored"; "Chemical"; "Cold";
"Cruel"; "Curved"; "Delightful"; "Discreet"; "Elite"; "Evasive"; "Faded";
"Flat"; "Future"; "Grandiose"; "Hanging"; "Humorous"; "Interesting";
"Magenta"; "Magnificent"; "Numerous"; "Optimal"; "Pathetic"; "Possessive";
"Remarkable"; "Rightful"; "Ruthless"; "Stale"; "Unusual"; "Useless";
"Various" }
# 0-11 for month of year
:local secret2 { "Adhesive"; "Amusing"; "Astonishing"; "Frantic";
"Kindhearted"; "Limping"; "Roasted"; "Robust"; "Staking"; "Thundering";
"Ultra"; "Unusual" }
# 0-6 for days of week
:local secret3 { "Belief"; "Button"; "Curtain"; "Edge"; "Jewel"; "String";
"Whistle" }
:local months { :local months {
"jan"; "feb"; "mar"; "apr"; "may"; "jun"; "jan"; "feb"; "mar"; "apr"; "may"; "jun";
@ -52,7 +39,9 @@
:set sum ($sum + $month); :set sum ($sum + $month);
:set sum ($sum - (($sum / 7) * 7)); :set sum ($sum - (($sum / 7) * 7));
:local return ([ :pick $secret1 ($day - 1) ] . [ :pick $secret2 $month ] . [ :pick $secret3 $sum ]); :local return ([ :pick [ :pick $"daily-psk-secrets" 0 ] ($day - 1) ] . \
[ :pick [ :pick $"daily-psk-secrets" 1 ] $month ] . \
[ :pick [ :pick $"daily-psk-secrets" 2 ] $sum ]);
:return $return; :return $return;
} }