Won't perform DNS resolution if the only nameservers are IPv6
Running Debian/ppc64le with cqueues 20200726-2+b1.
If /etc/resolv.conf contains just nameserver fdb3:8168:d522::1, cqueues won't resolve DNS names:
$ lua -e 'print(require "cqueues.socket".connect{host="google.com"; port="443"}:connect())'
lua: (command line):1: socket:connect: A non-recoverable error occurred when attempting to resolve the name
stack traceback:
[C]: in function 'error'
/usr/share/lua/5.3/cqueues/socket.lua:90: in function </usr/share/lua/5.3/cqueues/socket.lua:75>
(...tail calls...)
/usr/share/lua/5.3/cqueues/socket.lua:271: in method 'connect'
(command line):1: in main chunk
[C]: in ?
strace sayeth...
fstat(3, {st_mode=S_IFREG|0644, st_size=74, ...}) = 0
_llseek(3, 0, [0], SEEK_SET) = 0
read(3, "search lw.ietfng.org.\n#nameserve"..., 512) = 74
read(3, "", 512) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=526, ...}) = 0
read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 1024) = 526
read(3, "", 1024) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=155, ...}) = 0
_llseek(3, 0, [0], SEEK_SET) = 0
read(3, "127.0.0.1\tlocalhost\n127.0.1.1\tve"..., 512) = 155
read(3, "", 512) = 0
close(3) = 0
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 3
bind(3, {sa_family=AF_INET, sin_port=htons(10218), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000}, {sa_handler=0x123a47670, sa_mask=[], sa_flags=SA_NODEFER|SA_RESETHAND}, 8) = 0
write(2, "lua: ", 5lua: ) = 5
The system as a whole can perform DNS resolution just fine; strace ping google.com sayeth:
newfstatat(AT_FDCWD, "/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=74, ...}, 0) = 0
newfstatat(AT_FDCWD, "/etc/nsswitch.conf", {st_mode=S_IFREG|0644, st_size=526, ...}, 0) = 0
openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=155, ...}) = 0
_llseek(5, 0, [0], SEEK_SET) = 0
read(5, "127.0.0.1\tlocalhost\n127.0.1.1\tve"..., 512) = 155
read(5, "", 512) = 0
close(5) = 0
socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 5
setsockopt(5, SOL_IPV6, IPV6_RECVERR, [1], 4) = 0
connect(5, {sa_family=AF_INET6, sin6_port=htons(53), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "fdb3:8168:d522::1", &sin6_addr), sin6_scope_id=0}, 28) = 0
poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
send(5, "^4\1\0\0\1\0\0\0\0\0\0\1e\0010\0010\0012\0010\0010\0010\0010\0010\0010"..., 90, MSG_NOSIGNAL) = 90
poll([{fd=5, events=POLLIN}], 1, 5000) = 1 ([{fd=5, revents=POLLIN}])
ioctl(5, FIONREAD, [129]) = 0
recvfrom(5, "^4\201\200\0\1\0\1\0\0\0\0\1e\0010\0010\0012\0010\0010\0010\0010\0010\0010"..., 1024, 0, {sa_family=AF_INET6, sin6_port=htons(53), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "fdb3:8168:d522::1", &sin6_addr), sin6_scope_id=0}, [28]) = 129
close(5) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x5), ...}) = 0
write(1, "PING google.com(yyz12s08-in-x0e."..., 84PING google.com(yyz12s08-in-x0e.1e100.net (2607:f8b0:400b:803::200e)) 56 data bytes
Adding an IPv4 nameserver to /etc/resolv.conf can workaround the issue, but is less than ideal.
Please advise if there's more I can tell you that'd be useful.
I have a similar issue on macOS Sonoma 15.5 (24F74):
❯ lua -e 'print(require "cqueues.socket".connect{host="google.com"; port="443"}:connect())' lua: (command line):1: socket:connect: A non-recoverable error occurred when attempting to resolve the name stack traceback: [C]: in function 'error' /opt/homebrew/share/lua/5.4/cqueues/socket.lua:90: in function </opt/homebrew/share/lua/5.4/cqueues/socket.lua:75> (...tail calls...) /opt/homebrew/share/lua/5.4/cqueues/socket.lua:271: in method 'connect' (command line):1: in main chunk [C]: in ?
❯ luarocks show cqueue
cqueues 20200726.54-0 - Continuation Queues: Embeddable asynchronous networking, threading, and notification framework for Lua on Unix.
License: MIT/X11 Homepage: http://25thandclement.com/~william/projects/cqueues.html Installed in: /opt/homebrew
Modules: _cqueues (/opt/homebrew/lib/lua/5.4/_cqueues.so) cqueues (/opt/homebrew/share/lua/5.4/cqueues.lua) cqueues.auxlib (/opt/homebrew/share/lua/5.4/cqueues/auxlib.lua) cqueues.condition (/opt/homebrew/share/lua/5.4/cqueues/condition.lua) cqueues.dns (/opt/homebrew/share/lua/5.4/cqueues/dns.lua) cqueues.dns.config (/opt/homebrew/share/lua/5.4/cqueues/dns/config.lua) cqueues.dns.hints (/opt/homebrew/share/lua/5.4/cqueues/dns/hints.lua) cqueues.dns.hosts (/opt/homebrew/share/lua/5.4/cqueues/dns/hosts.lua) cqueues.dns.packet (/opt/homebrew/share/lua/5.4/cqueues/dns/packet.lua) cqueues.dns.record (/opt/homebrew/share/lua/5.4/cqueues/dns/record.lua) cqueues.dns.resolver (/opt/homebrew/share/lua/5.4/cqueues/dns/resolver.lua) cqueues.dns.resolvers (/opt/homebrew/share/lua/5.4/cqueues/dns/resolvers.lua) cqueues.errno (/opt/homebrew/share/lua/5.4/cqueues/errno.lua) cqueues.notify (/opt/homebrew/share/lua/5.4/cqueues/notify.lua) cqueues.promise (/opt/homebrew/share/lua/5.4/cqueues/promise.lua) cqueues.signal (/opt/homebrew/share/lua/5.4/cqueues/signal.lua) cqueues.socket (/opt/homebrew/share/lua/5.4/cqueues/socket.lua) cqueues.thread (/opt/homebrew/share/lua/5.4/cqueues/thread.lua)
Depends on: lua 5.4 (using 5.4-1)
My current DNS config does not only contain IPv6 addresses, but it seems like IPv6 addresses are the first that are tried. The IPv4 DNS address is the last one in both scutil --dns and /etc/resolv.conf.