diff --git a/pkgs/odhcp-script/expected b/pkgs/odhcp-script/expected index 1acd0d9..4bf9a66 100644 --- a/pkgs/odhcp-script/expected +++ b/pkgs/odhcp-script/expected @@ -1,20 +1,20 @@ -./address/2001-8b0-1111-1111-0-ffff-1234-5678/address:2001:8b0:1111:1111:0:ffff:1234:5678 -./address/2001-8b0-1111-1111-0-ffff-1234-5678/len:128 -./address/2001-8b0-1111-1111-0-ffff-1234-5678/preferred:3600 -./address/2001-8b0-1111-1111-0-ffff-1234-5678/valid:7200 +./address/2001-8b0-1111-1111-0-ffff-1234-5678_BVG8Gro50UM/address:2001:8b0:1111:1111:0:ffff:1234:5678 +./address/2001-8b0-1111-1111-0-ffff-1234-5678_BVG8Gro50UM/len:128 +./address/2001-8b0-1111-1111-0-ffff-1234-5678_BVG8Gro50UM/preferred:3600 +./address/2001-8b0-1111-1111-0-ffff-1234-5678_BVG8Gro50UM/valid:7200 ./addresses:2001:8b0:1111:1111:0:ffff:1234:5678/128,3600,7200 ./ifname:ppp0 ./option_1:000300018cfdf02420eb ./option_2:000300010df0feca0df0 ./passthru:00170020200108b0000000000000000000002020200108b0000000000000000000002021 -./prefix/2001-8b0-de3a-22/address:2001:8b0:de3a:22:: -./prefix/2001-8b0-de3a-22/len:64 -./prefix/2001-8b0-de3a-22/preferred:7200 -./prefix/2001-8b0-de3a-22/valid:7200 -./prefix/2001-8b0-de3a-abcd/address:2001:8b0:de3a:abcd:: -./prefix/2001-8b0-de3a-abcd/len:64 -./prefix/2001-8b0-de3a-abcd/preferred:7200 -./prefix/2001-8b0-de3a-abcd/valid:7200 +./prefix/2001-8b0-de3a-22_hiaEztRS00M/address:2001:8b0:de3a:22:: +./prefix/2001-8b0-de3a-22_hiaEztRS00M/len:64 +./prefix/2001-8b0-de3a-22_hiaEztRS00M/preferred:7200 +./prefix/2001-8b0-de3a-22_hiaEztRS00M/valid:7200 +./prefix/2001-8b0-de3a-abcd_HmTdEWrIMEM/address:2001:8b0:de3a:abcd:: +./prefix/2001-8b0-de3a-abcd_HmTdEWrIMEM/len:64 +./prefix/2001-8b0-de3a-abcd_HmTdEWrIMEM/preferred:7200 +./prefix/2001-8b0-de3a-abcd_HmTdEWrIMEM/valid:7200 ./prefixes:2001:8b0:de3a:abcd::/64,7200,7200 2001:8b0:de3a:22::/64,7200,7200 ./ra_hoplimit:64 ./ra_mtu:0 diff --git a/pkgs/odhcp-script/odhcp6-script.fnl b/pkgs/odhcp-script/odhcp6-script.fnl index 2d4c61e..86ca0fc 100644 --- a/pkgs/odhcp-script/odhcp6-script.fnl +++ b/pkgs/odhcp-script/odhcp6-script.fnl @@ -1,4 +1,4 @@ -(local { : split : merge } (require :anoia)) +(local { : split : merge : hash : base64url } (require :anoia)) (local { : view } (require :fennel)) (local { : mktree : rmtree } (require :anoia.fs)) @@ -26,9 +26,18 @@ (fn write-addresses [prefix addresses] (each [_ a (ipairs (split " " addresses))] (let [address (parse-address a) - keydir (.. prefix (-> address.address - (: :gsub "::$" "") - (: :gsub ":" "-")))] + 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)] (mktree (.. state-directory "/" keydir)) (each [k v (pairs address)] (write-value (.. keydir "/" k) v)))))