lua-resty-ipmatcher icon indicating copy to clipboard operation
lua-resty-ipmatcher copied to clipboard

Add is private/public method

Open mhf-ir opened this issue 5 years ago • 1 comments

Add is private method:

ip:isPrivate("127.0.0.1")
ip:isPrivateV4("127.0.0.1")
ip:isPrivateV6("fd12:3456:789a:1::1")

ip:isPublic("8.8.8.8")
ip:isPublicV4("8.8.8.8")
ip:isPublicV6("2400:cb00::/32")

https://en.wikipedia.org/wiki/Private_network

RFC1918 name IP address range Number of addresses Largest CIDR block (subnet mask) Host ID size Mask bits Classful description
24-bit block 10.0.0.0 – 10.255.255.255 16777216 10.0.0.0/8 (255.0.0.0) 24 bits 8 bits single class A network
20-bit block 172.16.0.0 – 172.31.255.255 1048576 172.16.0.0/12 (255.240.0.0) 20 bits 12 bits 16 contiguous class B networks
16-bit block 192.168.0.0 – 192.168.255.255 65536 192.168.0.0/16 (255.255.0.0) 16 bits 16 bits 256 contiguous class C networks

mhf-ir avatar Jan 10 '20 13:01 mhf-ir

PR welcome

membphis avatar Jan 12 '20 01:01 membphis