diff --git a/app.js b/app.js index 23e6630..d79afa6 100644 --- a/app.js +++ b/app.js @@ -44,7 +44,6 @@ app.get('/', function(req, res) { }); app.post('/text', function(req, res) { - var keystr = req.connection.remoteAddress + '_' + dateStr(); var number = stripPhone(req.body.number); if (number.length < 9 || number.length > 10) { @@ -52,14 +51,17 @@ app.post('/text', function(req, res) { return; } - redis.incr('phone:' + number, function(err, num) { + var ipkey = 'textbelt:ip:' + req.connection.remoteAddress + '_' + dateStr(); + var phonekey = 'textbelt:phone:' + number; + + redis.incr(phonekey, function(err, num) { if (err) { res.send({success:false,message:'Could not validate phone# quota.'}); return; } setTimeout(function() { - redis.decr('phone:' + number, function(err, num) { + redis.decr(phonekey, function(err, num) { if (err) { console.log('*** WARNING failed to decr ' + number); } @@ -71,7 +73,7 @@ app.post('/text', function(req, res) { } // now check against ip quota - redis.incr(keystr, function(err, num) { + redis.incr(ipkey, function(err, num) { if (err) { res.send({success:false,message:'Could not validate IP quota.'}); return; @@ -119,19 +121,23 @@ function sendText(phone, message, cb) { }); - for (var i=0; i < providers.length; i++) { - var provider = providers[i]; + _.each(providers, function(provider) { var email = provider.replace('%s', phone); + console.log('email', email); var child = spawn('sendmail', ['-f', 'txt@textbelt.com', email]); child.stdout.on('data', console.log); child.stderr.on('data', console.log); - child.on('error', console.log); + child.on('error', function() { + console.log('failed', email); + done(); + }); child.on('exit', function(code, signal) { + console.log('done', email); done(); }); child.stdin.write(message + '\n.'); child.stdin.end(); - } + }); /* diff --git a/providers.js b/providers.js index 2efce79..b7cf861 100644 --- a/providers.js +++ b/providers.js @@ -6,8 +6,7 @@ module.exports = { '%s@paging.acswireless.com', '%s@txt.att.net', '%s@myboostmobile.com', - '%s@mobile.celloneusa.com', - '%s@sms.edgewireless.com', + //'%s@sms.edgewireless.com', // slow '%s@messaging.sprintpcs.com', '%s@tmomail.net', '%s@mymetropcs.com', diff --git a/views/index.html b/views/index.html index dbf4ccd..1ef9312 100644 --- a/views/index.html +++ b/views/index.html @@ -58,7 +58,7 @@
IP addresses are limited to 75 texts per day. Phone numbers are limited to 3 texts every 3 minutes. If you need increased limits, please contact admin@textbelt.com.
Some carriers may deliver text messages from "txt@textbelt.com"
We support the following U.S. providers: Alltel, Ameritech, AT&T Wireless, Boost, CellularOne, Cingular, Edge Wireless, Sprint PCS, Telus Mobility, T-Mobile, Metro PCS, Nextel, O2, Orange, Qwest, Rogers Wireless, US Cellular, Verizon, Virgin Mobile.
We support the following U.S. providers: Alltel, Ameritech, AT&T Wireless, Boost, CellularOne, Cingular, Sprint PCS, Telus Mobility, T-Mobile, Metro PCS, Nextel, O2, Orange, Qwest, Rogers Wireless, US Cellular, Verizon, Virgin Mobile.