dhcpc6 scripts: simplify (and improve correctness)

This commit is contained in:
Daniel Barlow 2024-02-16 18:47:12 +00:00
parent 28fe37d555
commit 4bcc3d5b28
4 changed files with 138 additions and 92 deletions

View file

@ -30,17 +30,11 @@
(each [_ a (ipairs (split " " addresses))]
(let [address (parse-address a)
suffix (base64url (string.pack "n" (hash a)))
;; keydir should be a function of all the address
;; attributes: we want it to change whenever anything changes
;; so that clients can see which addresses are new without
;; deep table comparisons
keydir (..
prefix
(-> address.address
(: :gsub "::$" "")
(: :gsub ":" "-"))
"_"
suffix)]
(: :gsub ":" "-")))]
(mktree (.. state-directory "/" keydir))
(each [k v (pairs address)]
(write-value (.. keydir "/" k) v)))))