Skip to content

Commit 29a4eaf

Browse files
committed
[settings] setting to control protocol for internal localhost calls
1 parent 02afbba commit 29a4eaf

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

api/jobs/ping.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PingJob extends job.Job {
1515
* @param {done} done callback
1616
*/
1717
run(db, done) {
18-
request({strictSSL: false, uri: "http://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + "/configs"}, function() {});
18+
request({strictSSL: false, uri: (process.env.COUNTLY_CONFIG_PROTOCOL || "http") + "://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + "/configs"}, function() {});
1919
var countlyConfigOrig = JSON.parse(JSON.stringify(countlyConfig));
2020
var url = "https://count.ly/configurations/ce/tracking";
2121
if (versionInfo.type !== "777a2bf527a18e0fffe22fb5b3e322e68d9c07a6") {

api/utils/render.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ exports.renderView = function(options, cb) {
9292
log.d("Headless chrome page failed request", request.failure().errorText, request.url());
9393
});
9494

95-
var host = "http://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + countlyConfig.path;
95+
var host = (process.env.COUNTLY_CONFIG_PROTOCOL || "http") + "://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + countlyConfig.path;
9696

9797
if (options.host) {
9898
host = options.host + countlyConfig.path;

api/utils/taskmanager.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ taskmanager.longtask = function(options) {
8080
delete json.api_key;
8181

8282
options.request = {
83-
uri: "http://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + options.params.fullPath,
83+
uri: (process.env.COUNTLY_CONFIG_PROTOCOL || "http") + "://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + options.params.fullPath,
8484
method: 'POST',
8585
json: json
8686
};
@@ -500,7 +500,7 @@ taskmanager.checkIfRunning = function(options, callback) {
500500
//delete jquery param to prevent caching
501501
delete json._;
502502
query.request = {
503-
uri: "http://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + options.params.fullPath,
503+
uri: (process.env.COUNTLY_CONFIG_PROTOCOL || "http") + "://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + options.params.fullPath,
504504
method: 'POST',
505505
json: json
506506
};

bin/commands/scripts/api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ function output(err, body, pretty) {
1818
}
1919

2020
if (myArgs[0] == "pretty") {
21-
request({strictSSL: false, uri: 'http://localhost' + (countlyConfig.path || "") + myArgs[1]}, function(error, response, body) {
21+
request({strictSSL: false, uri: (process.env.COUNTLY_CONFIG_PROTOCOL || "http") + "://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + myArgs[1]}, function(error, response, body) {
2222
output(error, body, true);
2323
});
2424
}
2525
else {
26-
request({strictSSL: false, uri: 'http://localhost' + myArgs[0]}, function(error, response, body) {
26+
request({strictSSL: false, uri: (process.env.COUNTLY_CONFIG_PROTOCOL || "http") + "://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + myArgs[0]}, function(error, response, body) {
2727
output(error, body);
2828
});
2929
}

plugins/systemlogs/scripts/export.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ else {
4141
output.push(moment.unix(doc.ts).format("YYYY/MM/DD HH:mm:ss"));
4242
output.push(doc.user_id + (doc.u ? " (" + doc.u + ")" : ""));
4343
output.push(doc.ip);
44-
output.push(doc.app_id || plugins.getConfig("api").domain || "localhost");
44+
output.push(doc.app_id || plugins.getConfig("api").domain || process.env.COUNTLY_CONFIG_HOSTNAME || "localhost");
4545
if (loginActions.indexOf(doc.a) !== -1) {
4646
console.log("Time stamp | User ID | Login device IP or Hostname | Application/Service/Server Name | Result");
4747
output.push(properties["systemlogs.action." + doc.a] || doc.a);

plugins/web/frontend/app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var exported = {},
1818
}
1919
app.get(countlyConfig.path + '/pixel.png', function(req, res) {
2020
if (req.query.app_key) {
21-
var options = {uri: "http://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + "/i", method: "POST", timeout: 4E3, json: {}, strictSSL: false};
21+
var options = {uri: (process.env.COUNTLY_CONFIG_PROTOCOL || "http") + "://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "") + "/i", method: "POST", timeout: 4E3, json: {}, strictSSL: false};
2222
if (req && req.headers && req.headers['user-agent']) {
2323
options.headers = {'user-agent': req.headers['user-agent']};
2424
}

test/testUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var testUtils = function testUtils() {
3434
};
3535
var RE = /^-{0,1}\d*\.{0,1}\d+$/;
3636

37-
this.url = "http://localhost" + (countlyConfig.path || "");
37+
this.url = (process.env.COUNTLY_CONFIG_PROTOCOL || "http") + "://" + (process.env.COUNTLY_CONFIG_HOSTNAME || "localhost") + (countlyConfig.path || "");
3838
this.name = "Test Test";
3939
this.username = "test";
4040
this.password = "Test1test$";

0 commit comments

Comments
 (0)