Merge branch 'master' into docker
This commit is contained in:
commit
8d341c3010
5
doc.md
5
doc.md
|
@ -209,6 +209,10 @@ w.postMessage('start '+JSON.stringify(params))
|
||||||
* __url_getIp__: path to getIP.php or replacement
|
* __url_getIp__: path to getIP.php or replacement
|
||||||
* Default: `getIP.php`
|
* Default: `getIP.php`
|
||||||
* __Important:__ path is relative to js file
|
* __Important:__ path is relative to js file
|
||||||
|
* __url_telemetry__: path to telemetry.php or replacement
|
||||||
|
* Default: `telemetry/telemetry.php`
|
||||||
|
* __Important:__ path is relative to js file
|
||||||
|
* __Note:__ you can ignore this parameter if you're not using the telemetry
|
||||||
|
|
||||||
#### Advanced test parameters
|
#### Advanced test parameters
|
||||||
* __test_order__: the order in which tests will be performed. Each character represents an operation:
|
* __test_order__: the order in which tests will be performed. Each character represents an operation:
|
||||||
|
@ -274,6 +278,7 @@ w.postMessage('start '+JSON.stringify(params))
|
||||||
* `1514 / 1460`: TCP+IPv4+ETH, ignoring HTTP overhead
|
* `1514 / 1460`: TCP+IPv4+ETH, ignoring HTTP overhead
|
||||||
* `1514 / 1440`: TCP+IPv6+ETH, ignoring HTTP overhead
|
* `1514 / 1440`: TCP+IPv6+ETH, ignoring HTTP overhead
|
||||||
* `1`: ignore overheads. This measures the speed at which you actually download and upload files rather than the raw connection speed
|
* `1`: ignore overheads. This measures the speed at which you actually download and upload files rather than the raw connection speed
|
||||||
|
* __telemetry_extra__: Extra data that you want to be passed to the telemetry. This is a string field, if you want to pass an object, make sure you use ``JSON.stringify``.
|
||||||
|
|
||||||
### Aborting the test prematurely
|
### Aborting the test prematurely
|
||||||
The test can be aborted at any time by sending an abort command to the worker:
|
The test can be aborted at any time by sending an abort command to the worker:
|
||||||
|
|
|
@ -17,11 +17,6 @@ var ulProgress = 0 //progress of upload test 0-1
|
||||||
var pingProgress = 0 //progress of ping+jitter test 0-1
|
var pingProgress = 0 //progress of ping+jitter test 0-1
|
||||||
var testId = 'noID' //test ID (sent back by telemetry if used, the string 'noID' otherwise)
|
var testId = 'noID' //test ID (sent back by telemetry if used, the string 'noID' otherwise)
|
||||||
|
|
||||||
var HTML_ESCAPE_MAP={'&': '&','<': '<','>': '>','"': '"',"'": '''};
|
|
||||||
String.prototype.escapeHtml=function(){
|
|
||||||
return this.replace(/[&<>"']/g, function(m){return HTML_ESCAPE_MAP[m]});
|
|
||||||
}
|
|
||||||
|
|
||||||
var log='' //telemetry log
|
var log='' //telemetry log
|
||||||
function tlog(s){log+=Date.now()+': '+s+'\n'}
|
function tlog(s){log+=Date.now()+': '+s+'\n'}
|
||||||
function twarn(s){log+=Date.now()+' WARN: '+s+'\n'; console.warn(s)}
|
function twarn(s){log+=Date.now()+' WARN: '+s+'\n'; console.warn(s)}
|
||||||
|
@ -52,7 +47,8 @@ var settings = {
|
||||||
overheadCompensationFactor: 1.06, //can be changed to compensatie for transport overhead. (see doc.md for some other values)
|
overheadCompensationFactor: 1.06, //can be changed to compensatie for transport overhead. (see doc.md for some other values)
|
||||||
useMebibits: false, //if set to true, speed will be reported in mebibits/s instead of megabits/s
|
useMebibits: false, //if set to true, speed will be reported in mebibits/s instead of megabits/s
|
||||||
telemetry_level: 0, // 0=disabled, 1=basic (results only), 2=full (results+log)
|
telemetry_level: 0, // 0=disabled, 1=basic (results only), 2=full (results+log)
|
||||||
url_telemetry: 'telemetry/telemetry.php' // path to the script that adds telemetry data to the database
|
url_telemetry: 'telemetry/telemetry.php', // path to the script that adds telemetry data to the database
|
||||||
|
telemetry_extra: '' //extra data that can be passed to the telemetry through the settings
|
||||||
}
|
}
|
||||||
|
|
||||||
var xhr = null // array of currently active xhr requests
|
var xhr = null // array of currently active xhr requests
|
||||||
|
@ -181,10 +177,10 @@ function getIp (done) {
|
||||||
tlog("IP: "+xhr.responseText)
|
tlog("IP: "+xhr.responseText)
|
||||||
try{
|
try{
|
||||||
var data=JSON.parse(xhr.responseText)
|
var data=JSON.parse(xhr.responseText)
|
||||||
clientIp=data.processedString.escapeHtml()
|
clientIp=data.processedString
|
||||||
ispInfo=data.rawIspInfo
|
ispInfo=data.rawIspInfo
|
||||||
}catch(e){
|
}catch(e){
|
||||||
clientIp = xhr.responseText.escapeHtml()
|
clientIp = xhr.responseText
|
||||||
ispInfo=''
|
ispInfo=''
|
||||||
}
|
}
|
||||||
done()
|
done()
|
||||||
|
@ -498,9 +494,10 @@ function sendTelemetry(done){
|
||||||
fd.append('ping', pingStatus)
|
fd.append('ping', pingStatus)
|
||||||
fd.append('jitter', jitterStatus)
|
fd.append('jitter', jitterStatus)
|
||||||
fd.append('log', settings.telemetry_level>1?log:"")
|
fd.append('log', settings.telemetry_level>1?log:"")
|
||||||
|
fd.append('extra', settings.telemetry_extra);
|
||||||
xhr.send(fd)
|
xhr.send(fd)
|
||||||
}catch(ex){
|
}catch(ex){
|
||||||
var postData = 'ispinfo='+encodeURIComponent(JSON.stringify(telemetryIspInfo))+'&dl='+encodeURIComponent(dlStatus)+'&ul='+encodeURIComponent(ulStatus)+'&ping='+encodeURIComponent(pingStatus)+'&jitter='+encodeURIComponent(jitterStatus)+'&log='+encodeURIComponent(settings.telemetry_level>1?log:'')
|
var postData = 'extra='+encodeURIComponent(settings.telemetry_extra)+'&ispinfo='+encodeURIComponent(JSON.stringify(telemetryIspInfo))+'&dl='+encodeURIComponent(dlStatus)+'&ul='+encodeURIComponent(ulStatus)+'&ping='+encodeURIComponent(pingStatus)+'&jitter='+encodeURIComponent(jitterStatus)+'&log='+encodeURIComponent(settings.telemetry_level>1?log:'')
|
||||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
xhr.send(postData)
|
xhr.send(postData)
|
||||||
}
|
}
|
||||||
|
|
2
speedtest_worker.min.js
vendored
2
speedtest_worker.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -88,26 +88,26 @@ if($stats_password=="PASSWORD"){
|
||||||
if($_GET["op"]=="id"&&!empty($_POST["id"])){
|
if($_GET["op"]=="id"&&!empty($_POST["id"])){
|
||||||
$id=$_POST["id"];
|
$id=$_POST["id"];
|
||||||
if($db_type=="mysql"){
|
if($db_type=="mysql"){
|
||||||
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log from speedtest_users where id=?");
|
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log,extra from speedtest_users where id=?");
|
||||||
$q->bind_param("i",$_POST["id"]);
|
$q->bind_param("i",$_POST["id"]);
|
||||||
$q->execute();
|
$q->execute();
|
||||||
$q->bind_result($id,$timestamp,$ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log);
|
$q->bind_result($id,$timestamp,$ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log,$extra);
|
||||||
} else if($db_type=="sqlite"||$db_type=="postgresql"){
|
} else if($db_type=="sqlite"||$db_type=="postgresql"){
|
||||||
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log from speedtest_users where id=?");
|
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log,extra from speedtest_users where id=?");
|
||||||
$q->execute(array($id));
|
$q->execute(array($id));
|
||||||
} else die();
|
} else die();
|
||||||
}else{
|
}else{
|
||||||
if($db_type=="mysql"){
|
if($db_type=="mysql"){
|
||||||
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log from speedtest_users order by timestamp desc limit 0,100");
|
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log,extra from speedtest_users order by timestamp desc limit 0,100");
|
||||||
$q->execute();
|
$q->execute();
|
||||||
$q->bind_result($id,$timestamp,$ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log);
|
$q->bind_result($id,$timestamp,$ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log,$extra);
|
||||||
} else if($db_type=="sqlite"||$db_type=="postgresql"){
|
} else if($db_type=="sqlite"||$db_type=="postgresql"){
|
||||||
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log from speedtest_users order by timestamp desc limit 0,100");
|
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log,extra from speedtest_users order by timestamp desc limit 0,100");
|
||||||
$q->execute();
|
$q->execute();
|
||||||
}else die();
|
}else die();
|
||||||
}
|
}
|
||||||
while(true){
|
while(true){
|
||||||
$id=null; $timestamp=null; $ip=null; $ispinfo=null; $ua=null; $lang=null; $dl=null; $ul=null; $ping=null; $jitter=null; $log=null;
|
$id=null; $timestamp=null; $ip=null; $ispinfo=null; $ua=null; $lang=null; $dl=null; $ul=null; $ping=null; $jitter=null; $log=null; $extra=null;
|
||||||
if($db_type=="mysql"){
|
if($db_type=="mysql"){
|
||||||
if(!$q->fetch()) break;
|
if(!$q->fetch()) break;
|
||||||
} else if($db_type=="sqlite"||$db_type=="postgresql"){
|
} else if($db_type=="sqlite"||$db_type=="postgresql"){
|
||||||
|
@ -123,6 +123,7 @@ if($stats_password=="PASSWORD"){
|
||||||
$ping=$row["ping"];
|
$ping=$row["ping"];
|
||||||
$jitter=$row["jitter"];
|
$jitter=$row["jitter"];
|
||||||
$log=$row["log"];
|
$log=$row["log"];
|
||||||
|
$extra=$row["extra"];
|
||||||
}else die();
|
}else die();
|
||||||
?>
|
?>
|
||||||
<table>
|
<table>
|
||||||
|
@ -135,6 +136,7 @@ if($stats_password=="PASSWORD"){
|
||||||
<tr><th>Ping</th><td><?=htmlspecialchars($ping, ENT_HTML5, 'UTF-8') ?></td></tr>
|
<tr><th>Ping</th><td><?=htmlspecialchars($ping, ENT_HTML5, 'UTF-8') ?></td></tr>
|
||||||
<tr><th>Jitter</th><td><?=htmlspecialchars($jitter, ENT_HTML5, 'UTF-8') ?></td></tr>
|
<tr><th>Jitter</th><td><?=htmlspecialchars($jitter, ENT_HTML5, 'UTF-8') ?></td></tr>
|
||||||
<tr><th>Log</th><td><?=htmlspecialchars($log, ENT_HTML5, 'UTF-8') ?></td></tr>
|
<tr><th>Log</th><td><?=htmlspecialchars($log, ENT_HTML5, 'UTF-8') ?></td></tr>
|
||||||
|
<tr><th>Extra info</th><td><?=htmlspecialchars($extra, ENT_HTML5, 'UTF-8') ?></td></tr>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ include_once('telemetry_settings.php');
|
||||||
|
|
||||||
$ip=($_SERVER['REMOTE_ADDR']);
|
$ip=($_SERVER['REMOTE_ADDR']);
|
||||||
$ispinfo=($_POST["ispinfo"]);
|
$ispinfo=($_POST["ispinfo"]);
|
||||||
|
$extra=($_POST["extra"]);
|
||||||
$ua=($_SERVER['HTTP_USER_AGENT']);
|
$ua=($_SERVER['HTTP_USER_AGENT']);
|
||||||
$lang=""; if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) $lang=($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
$lang=""; if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) $lang=($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||||
$dl=($_POST["dl"]);
|
$dl=($_POST["dl"]);
|
||||||
|
@ -13,8 +14,8 @@ $log=($_POST["log"]);
|
||||||
|
|
||||||
if($db_type=="mysql"){
|
if($db_type=="mysql"){
|
||||||
$conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename) or die("1");
|
$conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename) or die("1");
|
||||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?)") or die("2");
|
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
|
||||||
$stmt->bind_param("sssssssss",$ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3");
|
$stmt->bind_param("ssssssssss",$ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3");
|
||||||
$stmt->execute() or die("4");
|
$stmt->execute() or die("4");
|
||||||
$stmt->close() or die("5");
|
$stmt->close() or die("5");
|
||||||
echo "id ".$conn->insert_id;
|
echo "id ".$conn->insert_id;
|
||||||
|
@ -26,6 +27,7 @@ if($db_type=="mysql"){
|
||||||
CREATE TABLE IF NOT EXISTS `speedtest_users` (
|
CREATE TABLE IF NOT EXISTS `speedtest_users` (
|
||||||
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||||
`ispinfo` text,
|
`ispinfo` text,
|
||||||
|
`extra` text,
|
||||||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`ip` text NOT NULL,
|
`ip` text NOT NULL,
|
||||||
`ua` text NOT NULL,
|
`ua` text NOT NULL,
|
||||||
|
@ -37,8 +39,8 @@ if($db_type=="mysql"){
|
||||||
`log` longtext
|
`log` longtext
|
||||||
);
|
);
|
||||||
");
|
");
|
||||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?)") or die("2");
|
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
|
||||||
$stmt->execute(array($ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
$stmt->execute(array($ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
||||||
echo "id ".$conn->lastInsertId();
|
echo "id ".$conn->lastInsertId();
|
||||||
$conn = null;
|
$conn = null;
|
||||||
}elseif($db_type=="postgresql"){
|
}elseif($db_type=="postgresql"){
|
||||||
|
@ -49,8 +51,8 @@ if($db_type=="mysql"){
|
||||||
$conn_password = "password=$PostgreSql_password";
|
$conn_password = "password=$PostgreSql_password";
|
||||||
// Create db connection
|
// Create db connection
|
||||||
$conn = new PDO("pgsql:$conn_host;$conn_db;$conn_user;$conn_password") or die("1");
|
$conn = new PDO("pgsql:$conn_host;$conn_db;$conn_user;$conn_password") or die("1");
|
||||||
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?)") or die("2");
|
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
|
||||||
$stmt->execute(array($ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
$stmt->execute(array($ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
|
||||||
echo "id ".$conn->lastInsertId();
|
echo "id ".$conn->lastInsertId();
|
||||||
$conn = null;
|
$conn = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ CREATE TABLE `speedtest_users` (
|
||||||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`ip` text NOT NULL,
|
`ip` text NOT NULL,
|
||||||
`ispinfo` text,
|
`ispinfo` text,
|
||||||
|
`extra` text,
|
||||||
`ua` text NOT NULL,
|
`ua` text NOT NULL,
|
||||||
`lang` text NOT NULL,
|
`lang` text NOT NULL,
|
||||||
`dl` text,
|
`dl` text,
|
||||||
|
|
|
@ -43,6 +43,7 @@ CREATE TABLE speedtest_users (
|
||||||
"timestamp" timestamp without time zone DEFAULT now() NOT NULL,
|
"timestamp" timestamp without time zone DEFAULT now() NOT NULL,
|
||||||
ip text NOT NULL,
|
ip text NOT NULL,
|
||||||
ispinfo text,
|
ispinfo text,
|
||||||
|
extra text,
|
||||||
ua text NOT NULL,
|
ua text NOT NULL,
|
||||||
lang text NOT NULL,
|
lang text NOT NULL,
|
||||||
dl text,
|
dl text,
|
||||||
|
|
Loading…
Reference in a new issue