Skip to content

Instantly share code, notes, and snippets.

@fbettag
Created December 14, 2012 20:12
Show Gist options
  • Save fbettag/4288275 to your computer and use it in GitHub Desktop.
Save fbettag/4288275 to your computer and use it in GitHub Desktop.
scala> val ip = java.net.InetAddress.getByName("1.2.176.0")
base: java.net.InetAddress = /1.2.176.0
scala> val prefix = io.wasted.util.InetPrefix(ip, 20)
prefix: io.wasted.util.InetPrefix = /1.2.176.0/20
scala> prefix.contains(base)
res1: Boolean = true
scala> prefix.contains(java.net.InetAddress.getByName("1.2.191.20"))
res3: Boolean = true
scala> prefix.contains(java.net.InetAddress.getByName("1.2.192.0"))
res4: Boolean = false
scala> prefix.contains(java.net.InetAddress.getByName("1.2.172.0"))
res5: Boolean = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment