Open FreshXOpenSource opened 8 years ago
I like how dns was done in luvit. I simply bound the libuv methods directly and then implemented the node dns APIs on top of the libuv udp bindings.
I can work on the C part tonight if you need dns in seaduk. It covers the main case of resolving a domain name to a dns address.
I've added the dns bindings to seaduk.
There are two new functions uv.getnameinfo(options, callback)
and uv.getaddrinfo(options, callback)
address-to-name translation in protocol-independent manner
The callback will have (err, hostname, servicename)
.
network address and service translation
inet
or inet6
To simply resolve a hostname to an IPv4 address, do something like:
uv.getaddrinfo({
node: "luvit.io",
socktype: "stream", // Only show TCP results
family: "inet", // Only show IPv4 results
}, function (err, results) {
assert(!err, err);
p("Dns results for luvit.io", results);
});
I believe libuv supports sync mode and I can add it with more work (same as the uv.fs_*
functions). Currently it runs in async mode and you must pass in a callback.
that looks pretty nice to me! the sync functionality is not really needed.
Nice! Thanks for doing this @creationix!
i started to work on a basic DNS implementation at https://github.com/FreshXOpenSource/seaduk/tree/dns (for now only _sync name lookups to ip-strings or arrays work).
i realize that im not yet that fit to implement an async version and would like to request help here for one async resolve example. furthermore there are several issues not yet addressed:
any input welcome...