Address lookup: return the first result *of the right type*.

Previously, this code was doing a DNS lookup, searching for the first result
of the right type within the returned results, then (unless no match was
found) ignoring the search and returning the first result anyway. This led
to the possibility of IPv6 addresses being used when IPv6 is available but
Unv has only IPv4 enabled.
Don't add local addresses for which the corresponding address type isn't enabled.