src/IPv4Address.hs: fix the inverse toEnum/fromEnum property on x86.
The second half of the fix in the previous commit turned out to be in
the test itself. The "smallness test" that I was using was to compare
against the number (2^32 - 1), which works great if said number is
interpreted as a 64-bit integer. However on x86 systems, it's a 32-bit
integer, namely negative one! Oops.
This commit splits that test into two; one that tests randomly-generated
Int32s, and one that tests randomly-generated Int64s. Hopefully this
ensures that no similar problems with the machine Int type creep in.
src/IPv4Address.hs: convert Int to Word32 before doing math in toEnum.
On x86, the machine Int type isn't big enough to hold half of the
IPv4 address space. Big addresses get converted into negative numbers,
and all hell breaks loose. Unfortunately, the Int type is baked into
the Enum typeclass, so we can't avoid it entirely. We can however
cast to Word32 before doing any math.
This commit updates the toEnum implementation for IPv4Address to
convert back and forth between Word32, fixing part of this bug.
However, the inverse property of toEnum and fromEnum is still
failing for IPv4Address.
Thanks to Thomas Deutschmann <whissi@gentoo.org> for finding the bug.
Michael Orlitzky [Fri, 21 Apr 2017 12:13:45 +0000 (08:13 -0400)]
Require base >= 4.9 to pull in ghc-8.x.
A newer version of GHC is needed since we stopped deriving Typeable
and began to use the new -Wfoo style for warnings. See commits fb27e58 and 3f8eddf.
Michael Orlitzky [Mon, 17 Apr 2017 01:56:51 +0000 (21:56 -0400)]
Add a new "normalize" function to the Cidr module.
There are several different ways to represent the same Cidr, as their
Eq instance shows. The canonical way to represent a given CIDR is with
its host bits zeroed out; for example, "127.0.0.0/8" instead of
"127.0.0.1/8". This commit adds a normalization function to the Cidr
module.
It should be possible to use the new function to clean up the code
some, and to allow the user to specify normalized output for the
"reduced" mode.
Michael Orlitzky [Fri, 14 Apr 2017 04:00:17 +0000 (00:00 -0400)]
Use the derived instance for Ord and add a test case.
There was a bug in my implementation of Ord for Octets that was
pointed out by Michael McKibben. As a result, the octets corresponding
to (for example) 2 and 4 would compare incorrectly. This is fixed by
simply adopting the derived Ord instance for Octets. Why didn't I do
that in the first place?
With the bug fixed, I've added a QuickCheck property to ensure that
the Ord instances for Octet and Int agree when the Int is between 0
and 255.
Michael Orlitzky [Thu, 12 Nov 2015 13:14:24 +0000 (08:14 -0500)]
Remove the "reversed" mode -- do one thing and do it well and all that.
Remove the old README.
Switch license from GPL-3 to AGPL-3.
Add a reverse lookup example (using dig) to the man page.
Michael Orlitzky [Sun, 22 Feb 2015 03:28:33 +0000 (22:28 -0500)]
Bulletproof the test suite and examples; version bump the cabal file.
The examples in the man page used the "<<<" syntax which is specific
to bash. Now "echo 'foo' | hath ..." is used, and that should work in
any shell. The shelltest suite was updated to use the same.
The two ShellTests(Net) modules were also updated to run the
shelltests with an empty environment. This allowed the --color=never
argument to be removed from the tests themselves, since $GREP_OPTIONS
can't be populated.
Michael Orlitzky [Sat, 24 May 2014 16:57:55 +0000 (12:57 -0400)]
Bump version to 0.2.1.
Update dependencies for ghc-7.8.
Require a newer tasty-quickcheck that re-exports Gen.
Use lookupRDNS from newer versions of dns instead of a custom implementation.
Fix deprecation warnings in shelltests.
Michael Orlitzky [Wed, 16 Oct 2013 14:51:44 +0000 (10:51 -0400)]
List regex alternates in reverse order to avoid matching single digits before the entire octet.
Add a test for the bug fixed by the code change.
Update existing tests and documentation for the new output.
Michael Orlitzky [Mon, 14 Oct 2013 02:11:09 +0000 (22:11 -0400)]
Rewrite command-line parsing to use cmdargs.
Make the regexp barriers optional via --barriers.
Bump to version 0.0.6.
Add two new test suites (shelltestrunner) for Cabal.
Michael Orlitzky [Sat, 17 Aug 2013 21:25:52 +0000 (17:25 -0400)]
Bump the version number to 0.0.4 in hath.cabal.
Add two new modes: 'List' and 'Reversed' to list and perform a PTR lookup on a CIDR's addresses respectively.
Add a .ghci file which loads some modules automatically.
Add Bounded and Enum instances for Bit, Octet, IPv4Address.
Add some tests for the new functionality.
Add more Haddock comments.
Replace a few custom functions with library ones.
Allow input CIDRs to be separated by any whitespace, not just newlines.
Split the exit codes out into their own module.
Remove now-unused ListUtils modules.
Update deps in cabal file.
Add a man page.
Make combine_all operate recursively.
Create a new test to test the recursive combine_all.
Add a custom (==) implementation for Cidrs.
Fix an incorrect test.