From 8be7c5d959951dfafaf3fcaebe860a64ee3d8f7f Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Sun, 28 Nov 2021 16:55:46 -0700 Subject: initail commit --- lisp/dns/dns.lisp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lisp/dns/dns.lisp (limited to 'lisp/dns/dns.lisp') diff --git a/lisp/dns/dns.lisp b/lisp/dns/dns.lisp new file mode 100644 index 0000000..f0dfeda --- /dev/null +++ b/lisp/dns/dns.lisp @@ -0,0 +1,53 @@ +;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +(declaim (optimize (speed 0) (safety 3) (debug 3))) + +(in-package #:dns-admin) + +(defclass dns () + ((label :initarg :label + :initform nil + :accessor label) + (backend-type :initarg :backend-type + :initform nil + :accessor backend-type)) + (:documentation "")) + +(defclass dns-infoblox (dns) + ((url :initarg :url + :initform nil + :accessor url) + (username :initarg :username + :initform nil + :accessor username) + (password :initarg :password + :initform nil + :accessor password)) + (:documentation "Used to provide an object-oriented interface to the +DNS options in the webapp config file.")) + +(defclass dns-nsupdate (dns) + ((hostname :initarg :hostname + :initform nil + :accessor hostname) + (forward-zone :initarg :forward-zone + :initform nil + :accessor forward-zone) + (reverse-zone :initarg :reverse-zone + :initform nil + :accessor reverse-zone) + (dnssec-key :initarg :dnssec-key + :initform nil + :accessor dnssec-key + :documentation "This is a filepath, not the actual contents of the key.")) + (:documentation "")) + +(defmethod initialize-instance :after ((dns dns) &key config) + (loop for slot in (map-slot-names dns) do + (setf (slot-value dns slot) (getf config (intern (symbol-name slot) :keyword))))) + +(defmacro with-dns ((dns-name) &body body) + (let ((package (package-name #.*package*))) + `(let* ((config (dns *webapp*)) + (dns-class (intern (string-upcase (concatenate 'string "dns-" (getf config :backend-type))) (find-package ,package))) + (,dns-name (make-instance dns-class :config config))) + ,@body))) -- cgit v1.3