Skip to content

IanLuites/cider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cider

Hex.pm Build Status Coverage Status Inline docs Deps Status Hex.pm

CIDR library for Elixer.

Quick Start

{:ok, whitelist} = Cider.whitelist("192.168.0.1-3, 192.168.2.0/24, ::1")
Cider.whitelisted?("192.168.0.2", whitelist) # true
Cider.optimize!("192.168.0.0/31, 192.168.0.2-3")  |> Cider.to_string
"192.168.0.0/30"```

```elixir
Cider.optimize("192.168.0.0/31, 192.168.0.2-4") |> Cider.to_string
"192.168.0.0-4"```

```elixir
Cider.optimize("192.168.0.0-5, 192.168.0.2-3, 192.168.0.4-255") |> Cider.to_string
"192.168.0.0/24"```

```elixir
Cider.optimize("192.168.0.0-5, 192.168.0.2-3, 192.168.0.4-127") |> Cider.to_string
"192.168.0.0/25"```

## Installation

The package can be installed
by adding `cider` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [{:cider, "~> 0.3.0"}]
end

Changelog

v0.3.3 (2020-05-10)

  • Add function to add CIDR or range to whitelist. (Cider.whitelist/2)
  • Add function to remove CIDR or range from whitelist. (Cider.blacklist/2)

v0.3.1 (2019-05-10)

  • Add function to optimize whitelists. (Cider.optimize/1)
  • Add ability to to_string to print whitelists.

v0.3.0 (2019-05-09)

  • Add ability to define ranges: 192.168.0.1-43.
  • Add function to create whitelist: Cider.whitelist/1.
  • Add function to match IP to whitelist: Cider.whitelisted?/2.

Packages

No packages published

Languages