lionsoul2014/ip2region · error · Error
invalid ipv6 address
Error message
invalid ipv6 address
What it means
Structural guard in the IPv6 parser: the string contained a colon (so it was routed to the v6 parser) but splitting on ':' produced fewer than 3 groups, which is too short to be any legal IPv6 form (even '::' yields 3 parts).
Source
Thrown at binding/javascript/util.js:79
if (isNaN(v)) {
throw new Error(`invalid ipv4 part '${ps[i]}', a valid number expected`);
}
if (v < 0 || v > 255) {
throw new Error(`invalid ipv4 part '${ps[i]}' should >= 0 and <= 255`);
}
ipBytes[i] = (v & 0xFF);
}
return ipBytes;
}
// parse ipv6 address
function _parse_ipv6_addr(v6String) {
let ps = v6String.split(':', 8);
if (ps.length < 3) {
throw new Error('invalid ipv6 address');
}
let dc_num = 0, offset = 0;
const ipBytes = Buffer.alloc(16);
for (var i = 0; i < ps.length; i++) {
let s = ps[i].trim();
// Double colon check and auto padding
if (s.length == 0) {
// ONLY one double colon allow
if (dc_num > 0) {
throw new Error('invalid ipv6 address: multi double colon detected');
}
let start = i, mi = ps.length - 1;
// clear all the consecutive spaces
for (i++;;) {
s = ps[i].trim();View on GitHub (pinned to c1a1fc7d59)
Solutions
- Pass a complete IPv6 address such as '2001:db8::1' or '1:2:3:4:5:6:7:8'
- Pre-check with net.isIPv6 (or equivalent) before parsing
- Ensure the string was not truncated before reaching the parser
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at binding/javascript/util.js:79 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of lionsoul2014/ip2region@c1a1fc7d59 (2026-09-02).
Data as JSON: /api/errors/f6e1a78f9a38c2db.
Report an issue: GitHub.