├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── LICENSE
├── README.md
├── app
├── app.js
├── assets
│ └── icons
│ │ ├── check.svg
│ │ ├── exclamation-circle-fill.svg
│ │ └── question-circle.svg
├── dashboard.css
├── icon.ico
├── index.html
├── jquery.min.js
├── jquery.tabletojson.min.js
├── renderer.js
└── setup.js
├── main.js
├── package-lock.json
├── package.json
└── screenshots
├── main.png
└── runcheck.png
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: cjerrington
7 | ---
8 |
9 | **Describe the bug**
10 | A clear and concise description of what the bug is.
11 |
12 | **To Reproduce**
13 | Steps to reproduce the behavior:
14 |
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 |
28 | - OS: [e.g. iOS]
29 | - Browser [e.g. chrome, safari]
30 | - Version [e.g. 22]
31 |
32 | **Additional context**
33 | Add any other context about the problem here.
34 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: enhancement
6 | assignees: cjerrington
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 | app/urls.json
11 | .github/*
12 | out/
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # nyc test coverage
21 | .nyc_output
22 |
23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24 | .grunt
25 |
26 | # node-waf configuration
27 | .lock-wscript
28 |
29 | # Compiled binary addons (http://nodejs.org/api/addons.html)
30 | build/Release
31 | release-builds
32 | _site
33 | .jekyll-cache
34 | Gemfile.lock
35 |
36 | # Dependency directories
37 | node_modules
38 | jspm_packages
39 |
40 | # Optional npm cache directory
41 | .npm
42 |
43 | # Optional REPL history
44 | .node_repl_history
45 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Patrick Moffitt
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Network Status Check application written with Electron, Bootstrap, jQuery
2 |
3 | This is a tool to add URLs and ports to check to see if they are open or not. You can add as many items to the list, and edit the list as well if needed. You can save your list and eventually reimport the list as well on launch or by using the Load URLs button.
4 |
5 | Main Window
6 |
7 | 
8 |
9 | Run Check
10 |
11 | 
12 |
13 | ## Quick Code Tour
14 |
15 | - The code entry point is in **package.json** under the key "main". The value is "main.js"
16 | - **main.js** creates a BrowserWindow and loads **index.html**. It also has event handlers that enable keyboard shortcuts for Developer Tools on various platforms. Note that loadURL uses a [template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) to give the source file's location.`` `file://${__dirname}/app/index.html` ``
17 | - **index.html** loads Bootstrap's CSS in the <head> tag and **renderer.js** after the closing <body> tag. On the web Bootstrap's JavaScript would also load in this location but the Electron way is to load it in **renderer.js** with a require(). Note that these src and href attributes use normal relative paths. An HTTP server is not necessary.
18 | - **renderer.js** loads jQuery, Bootstrap and it's dependency; Tether. Each is assigned to the window object because this is the web application custom. It's not the Node.js or Electron custom because window is a global. For now we must do it this way or it won't work.
19 | - **setup.js** setups up some overall settings for the application
20 | - **app.js** is the real worker of functions.
21 |
22 | ## Releases
23 |
24 | At this time the releases are for Windows as that is my main developing platform and where I use this tool mostly; on Windows environments.
25 |
26 | [View Releases](https://github.com/cjerrington/net-check/releases/latest)
27 |
28 | ## Running Application
29 |
30 | First download and install dependencies, then start the app.
31 |
32 | ```bash
33 | git clone https://github.com/cjerrington/net-check.git
34 | cd net-check
35 | npm install
36 | npm start
37 | ```
38 |
39 | ## Creating Releases
40 |
41 | Electron Forge allows us to make builds based on our operating system we are running from. Linux (Debian) and Windows 10 tested.
42 |
43 | ```bash
44 | npm run make
45 | ```
46 |
47 | You can check websites like google.com, github.com, or any URL you need and the port. It is best to use the FQDN for local addresses or use the hostnames IP instead.
48 |
49 | Please let me know if you have any issues or questions. If you have a suggestion for approval create an issue or a pull request.
50 |
--------------------------------------------------------------------------------
/app/app.js:
--------------------------------------------------------------------------------
1 | // for file saving
2 | const fs = require('fs');
3 | const path = require('path');
4 | // for checking if ports are open
5 | var isPortReachable = require("is-port-reachable");
6 | var isReachable = require("is-reachable")
7 |
8 | $(document).ready(function() {
9 |
10 | $("#add_form").submit(function(e) {
11 | e.preventDefault();
12 | });
13 |
14 | $(".add-row").click(function(){
15 | var rowCount = $('#urltable tr').length;
16 | var url = $("#hostname").val();
17 | var port = $("#port").val();
18 | var markup = "
" + rowCount + "
" + url + "
" + port + "
";
19 |
20 | if((url.length !==0) || (port.length !==0)){
21 | $("table tbody").append(markup);
22 | }else{
23 | $("#invalidinput").modal('toggle')
24 | }
25 | });
26 |
27 | // Find and remove selected table rows
28 | $(".delete-row").click(function(){
29 | $("table tbody").find('input[name="record"]').each(function(){
30 | if($(this).is(":checked")){
31 | //remove row
32 | $(this).parents("tr").remove();
33 | }
34 | });
35 |
36 | // Reset the row counts.
37 | var i = 0;
38 | $("tr").find("td:first").each(function (i) {
39 | // For each TR find the first TD and replace it with the row count
40 | // We should have a small enough list updating the whole table
41 | // shouldn't be an issue instead of only modifying the ones that are after
42 | $(this).html(i + 1);
43 | });
44 | });
45 |
46 | // Save the table to a JSON file
47 | $('#convert-table').click( function(e) {
48 | e.preventDefault();
49 | // convert table to json
50 | var table = $('#urltable').tableToJSON();
51 | // log table to make sure we see if correctly.
52 | console.log('Output of current table: ')
53 | console.log(table);
54 | // create file
55 | var filepath = path.join(__dirname,"urls.json");
56 | // Open file for writing, will always overwrite the current file
57 | fs.open(filepath, 'w+', function(err, fd) {
58 | if (err) {
59 | throw 'error opening file: ' + err;
60 | }
61 |
62 | // writeFileSync does not return a value, need to be a try/catch
63 | try {
64 | fs.writeFileSync(filepath, JSON.stringify(table, null, 2) , 'utf-8', (err) => {
65 | if (err) throw err
66 | });
67 | console.log('The file has been saved to: ' + filepath);
68 | $('.savefile').html(filepath);
69 | $("#saveurlsModalCenter").modal('toggle');
70 | } catch (err) {
71 | console.log(err);
72 | }
73 | });
74 | });
75 |
76 | // Run checks for each row in the html table
77 | var successState = ``;
78 | var failState = ``;
79 | var unknownState = ``;
80 |
81 | $('#runcheck').click(function(e){
82 | // For each row run the checks
83 | $('#urltable > tbody > tr').each(function() {
84 | // Get hostname and port
85 | var myDomain = $(this).closest('tr').find('td:eq(2)').text();
86 | var myPort = $(this).closest('tr').find('td:eq(3)').text();
87 | //console.log(myDomain+":"+myPort);
88 |
89 | (async () => {
90 | // Check if domain is valid first
91 | valid = await isReachable(myDomain);
92 | if(valid == true){
93 | console.log(myDomain + " exists");
94 | // Start the check for the port
95 | (async () => {
96 | // use the hostname and port from the table.
97 | var cmd = await isPortReachable(myPort, {host: myDomain});
98 | if(cmd == true){
99 | // if port works, send to console
100 | console.log(myDomain+":"+myPort+" is open.");
101 | // and set the staus to success
102 | $(this).closest('tr').find('td:eq(4)').html(successState);
103 | }
104 | else{
105 | // if port is not open, send to console
106 | console.log(myDomain+":"+myPort+" is closed.");
107 | // and set the status to failed
108 | $(this).closest('tr').find('td:eq(4)').html(failState);
109 | }
110 | //=> true
111 | })();
112 | }else{
113 | console.log(myDomain + " is not reachable")
114 | $(this).closest('tr').find('td:eq(4)').html(failState);
115 | }
116 | })();
117 |
118 | // Start the check old way
119 | /* (async () => {
120 | // use the hostname and port from the table.
121 | var cmd = await isPortReachable(port, {host: hostname});
122 | if(cmd == true){
123 | // if port works, send to console
124 | console.log(hostname+":"+port+" is open.");
125 | // and set the staus to success
126 | $(this).closest('tr').find('td:eq(4)').html(successState);
127 | }
128 | else{
129 | // if port is not open, send to console
130 | console.log(hostname+":"+port+" is closed.");
131 | // and set the status to failed
132 | $(this).closest('tr').find('td:eq(4)').html(failState);
133 | }
134 | //=> true
135 | })(); */
136 | });
137 | });
138 |
139 | // Open Load URLs modal
140 | $("#load-urls").click(function(e){
141 | e.preventDefault();
142 | $("#loadurlsModalCenter").modal('toggle');
143 | });
144 |
145 | // Create table from JSON
146 |
147 | //implementation
148 | //https://stackoverflow.com/questions/12694135/how-to-append-json-array-data-to-html-table-tbody/31810319#31810319
149 | function jsonToHtmlTable(jsonObj, selector) {
150 | addColumns(jsonObj, selector);
151 | addRows(jsonObj, selector);
152 | }
153 |
154 | function addColumns(jsonObj, selector) {
155 | if (!$.isArray(jsonObj) || jsonObj.length < 1)
156 | return;
157 | var object = jsonObj[0];
158 | var theadHtml = "";
159 | for (var property in object) {
160 | if (object.hasOwnProperty(property))
161 | theadHtml += "