Last active
August 29, 2015 14:24
-
-
Save mattburch/95d2157b06dd7fef5bb2 to your computer and use it in GitHub Desktop.
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
var deliverableUniquePortSummary = function(protocol) { | |
// Generates a of reports for deliverable template | |
// Usages: deliverableUniquePortSummary() | |
// Created by: Matt Burch | |
// Requires client-side updates: false | |
var PROJECT_ID = Session.get('projectId'); | |
var unique = {}; | |
function checkservice(list, p) { | |
for (i=0; i<list.length; i++) { | |
if (list[i] == p) { | |
return true; | |
} | |
}; | |
return false; | |
}; | |
var ports = Ports.find({'project_id' : PROJECT_ID}).fetch() | |
ports.forEach( function(port) { | |
service = port.service.toUpperCase() + "_" + port.protocol.toUpperCase(); | |
if (port.port == 0){ | |
return; | |
} | |
if (!(port.service)) { | |
port.service = "unknown" | |
} | |
if (!(service in unique)) { | |
unique[service] = [port.port] | |
} | |
else { | |
if (!checkservice(unique[service], port.port)) { | |
unique[service].push(port.port); | |
} | |
} | |
}); | |
for (key in unique) { | |
port = key.split("_"); | |
if (unique[key].length > 1) { | |
console.log(port[0] + " (VARIOUS/" + port[1] + ")"); | |
} | |
else { | |
console.log(port[0] + " (" + unique[key] + "/" + port[1] + ")"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment