ip-address icon indicating copy to clipboard operation
ip-address copied to clipboard

Add examples to documentation

Open onury opened this issue 8 years ago • 7 comments

I can't see how I can get CIDR prefix length (bits) of an IPv6 subnet. I have the IP address and the subnet mask. Is it even possible with this lib?

Also to get the first and last IPv6 in a subnet, you have .startAddress() and endAddress() methods but I cannot get a valid result from them. But both start and end returns ffff:ffff:ffff:ffff:0000:0000:0000:0000

onury avatar Aug 13 '16 20:08 onury

re: 1., given a mask like 0000:0000:0000:0000:ffff:ffff:ffff:ffff are you looking for a function that returns 64?

re: 2., here's a working example: http://requirebin.com/?gist=982bc23a191d601dca5b53b5ef7e7403

point taken re: adding examples to the documentation though. happy to merge any documentation PRs if you get to them before I do! ✨

beaugunderson avatar Aug 14 '16 00:08 beaugunderson

  1. Exactly. We should either be getting CIDR or bits (so we can get CIDR via 128 - bits)
  2. Thanks for the example. See, for example Node's os.networkInterfaces() returns IPv6 subnet mask in address form, not CIDR. so to init an IPv6 like new ip.Address6('1:2:3:4::/64') I should be able to convert from address/mask form to CIDR.

onury avatar Aug 14 '16 02:08 onury

ah, thanks for the pointer to os.networkInterfaces(); I'll add this soon!

beaugunderson avatar Aug 14 '16 03:08 beaugunderson

any news on this (conversion from address/mask form to CIDR)?

btw, cannot reach documentation @ ip-address.js.org

onury avatar Jun 23 '17 20:06 onury

can you try ip-address.js.org again? it's working for me

re: the conversion; i'm work on a function for you right now

beaugunderson avatar Jun 26 '17 17:06 beaugunderson

@onury can you see if this meets your needs?

http://requirebin.com/?gist=7b4a2156b1f783ede271e68eaf44d281

if it does, i'll flesh it out further and add it to the library :)

beaugunderson avatar Jun 26 '17 18:06 beaugunderson

I think so. thanks. docs are working again.

onury avatar Jun 26 '17 23:06 onury