Hi Xavier,

Thanks for the feedback.

> do you plan to return an empty array when there is no failure but no
> matching record, or false ?

An empty array. false is only for when getaddrinfo() itself fails (e.g.
unknown host), with the usual warning like stream connections.
php_network_getaddresses() always queries AF_UNSPEC and $family is applied
afterwards, so it's easy to tell the two cases apart. Relying on
EAI_NODATA/EAI_ADDRFAMILY would not be portable anyway.

> why only A and AAAA? Other records are useful too, especially SVC

getaddrinfo() only gives addresses back. SVCB/HTTPS, MX, TXT... are
DNS-only records, and /etc/hosts or nsswitch have no equivalent. They
belong in dns_get_record(), which does not know SVCB/HTTPS yet. That's a
a good suggestion !

> do you think you may wrap the syscall with a timeout somehow ?

Not portably. getaddrinfo_a() is glibc only, and otherwise it means a
helper thread. Today the timeout comes from the resolver config
(resolv.conf timeout/attempts and so on), and stream connections behave
the same way since the connect timeout does not cover the name
resolution. I'd rather stay consistent with that.

> may you add the ip of the dns server to reach ?

getaddrinfo() does not expose it. Depending on nsswitch, the answer can
come from /etc/hosts, nscd, systemd-resolved or mDNS, so there is not
always a DNS server to report. dns_get_record() is a better fit for that
kind of detail.

So I'll keep the proposal as is, and the PR will document and test the
empty array vs false behaviour.

Cheers.

Reply via email to