glm_cidr
This is a simple library to assist with answering these basic questions:
- Is a given ip address in a given subnet?
- What is the next usable address in a given subnet, after a given address?
- How many usable addresses are in a given subnet?
I’m sure there are other interesting questions related to cidr.
Feel free to fork and/or submit PR’s for additional functionality.
gleam add glm_cidr
import glm_cidr as cidr
pub fn main() -> Nil {
let subnet = cidr.subnet("10.0.0.1/24")
let relation = cidr.relationship(subnet, "10.0.0.66")
/// -> Ok(AddressIsInsideSubnet(next: 10.0.0.67, subnet_metadata: { first: 10.0.0.1, last: 10.0.0.255, count: 254 } )
}
Further documentation can be found at https://hexdocs.pm/glm_cidr.
Development
gleam check # Check the project
gleam test # Run the tests