connchk
About
connchk is command-line network verification utility written in Rust. It aims
to provide a cross platform utility that can verify if your host can reach
targets defined in a TOML document. These hosts are checked in the following
ways:
- For plain TCP hosts, a TcpStream is opened or the relevant error is returned
- For HTTP(S) hosts either
- A basic check declares success if a status code of 200 is returned
- A custom check declares success based on a user-defined status code for POSTs of given
- Form encoded data, or
- JSON body
- In either case errors are returned to the user
The application expects exactly one argument which is the TOML document defining target hosts.
Starting in version 0.5.0, it is also possible to use connchk as a Rust library.
Documentation is available here.
Install
To get connchk run cargo install connchk on a system with Cargo installed.
Example TOML Config
# example.toml
[[]]
= "GitLab SSH"
= "gitlab.com:22"
[[]]
= "Freenode IRC"
= "irc.freenode.net:6667"
[[]]
= "httpbin IP endpoint"
= "https://httpbin.org/ip"
# Posts as a form and reports success if the status code returned is 400
# which it will be for this bad request to this particular endpoint
[[]]
= "httpbin POST endpoint (form)"
= "https://httpbin.org/status/undefined"
= { = { = "SpecialValue" }, = 400 }
# Posts as JSON and reports success if the status code returned is 400
# as it will be for this particular endpoint
[[]]
= "httpbin JSON endpoint"
= "https://httpbin.org/status/400"
= { = { = "SpecialValue" }, = 400 }
# An example failure - this endpoint will return a 502 status code,
# but our configuration expects a 400
[[]]
= "httpbin JSON endpoint - Error"
= "https://httpbin.org/status/502"
= { = { = [3, "AnotherValue", false], = { = "value", = [1, 2, 3] } }, = 400 }
Example Usage
$ ./connchk example.toml
Successfully connected to GitLab SSH
Successfully connected to Freenode IRC
Successfully connected to httpbin POST endpoint (form)
Successfully connected to httpbin IP endpoint
Successfully connected to httpbin JSON endpoint
Failed to connect to httpbin JSON endpoint - Error with:
Status: 502
Details:
JSON Bodies
The TOML structure of the configuration file maps on to JSON cleanly. Defining
JSON bodies should be as easy as custom = { json = <Your JSON Here> }. While
this was tested to a reasonable degree it's unlikely that every single possibility
has been explored, so if issues are encountered please let it be known.
Major Changes
- v0.5.0
- Refactored to produce both binary and library crates
- Created a common
Resourcestruct to mapTcpResourceandHttpResourcesonto for consumption bypar_iter()byrayon - The order in which success or failure messages are displayed may not be consistent with the order of definition in the TOML input file
- v0.4.0
- Adds use of
rayonto support parallel connection execution
- Adds use of
- v0.3.0
- Adds support for JSON post bodies.
- Removes declaration of a "bad" status code. Custom tests define only the expected good status code.
- v0.2.1 fixes error handling such that testing does not abort with the first failure
- v0.2.0 disabled the default
reqwestfeatures to move the package to use ofrustlsinstead ofnative-tls
License
This project uses GPL-3.0+.
Copyright (C) 2020-2021 Anthony Martinez