oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.84k stars 2.56k forks source link

Implement `dns.setServers` #11543

Open teidesu opened 1 month ago

teidesu commented 1 month ago

What version of Bun is running?

1.1.10-canary.1+4b8f89cb7

What platform is your computer?

Darwin 23.2.0 arm64 arm

What steps can reproduce the bug?

  1. put 127.0.0.1 example.com into /etc/hosts
  2. run the following script and compare output from node and bun:
    
    import * as dns from 'node:dns'

dns.setServers(['8.8.8.8']) dns.resolve4('example.com', console.log)


### What is the expected behavior?

the code prints actual ips of example.com through the 8.8.8.8 dns server:

null [ '93.184.215.14' ]


### What do you see instead?

the code prints `127.0.0.1`, twice:

null [ "127.0.0.1", "127.0.0.1" ]



### Additional information

according to [Node.js docs](https://nodejs.org/api/dns.html#dnsresolve-dnsresolve-and-dnsreverse), `dns.resolve()`, `dns.resolve*()`, `and dns.reverse()` ... *always* perform a DNS query on the network
Electroid commented 1 month ago

This is because we are currently no-op'ing for setServers, we need to implement it.