net: Allow custom DNS resolvers

net.connect now checks whether the user has provided a dns
resolution function, this arguments and expected output
for which mirror the existing dns.lookup implementation.

Fixes #8475