Skip to content

Commit

Permalink
Ignore non-existent /etc/hosts
Browse files Browse the repository at this point in the history
Fixes #64
  • Loading branch information
sionescu committed Jun 9, 2021
1 parent dac715c commit 3e213d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/sockets/namedb/hosts.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@
(destructuring-bind (address cname &rest aliases) tokens
(push (make-host cname (ensure-address address) aliases)
hosts))))
(map-etc-file (lambda (tokens) (ignore-errors (parse-one-line tokens)))
file)
(alexandria:ignore-some-conditions (file-error)
(map-etc-file (lambda (tokens) (ignore-errors (parse-one-line tokens)))
file))
(nreverse hosts))))

(defun search-host-by-name (name ipv6)
Expand Down
3 changes: 3 additions & 0 deletions tests/sockets.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
(defparameter *google-ns*
(list #/ip/8.8.8.8 #/ip/8.8.4.4))

(test (missing-hosts-file :compile-at :definition-time)
(is-false (iolib/sockets::parse-/etc/hosts "/foo/no-such-file")))

#-no-internet-available
(test (lookup-hostname.1 :compile-at :definition-time)
(is (equalp (multiple-value-bind (address addresses truename)
Expand Down

0 comments on commit 3e213d3

Please sign in to comment.