-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement JavaScript Standard Style Guide
- Loading branch information
1 parent
1bf0d6c
commit 0beeca8
Showing
6 changed files
with
139 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"extends": "standard"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
var http = require('http') | ||
, portscanner = require('../lib/portscanner.js') | ||
var http = require('http') | ||
var portscanner = require('../lib/portscanner.js') | ||
|
||
// Sets up an HTTP server listening on port 3005 | ||
var server = http.createServer(function (request, response) { | ||
}) | ||
|
||
server.listen(3005, '127.0.0.1', function() { | ||
server.listen(3005, '127.0.0.1', function () { | ||
// Checks the status of an individual port. | ||
portscanner.checkPortStatus(3005, '127.0.0.1', function(error, status) { | ||
portscanner.checkPortStatus(3005, '127.0.0.1', function (error, status) { | ||
// Status should be 'open' since the HTTP server is listening on that port | ||
console.log('Status at port 3005 is ' + status) | ||
if (error) console.error(error); | ||
if (error) console.error(error) | ||
}) | ||
portscanner.checkPortStatus(3000, '127.0.0.1', function(error, status) { | ||
portscanner.checkPortStatus(3000, '127.0.0.1', function (error, status) { | ||
// Status should be 'closed' since no service is listening on that port. | ||
console.log('Status at port 3000 is ' + status) | ||
if (error) console.error(error); | ||
if (error) console.error(error) | ||
}) | ||
|
||
// Finds a port that a service is listening on | ||
portscanner.findAPortInUse(3000, 3010, '127.0.0.1', function(error, port) { | ||
portscanner.findAPortInUse(3000, 3010, '127.0.0.1', function (error, port) { | ||
// Port should be 3005 as the HTTP server is listening on that port | ||
console.log('Found an open port at ' + port) | ||
if (error) console.error(error); | ||
if (error) console.error(error) | ||
}) | ||
// Finds a port no service is listening on | ||
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', function(error, port) { | ||
portscanner.findAPortNotInUse(3000, 3010, '127.0.0.1', function (error, port) { | ||
// Will return any number between 3000 and 3010 (inclusive), that's not 3005. | ||
// The order is unknown as the port status checks are asynchronous. | ||
console.log('Found a closed port at ' + port) | ||
if (error) console.error(error); | ||
if (error) console.error(error) | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.