From: Michael Orlitzky Date: Thu, 12 Nov 2015 13:14:24 +0000 (-0500) Subject: Remove the "reversed" mode -- do one thing and do it well and all that. X-Git-Tag: 0.3.0 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=3117da60b31802acd87bb41a352379d6a1fce787;p=hath.git 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. --- diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index 13e4d83..0000000 --- a/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -[^.]* diff --git a/doc/LICENSE b/doc/LICENSE index bc08fe2..dba13ed 100644 --- a/doc/LICENSE +++ b/doc/LICENSE @@ -1,5 +1,5 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies @@ -7,17 +7,15 @@ Preamble - The GNU General Public License is a free, copyleft license for -software and other kinds of works. + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to +our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. +software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you @@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. The precise terms and conditions for copying, distribution and modification follow. @@ -72,7 +60,7 @@ modification follow. 0. Definitions. - "This License" refers to version 3 of the GNU General Public License. + "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. @@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. - 13. Use with the GNU Affero General Public License. + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single +under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General +Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published +GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's +versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. @@ -617,3 +615,47 @@ reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/doc/README b/doc/README deleted file mode 100644 index 5ad9154..0000000 --- a/doc/README +++ /dev/null @@ -1,81 +0,0 @@ - -Overview --------- - -Hath is a Haskell program for working with network blocks in CIDR[1] -notation. When dealing with blocks of network addresses, there are a -few things that you (i.e. I) want to do with them: - - * Create a regular expression matching the CIDR block(s). This is - because grep will throw up if you feed it CIDR. - - * Combine small blocks into larger ones. For example, if you have two - consecutive /24s, they might combine into a larger /23. - - * View the result of block combination in a useful way. - -Hath does just that. It takes as its input (via stdin, or a file with -the -i parameter) a list of CIDR blocks. From now on, assume we have -the following in cidrs.txt: - - 10.0.0.0/24 - 10.0.1.0/24 - - -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. - - $ hath -i cidrs.txt - ([^\.0-9](10)\.(0)\.(0)\.(0)[^\.0-9]|[^\.0-9](10)\.(0)\.(1) - \.(0)[^\.0-9]) - - * Reduced - - This combines small blocks into larger ones where possible, and - eliminates redundant blocks. The output should be equivalent to - the input, though. - - $ hath reduced -i cidrs.txt - 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. - - $ hath duped -i cidrs.txt - 10.0.0.0/24 - 10.0.1.0/24 - - * Diffed - - Shows what would change if you used reduce. Uses diff-like - notation. - - $ hath diffed -i cidrs.txt - -10.0.0.0/24 - -10.0.1.0/24 - +10.0.0.0/23 - -Each of the modes also supports a present-tense flavor; the following -are equivalent to their counterparts: regex, reduce, dupe, diff. - - -Bugs ----- - -Send bugs to the moon[2]. - - - -[1] http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing - -[2] michael@orlitzky.com diff --git a/doc/TODO b/doc/TODO deleted file mode 100644 index 3c6bbe1..0000000 --- a/doc/TODO +++ /dev/null @@ -1,3 +0,0 @@ -1. The use of parallel-io limits us to a number of threads equal to - the number of capabilities. This doesn't make much sense since the - DNS lookups aren't CPU-bound. diff --git a/doc/man1/hath.1 b/doc/man1/hath.1 index 6e4ef37..0316c56 100644 --- a/doc/man1/hath.1 +++ b/doc/man1/hath.1 @@ -4,7 +4,7 @@ hath \- Manipulate network blocks in CIDR notation .SH SYNOPSIS -\fBhath\fR [\fBregexed|reduced|duped|diffed|listed|reversed\fR] [\fB\-hb\fR] \fI\fR +\fBhath\fR [\fBregexed|reduced|duped|diffed|listed\fR] [\fB\-hb\fR] \fI\fR .SH INPUT .P The \fIinput\fR (stdin) should be a list of CIDR blocks, separated by @@ -25,8 +25,6 @@ consecutive /24s, they might combine into a larger /23. View the result of block combination in a useful way. .IP \(bu List them. -.IP \(bu -Find their associated PTR records. .P Hath does just that. It takes as its input (via stdin) a list of CIDR blocks. @@ -35,32 +33,32 @@ blocks. Hath has several modes: .IP \(bu 2 \fBRegexed\fR -.P + This computes a (Perl-compatible) regular expression matching the input CIDR blocks. It's the default mode of operation. -.P + .nf .I $ echo \(dq10.0.0.0/29 10.0.0.8/29\(dq | hath ((10)\.(0)\.(0)\.(15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0)) .fi .IP \(bu 2 \fBReduced\fR -.P + This combines small blocks into larger ones where possible, and eliminates redundant blocks. The output should be equivalent to the input, though. -.P + .nf .I $ echo \(dq10.0.0.0/24 10.0.1.0/24\(dq | hath reduced 10.0.0.0/23 .fi .IP \(bu 2 \fBDuped\fR -.P + 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. -.P + .nf .I $ echo \(dq10.0.0.0/24 10.0.1.0/24\(dq | hath duped 10.0.0.0/24 @@ -68,10 +66,10 @@ simply redundant. .fi .IP \(bu 2 \fBDiffed\fR -.P + Shows what would change if you used reduce. Uses diff-like notation. -.P + .nf .I $ echo \(dq10.0.0.0/24 10.0.1.0/24\(dq | hath diffed -10.0.0.0/24 @@ -80,9 +78,9 @@ notation. .fi .IP \(bu 2 \fBListed\fR -.P + List the IP addresses contained within the given CIDRs. -.P + .nf .I $ echo 192.168.0.240/29 | hath listed 192.168.0.240 @@ -94,42 +92,25 @@ List the IP addresses contained within the given CIDRs. 192.168.0.246 192.168.0.247 .fi -.IP \(bu 2 -\fBReversed\fR -.P -Perform reverse DNS (PTR) lookups on the IP addresses contained within -the given CIDRs. -.P -.nf -.I $ echo 198.41.0.4/30 | hath reversed -198.41.0.4: a.root-servers.net. -198.41.0.5: -198.41.0.6: rs.internic.net. -198.41.0.7: -.fi -.P -The DNS lookups are usually the bottleneck for this mode, but we can -perform them in parallel. Simply pass the number of threads to the GHC -runtime on the command line; for example, the following will perform -25 lookups in parallel: +.SH EXAMPLES .P +Use the \(dqdig\(dq command to look up the PTR records for a netblock: + .nf -.I $ echo 198.41.0.4/24 | hath reversed +RTS -N25 -198.41.0.4: a.root-servers.net. -198.41.0.5: -198.41.0.6: rs.internic.net. -\(pc\(pc\(pc +.I $ echo 198.41.0.4/30 | hath listed | xargs -I{} dig +noall +answer -x '{}' +4.0.41.198.in-addr.arpa. 897 IN PTR a.root-servers.net. +6.0.41.198.in-addr.arpa. 900 IN PTR rs.internic.net. .fi - .SH OPTIONS .IP \fB\-\-barriers\fR,\ \fB\-b\fR -(regexed mode only) place barriers in front/back of the regex to -prevent e.g. '127.0.0.1' from matching '127.0.0.100'. The downside is -that the resulting regexp will match something that is not an IP -address, and this messes up e.g. \fIgrep -o\fR. +(regexed mode only) + +Place barriers in front/back of the regex to prevent, for +example, '127.0.0.1' from matching '127.0.0.100'. The downside is that +the resulting regexp will match something that is not an IP address. +This can interfere with things like \fIgrep -o\fR. -.P Without \fB\-\-barriers\fR, you can match things you shouldn't: .nf @@ -137,20 +118,19 @@ Without \fB\-\-barriers\fR, you can match things you shouldn't: 127.0.0.100 .fi -.P Using \fB\-\-barriers\fR can prevent this: - .nf .I $ echo 127.0.0.100 | grep -P $(echo 127.0.0.1/32 | hath -b) .I $ echo $? 1 .fi -.P But, this may also cause the regex to match something that isn't an IP address: - .nf .I $ echo x127.0.0.1x | grep -Po $(echo 127.0.0.1/32 | hath -b) x127.0.0.1x .fi +.SH BUGS + +Send bugs to michael@orlitzky.com. diff --git a/hath.cabal b/hath.cabal index 89e779c..9bff315 100644 --- a/hath.cabal +++ b/hath.cabal @@ -1,17 +1,16 @@ name: hath -version: 0.2.4 +version: 0.3.0 cabal-version: >= 1.8 author: Michael Orlitzky maintainer: Michael Orlitzky homepage: http://michael.orlitzky.com/code/hath.php category: Utils -license: GPL-3 +license: AGPL-3 license-file: doc/LICENSE build-type: Simple extra-source-files: doc/man1/hath.1 test/shell/*.test - test/shell-net/*.test synopsis: Hath manipulates network blocks in CIDR notation. description: @@ -28,8 +27,6 @@ description: * View the result of block combination in a useful way. . * List them. - . - * Find their associated PTR records. . Hath has several modes to perform these functions: . @@ -53,10 +50,6 @@ description: . [@Listed@] List the IP addresses contained within the given CIDRs. - . - [@Reversed@] - Perform reverse DNS (PTR) lookups on the IP addresses contained - within the given CIDRs. . /Examples/: . @@ -89,29 +82,6 @@ description: 192.168.0.247 @ . - Perform PTR lookups on all of 198.41.0.4\/30: - . - @ - $ echo 198.41.0.4\/30 | hath reversed - 198.41.0.4: a.root-servers.net. - 198.41.0.5: - 198.41.0.6: rs.internic.net. - 198.41.0.7: - @ - . - The DNS lookups are usually the bottleneck for this mode, but we can - perform them in parallel. Simply pass the number of threads to the - GHC runtime on the command line; for example, the following will - perform 25 lookups in parallel: - . - @ - $ echo 198.41.0.4\/24 | hath reversed +RTS -N25 - 198.41.0.4: a.root-servers.net. - 198.41.0.5: - 198.41.0.6: rs.internic.net. - ... - @ - . The command-line syntax and complete set of options are documented in the man page. @@ -128,7 +98,6 @@ executable hath Bit Cidr CommandLine - DNS ExitCodes IPv4Address Maskable @@ -137,11 +106,8 @@ executable hath build-depends: base == 4.*, - bytestring >= 0.10, cmdargs >= 0.10, - dns >= 1.2, MissingH >= 1.2, - parallel-io >= 0.3, split >= 0.2, tasty >= 0.8, tasty-hunit >= 0.8, @@ -177,11 +143,8 @@ test-suite testsuite build-depends: base == 4.*, - bytestring >= 0.10, cmdargs >= 0.10, - dns >= 1.2, MissingH >= 1.2, - parallel-io >= 0.3, split >= 0.2, tasty >= 0.8, tasty-hunit >= 0.8, @@ -216,11 +179,8 @@ test-suite shelltests build-depends: base == 4.*, - bytestring >= 0.10, cmdargs >= 0.10, - dns >= 1.2, MissingH >= 1.2, - parallel-io >= 0.3, process >= 1.1, split >= 0.2, tasty >= 0.8, @@ -245,44 +205,6 @@ test-suite shelltests -optc-march=native -O2 - -test-suite shelltests-net - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: ShellTestsNet.hs - - build-depends: - base == 4.*, - bytestring >= 0.10, - cmdargs >= 0.10, - dns >= 1.2, - MissingH >= 1.2, - parallel-io >= 0.3, - process >= 1.1, - split >= 0.2, - tasty >= 0.8, - tasty-hunit >= 0.8, - tasty-quickcheck >= 0.8.1 - - -- It's not entirely clear to me why I have to reproduce all of this. - ghc-options: - -Wall - -fwarn-hi-shadowing - -fwarn-missing-signatures - -fwarn-name-shadowing - -fwarn-orphans - -fwarn-type-defaults - -fwarn-tabs - -fwarn-incomplete-record-updates - -fwarn-monomorphism-restriction - -fwarn-unused-do-bind - -rtsopts - -threaded - -optc-O3 - -optc-march=native - -O2 - - source-repository head type: git location: http://michael.orlitzky.com/git/hath.git diff --git a/src/CommandLine.hs b/src/CommandLine.hs index 789f76c..d0cf6f4 100644 --- a/src/CommandLine.hs +++ b/src/CommandLine.hs @@ -64,8 +64,7 @@ data Args = Reduced { barriers :: Bool } | Duped { barriers :: Bool } | Diffed { barriers :: Bool } | - Listed { barriers :: Bool } | - Reversed { barriers :: Bool } + Listed { barriers :: Bool } deriving (Data, Show, Typeable) -- | Description of the 'Regexed' mode. @@ -92,20 +91,13 @@ listed_description :: String listed_description = "Enumerate the IP addresses contained within the input CIDRs." --- | Description of the 'Reversed' mode. -reversed_description :: String -reversed_description = - "Perform a reverse DNS (PTR) lookup on each IP address " ++ - "contained within the input CIDRs." - - -- | We use explicit annotation here because if we use the magic -- annotation, we have to duplicate the same argument definitions six -- times. -- arg_spec :: Annotate Ann arg_spec = - modes_ [regexed += auto, reduced, duped, diffed, listed, reversed] + modes_ [regexed += auto, reduced, duped, diffed, listed] += program program_name += summary my_summary += helpArg [explicit, @@ -129,7 +121,6 @@ arg_spec = duped = make_mode Duped duped_description diffed = make_mode Diffed diffed_description listed = make_mode Listed listed_description - reversed = make_mode Reversed reversed_description -- | This is the public interface; i.e. what main() should use to get -- the command-line arguments. diff --git a/src/DNS.hs b/src/DNS.hs deleted file mode 100644 index a535de5..0000000 --- a/src/DNS.hs +++ /dev/null @@ -1,38 +0,0 @@ --- | Helpers to perform DNS queries. -module DNS ( - Domain, - PTRResult, - lookup_ptrs ) -where - -import Control.Concurrent.ParallelIO.Global ( parallel ) -import Network.DNS ( - Domain, - DNSError, - ResolvConf(..), - defaultResolvConf, - lookupRDNS, - makeResolvSeed, - withResolver ) - - --- The return type of lookupRDNS. -type PTRResult = Either DNSError [Domain] - - --- | Take the default ResolvConf and increase the timeout to 15 --- seconds. -our_resolv_conf :: ResolvConf -our_resolv_conf = - defaultResolvConf { resolvTimeout = 15*1000*1000 } -- 15s - - --- | Takes a list of IP addresses (as ByteStrings) and performs --- reverse (PTR) lookups on each of them. -lookup_ptrs :: [Domain] -> IO [PTRResult] -lookup_ptrs ips = do - rs <- makeResolvSeed our_resolv_conf - let lookup' addr = withResolver rs $ \resolver -> - lookupRDNS resolver addr - - parallel $ map lookup' ips diff --git a/src/Main.hs b/src/Main.hs index 2bb5869..5b75533 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,13 +1,10 @@ module Main where -import Control.Concurrent.ParallelIO.Global ( stopGlobalPool ) import Control.Monad (when) -import qualified Data.ByteString.Char8 as BS (intercalate, pack, unpack) import Data.List ((\\), intercalate) import Data.Maybe (catMaybes, isNothing) import Data.String.Utils (splitWs) -import Network.DNS.Types ( DNSError (NameError) ) import System.Exit (ExitCode(..), exitWith) import System.IO (stderr, hPutStrLn) import Text.Read (readMaybe) @@ -25,12 +22,12 @@ import Cidr ( min_octet3, min_octet4 ) import CommandLine (Args(..), get_args) -import DNS (Domain, PTRResult, lookup_ptrs) import ExitCodes ( exit_invalid_cidr ) import Octet () -- | A regular expression that matches a non-address character. +-- non_addr_char :: String non_addr_char = "[^\\.0-9]" @@ -38,6 +35,7 @@ non_addr_char = "[^\\.0-9]" -- | Add non_addr_chars on either side of the given String. This -- prevents (for example) the regex '127.0.0.1' from matching -- '127.0.0.100'. +-- add_barriers :: String -> String add_barriers x = non_addr_char ++ x ++ non_addr_char @@ -75,6 +73,7 @@ cidr_to_regex use_barriers cidr = -- | Take a list of Strings, and return a regular expression matching -- any of them. +-- alternate :: [String] -> String alternate terms = "(" ++ (intercalate "|" terms) ++ ")" @@ -142,25 +141,3 @@ main = do let combined_cidrs = combine_all valid_cidrs let addrs = concatMap enumerate combined_cidrs mapM_ print addrs - Reversed{} -> do - let combined_cidrs = combine_all valid_cidrs - let addrs = concatMap enumerate combined_cidrs - let addr_bytestrings = map (BS.pack . show) addrs - ptrs <- lookup_ptrs addr_bytestrings - let pairs = zip addr_bytestrings ptrs - mapM_ (putStrLn . show_pair) pairs - - stopGlobalPool - - where - show_pair :: (Domain, PTRResult) -> String - show_pair (s, eds) = - (BS.unpack s) ++ ": " ++ results - where - space = BS.pack " " - results = - case eds of - -- NameError simply means "not found" so we output nothing. - Left NameError -> "" - Left err -> "ERROR (" ++ (show err) ++ ")" - Right ds -> BS.unpack $ BS.intercalate space ds diff --git a/test/ShellTestsNet.hs b/test/ShellTestsNet.hs deleted file mode 100644 index 74acd73..0000000 --- a/test/ShellTestsNet.hs +++ /dev/null @@ -1,24 +0,0 @@ -module Main -where - -import System.Process ( - CreateProcess( env ), - createProcess, - shell, - waitForProcess ) -import System.Exit ( exitWith ) - -main :: IO () -main = do - -- Get a CreateProcess object corresponding to our shell command. - let createproc = shell "shelltest test/shell-net/*.test" - - -- But clear its environment before running the command. - let empty_env_createproc = createproc { env = Just [] } - - -- Ignore stdin/stdout/stderr... - (_,_,_,hproc) <- createProcess empty_env_createproc - - -- Now run the ProcessHandle and exit with its result. - result <- waitForProcess hproc - exitWith result diff --git a/test/TestSuite.hs b/test/TestSuite.hs index 7cd8d93..468afeb 100644 --- a/test/TestSuite.hs +++ b/test/TestSuite.hs @@ -13,7 +13,6 @@ tests = testGroup "All Tests" [ octet_properties, octet_tests ] --- TODO: Run 5000 generated tests, we have a large space. main :: IO () main = defaultMain $ diff --git a/test/shell-net/manpage-reversed.test b/test/shell-net/manpage-reversed.test deleted file mode 100644 index f1bb686..0000000 --- a/test/shell-net/manpage-reversed.test +++ /dev/null @@ -1,8 +0,0 @@ -# Test the regexed example from the man page. -echo 198.41.0.4/30 | dist/build/hath/hath reversed ->>> -198.41.0.4: a.root-servers.net. -198.41.0.5: -198.41.0.6: rs.internic.net. -198.41.0.7: ->>>= 0