michael orlitzky

hath

Get It

Release
hath-0.5.8.tar.gz
Browse source
gitweb
Clone it
git clone https://gitweb.michael.orlitzky.com/hath.git

What is it?

Hath is a Haskell program for working with network blocks in CIDR notation. When dealing with blocks of network addresses, there are a few things that one usually wants to do with them:

Hath does just that. It takes as its input (via stdin) a list of CIDR blocks.

Modes

Hath has the following modes:

Regexed

This computes a (Perl-compatible) regular expression matching the input CIDR blocks. It's the default mode of operation.

user $ echo "10.0.0.0/29 10.0.0.8/29" | hath

((10)\.(0)\.(0)\.(15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0))

Reduced

This combines small blocks into larger ones where possible, and eliminates redundant blocks. The output should be equivalent to the input, though.

user $ echo "10.0.0.0/24 10.0.1.0/24" | hath reduced

10.0.0.0/23

Duped

Shows only the blocks that would be removed by reduce; that is, it shows the ones that would get combined into larger blocks or are simply redundant.

user $ echo "10.0.0.0/24 10.0.1.0/24" | hath duped

10.0.0.0/24

10.0.1.0/24

Diffed

Shows what would change if you used reduce. Uses diff-like notation.

user $ echo "10.0.0.0/24 10.0.1.0/24" | hath diffed

-10.0.0.0/24

-10.0.1.0/24

+10.0.0.0/23

Listed

List the IP addresses contained within the given CIDRs.

user $ echo 192.168.0.240/29 | hath listed

192.168.0.240

192.168.0.241

192.168.0.242

192.168.0.243

192.168.0.244

192.168.0.245

192.168.0.246

192.168.0.247

The command-line syntax and complete set of options are documented in the man page.

Requirements

All of the software dependencies are listed in the hath.cabal file. Just use cabal to build it.

Installation

Cabal handles the build, so do whatever you normally do to install cabal packages. If you just want to install it for your user,

user $ runghc Setup.hs configure --user

user $ runghc Setup.hs build

user $ runghc Setup.hs install

should do it.

How to report bugs

Email them to me at michael@orlitzky.com.