summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--functions/connection.php19
-rw-r--r--functions/json.php4
-rw-r--r--functions/variables.php1
4 files changed, 22 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3636d51..4b083f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
## 2.2
- Add SSLv2 test
+- Fix long duration and possible timeout on non-http(s) tests
## 2.1
diff --git a/functions/connection.php b/functions/connection.php
index d6d1391..0ab8e7c 100644
--- a/functions/connection.php
+++ b/functions/connection.php
@@ -28,6 +28,22 @@ function get(&$var, $default=null) {
}
function server_http_headers($host, $port){
+ // first check if server is http. otherwise long timeout.
+ $ch = curl_init(("https://" . $host . ":" . $port));
+ curl_setopt($ch, CURLOPT_TIMEOUT, 2);
+ curl_setopt($ch, CURLOPT_NOBODY, true);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_FAILONERROR, true);
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
+ if(curl_exec($ch) === false) {
+ curl_close($ch);
+ return false;
+ }
+ curl_close($ch);
+
stream_context_set_default(
array("ssl" =>
array("verify_peer" => false,
@@ -37,7 +53,8 @@ function server_http_headers($host, $port){
"sni_enabled" => true),
'http' => array(
'method' => 'GET',
- 'max_redirects' => 1
+ 'max_redirects' => 1,
+ 'timeout' => 2
)
)
);
diff --git a/functions/json.php b/functions/json.php
index 26058a6..8e6dc97 100644
--- a/functions/json.php
+++ b/functions/json.php
@@ -45,9 +45,9 @@ function check_json($host,$port) {
$chain_key = (string)$key+1;
if ($key == 0) {
$data["connection"] = ssl_conn_metadata_json($host, $port, $read_stream, $chain_data);
- $data["chain"][$chain_key] = cert_parse_json($curr, $next, $host, true);
+ //$data["chain"][$chain_key] = cert_parse_json($curr, $next, $host, true);
} else {
- $data["chain"][$chain_key] = cert_parse_json($curr, $next, null, false);
+ //$data["chain"][$chain_key] = cert_parse_json($curr, $next, null, false);
}
}
} else {
diff --git a/functions/variables.php b/functions/variables.php
index c578bed..6869f71 100644
--- a/functions/variables.php
+++ b/functions/variables.php
@@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
date_default_timezone_set('UTC');
+ini_set('default_socket_timeout', 2);
$version = 2.2;