Fix IP tracking
This commit is contained in:
parent
8063862d4c
commit
26c02ff74d
@ -93,6 +93,9 @@ function textRequestHandler(req, res, number, region, key) {
|
|||||||
if (!ip || ip === '127.0.0.1') {
|
if (!ip || ip === '127.0.0.1') {
|
||||||
ip = req.header('X-Real-IP');
|
ip = req.header('X-Real-IP');
|
||||||
}
|
}
|
||||||
|
if (req.header('CF-Connecting-IP')) {
|
||||||
|
ip = req.header('CF-Connecting-IP');
|
||||||
|
}
|
||||||
|
|
||||||
var authbox_details = {
|
var authbox_details = {
|
||||||
$actionName: 'text',
|
$actionName: 'text',
|
||||||
@ -100,7 +103,7 @@ function textRequestHandler(req, res, number, region, key) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!number || !req.body.message) {
|
if (!number || !req.body.message) {
|
||||||
mpq.track('incomplete request');
|
mpq.track('incomplete request', {ip: ip, ip2: ip});
|
||||||
authbox.log(req, _.extend(authbox_details, {$failureReason: 'incomplete_request'}));
|
authbox.log(req, _.extend(authbox_details, {$failureReason: 'incomplete_request'}));
|
||||||
res.send({success:false, message:'Number and message parameters are required.'});
|
res.send({success:false, message:'Number and message parameters are required.'});
|
||||||
return;
|
return;
|
||||||
@ -121,19 +124,20 @@ function textRequestHandler(req, res, number, region, key) {
|
|||||||
message__text: message
|
message__text: message
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var tracking_details = {
|
||||||
|
number: number,
|
||||||
|
message: req.body.message,
|
||||||
|
ip: ip,
|
||||||
|
ip2: ip
|
||||||
|
};
|
||||||
|
|
||||||
if (banned_numbers.BLACKLIST[number]) {
|
if (banned_numbers.BLACKLIST[number]) {
|
||||||
mpq.track('banned number');
|
mpq.track('banned number', tracking_details);
|
||||||
authbox.log(req, _.extend(authbox_details, {$failureReason: 'banned_number'}));
|
authbox.log(req, _.extend(authbox_details, {$failureReason: 'banned_number'}));
|
||||||
res.send({success:false,message:'Sorry, texts to this number are disabled.'});
|
res.send({success:false,message:'Sorry, texts to this number are disabled.'});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tracking_details = {
|
|
||||||
number: number,
|
|
||||||
message: req.body.message,
|
|
||||||
ip: ip
|
|
||||||
};
|
|
||||||
|
|
||||||
var doSendText = function(response_obj) {
|
var doSendText = function(response_obj) {
|
||||||
response_obj = response_obj || {};
|
response_obj = response_obj || {};
|
||||||
|
|
||||||
@ -187,8 +191,8 @@ function textRequestHandler(req, res, number, region, key) {
|
|||||||
});
|
});
|
||||||
}, 1000*60*3);
|
}, 1000*60*3);
|
||||||
if (num > 3) {
|
if (num > 3) {
|
||||||
mpq.track('exceeded phone quota');
|
//mpq.track('exceeded phone quota', tracking_details);
|
||||||
authbox.log(req, _.extend(authbox_details, {$failureReason: 'exceeded_phone_quota'}));
|
//authbox.log(req, _.extend(authbox_details, {$failureReason: 'exceeded_phone_quota'}));
|
||||||
res.send({success:false, message:'Exceeded quota for this phone number. ' + number});
|
res.send({success:false, message:'Exceeded quota for this phone number. ' + number});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -201,7 +205,7 @@ function textRequestHandler(req, res, number, region, key) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (num > 75) {
|
if (num > 75) {
|
||||||
mpq.track('exceeded ip quota');
|
mpq.track('exceeded ip quota', tracking_details);
|
||||||
authbox.log(req, _.extend(authbox_details, {$failureReason: 'exceeded_ip_quota'}));
|
authbox.log(req, _.extend(authbox_details, {$failureReason: 'exceeded_ip_quota'}));
|
||||||
res.send({success:false, message:'Exceeded quota for this IP address. ' + ip});
|
res.send({success:false, message:'Exceeded quota for this IP address. ' + ip});
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user