ip/README.md

40 lines
1.1 KiB
Markdown
Raw Normal View History

2017-10-06 14:56:47 +13:00
# IP
[![pipeline status](https://gitlab.com/jimsy/ip/badges/main/pipeline.svg)](https://gitlab.com/jimsy/ip/commits/main)
2017-10-11 18:26:19 +13:00
[![Hex.pm](https://img.shields.io/hexpm/v/ip.svg)](https://hex.pm/packages/ip)
2017-10-09 14:33:21 +13:00
IP, IP, Ooray! Simple IP Address representations.
2017-10-06 14:56:47 +13:00
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `ip` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
2019-07-01 19:35:15 +12:00
{:ip, "~> 1.0.0"}
2017-10-06 14:56:47 +13:00
]
end
```
2017-10-11 18:26:19 +13:00
## Usage
`ip` provides representations for IP addresses and subnets for Elixir with a bunch of helpful stuff tacked on the side.
2017-10-12 10:35:47 +13:00
iex> ~i(192.0.2.1)
2017-10-11 18:26:19 +13:00
#IP.Address<192.0.2.1 DOCUMENTATION>
2017-10-12 10:35:47 +13:00
iex> ~i(2001:db8::)
2017-10-11 18:26:19 +13:00
#IP.Address<2001:db8:: DOCUMENTATION>
2017-10-12 10:35:47 +13:00
iex> outside = ~i(2001:db8::/64)
2017-10-11 18:30:23 +13:00
...> inside = IP.Prefix.eui_64!(outside, "60:f8:1d:ad:d8:90")
2017-10-11 18:26:19 +13:00
...> IP.Prefix.contains_address?(outside, inside)
true
2017-10-06 14:56:47 +13:00
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/ip](https://hexdocs.pm/ip).