aports/testing/emacs-srv/optional-dns.el.patch
Celeste a84b494317 testing/emacs-srv: new aport
https://github.com/legoscia/srv.el
Elisp library to perform SRV DNS requests

Dependency of emacs-jabber
2024-04-02 02:35:24 +00:00

39 lines
1.1 KiB
Diff

--- a/srv.el
+++ b/srv.el
@@ -1,4 +1,4 @@
-;;; srv.el --- perform SRV DNS requests
+;;; srv.el --- perform SRV DNS requests -*- lexical-binding: t; -*-
;; Copyright (C) 2005, 2007, 2018 Magnus Henoch
@@ -44,7 +44,8 @@
;;; Code:
-(require 'dns)
+(require 'dns nil t)
+(eval-when-compile (require 'cl-lib))
;;;###autoload
(defun srv-lookup (target)
@@ -55,6 +56,10 @@
a hostname and PORT is a numeric port. The caller is supposed to
make connection attempts in the order given, starting from the beginning
of the list. The list is empty if no SRV records were found."
+ (if (not (boundp 'dns-query-types))
+ (error "No dns.el available")
+ (unless (assq 'SRV dns-query-types)
+ (error "dns.el doesn't support SRV lookups"))
(let* ((result (srv--dns-query target))
(answers (mapcar #'(lambda (a)
(cadr (assq 'data a)))
@@ -101,7 +106,7 @@
;; Extract hostnames and ports
(mapcar #'(lambda (a) (cons (cadr (assq 'target a))
(cadr (assq 'port a))))
- (nreverse weighted-result)))))
+ (nreverse weighted-result))))))
(defun srv--dns-query (target)
"Perform DNS query for TARGET.