mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
ws gotty credentials and ws gotty proxy redirection
This commit is contained in:
parent
d34aa0917b
commit
df576a3b86
@ -230,7 +230,7 @@ function quickShell()
|
|||||||
$r .= "var gotty_auth_token = '';";
|
$r .= "var gotty_auth_token = '';";
|
||||||
} else {
|
} else {
|
||||||
$r .= "var gotty_auth_token = '";
|
$r .= "var gotty_auth_token = '";
|
||||||
$r .= $config['gotty_user'].':'.$gotty_pass."';";
|
$r .= $config['gotty_user'].':'.$config['gotty_pass']."';";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set websocket target and method.
|
// Set websocket target and method.
|
||||||
@ -309,10 +309,22 @@ function quickShellSettings()
|
|||||||
$config['gotty_telnet_port']
|
$config['gotty_telnet_port']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$gotty_user = get_parameter(
|
||||||
|
'gotty_user',
|
||||||
|
$config['gotty_user']
|
||||||
|
);
|
||||||
|
|
||||||
|
$gotty_pass = get_parameter(
|
||||||
|
'gotty_pass',
|
||||||
|
$config['gotty_pass']
|
||||||
|
);
|
||||||
|
|
||||||
$changes = 0;
|
$changes = 0;
|
||||||
|
$critical = 0;
|
||||||
if ($config['gotty'] != $gotty) {
|
if ($config['gotty'] != $gotty) {
|
||||||
config_update_value('gotty', $gotty);
|
config_update_value('gotty', $gotty);
|
||||||
$changes++;
|
$changes++;
|
||||||
|
$critical++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['gotty_host'] != $gotty_host) {
|
if ($config['gotty_host'] != $gotty_host) {
|
||||||
@ -330,13 +342,31 @@ function quickShellSettings()
|
|||||||
$changes++;
|
$changes++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($config['gotty_user'] != $gotty_user) {
|
||||||
|
config_update_value('gotty_user', $gotty_user);
|
||||||
|
$changes++;
|
||||||
|
$critical++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($config['gotty_pass'] != $gotty_pass) {
|
||||||
|
config_update_value('gotty_pass', $gotty_pass);
|
||||||
|
$changes++;
|
||||||
|
$critical++;
|
||||||
|
}
|
||||||
|
|
||||||
// Interface.
|
// Interface.
|
||||||
ui_print_page_header(__('QuickShell settings'));
|
ui_print_page_header(__('QuickShell settings'));
|
||||||
|
|
||||||
if ($changes > 0) {
|
if ($changes > 0) {
|
||||||
ui_print_success_message(
|
$msg = __(
|
||||||
__('%d Updated, please restart WebSocket engine service', $changes)
|
'%d Updated, please restart WebSocket engine service',
|
||||||
|
$changes
|
||||||
);
|
);
|
||||||
|
if ($critical > 0) {
|
||||||
|
$msg = __('%d Updated', $changes);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui_print_success_message($msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Form.
|
// Form.
|
||||||
@ -382,6 +412,22 @@ function quickShellSettings()
|
|||||||
'value' => $config['gotty_telnet_port'],
|
'value' => $config['gotty_telnet_port'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'label' => __('Gotty user'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'text',
|
||||||
|
'name' => 'gotty_user',
|
||||||
|
'value' => $config['gotty_user'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => __('Gotty password'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'text',
|
||||||
|
'name' => 'gotty_pass',
|
||||||
|
'value' => $config['gotty_pass'],
|
||||||
|
],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'arguments' => [
|
'arguments' => [
|
||||||
'type' => 'submit',
|
'type' => 'submit',
|
||||||
|
@ -97,27 +97,37 @@ error_reporting(E_ALL);
|
|||||||
|
|
||||||
$os = strtolower(PHP_OS);
|
$os = strtolower(PHP_OS);
|
||||||
if (substr($os, 0, 3) !== 'win') {
|
if (substr($os, 0, 3) !== 'win') {
|
||||||
if (is_executable($config['gotty']) === false) {
|
if (empty($config['gotty']) === false) {
|
||||||
echo 'Failed to execute gotty ['.$config['gotty']."]\n";
|
// Allow start without gotty binary. External service.
|
||||||
exit(1);
|
if (is_executable($config['gotty']) === false) {
|
||||||
|
echo 'Failed to execute gotty ['.$config['gotty']."]\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$gotty_creds = '';
|
||||||
|
if (empty($config['gotty_user']) === false
|
||||||
|
&& empty($config['gotty_pass']) === false
|
||||||
|
) {
|
||||||
|
$gotty_creds = " -c '".$gotty_user.':'.$gotty_pass."'";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kill previous gotty running.
|
||||||
|
shell_exec('killall "'.$config['gotty'].'" >/dev/null 2>&1');
|
||||||
|
|
||||||
|
// Common.
|
||||||
|
$base_cmd = 'nohup "'.$config['gotty'].'" '.$gotty_creds;
|
||||||
|
$base_cmd .= ' --permit-arguments -a 127.0.0.1 -w ';
|
||||||
|
|
||||||
|
// Launch gotty - SSH.
|
||||||
|
$cmd = $base_cmd.' --port '.$config['gotty_ssh_port'];
|
||||||
|
$cmd .= ' ssh >> '.__DIR__.'/pandora_console.log 2>&1 &';
|
||||||
|
shell_exec($cmd);
|
||||||
|
|
||||||
|
// Launch gotty - telnet.
|
||||||
|
$cmd = $base_cmd.' --port '.$config['gotty_telnet_port'];
|
||||||
|
$cmd .= ' telnet >> '.__DIR__.'/pandora_console.log 2>&1 &';
|
||||||
|
shell_exec($cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill previous gotty running.
|
|
||||||
shell_exec('killall "'.$config['gotty'].'" >/dev/null 2>&1');
|
|
||||||
|
|
||||||
// Common.
|
|
||||||
$base_cmd = 'nohup "'.$config['gotty'].'"';
|
|
||||||
$base_cmd .= ' --permit-arguments -a 127.0.0.1 -w ';
|
|
||||||
|
|
||||||
// Launch gotty - SSH.
|
|
||||||
$cmd = $base_cmd.' --port '.$config['gotty_ssh_port'];
|
|
||||||
$cmd .= ' ssh >> '.__DIR__.'/pandora_console.log 2>&1 &';
|
|
||||||
shell_exec($cmd);
|
|
||||||
|
|
||||||
// Launch gotty - telnet.
|
|
||||||
$cmd = $base_cmd.' --port '.$config['gotty_telnet_port'];
|
|
||||||
$cmd .= ' telnet >> '.__DIR__.'/pandora_console.log 2>&1 &';
|
|
||||||
shell_exec($cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start Web SocketProxy.
|
// Start Web SocketProxy.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user