szmarczak / cacheable-lookup

A cacheable dns.lookup(…) that respects TTL :tada:
MIT License
193 stars 29 forks source link

Respect IPv6 in `hosts` file #9

Closed szmarczak closed 4 years ago

szmarczak commented 4 years ago

We can just parse the hosts file in the following way:

  1. Fetch the lines.
  2. Split the lines [characters] [whitespace] [a-ZA-Z0-9-]
  3. Check if the first group is an IP using net.isIP.

(no need to use regexp here)