Reputation: 153
Is there some property on req
object to get ip's family (IPv4 or IPv6)? Or how can I figure it out? I want to change behavior based on this info. I'm not sure if checking if the string contains a colon is the right way.
Upvotes: 0
Views: 149
Reputation: 516
You can use the built-in net package for this:
You also have net.isIP(input)
which will return 6
, 4
or 0
if the parameter is respectively an IPv6, an IPv4, or not an IP.
Upvotes: 1