Skip to content

Instantly share code, notes, and snippets.

@rg443a
Last active January 2, 2020 06:37
Show Gist options
  • Save rg443a/905654d929533a87d6a5c10a61be2fb2 to your computer and use it in GitHub Desktop.
Save rg443a/905654d929533a87d6a5c10a61be2fb2 to your computer and use it in GitHub Desktop.
inet_aton, inet_ntoa, ip2int, int2ip
function inet_aton(a) {
return a.split(".").reduce(function(a, b) {
return (a << 8) + parseInt(b, 10);
}, 0) >>> 0;
}
function inet_ntoa(a) {
return (a >>> 24) + "." + (a >> 16 & 255) + "." + (a >> 8 & 255) + "." + (a & 255);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment