File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2159,13 +2159,13 @@ void SetServers(const FunctionCallbackInfo<Value>& args) {
21592159 if (!elm->Get (env->context (), 1 ).ToLocal (&ipValue)) return ;
21602160 if (!elm->Get (env->context (), 2 ).ToLocal (&portValue)) return ;
21612161
2162- CHECK (familyValue->Int32Value (env-> context ()). FromJust ());
2162+ CHECK (familyValue->IsInt32 ());
21632163 CHECK (ipValue->IsString ());
2164- CHECK (portValue->Int32Value (env-> context ()). FromJust ());
2164+ CHECK (portValue->IsInt32 ());
21652165
2166- int fam = familyValue-> Int32Value (env-> context ()). FromJust ();
2166+ int32_t fam = familyValue. As <Int32>()-> Value ();
21672167 node::Utf8Value ip (env->isolate (), ipValue);
2168- int port = portValue-> Int32Value (env-> context ()). FromJust ();
2168+ int32_t port = portValue. As <Int32>()-> Value ();
21692169
21702170 ares_addr_port_node* cur = &servers[i];
21712171
Original file line number Diff line number Diff line change @@ -136,6 +136,10 @@ const portsExpected = [
136136dns . setServers ( ports ) ;
137137assert . deepStrictEqual ( dns . getServers ( ) , portsExpected ) ;
138138
139+ // Port 0 means "use the default port" for c-ares.
140+ dns . setServers ( [ '4.4.4.4:0' , '[2001:4860:4860::8888]:0' ] ) ;
141+ assert . deepStrictEqual ( dns . getServers ( ) , [ '4.4.4.4' , '2001:4860:4860::8888' ] ) ;
142+
139143dns . setServers ( [ ] ) ;
140144assert . deepStrictEqual ( dns . getServers ( ) , [ ] ) ;
141145
You can’t perform that action at this time.
0 commit comments