X-Git-Url: https://git.distorted.org.uk/~mdw/zone/blobdiff_plain/729a79bd5d5a1594cbf4be09066df039e6374f02..717391672eedac95f8c2589d70026125589560ff:/zone.lisp diff --git a/zone.lisp b/zone.lisp index 726791f..f3ea23c 100644 --- a/zone.lisp +++ b/zone.lisp @@ -694,8 +694,8 @@ (with-gensyms (ipn) `(dolist (,ipn (net-parse-to-ipnets ',nets ,family)) (let ((*address-family* (ipnet-family ,ipn))) - (zone-create `((,(format nil "~A." (reverse-domain ,ipn - ,prefix-bits)) + (zone-create `((,(format nil "~A" (reverse-domain ,ipn + ,prefix-bits)) ,@',(loop for (k v) on args by #'cddr unless (member k '(:family :prefix-bits)) @@ -1084,6 +1084,9 @@ "Default pathname components for TLSA records.") (pushnew '*tlsa-pathname-defaults* *zone-config*) +(defparameter *tlsa-data-cache* (make-hash-table :test #'equal) + "Cache for TLSA association data; keys are (DATA SELECTOR MATCH).") + (defun convert-tlsa-selector-data (data selector match) "Convert certificate association DATA as required by SELECTOR and MATCH. @@ -1104,15 +1107,19 @@ (reverse-enum 'tlsa-match match))) bin)) (pathname - (with-temporary-files (context :base "tmpfile.tmp") - (let* ((file (or (find-if #'probe-file - (mapcar (lambda (template) - (merge-pathnames data template)) - *tlsa-pathname-defaults*)) - (error "Couldn't find TLSA file `~A'" data))) - (kind (identify-tlsa-selector-file file)) - (raw (raw-tlsa-assoc-data kind selector file context))) - (read-tlsa-match-data match raw context)))))) + (let ((key (list data selector match))) + (or (gethash key *tlsa-data-cache*) + (with-temporary-files (context :base (make-pathname :type "tmp")) + (let* ((file (or (find-if #'probe-file + (mapcar (lambda (template) + (merge-pathnames data + template)) + *tlsa-pathname-defaults*)) + (error "Couldn't find TLSA file `~A'" data))) + (kind (identify-tlsa-selector-file file)) + (raw (raw-tlsa-assoc-data kind selector file context)) + (binary (read-tlsa-match-data match raw context))) + (setf (gethash key *tlsa-data-cache*) binary)))))))) (defzoneparse :tlsa (name data rec) ":tlsa (((SERVICE|PORT &key :protocol)*) (USAGE SELECTOR MATCH DATA)*)"