Skip to content

IP address and range manipulation, including CIDR syntax support; inspired by Ruby IPAddr

License

Notifications You must be signed in to change notification settings

jec/ipaddr-elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jec

IPAddr for Elixir

The IPAddr module provides IP address manipulation, including CIDR-style range calculations, for both IPv4 and IPv6 addresses. The functions provided were loosely inspired by Ruby's IPAddr class, along with some others I've found useful.

Examples

range = IPAddr.new("192.168.10.0/24")
ip = IPAddr.new("192.168.10.50")
IO.inspect(range)
IO.inspect(ip)
IO.inspect(IPAddr.include?(range, ip))
IO.inspect(IPAddr.include?(range, IPAddr.new("192.168.11.50")))

produces:

%IPAddr{family: :ipv4, ip: {192, 168, 10, 0}, mask: 24}
%IPAddr{family: :ipv4, ip: {192, 168, 10, 50}, mask: 32}
true
false

License

IPAddr is licensed under the three-clause BSD license (see LICENSE.txt).

About

IP address and range manipulation, including CIDR syntax support; inspired by Ruby IPAddr

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages