From d8c1e7f0adac0a739bdfac0273c2876cb7a70c52 Mon Sep 17 00:00:00 2001 From: interp Date: Mon, 26 Aug 2002 15:33:22 +0000 Subject: [PATCH] fixing system-fqdn --- scheme/lib/sunet-utilities.scm | 27 +++++++-------------------- scheme/packages.scm | 1 + 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/scheme/lib/sunet-utilities.scm b/scheme/lib/sunet-utilities.scm index e407b98..759533f 100644 --- a/scheme/lib/sunet-utilities.scm +++ b/scheme/lib/sunet-utilities.scm @@ -33,24 +33,11 @@ (write-char c) (loop (read-char fd)))))) -;; out from ecm-utilities.scm -;; please tell me if this doesn't work on your system. + (define (system-fqdn) - (let ((sysname (system-name))) - (if (string-index sysname #\.) - sysname - (nslookup-fqdn)))) - -;; This doesn't work on my system. Probably it is not configured well. -;; Nevertheless, the alternative seems better to me -;(define (nslookup-fqdn) -; (let* ((cmd (format #f "nslookup ~a" (system-name))) -; (raw (string-join (run/strings (nslookup ,(system-name))))) -; (match (string-match "Name: +([-a-zA-Z0-9.]+)" raw))) -; (display raw) -; (match:substring match 1))) - -(define (nslookup-fqdn) - (host-info:name (host-info (system-name)))) -; another easy alternative: -; (car (run/strings (hostname "--long")))) \ No newline at end of file + (let ((host (host-info (system-name)))) + (let loop ((addresses (host-info:addresses host))) + (if (null? addresses) + #f + (or (dns-lookup-ip (car addresses)) + (loop (cdr addresses))))))) diff --git a/scheme/packages.scm b/scheme/packages.scm index 89a93ed..1ee2311 100644 --- a/scheme/packages.scm +++ b/scheme/packages.scm @@ -637,6 +637,7 @@ sigevents let-opt srfi-13 + dns handle-fatal-error) (files (lib sunet-utilities)))