File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,13 @@ function validateUserForMgmtReadAPI(callback, params) {
117
117
} ) ;
118
118
}
119
119
120
+ function getIpAddress ( req ) {
121
+ var ipAddress = req . headers [ 'x-forwarded-for' ] || req . connection . remoteAddress || req . socket . remoteAddress || req . connection . socket . remoteAddress ;
122
+
123
+ /* Since x-forwarded-for: client, proxy1, proxy2, proxy3 */
124
+ return ipAddress . split ( ',' ) [ 0 ] ;
125
+ }
126
+
120
127
if ( cluster . isMaster ) {
121
128
122
129
var workerCount = ( common . config . api . workers ) ? common . config . api . workers : os . cpus ( ) . length ;
@@ -297,9 +304,7 @@ if (cluster.isMaster) {
297
304
}
298
305
case '/i' :
299
306
{
300
- var ipAddress = req . headers [ 'x-forwarded-for' ] || req . connection . remoteAddress ;
301
-
302
- params . ip_address = params . qstring . ip_address || ipAddress . split ( "," ) [ 0 ] ;
307
+ params . ip_address = getIpAddress ( req ) ;
303
308
params . user = {
304
309
'country' :'Unknown' ,
305
310
'city' :'Unknown'
You can’t perform that action at this time.
0 commit comments