diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2018-01-10 16:56:39 -0800 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2018-01-10 16:56:39 -0800 |
commit | 4e79804cd3750e9a2b030bc8613171ec82805553 (patch) | |
tree | 382357cb6b93a8ef0e1f7ecdb285e767e24be195 /attic/big-http-test/server.js | |
parent | 86d526416765db2356de4bd5b63b5bef1ed6be44 (diff) | |
download | infinitytier-4e79804cd3750e9a2b030bc8613171ec82805553.tar.gz infinitytier-4e79804cd3750e9a2b030bc8613171ec82805553.zip |
cleanup
Diffstat (limited to 'attic/big-http-test/server.js')
-rw-r--r-- | attic/big-http-test/server.js | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/attic/big-http-test/server.js b/attic/big-http-test/server.js deleted file mode 100644 index 629784da..00000000 --- a/attic/big-http-test/server.js +++ /dev/null @@ -1,53 +0,0 @@ -// ZeroTier distributed HTTP test coordinator and result-reporting server - -// --------------------------------------------------------------------------- -// Customizable parameters: - -var SERVER_PORT = 18080; - -// --------------------------------------------------------------------------- - -var fs = require('fs'); - -var express = require('express'); -var app = express(); - -app.use(function(req,res,next) { - req.rawBody = ''; - req.on('data', function(chunk) { req.rawBody += chunk.toString(); }); - req.on('end', function() { return next(); }); -}); - -var knownAgents = {}; - -app.post('/:agentId',function(req,res) { - var agentId = req.params.agentId; - if ((!agentId)||(agentId.length !== 32)) - return res.status(404).send(''); - - if (req.rawBody) { - var receiveTime = Date.now(); - var resultData = null; - try { - resultData = JSON.parse(req.rawBody); - console.log(Date.now().toString()+','+resultData.source+','+resultData.target+','+resultData.time+','+resultData.bytes+','+resultData.timedOut+',"'+((resultData.error) ? resultData.error : '')+'"'); - } catch (e) {} - } - - knownAgents[agentId] = true; - var thisUpdate = []; - var agents = Object.keys(knownAgents); - if (agents.length < 100) - thisUpdate = agents; - else { - for(var xx=0;xx<100;++xx) - thisUpdate.push(agents[Math.floor(Math.random() * agents.length)]); - } - - return res.status(200).send(JSON.stringify(thisUpdate)); -}); - -var expressServer = app.listen(SERVER_PORT,function () { - console.log('LISTENING ON '+SERVER_PORT); - console.log(''); -}); |