lionsoul2014/ip2region · error · Error
invalid ip address '${ipString}'
Error message
invalid ip address '${ipString}' What it means
Top-level dispatch guard in parseIP: the input string contains neither a dot nor a colon, so it cannot be routed to either the IPv4 or the IPv6 parser; it is not an IP address at all (e.g. 'localhost' or a bare number).
Source
Thrown at binding/javascript/util.js:145
offset += 2;
}
return ipBytes;
}
// parse the specified string ip and return its bytes
// @param ip string
// @return Buffer
export function parseIP(ipString) {
let sDot = ipString.indexOf('.');
let cDot = ipString.indexOf(':');
if (sDot > -1 && cDot == -1) {
return _parse_ipv4_addr(ipString);
} else if (cDot > -1) {
return _parse_ipv6_addr(ipString);
} else {
throw new Error(`invalid ip address '${ipString}'`);
}
}
// ---
// ipv4 bytes to string
function _ipv4_to_string(v4Bytes) {
return v4Bytes.join('.');
}
// ipv6 bytes to string
function _ipv6_to_string(v6Bytes, compress) {
let ps = [], needCompress = false;
let lastHex = -1, hex = 0;
for (var i = 0; i < v6Bytes.length; i += 2) {
hex = v6Bytes.readUint16BE(i).toString(16);
ps.push(hex);
View on GitHub (pinned to c1a1fc7d59)
Solutions
- Pass a valid IPv4 or IPv6 string; resolve hostnames to IPs before searching
- Validate the input with net.isIP before calling the searcher
- Reject non-IP identifiers at the API boundary instead of inside search
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at binding/javascript/util.js:145 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/cc4e119306230194.
Report an issue: GitHub.