Pavel Loginov 3 years ago
parent ef19e1bb1a
commit b6bf804f73

@ -571,6 +571,22 @@ def update_db_v_5_3_0(**kwargs):
{'param': 'haproxy_container_name', 'value': 'haproxy', 'section': 'haproxy',
'desc': 'Docker container name for HAProxy service',
'group': g.group_id},
{'param': 'apache_path_logs', 'value': '/var/log/httpd/', 'section': 'apache',
'desc': 'The path for Apache logs', 'group': g.group_id},
{'param': 'apache_stats_user', 'value': 'admin', 'section': 'apache',
'desc': 'Username for accessing Apache stats page', 'group': g.group_id},
{'param': 'apache_stats_password', 'value': 'password', 'section': 'apache',
'desc': 'Password for Apache stats webpage', 'group': g.group_id},
{'param': 'apache_stats_port', 'value': '8087', 'section': 'apache', 'desc': 'Stats port for webpage Apache',
'group': g.group_id},
{'param': 'apache_stats_page', 'value': 'stats', 'section': 'apache', 'desc': 'URI Stats for webpage Apache',
'group': g.group_id},
{'param': 'apache_dir', 'value': '/etc/httpd/', 'section': 'apache',
'desc': 'Path to the Apache directory with config files', 'group': g.group_id},
{'param': 'apache_config_path', 'value': '/etc/httpd/conf/httpd.conf', 'section': 'apache',
'desc': 'Path to the main Apache configuration file', 'group': g.group_id},
{'param': 'apache_container_name', 'value': 'apache', 'section': 'apache',
'desc': 'Docker container name for Apache service', 'group': g.group_id},
]
try:

@ -9,11 +9,7 @@ def is_ip_or_dns(server_from_request: str) -> str:
ip_regex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
dns_regex = "^(?!-)[A-Za-z0-9-]+([\\-\\.]{1}[a-z0-9]+)*\\.[A-Za-z]{2,6}$"
try:
if ('roxy-wi' in server_from_request or
'fail2ban' in server_from_request or
'prometheus' in server_from_request or
'all' in server_from_request or
'grafana-server' in server_from_request):
if server_from_request in ('roxy-wi', 'fail2ban', 'prometheus', 'all', 'grafana-server', 'rabbitmq-server'):
return server_from_request
if re.match(ip_regex, server_from_request):
return server_from_request
@ -522,20 +518,18 @@ def get_sections(config, **kwargs):
if find_ip:
return_config.append(find_ip[0])
else:
if (
line.startswith('listen') or
line.startswith('frontend') or
line.startswith('backend') or
line.startswith('cache') or
line.startswith('defaults') or
line.startswith('global') or
line.startswith('#HideBlockEnd') or
line.startswith('#HideBlockStart') or
line.startswith('peers') or
line.startswith('resolvers') or
line.startswith('userlist') or
line.startswith('http-errors')
):
if line.startswith(('global',
'listen',
'frontend',
'backend',
'cache',
'defaults',
'#HideBlockStart',
'#HideBlockEnd',
'peers',
'resolvers',
'userlist',
'http-errors')):
line = line.strip()
return_config.append(line)
@ -555,20 +549,18 @@ def get_section_from_config(config, section):
record = True
continue
if record:
if (
line.startswith('listen') or
line.startswith('frontend') or
line.startswith('backend') or
line.startswith('cache') or
line.startswith('defaults') or
line.startswith('global') or
line.startswith('#HideBlockEnd') or
line.startswith('#HideBlockStart') or
line.startswith('peers') or
line.startswith('resolvers') or
line.startswith('userlist') or
line.startswith('http-errors')
):
if line.startswith(('global',
'listen',
'frontend',
'backend',
'cache',
'defaults',
'#HideBlockStart',
'#HideBlockEnd',
'peers',
'resolvers',
'userlist',
'http-errors')):
record = False
end_line = index
end_line = end_line - 1

@ -47,7 +47,7 @@ if serv is not None and section is not None:
if serv is not None and form.getvalue('config') is not None:
try:
funct.logging(serv, "config.py edited config")
funct.logging(serv, "sections.py edited config")
except Exception:
pass
@ -69,7 +69,10 @@ if serv is not None and form.getvalue('config') is not None:
except IOError:
error = "Can't read import config file"
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save)
stderr = funct.master_slave_upload_and_restart(serv, cfg, just_save=save, oldcfg=oldcfg)
if "is valid" in stderr:
stderr = ''
funct.diff_config(oldcfg, cfg)

@ -1798,16 +1798,10 @@ def get_setting(param, **kwargs):
return query_res
else:
for setting in query_res:
if (
param == 'nginx_stats_port' or param == 'session_ttl' or param == 'token_ttl' or
param == 'stats_port' or param == 'haproxy_sock_port' or param == 'ldap_type' or
param == 'ldap_port' or param == 'ldap_enable' or param == 'log_time_storage' or
param == 'syslog_server_enable' or param == 'smon_check_interval' or
param == 'checker_check_interval' or param == 'port_scan_interval' or
param == 'smon_keep_history_range' or param == 'checker_keep_history_range' or
param == 'portscanner_keep_history_range' or param == 'checker_maxconn_threshold' or
param == 'apache_stats_port'
):
if param in ('nginx_stats_port', 'session_ttl', 'token_ttl', 'stats_port', 'haproxy_sock_port', 'ldap_type',
'ldap_port', 'ldap_enable', 'log_time_storage', 'syslog_server_enable', 'smon_check_interval',
'checker_check_interval', 'port_scan_interval', 'smon_keep_history_range', 'checker_keep_history_range',
'portscanner_keep_history_range', 'checker_maxconn_threshold', 'apache_stats_port'):
return int(setting.value)
else:
return setting.value

@ -27,20 +27,16 @@
{{set.param}}
</td>
<td class="addOption">
{% if set.param == 'ldap_password' or set.param == 'stats_password' or set.param == 'nginx_stats_password' %}
{% if set.param in ('ldap_password', 'stats_password', 'nginx_stats_password', 'apache_stats_password', 'rabbitmq_password') %}
{% if set.value is none %}
{{ input(set.param, size='25', type='password') }}
{% else %}
{{ input(set.param, size='25', type='password', placeholder='*****') }}
{% endif %}
{% elif set.param == 'nginx_stats_port' or set.param == 'session_ttl' or set.param == 'token_ttl' or
set.param == 'stats_port' or set.param == 'haproxy_sock_port' or set.param == 'ldap_type' or
set.param == 'ldap_port' or set.param == 'ldap_enable' or set.param == 'log_time_storage' or
set.param == 'syslog_server_enable' or set.param == 'smon_check_interval' or
set.param == 'checker_check_interval' or set.param == 'port_scan_interval' or
set.param == 'smon_keep_history_range' or set.param == 'checker_keep_history_range' or
set.param == 'portscanner_keep_history_range' or set.param == 'haproxy_enterprise' or
set.param == 'checker_maxconn_threshold' %}
{% elif set.param in ('nginx_stats_port', 'session_ttl', 'token_ttl', 'stats_port', 'haproxy_sock_port',
'ldap_type', 'ldap_port', 'ldap_enable', 'log_time_storage', 'syslog_server_enable', 'smon_check_interval',
'checker_check_interval', 'port_scan_interval', 'smon_keep_history_range', 'checker_keep_history_range',
'portscanner_keep_history_range', 'haproxy_enterprise', 'checker_maxconn_threshold', 'apache_stats_port') %}
{{ input(set.param, value=set.value, style='width: 210px;', type='number') }}
{% else %}

@ -1,5 +1,8 @@
{% extends "base.html" %}
{% block content %}
{% if is_serv_protected and role > 2 %}
<meta http-equiv="refresh" content="0; url=/app/hapservers.py?service={{service}}">
{% else %}
<link rel="stylesheet" href="/inc/codemirror/codemirror.css">
<script src="/inc/codemirror/codemirror.js"></script>
<script src="/inc/codemirror/nginx.js"></script>
@ -74,4 +77,5 @@
{% endif %}
</div>
</div>
{% endif %}
{% endblock %}
Loading…
Cancel
Save