diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php
index cd35c15e8e..391263f1fd 100644
--- a/pandora_console/extensions/quick_shell.php
+++ b/pandora_console/extensions/quick_shell.php
@@ -79,6 +79,8 @@ function quickShell()
return;
}
+ $method = get_parameter('method', null);
+
$setup_anchor = html_print_anchor(
[
'href' => 'index.php?sec=gsetup&sec2=godmode/setup/setup§ion=quickshell',
@@ -87,15 +89,6 @@ function quickShell()
true
);
- $fetch_result = get_parameter('fetch-result', null);
-
- if (isset($fetch_result) === true && $fetch_result === '0') {
- ui_print_error_message(__('Connection error. Please check your settings at %s', $setup_anchor));
- return;
- }
-
- $method = get_parameter('method', null);
-
if ((bool) $config['gotty_ssh_enabled'] === false
&& (bool) $config['gotty_telnet_enabled'] === false
) {
@@ -125,9 +118,6 @@ function quickShell()
$connectionURL = buildConnectionURL($method);
$gotty_addr = $connectionURL.$args;
- $connectionURLSSH = buildConnectionURL('ssh');
- $connectionURLTelnet = buildConnectionURL('telnet');
-
// Username. Retrieve from form.
if (empty($username) === true) {
// No username provided, ask for it.
@@ -170,7 +160,6 @@ function quickShell()
'label' => __('Username'),
'arguments' => [
'type' => 'text',
- 'id' => 'username',
'name' => 'username',
'required' => true,
],
@@ -202,7 +191,7 @@ function quickShell()
html_print_action_buttons(
html_print_submit_button(
__('Connect'),
- 'submit-btn',
+ 'submit',
false,
[
'icon' => 'cog',
@@ -211,57 +200,30 @@ function quickShell()
true
)
);
-
- echo "";
-
return;
}
+ // Check gotty connection before trying to load iframe.
+ $ch = curl_init($gotty_addr);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ // Maximum time for the entire request.
+ curl_setopt($ch, CURLOPT_TIMEOUT, 3);
+ // Maximum time to establish a connection.
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
+
+ $response = curl_exec($ch);
+ $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ $finalUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
+
+ curl_close($ch);
+
+ if ($responseCode !== 200) {
+ ui_print_error_message(__('Connection error. Please check your settings at %s', $setup_anchor));
+ exit;
+ }
+
?>