It took me a while until I understood your range notation. Consider switching to CIDR syntax. Networks are routed using CIDR so you usually can express ownership of an IP address by CIDR notation.
Another thing to note is that your code does not support IPv6. IPv6 will become more and more impor...