UNPKG

3.52 kBMarkdownView Raw
1#network-diagnostics
2Network-diagnostics provides a library for diagnosing network problems.
3
4This module, network-diagnostics , is published under the MIT license. It is written by Nate Watson and Oluwafunmiwo Juda Sholola. Copyright 2015.
5
6## Installation Instructions
7
8### Local Installation
9
100. Goto the directory that the module is requred in: "cd *directory*".
11
121. Run this instruction:
13
14```
15npm install network-diagnostics
16```
17
182. Verify the installation
19
20### Global Installation
21
220. Ensure you have the right to perform global module installations.
23
241. Run this instruction:
25
26```
27npm install -g network-diagnostics
28```
29
302. Verify the installation
31
32### Installation Verification
33
340. Navigate to the directory of installation.
35
361. Run this instruction:
37
38```
39node diagnosticsTester.js
40```
41
422. It should print an array of numbers and a list of strings. If it does this, the installation ran smoothly. If this does not happen, reinstall.
43
44## Example
45
46```
47var diagnostics = require("./diagnostics");
48var diagnoseProcedure = diagnostics.diagnose(function(result){
49 console.dir(result);
50 for (var index = 0; index< result.length; index++) {
51 console.log(diagnostics.getError(result[index]));
52 }
53});
54```
55
56## Features
57
58network-diagnostics provides the following features:
59
60* Individual tests for several specific network problems, such as a lack of IPv6.
61* A consolidated method which performs the most common tests, and gives an array of error codes.
62* A method that takes an error code, and returns what it means.
63
64## Individual Tests
65### TestURL
66
67network-diagnostics provides two functions for changing the URL that HTTP is tested with. By default, the URL that is used for network tests is "google.com".
68
69```
70var result = diagnostics.getTestURL(); /*result would be "google.com"*/
71```
72
73```
74diagnostics.setTestURL("yahoo.com");
75```
76
77### diagnostics.haveIPv4
78This function returns a boolean value which states if an IPv4 connection is usable, not counting the one for localhost.
79```
80if (diagnostics.haveIPv4() == false) {
81 console.log("We have a problem.");
82}
83```
84
85### diagnostics.haveIPv6
86This function returns a boolean value which states if an IPv6 connection is usable, not counting the one for localhost.
87```
88if (diagnostics.haveIPv6() == false) {
89 console.log("We have a bad network.");
90}
91```
92
93### diagnostics.haveConnection
94This function returns a boolean value which states if an IP connection of any type is usable, not counting the one for localhost.
95```
96if (diagnostics.haveConnection() == false) {
97 console.log("This is all there is. The outside world is a myth.");
98}
99```
100
101### diagnostics.haveDNS
102This function returns a boolean value which states if it's possible to perform non-cached DNS lookups.
103```
104if (diagnostics.haveDNS() == false) {
105 console.log("Start memorizing numbers. DNS isn't working.");
106}
107```
108
109### diagnostics.haveHTTP
110This function returns a boolean value which states if it's possible to perform non-cached HTTP requests.
111```
112if (diagnostics.haveHTTP() == false) {
113 console.log("Don't worry, stackoverflow uses https, not http.");
114}
115```
116
117### diagnostics.haveHTTPS
118This function returns a boolean value which states if it's possible to perform non-cached HTTP requests.
119```
120if (diagnostics.haveHTTPS() == false) {
121 console.log("Uh oh. Without HTTPS, we can't get to stackoverflow to solve the problem we just found!");
122}
123```
124
125##Standardized Test
126##Error Code Lookups