forked from lair-framework/browser-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_url_list.js
44 lines (43 loc) · 1.27 KB
/
generate_url_list.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var generateURLList = function () {
// Generate a list of URLs for all http(s) services in the current project
//
// Created by: Dan Kottmann
// Usage: generateURLList();
// Requires client-side updates: false
var projectId = Session.get('projectId');
var q = {
'project_id': projectId
};
var hosts = Hosts.find(q).fetch();
if (!hosts) {
console.log('No hosts found');
return;
}
var c = 0;
hosts.forEach(function (host) {
var names = host.hostnames;
var hostId = host._id;
var query = {
'project_id': projectId,
'host_id': hostId
};
query.service = {
'$regex': 'web|www|ssl|http|https',
'$options': 'i'
};
var ports = Ports.find(query).fetch();
ports.forEach(function (port) {
var protocol = 'http://';
if (port.service.match(/(ssl|https)/g)) {
protocol = 'https://';
}
c++;
console.log(protocol + host.string_addr + ':' + port.port);
names.forEach(function (n) {
c++;
console.log(protocol + n + ':' + port.port);
});
});
});
console.log(c + ' URL(s) generated');
};