Skip to content

Encapsulates IPv4 and IPv6 Addresses and Blocks.

License

Notifications You must be signed in to change notification settings

chris-huxtable/ip_address.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ip_address.cr

Docs GitHub release Build Status

Encapsulates IPv4 and IPv6 Addresses and Blocks.

Installation

Add this to your application's shard.yml:

dependencies:
  ip_address:
    github: chris-huxtable/ip_address.cr

Usage

require "ip_address"

Some samples:

address0 = IP["127.0.0.128"]
address1 = IP["10.0.0.0"]?
address2 = IP.new("127.0.0.0")
address3 = IP.new?("127.0.0.0")

address4 = IP["2001:0db8:123:4567:89ab:cdef:1234:5678"]
address5 = IP::Address["1::2"]?
address6 = IP.new("::1")
address7 = IP::Address.new?("::0")

block0 = IP["127.0.0.0/8"]
block1 = IP::Block["10.0.0.0/8"]?
block2 = IP.new("127.0.0.0/8")
block3 = IP::Block.new?("127.0.0.0/8")

block0 = IP["127.0.0.0/8"]
block1 = IP::Block["10.0.0.0/8"]?
block2 = IP.new("127.0.0.0/8")
block3 = IP::Block.new?("127.0.0.0/8")

loopback = IP::Address::IPv4.loopback

block0.includes?(address0)

Contributing

  1. Fork it ( https://github.com/chris-huxtable/ip_address.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors