just-js / lo

it's JavaScript Jim, but not as we know it. :space_invader:
MIT License
241 stars 9 forks source link

lib/dns: EINVAL on dns lookup (wrong bind ip for some environment) #42

Open lostrepo opened 1 month ago

lostrepo commented 1 month ago

I'm getting EINVAL when trying to resolve dns By changing bind ip https://github.com/just-js/lo/blob/4356cdbb8b0187bf74a834726c56a709e95c12f5/lib/dns/dns.js#L131 from 127.0.0.1 to external interface ip I'm able to resolve dns without errors

Possible solutions I see:

  1. pass bind_ip parameter to lookup method as override
  2. on dns module load save LO_DNS_BIND_IP environment variable as default override
  3. on dns module load use ioctl to find all interface' ips (something like https://stackoverflow.com/a/4139811, https://stackoverflow.com/a/4267204), try to resolve and bind to all ips, save ip that resolved as default override
  4. all/some of the above (priority: 1 > 2 > 3)