summaryrefslogtreecommitdiff
path: root/lisp/dns/dns.lisp
diff options
context:
space:
mode:
authorckonstanski <carlos.konstanski@olo.com>2021-11-28 16:55:46 -0700
committerckonstanski <carlos.konstanski@olo.com>2021-11-28 16:55:46 -0700
commit8be7c5d959951dfafaf3fcaebe860a64ee3d8f7f (patch)
tree57e0dc941d54685629630528ae34d892e5138102 /lisp/dns/dns.lisp
initail commit
Diffstat (limited to 'lisp/dns/dns.lisp')
-rw-r--r--lisp/dns/dns.lisp53
1 files changed, 53 insertions, 0 deletions
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)))