@kyle.dev/check-host
v1.0.0-7KPI
Published
`check-host` is a Node.js package that provides an API interface for interacting with Check-Host.net. This package allows you to perform various types of checks (such as HTTP, Ping, TCP, DNS) and use available nodes for testing.
Downloads
4
Readme
Check-Host
check-host
is a Node.js package that provides an API interface for interacting with Check-Host.net. This package allows you to perform various types of checks (such as HTTP, Ping, TCP, DNS) and use available nodes for testing.
Installation
You can install the package using npm:
npm install check-host
Usage
Import Classes
const { CheckHost, CheckContent } = require('check-host');
Setting Up CheckHost
Create an instance of
CheckHost
:const CH = new CheckHost();
Load the list of nodes:
CH.loadNodes().then(() => { /* Set the URL to check and choose the desired check type */ CH.SetUrl('google.com:443'); /* Start the check using TcpCheck with specified nodes */ CH.SCAN(CheckContent.TcpCheck, (results) => { console.log('Done Scan results:'); console.log(results); }); });
Available Checks
1. HTTP Check
Example:
CH.SCAN(CheckContent.HttpCheck, (results) => {
console.log('Done Scan results:');
console.log(results);
});
2. Ping Check
Example:
CH.SCAN(CheckContent.PingCheck, (results) => {
console.log('Done Scan results:');
console.log(results);
});
3. TCP Check
Example:
CH.SCAN(CheckContent.TcpCheck, (results) => {
console.log('Done Scan results:');
console.log(results);
});
4. DNS Check
Example:
CH.SCAN(CheckContent.DnsCheck, (results) => {
console.log('Done Scan results:');
console.log(results);
});
Available Check Functions
HttpCheck(url, nodes)
: HTTP check for the specified URL with the given nodes.PingCheck(host, nodes)
: Ping check for the specified host with the given nodes.TcpCheck(host, nodes)
: TCP check for the specified host with the given nodes.DnsCheck(host, nodes)
: DNS check for the specified host with the given nodes.
Setting the URL
Example:
CH.SetUrl('https://npmjs.com');
Check Results
The results will be displayed in a formatted manner based on the type of check performed.
Node List
You can load the list of available nodes using the loadNodes()
method in CheckHost
. This list is used to specify which nodes you want to use for the checks.
Example:
CH.loadNodes().then(() => {
console.log('Nodes loaded:', CH.nodes);
});