(servers)
| 107 | } |
| 108 | |
| 109 | setServers(servers) { |
| 110 | validateArray(servers, 'servers'); |
| 111 | |
| 112 | // Cache the original servers because in the event of an error while |
| 113 | // setting the servers, c-ares won't have any servers available for |
| 114 | // resolution. |
| 115 | const newSet = []; |
| 116 | ArrayPrototypeForEach(servers, (serv, index) => { |
| 117 | validateString(serv, `servers[${index}]`); |
| 118 | let ipVersion = isIP(serv); |
| 119 | |
| 120 | if (ipVersion !== 0) |
| 121 | return ArrayPrototypePush(newSet, [ipVersion, serv, IANA_DNS_PORT]); |
| 122 | |
| 123 | const match = RegExpPrototypeExec(IPv6RE, serv); |
| 124 | |
| 125 | // Check for an IPv6 in brackets. |
| 126 | if (match) { |
| 127 | ipVersion = isIP(match[1]); |
| 128 | |
| 129 | if (ipVersion !== 0) { |
| 130 | const port = NumberParseInt( |
| 131 | RegExpPrototypeSymbolReplace(addrSplitRE, serv, '$2')) || IANA_DNS_PORT; |
| 132 | return ArrayPrototypePush(newSet, [ipVersion, match[1], port]); |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | // addr::port |
| 137 | const addrSplitMatch = RegExpPrototypeExec(addrSplitRE, serv); |
| 138 | |
| 139 | if (addrSplitMatch) { |
| 140 | const hostIP = addrSplitMatch[1]; |
| 141 | const port = addrSplitMatch[2] || IANA_DNS_PORT; |
| 142 | |
| 143 | ipVersion = isIP(hostIP); |
| 144 | |
| 145 | if (ipVersion !== 0) { |
| 146 | return ArrayPrototypePush( |
| 147 | newSet, [ipVersion, hostIP, NumberParseInt(port)]); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | throw new ERR_INVALID_IP_ADDRESS(serv); |
| 152 | }); |
| 153 | |
| 154 | this[kSetServersInternal](newSet, servers); |
| 155 | } |
| 156 | |
| 157 | [kSetServersInternal](newSet, servers) { |
| 158 | const orig = ArrayPrototypeMap(this._handle.getServers() || [], (val) => { |
no test coverage detected