diff options
author | Grant Limberg <glimberg@gmail.com> | 2015-11-02 18:30:54 -0800 |
---|---|---|
committer | Grant Limberg <glimberg@gmail.com> | 2015-11-02 18:30:54 -0800 |
commit | a19e82fcbc2203f0d84a0e744d344e0796bc0c33 (patch) | |
tree | 2f8cfc56a03cf6e614991c83a309b5fce5a48e48 /tests/http/server.js | |
parent | 0ffcfa307e537347f181e7b22047f252d0cdc414 (diff) | |
parent | 4e9d4304761f93a1764d3ec2d2b0c38140decad8 (diff) | |
download | infinitytier-a19e82fcbc2203f0d84a0e744d344e0796bc0c33.tar.gz infinitytier-a19e82fcbc2203f0d84a0e744d344e0796bc0c33.zip |
Merge branch 'edge' into windows-ui
Diffstat (limited to 'tests/http/server.js')
-rw-r--r-- | tests/http/server.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/http/server.js b/tests/http/server.js new file mode 100644 index 00000000..57109392 --- /dev/null +++ b/tests/http/server.js @@ -0,0 +1,44 @@ +// 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(resultData.source+','+resultData.target+','+resultData.time+','+resultData.bytes+','+resultData.timedOut+',"'+((resultData.error) ? resultData.error : '')+'"'); + } catch (e) {} + } + + knownAgents[agentId] = Date.now(); + return res.status(200).send(JSON.stringify(Object.keys(knownAgents))); +}); + +var expressServer = app.listen(SERVER_PORT,function () { + console.log('LISTENING ON '+SERVER_PORT); + console.log(''); +}); |