diff --git a/README.md b/README.md index 2cb3ed5..082ba2d 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ This is a nodeJS Port from the original PHP-based [LibreSpeed](https://github.co ## Installation For any instructions and support please check out the [Wiki](https://github.com/librespeed/speedtest/wiki) +##Multiple test points (Node.js port) +You can use any combinations of php and node.js backends, read more at [Wiki](https://github.com/librespeed/speedtest/wiki/Multiple-test-points-(PHP\)) + +Rename src/public/example-multipleServers-pretty.html to src/public/index.html if you want to use multiple test points mode. + ## Support If you like this project and want to support our work you can either do pull requests or donate via [PayPal](https://paypal.me/dunklesToast) diff --git a/package.json b/package.json index ae67f2f..6177084 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "private": false, "dependencies": { "express": "^4.16.3", + "cors": "^2.8.5", "gps-distance": "^0.0.4", "random-bytes": "^1.0.0", "request": "^2.85.0" diff --git a/src/SpeedTest.js b/src/SpeedTest.js index 1ae6abf..b438f2d 100644 --- a/src/SpeedTest.js +++ b/src/SpeedTest.js @@ -4,18 +4,21 @@ const randomBytes = require('random-bytes'); const path = require('path'); const request = require('request'); const helpers = require('./Helpers'); +const cors = require('cors'); let cache; +Server.use(cors()); + Server.get('/empty', function (req, res) { - res.sendStatus(200); + res.status(200).send(''); }); Server.post('/empty', function (req, res) { res.set("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0"); res.set("Cache-Control", "post-check=0, pre-check=0"); res.set("Pragma", "no-cache"); - res.sendStatus(200); + res.status(200).send(''); }); Server.get('/garbage', function (req, res) { @@ -27,13 +30,13 @@ Server.get('/garbage', function (req, res) { res.set('Cache-Control', 'post-check=0, pre-check=0', false); res.set('Pragma', 'no-cache'); const requestedSize = (req.query.ckSize || 100); - + const send = () => { for (let i = 0; i < requestedSize; i++) res.write(cache); res.end(); } - + if (cache) { send(); } else { diff --git a/src/public/example-multipleServers-pretty.html b/src/public/example-multipleServers-pretty.html new file mode 100644 index 0000000..f472e71 --- /dev/null +++ b/src/public/example-multipleServers-pretty.html @@ -0,0 +1,225 @@ + + + + + + +LibreSpeed Example + + + + + + +

LibreSpeed Example

+
+
Selecting server...
+
+
+
+
Download
+
+
Mbps
+
+
+
Upload
+
+
Mbps
+
+
+
+
+
Ping
+
+
ms
+
+
+
Jitter
+
+
ms
+
+
+
+ IP Address: +
+
+Source code + + +