(ip)
| 165 | } |
| 166 | |
| 167 | function writeIPv6(ip) { |
| 168 | const parts = ip.replace(/^:|:$/g, '').split(':'); |
| 169 | const buf = Buffer.alloc(16); |
| 170 | |
| 171 | let offset = 0; |
| 172 | for (const part of parts) { |
| 173 | if (part === '') { |
| 174 | offset += 16 - 2 * (parts.length - 1); |
| 175 | } else { |
| 176 | buf.writeUInt16BE(parseInt(part, 16), offset); |
| 177 | offset += 2; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | return buf; |
| 182 | } |
| 183 | |
| 184 | function writeDomainName(domain) { |
| 185 | return Buffer.concat(domain.split('.').map((label) => { |
no test coverage detected
searching dependent graphs…