add remoteAddress fallback
This commit is contained in:
parent
9ab1699e41
commit
991217efad
6
app.js
6
app.js
@ -46,7 +46,7 @@ app.get('/providers/:region', function(req, res) {
|
|||||||
app.post('/text', function(req, res) {
|
app.post('/text', function(req, res) {
|
||||||
var number = stripPhone(req.body.number);
|
var number = stripPhone(req.body.number);
|
||||||
if (number.length < 9 || number.length > 10) {
|
if (number.length < 9 || number.length > 10) {
|
||||||
res.send({success:false,message:'Invalid phone number.'});
|
res.send({success:false, message:'Invalid phone number.'});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
textRequestHandler(req, res, number, 'us', req.query.key);
|
textRequestHandler(req, res, number, 'us', req.query.key);
|
||||||
@ -65,10 +65,10 @@ app.post('/intl', function(req, res) {
|
|||||||
function textRequestHandler(req, res, number, region, key) {
|
function textRequestHandler(req, res, number, region, key) {
|
||||||
if (!req.body.number || !req.body.message) {
|
if (!req.body.number || !req.body.message) {
|
||||||
mpq.track('incomplete request');
|
mpq.track('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;
|
||||||
}
|
}
|
||||||
var ip = req.header('X-Real-IP');// || req.connection.remoteAddress;
|
var ip = req.header('X-Real-IP') || req.connection.remoteAddress;
|
||||||
|
|
||||||
var message = req.body.message;
|
var message = req.body.message;
|
||||||
if (message.indexOf(':') > -1) {
|
if (message.indexOf(':') > -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user