From e50c362244be69c12a6d4f320c6ca00475d2de34 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 22 Jan 2020 18:04:26 +0000 Subject: feat(lisp/dns): Check in very early DNS-over-HTTPS client This includes very barebones support for querying TXT and MX records right now. The returned structure is not turned into a more convenient format and error handling is, well, NIL. --- lisp/dns/resolver.lisp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lisp/dns/resolver.lisp (limited to 'lisp/dns/resolver.lisp') diff --git a/lisp/dns/resolver.lisp b/lisp/dns/resolver.lisp new file mode 100644 index 000000000000..774be525cb20 --- /dev/null +++ b/lisp/dns/resolver.lisp @@ -0,0 +1,29 @@ +;; Initial implementation is a simple client for +;; https://developers.google.com/speed/public-dns/docs/doh/json + +(defpackage #:dns + (:documentation "Simple DNS resolver in Common Lisp") + (:use #:cl) + (:export #:lookup-txt #:lookup-mx)) + +(defvar *doh-base-url* "https://dns.google/resolve" + "Base URL of the service providing DNS-over-HTTP(S). Defaults to the + Google-hosted API.") + +(defun lookup-generic (name type) + (multiple-value-bind (body) + (drakma:http-request *doh-base-url* + :decode-content t + :want-stream t + :parameters `(("type" . ,type) + ("name" . ,name) + ("ct" . "application/x-javascript"))) + (cl-json:decode-json body))) + +(defun lookup-txt (name) + "Look up the TXT records at NAME." + (lookup-generic name "TXT")) + +(defun lookup-mx (name) + "Look up the MX records at NAME." + (lookup-generic name "MX")) -- cgit 1.4.1