Skip to content

Commit 63a06fe

Browse files
committed
Merge branch 'master' into next
2 parents a1005e8 + aa2221f commit 63a06fe

File tree

2 files changed

+71
-29
lines changed

2 files changed

+71
-29
lines changed

CHANGELOG.md

+31-26
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,55 @@
22

33
**Fixes**
44

5-
* [crashes] improved type check
6-
* [ui] fixed "Email value too long" issue.
7-
* [slipping-away-users] fix style issue
8-
* [crashes] fix escaping in crash error and stacktrace
9-
* [events] updated compare_arrays function for events to have more checks if both passed are arrays
10-
* [install] fix permission issue
11-
* [systemlogs] fixed system logs plugin table sorting issue
12-
* [push] Fix for upload of APN credentials from windows / no mime-aware systems
13-
* [config] fixes for relative path changes
14-
* [db]fixed replacement of db name in mongodb connection string
15-
* [push] Fix for race condition in message status updates
16-
* [frontend] fix title if not available
17-
* [data-migration] log redirect url in logger
18-
* [logger] improve info column formatting
19-
* [ui] drop down fix
20-
* [api] deeper escaping of objects
21-
* [api] more error checks and handling
5+
* [api] added support for ports and brackets in ip addresses
6+
* [api] added support for partial ip address as masks in ignoreProxy config
227
* [api] check correctly for finished none http requests
8+
* [api] deeper escaping of objects
239
* [api] fixes for handling unparsable period
10+
* [api] more error checks and handling
2411
* [api] regular expression checks
25-
* [security] more cross site scripting preventions
26-
* [populator] fixed campaign session issue for web apps in populator
27-
* [nginx] remove server flag
12+
* [appmanagement] load configuration on new app(on new server)
13+
* [config] fixes for relative path changes
14+
* [crashes] fix escaping in crash error and stacktrace
15+
* [crashes] improve search index
16+
* [crashes] improved type check
17+
* [data-migration] log redirect url in logger
18+
* [db]fixed replacement of db name in mongodb connection string
19+
* [events] updated compare_arrays function for events to have more checks if both passed are arrays
2820
* [feedback] device_id fix and script for correcting data
29-
* [frontend] fix not using data on init for today period
3021
* [frontend] correctly genersate ticks for month buckets
31-
* [appmanagement] load configuration on new app(on new server)
22+
* [frontend] fix not using data on init for today period
23+
* [frontend] fix title if not available
24+
* [install] fix permission issue
25+
* [logger] improve info column formatting
26+
* [nginx] remove server flag
27+
* [populator] fixed campaign session issue for web apps in populator
3228
* [push] Deny APN app settings update if no file is selected
29+
* [push] Fix for race condition in message status updates
30+
* [push] Fix for upload of APN credentials from windows / no mime-aware systems
31+
* [security] more cross site scripting preventions
32+
* [slipping-away-users] fix style issue
33+
* [systemlogs] fixed system logs plugin table sorting issue
34+
* [ui] drop down fix
35+
* [ui] fixed "Email value too long" issue.
36+
3337

3438
**Enterprise fixes**
3539

36-
* [push] Approver update
3740
* [drill] correctly check projection key result type
3841
* [drill] fix filter render bug
39-
* [revenue] use user estimation correction
4042
* [drill] fix switching bucket UI
43+
* [push] Approver update
44+
* [recaptcha] scroll fix on login screen
45+
* [revenue] use user estimation correction
4146

4247
**New Features**
4348
* [api] support for multiple errors message
49+
* [server-stats] display datapoints for admins and users too
4450

4551
**New Enterprise Features**
46-
* [drill] added no_map param to display plain country data
4752
* [dashboard] disabling sharing dashboards
48-
53+
* [drill] added no_map param to display plain country data
4954

5055
## Version 18.08.1
5156

api/utils/common.js

+40-3
Original file line numberDiff line numberDiff line change
@@ -1134,20 +1134,57 @@ common.getIpAddress = function(req) {
11341134
//if ignoreProxies not setup, use outmost left ip address
11351135
if (!countlyConfig.ignoreProxies || !countlyConfig.ignoreProxies.length) {
11361136
ipLogger.d("From %s found ip %s", ipAddress, ips[0]);
1137-
return ips[0];
1137+
return stripPort(ips[0]);
11381138
}
11391139
//search for the outmost right ip address ignoring provided proxies
11401140
var ip = "";
11411141
for (var i = ips.length - 1; i >= 0; i--) {
1142-
if (ips[i].trim() !== "127.0.0.1" && (!countlyConfig.ignoreProxies || countlyConfig.ignoreProxies.indexOf(ips[i].trim()) === -1)) {
1143-
ip = ips[i].trim();
1142+
ips[i] = stripPort(ips[i]);
1143+
var masks = false;
1144+
if (countlyConfig.ignoreProxies && countlyConfig.ignoreProxies.length) {
1145+
masks = countlyConfig.ignoreProxies.some(function(elem) {
1146+
return ips[i].startsWith(elem);
1147+
});
1148+
}
1149+
if (ips[i] !== "127.0.0.1" && (!countlyConfig.ignoreProxies || !masks)) {
1150+
ip = ips[i];
11441151
break;
11451152
}
11461153
}
11471154
ipLogger.d("From %s found ip %s", ipAddress, ip);
11481155
return ip;
11491156
};
11501157

1158+
/**
1159+
* This function takes ipv4 or ipv6 with possible port, removes port information and returns plain ip address
1160+
* @param {string} ip - ip address to check for port and return plain ip
1161+
* @returns {string} plain ip address
1162+
*/
1163+
function stripPort(ip) {
1164+
var parts = (ip + "").split(".");
1165+
//check if ipv4
1166+
if (parts.length === 4) {
1167+
return ip.split(":")[0].trim();
1168+
}
1169+
else {
1170+
parts = (ip + "").split(":");
1171+
if (parts.length === 9) {
1172+
parts.pop();
1173+
}
1174+
if (parts.length === 8) {
1175+
ip = parts.join(":");
1176+
//remove enclosing [] for ipv6 if they are there
1177+
if (ip[0] === "[") {
1178+
ip = ip.substring(1);
1179+
}
1180+
if (ip[ip.length - 1] === "]") {
1181+
ip = ip.slice(0, -1);
1182+
}
1183+
}
1184+
}
1185+
return (ip + "").trim();
1186+
}
1187+
11511188
/**
11521189
* Modifies provided object filling properties used in zero documents in the format object["2012.7.20.property"] = increment.
11531190
* Usualy used when filling up Countly metric model zero document

0 commit comments

Comments
 (0)