Skip to content

Repository files navigation

ip - A handy internet protocol address helper

This ip package will help you retrieve info for a given ip and subnet. Currently only supports ipv4. This package is written in vanilla cfml and requires no depencies

License

I dont know about licenses, do whatever you want.

Instructions

Just drop into your modules folder or use the box-cli to install

box install ip

Models

The module registers the following mapping in WireBox: ip@ip. Which is the class you will use to parse ip addresses and subnets. Currently this class supports one method, with two signatures.

  • v4( ipAddress, subnetmask ) - Parse ip address with a given subnet mask
  • v4( cidrString ) - Parse cidr signature.

E.g.

//wirebox stylevarip=getInstance('ip@ip');//vanilla stylevarip=newmy.lib.ip.models.ip();

This returned value is an object which you can use to retrieve information for the given subetnet.

Below is example along with all the methods available to you:

// instation:varip=getInstance('ip@ip');// you can disable loading all available addresses to speed up performance for large subnets, by default this is trueip.setLoadRange(false);ip.setLoadRange(true);//load subnetvarsubnet=ip.v4('192.168.0.1/24');// or ip.v4('192.168.0.1','255.255.255.0')// available getterssubnet.getAddress()// 192.168.0.1subnet.getNumHosts()// 254subnet.getPrefixLength()// 24subnet.getBroadcastAddress()// 192.168.0.255subnet.getNetworkAddress()// 192.168.0.0subnet.getSubnetMask()// 255.255.255.0subnet.getCidrSignature()// 192.168.0.1/24subnet.getFirstAddress()// 192.168.0.1subnet.getLastAddress()// 192.168.0.254subnet.getBinary()// 11000000101010000000000000000001subnet.getIpDecimal()// 3232235521subnet.getNetworkDecimal()// 3232235520subnet.getBroadcastDecimal()// 3232235775subnet.getAddressses()// A struct containing all available addresses // utility functionsvarisInRange=subnet.isInRange('192.168.0.4');//truevarisInRange=subnet.isInRange('192.168.2.9');//false// can return a struct with all the above information of the subnetvarmemento=subnet.toMemento();/* memento = { "address": "192.168.0.1", "numHosts": 254, "prefixLength": 24, "broadcastAddress": "192.168.0.255", "networkAddress": "192.168.0.0", "subnetMask": "255.255.255.0", "cidrSignature": "192.168.0.1/24", "firstAddress": "192.168.0.1", "lastAddress": "192.168.0.254", "binary": "11000000101010000000000000000001", "ipDecimal": 3232235521, "networkDecimal": 3232235520, "broadcastDecimal": 3232235775, "ipAddresses": [ "192.168.0.0", "192.168.0.1", "192.168.0.2", ... "192.168.0.254", "192.168.0.255" ] }*/

About

A package to retrieve information for a given ip and subnet

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages