Merge remote-tracking branch 'remotes/origin/ent-5108-ws-cookie-parser' into develop

This commit is contained in:
artica 2019-12-16 11:23:06 +01:00
commit b71752ea03
19 changed files with 300 additions and 172 deletions

View File

@ -8,8 +8,19 @@ fi
echo "Creating DEB packages in $RPMHOME/DEB"
# Console
# Extra files to be added to rpm.
if [ "$X86_64" == "" ]; then
# Fake gotty.
echo 'Only x86_64 is supported' > $CODEHOME/pandora_console/gotty
chmod +x pandora_console/gotty
else
cp /root/bin/winexe/x64/gotty $CODEHOME/pandora_console/
fi
cd $CODEHOME/pandora_console/DEBIAN && bash ./make_deb_package.sh && mv ../*.deb $RPMHOME/DEB || exit 1
# Cleanup.
rm -f pandora_console/gotty
# Server
cd $CODEHOME/pandora_server/DEBIAN && bash ./make_deb_package.sh && mv ../*.deb $RPMHOME/DEB || exit 1

View File

@ -8,8 +8,20 @@ fi
echo "Creating RPM packages in $RPMHOME/RPMS"
# Console
# Extra files to be added to rpm.
if [ "$X86_64" == "" ]; then
# Fake gotty.
echo 'Only x86_64 is supported' > $CODEHOME/pandora_console/gotty
chmod +x pandora_console/gotty
else
cp /root/bin/winexe/x64/gotty $CODEHOME/pandora_console/
fi
rpmbuild -ba $CODEHOME/pandora_console/pandora_console.spec || exit 1
# Cleanup.
rm -f pandora_console/gotty
# Server
rpmbuild -ba $CODEHOME/pandora_server/pandora_server.spec || exit 1

View File

@ -8,8 +8,20 @@ fi
echo "Creating RPM packages in $RPMHOME/RPMS"
# Console
# Extra files to be added to rpm.
if [ "$X86_64" == "" ]; then
# Fake gotty.
echo 'Only x86_64 is supported' > $CODEHOME/pandora_console/gotty
chmod +x pandora_console/gotty
else
cp /root/bin/winexe/x64/gotty $CODEHOME/pandora_console/
fi
rpmbuild -ba $CODEHOME/pandora_console/pandora_console.redhat.spec || exit 1
# Cleanup.
rm -f pandora_console/gotty
# Server
rpmbuild -ba $CODEHOME/pandora_server/pandora_server.redhat.spec || exit 1

View File

@ -8,13 +8,25 @@ fi
echo "Creating RPM packages in $RPMHOME/RPMS"
# Console
# Extra files to be added to rpm.
if [ "$X86_64" == "" ]; then
# Fake gotty.
echo 'Only x86_64 is supported' > $CODEHOME/pandora_console/gotty
chmod +x pandora_console/gotty
else
cp /root/bin/winexe/x64/gotty $CODEHOME/pandora_console/
fi
rpmbuild -ba $CODEHOME/pandora_console/pandora_console.rhel7.spec || exit 1
# Cleanup.
rm -f pandora_console/gotty
# Server
#rpmbuild -ba $CODEHOME/pandora_server/pandora_server.rhel7.spec || exit 1
rpmbuild -ba $CODEHOME/pandora_server/pandora_server.redhat.spec || exit 1
# Unix agent
#rpmbuild -ba $CODEHOME/pandora_agents/unix/pandora_agent.rhel7.spec || exit 1
rpmbuild -ba $CODEHOME/pandora_agents/unix/pandora_agent.redhat.spec || exit 1
# Enterprise console
rpmbuild -ba $PANDHOME_ENT/pandora_console/enterprise/pandora_console_enterprise.rhel7.spec || exit 1

View File

@ -10,6 +10,9 @@ if [ -f /etc/init.d/apache2 ]; then
echo Restart the apache.
/etc/init.d/apache2 restart
fi
# Install GoTTY binary file.
cp -pf %{prefix}/pandora_console/gotty /usr/bin/
chmod +x /usr/bin/gotty
# Install pandora_websocket_engine service.
cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/

View File

@ -65,17 +65,13 @@ function quickShell()
ui_require_css_file('discovery');
// Settings.
// WebSocket host, where to connect.
if (isset($config['ws_host']) === false) {
config_update_value('ws_host', $_SERVER['SERVER_ADDR']);
}
// WebSocket host, where client should connect.
if (isset($config['ws_port']) === false) {
config_update_value('ws_port', 8080);
}
if (empty($config['ws_proxy_url']) === true) {
$ws_url = 'http://'.$config['ws_host'].':'.$config['ws_port'];
$ws_url = 'http://'.$_SERVER['SERVER_ADDR'].':'.$config['ws_port'];
} else {
preg_match('/\/\/(.*)/', $config['ws_proxy_url'], $matches);
if (isset($_SERVER['HTTPS']) === true) {
@ -313,7 +309,7 @@ function quickShellSettings()
}
// Parser.
if (get_parameter('qs_update', false) !== false) {
if (get_parameter('update_config', false) !== false) {
// Gotty settings. Internal communication (WS).
$gotty = get_parameter(
'gotty',
@ -381,14 +377,6 @@ function quickShellSettings()
}
}
// Interface.
ui_print_page_header(
__('QuickShell settings'),
'',
false,
'quickshell_settings'
);
if ($changes > 0) {
$msg = __('%d Updated', $changes);
if ($critical > 0) {
@ -401,100 +389,104 @@ function quickShellSettings()
ui_print_success_message($msg);
}
// Form.
$wiz = new Wizard();
// Form. Using old style.
echo '<fieldset>';
echo '<legend>'.__('Quickshell').'</legend>';
$wiz->printForm(
[
'form' => [
'action' => '#',
'class' => 'wizard',
'method' => 'post',
],
'inputs' => [
[
'label' => __('Gotty path').ui_print_help_tip(
__('Leave blank if using an external Gotty service'),
true
),
'arguments' => [
'type' => 'text',
'name' => 'gotty',
'value' => $config['gotty'],
],
],
[
'label' => __('Gotty host'),
'arguments' => [
'type' => 'text',
'name' => 'gotty_host',
'value' => $config['gotty_host'],
],
],
[
'label' => __('Gotty ssh port'),
'arguments' => [
'type' => 'text',
'name' => 'gotty_ssh_port',
'value' => $config['gotty_ssh_port'],
],
],
[
'label' => __('Gotty telnet port'),
'arguments' => [
'type' => 'text',
'name' => 'gotty_telnet_port',
'value' => $config['gotty_telnet_port'],
],
],
[
'toggle' => true,
'toggle_name' => 'Advanced',
'block_content' => [
[
'label' => __('Gotty user').ui_print_help_tip(
__('Optional, set a user to access gotty service'),
true
),
'arguments' => [
'type' => 'text',
'name' => 'gotty_user',
'value' => $config['gotty_user'],
],
],
[
'label' => __('Gotty password').ui_print_help_tip(
__('Optional, set a password to access gotty service'),
true
),
'arguments' => [
'type' => 'password',
'name' => 'gotty_pass',
'value' => io_output_password($config['gotty_pass']),
],
],
],
],
[
'arguments' => [
'type' => 'hidden',
'name' => 'qs_update',
'value' => 1,
],
],
[
'arguments' => [
'type' => 'submit',
'label' => __('Update'),
'attributes' => 'class="sub next"',
],
],
],
],
false,
$t = new StdClass();
$t->data = [];
$t->width = '100%';
$t->class = 'databox filters';
$t->data = [];
$t->style[0] = 'font-weight: bold';
$t->data[0][0] = __('Gotty path');
$t->data[0][1] = html_print_input_text(
'gotty',
$config['gotty'],
'',
30,
100,
true
);
$t->data[1][0] = __('Gotty host');
$t->data[1][1] = html_print_input_text(
'gotty_host',
$config['gotty_host'],
'',
30,
100,
true
);
$t->data[2][0] = __('Gotty ssh port');
$t->data[2][1] = html_print_input_text(
'gotty_ssh_port',
$config['gotty_ssh_port'],
'',
30,
100,
true
);
$t->data[3][0] = __('Gotty telnet port');
$t->data[3][1] = html_print_input_text(
'gotty_telnet_port',
$config['gotty_telnet_port'],
'',
30,
100,
true
);
$hidden = new StdClass();
$hidden->data = [];
$hidden->width = '100%';
$hidden->class = 'databox filters';
$hidden->data = [];
$hidden->style[0] = 'font-weight: bold';
$hidden->data[0][0] = __('Gotty user').ui_print_help_tip(
__('Optional, set a user to access gotty service'),
true
);
$hidden->data[0][1] = html_print_input_text(
'gotty_user',
$config['gotty_user'],
'',
30,
100,
true
);
$hidden->data[1][0] = __('Gotty password').ui_print_help_tip(
__('Optional, set a password to access gotty service'),
true
);
$hidden->data[1][1] = html_print_input_password(
'gotty_pass',
io_output_password($config['gotty_pass']),
'',
30,
100,
true
);
html_print_table($t);
ui_print_toggle(
[
'content' => html_print_table($hidden, true),
'name' => __('Advanced options'),
'clean' => false,
'main_class' => 'no-border-imp',
'container_class' => 'no-border-imp',
]
);
echo '</fieldset>';
}
@ -523,19 +515,4 @@ if (empty($agent_id) === false
}
}
extensions_add_godmode_menu_option(
// Name.
__('QuickShell settings'),
// Acl.
'PM',
// FatherId.
'gextensions',
// Icon.
'images/ehorus/terminal.png',
// Version.
'N/A',
// SubfatherId.
null
);
extensions_add_godmode_function('quickShellSettings');

View File

@ -129,6 +129,7 @@ if ($disabled != '') {
$extensions = extensions_get_extension_info();
$table = new StdClass;
$table->width = '98%';
$table->head = [];

View File

@ -316,6 +316,13 @@ if (check_acl($config['id_user'], 0, 'PM')) {
$sub2['godmode/setup/setup&amp;section=notifications']['text'] = __('Notifications');
$sub2['godmode/setup/setup&amp;section=notifications']['refr'] = 0;
// Enable only if quickshell is enabled.
if (function_exists('quickShellSettings') === true) {
$sub2['godmode/setup/setup&amp;section=quickshell']['text'] = __('QuickShell');
$sub2['godmode/setup/setup&amp;section=quickshell']['refr'] = 0;
}
if ($config['activate_gis']) {
$sub2['godmode/setup/gis']['text'] = __('Map conections GIS');
}

View File

@ -133,6 +133,11 @@ $buttons['notifications'] = [
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=notifications').'">'.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'</a>',
];
$buttons['websocket_engine'] = [
'active' => false,
'text' => '<a href="'.ui_get_full_url('index.php?sec=gsetup&sec2=godmode/setup/setup&section=websocket_engine').'">'.html_print_image('images/websocket_small.png', true, ['title' => __('Websocket engine')]).'</a>',
];
$help_header = '';
if (enterprise_installed()) {
$subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header);
@ -183,6 +188,12 @@ switch ($section) {
$subpage = ' &raquo '.__('Notifications');
break;
case 'websocket_engine':
$buttons['websocket_engine']['active'] = true;
$subpage = ' &raquo '.__('Pandora Websocket Engine');
$help_header = 'quickshell_settings';
break;
case 'enterprise':
$buttons['enterprise']['active'] = true;
$subpage = ' &raquo '.__('Enterprise');
@ -247,6 +258,10 @@ switch ($section) {
include_once $config['homedir'].'/godmode/setup/setup_notifications.php';
break;
case 'websocket_engine':
include_once $config['homedir'].'/godmode/setup/setup_websocket_engine.php';
break;
default:
enterprise_hook('setup_enterprise_select_tab', [$section]);
break;

View File

@ -403,50 +403,6 @@ html_print_table($table_mail_conf);
echo '</fieldset>';
echo '<fieldset>';
echo '<legend>'.__('WebSocket settings').'</legend>';
$t = new StdClass();
$t->data = [];
$t->width = '100%';
$t->class = 'databox filters';
$t->data = [];
$t->style[0] = 'font-weight: bold';
$t->data[0][0] = __('Bind address');
$t->data[0][1] = html_print_input_text(
'ws_bind_address',
$config['ws_bind_address'],
'',
30,
100,
true
);
$t->data[1][0] = __('Bind port');
$t->data[1][2] = html_print_input_text(
'ws_port',
$config['ws_port'],
'',
30,
100,
true
);
$t->data[2][0] = __('WebSocket proxy url').ui_print_help_tip(__('If you had configured a wsproxy set here target URL (for instance ws://your.public.fqdn/ws).'), true);
$t->data[2][2] = html_print_input_text(
'ws_proxy_url',
$config['ws_proxy_url'],
'',
30,
100,
true
);
html_print_input_hidden('update_config', 1);
html_print_table($t);
echo '</fieldset>';
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');

View File

@ -0,0 +1,98 @@
<?php
/**
* Settings for Pandora Websocket engine.
*
* @category UI file
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
global $config;
$url = ui_get_full_url(
'index.php?sec=gsetup&sec2=godmode/setup/setup&amp;section=websocket_engine&amp;pure='.$config['pure']
);
echo '<form id="form_setup" method="post" action="'.$url.'">';
echo '<fieldset>';
echo '<legend>'.__('WebSocket settings').'</legend>';
$t = new StdClass();
$t->data = [];
$t->width = '100%';
$t->class = 'databox filters';
$t->data = [];
$t->style[0] = 'font-weight: bold';
$t->data[0][0] = __('Bind address');
$t->data[0][1] = html_print_input_text(
'ws_bind_address',
$config['ws_bind_address'],
'',
30,
100,
true
);
$t->data[1][0] = __('Bind port');
$t->data[1][2] = html_print_input_text(
'ws_port',
$config['ws_port'],
'',
30,
100,
true
);
$t->data[2][0] = __('WebSocket proxy url').ui_print_help_tip(
__('If you had configured a wsproxy set here target URL (for instance ws://your.public.fqdn/ws).'),
true
);
$t->data[2][2] = html_print_input_text(
'ws_proxy_url',
$config['ws_proxy_url'],
'',
30,
100,
true
);
html_print_input_hidden('update_config', 1);
html_print_table($t);
echo '</fieldset>';
if (function_exists('quickShellSettings') === true) {
quickShellSettings();
}
echo '<div class="action-buttons" style="width: 100%;">';
html_print_submit_button(
__('Update'),
'update_button',
false,
'class="sub upd"'
);
echo '</div>';
echo '</form>';

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -152,7 +152,7 @@ class WSManager extends WebSocketServer
*/
public function __construct(
$listen_addr,
$listen_port,
int $listen_port,
$connected=[],
$process=[],
$processRaw=[],
@ -271,12 +271,20 @@ class WSManager extends WebSocketServer
{
global $config;
$php_session_id = \str_replace(
'PHPSESSID=',
'',
$user->headers['cookie']
$match;
$php_session_id = '';
\preg_match(
'/PHPSESSID=(.*)/',
$user->headers['cookie'],
$match
);
if (is_array($match) === true) {
$php_session_id = $match[1];
}
$php_session_id = \preg_replace('/;.*$/', '', $php_session_id);
// If being redirected from proxy.
if (isset($user->headers['x-forwarded-for']) === true) {
$user->address = $user->headers['x-forwarded-for'];

View File

@ -590,6 +590,10 @@ select:-internal-list-box {
.no-border {
border: none;
}
.no-border-imp,
.no-border-imp > div {
border: none !important;
}
.no-padding {
padding: 0;
}

View File

@ -57,6 +57,10 @@ install -m 0644 pandora_console_logrotate_centos $RPM_BUILD_ROOT%{_sysconfdir}/l
rm -rf $RPM_BUILD_ROOT
%post
# Install GoTTY binary file.
cp -pf %{prefix}/pandora_console/gotty /usr/bin/
chmod +x /usr/bin/gotty
# Install pandora_websocket_engine service.
cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/
chmod +x /etc/init.d/pandora_websocket_engine

View File

@ -57,6 +57,10 @@ install -m 0644 pandora_console_logrotate_centos $RPM_BUILD_ROOT%{_sysconfdir}/l
rm -rf $RPM_BUILD_ROOT
%post
# Install GoTTY binary file.
cp -pf %{prefix}/pandora_console/gotty /usr/bin/
chmod +x /usr/bin/gotty
# Install pandora_websocket_engine service.
cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/
chmod +x /etc/init.d/pandora_websocket_engine

View File

@ -58,6 +58,10 @@ fi
rm -rf $RPM_BUILD_ROOT
%post
# Install GoTTY binary file.
cp -pf %{prefix}/pandora_console/gotty /usr/bin/
chmod +x /usr/bin/gotty
# Install pandora_websocket_engine service.
cp -pf %{prefix}/pandora_console/pandora_websocket_engine /etc/init.d/
chmod +x /etc/init.d/pandora_websocket_engine

View File

@ -139,7 +139,7 @@ $ws = new WSManager(
// Bind address.
$config['ws_bind_address'],
// Bind port.
$config['ws_port'],
(int) $config['ws_port'],
// Connected handlers.
['gotty' => 'proxyConnected'],
// Process handlers.