Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cares_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2251,13 +2251,13 @@ void SetServers(const FunctionCallbackInfo<Value>& args) {
if (!elm->Get(env->context(), 1).ToLocal(&ipValue)) return;
if (!elm->Get(env->context(), 2).ToLocal(&portValue)) return;

CHECK(familyValue->Int32Value(env->context()).FromJust());
CHECK(ipValue->IsString());
Comment thread
Renegade334 marked this conversation as resolved.
CHECK(portValue->Int32Value(env->context()).FromJust());

int fam = familyValue->Int32Value(env->context()).FromJust();
int32_t fam;
if (!familyValue->Int32Value(env->context()).To(&fam)) return;
node::Utf8Value ip(env->isolate(), ipValue);
int port = portValue->Int32Value(env->context()).FromJust();
int32_t port;
if (!portValue->Int32Value(env->context()).To(&port)) return;

if (!csv.empty()) csv += ',';

Expand Down
4 changes: 4 additions & 0 deletions test/parallel/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ const portsExpected = [
dns.setServers(ports);
assert.deepStrictEqual(dns.getServers(), portsExpected);

// Port 0 means "use the default port" for c-ares.
dns.setServers(['4.4.4.4:0', '[2001:4860:4860::8888]:0']);
assert.deepStrictEqual(dns.getServers(), ['4.4.4.4', '2001:4860:4860::8888']);

// Link-local IPv6 addresses require a zone index (scope id) to be usable;
// c-ares drops link-local servers configured without one.
dns.setServers(['[fe80::483a:5aff:fee6:1f04]%eth0']);
Expand Down
Loading