Crates.io | connchk |
lib.rs | connchk |
version | 0.9.2 |
source | src |
created_at | 2020-10-20 15:01:06.408152 |
updated_at | 2024-04-14 15:40:21.31117 |
description | Cross-platform command-line network checking tool in Rust |
homepage | https://github.com/anthonyjmartinez/connchk |
repository | https://github.com/anthonyjmartinez/connchk.git |
max_upload_size | |
id | 303520 |
size | 57,409 |
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:
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.
To get connchk
run cargo install connchk
on a system with Cargo installed.
# example.toml
[[target]]
kind = "Tcp"
desc = "GitLab SSH"
addr = "gitlab.com:22"
[[target]]
kind = "Tcp"
desc = "Freenode IRC"
addr = "irc.freenode.net:6667"
[[target]]
kind = "Tcp"
desc = "httpbin IP endpoint"
addr = "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
[[target]]
kind = "Http"
desc = "httpbin POST endpoint (form)"
addr = "https://httpbin.org/status/undefined"
custom = { params = { someKey = "SpecialValue" }, ok = 400 }
# Posts as JSON and reports success if the status code returned is 400
# as it will be for this particular endpoint
[[target]]
kind = "Http"
desc = "httpbin JSON endpoint"
addr = "https://httpbin.org/status/400"
custom = { json = { someKey = "SpecialValue" }, ok = 400 }
# An example failure - this endpoing will return a 502 status code,
# but our configuration expects a 400
[[target]]
kind = "Http"
desc = "httpbin JSON endpoint - Error"
addr = "https://httpbin.org/status/502"
custom = { json = { someKey = [3, "AnotherValue", false], anotherKey = { nested = "value", count = [1, 2, 3] } }, ok = 400 }
$ ./connchk example.toml
Successfully connected to GitLab SSH in 72ms
Successfully connected to Freenode IRC in 176ms
Successfully connected to httpbin IP endpoint in 648ms
Successfully connected to httpbin POST endpoint (form) in 666ms
Successfully connected to httpbin JSON endpoint in 647ms
Failed to connect to httpbin JSON endpoint - Error with:
Status: 502
Details:
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.
clap
v4.x.clap
v3.x.TcpResource
and HttpResource
structs differentiating individual Resource
kinds with the ResType
enumResource.kind
to hold ResType
variantsNetworkResources
to hold Vec<Resources>
in NetworkResources.target
[[http]]
or [[tcp]]
lines with [[target]]
kind = "Http"
to any block that previously stared with [[http]]
kind = "Tcp"
to any block that previously stared with [[tcp]]
Resource
struct to map TcpResource
and HttpResources
onto for consumption by par_iter()
by rayon
rayon
to support parallel connection executionreqwest
features to move the package to use of rustls
instead of native-tls
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Copyright (C) 2020-2024 Anthony Martinez