No need to separate IPv4 and IPv6, actually...

Nodejs accepts IPv6 and Bitcoin sends all addresses as IPv6 anyway (using the standard IPv4-to-IPv6 demarkation if only IPv4), so no need to add more logic there than necessary; the net.createConnection() function handles the translation already.