Pavel Loginov 3 years ago
parent f0da84e4ba
commit b1dc9b6ce8

@ -31,24 +31,27 @@ def default_values():
'group': '1'},
{'param': 'log_time_storage', 'value': '14', 'section': 'logs',
'desc': 'Retention period for user activity logs (in days)', 'group': '1'},
{'param': 'stats_user', 'value': 'admin', 'section': 'haproxy', 'desc': 'Username for Stats web page HAProxy',
{'param': 'stats_user', 'value': 'admin', 'section': 'haproxy', 'desc': 'Username for accessing HAProxy stats page',
'group': '1'},
{'param': 'stats_password', 'value': 'password', 'section': 'haproxy',
'desc': 'Password for Stats web page HAProxy', 'group': '1'},
{'param': 'stats_port', 'value': '8085', 'section': 'haproxy', 'desc': 'Port Stats web page HAProxy',
'desc': 'Password for accessing HAProxy stats page', 'group': '1'},
{'param': 'stats_port', 'value': '8085', 'section': 'haproxy', 'desc': 'Port for HAProxy stats page',
'group': '1'},
{'param': 'stats_page', 'value': 'stats', 'section': 'haproxy', 'desc': 'URI Stats web page HAProxy',
{'param': 'stats_page', 'value': 'stats', 'section': 'haproxy', 'desc': 'URI for HAProxy stats page',
'group': '1'},
{'param': 'haproxy_dir', 'value': '/etc/haproxy', 'section': 'haproxy', 'desc': 'Path to HAProxy dir',
{'param': 'haproxy_dir', 'value': '/etc/haproxy', 'section': 'haproxy', 'desc': 'Path to the HAProxy directory',
'group': '1'},
{'param': 'haproxy_config_path', 'value': '/etc/haproxy/haproxy.cfg', 'section': 'haproxy', 'desc': '',
{'param': 'haproxy_config_path', 'value': '/etc/haproxy/haproxy.cfg', 'section': 'haproxy', 'desc': 'Path to the HAProxy configuration file',
'group': '1'},
{'param': 'server_state_file', 'value': 'stats', 'section': 'haproxy', 'desc': 'Path to HAProxy config',
{'param': 'server_state_file', 'value': 'stats', 'section': 'haproxy', 'desc': 'Path to the HAProxy state file',
'group': '1'},
{'param': 'haproxy_sock', 'value': '/etc/haproxy/haproxy.state', 'section': 'haproxy',
'desc': 'Path to HAProxy state file', 'group': '1'},
'desc': 'Socket port for HAProxy', 'group': '1'},
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'HAProxy sock port',
'group': '1'},
{'param': 'haproxy_enterprise', 'value': '0', 'section': 'haproxy',
'desc': 'If you use enterprise HAProxy, set the value of this parameter to 1. The name of the service will be changed as it is required for the commercial version',
'group': '1'},
{'param': 'apache_log_path', 'value': '/var/log/httpd/', 'section': 'logs', 'desc': 'Path to Apache logs',
'group': '1'},
{'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx',
@ -61,10 +64,10 @@ def default_values():
'group': '1'},
{'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx',
'group': '1'},
{'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx', 'desc': 'Path to Nginx dir',
{'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx', 'desc': 'Path to the Nginx directory',
'group': '1'},
{'param': 'nginx_config_path', 'value': '/etc/nginx/conf.d/default.conf', 'section': 'nginx',
'desc': 'Path to Nginx config', 'group': '1'},
'desc': 'Path to the Nginx configuration file', 'group': '1'},
{'param': 'ldap_enable', 'value': '0', 'section': 'ldap', 'desc': 'Enable LDAP (1 - yes, 0 - no)',
'group': '1'},
{'param': 'ldap_server', 'value': '', 'section': 'ldap', 'desc': 'IP address of the LDAP server', 'group': '1'},
@ -84,9 +87,6 @@ def default_values():
{'param': 'ldap_search_field', 'value': 'mail', 'section': 'ldap',
'desc': 'The field for saving the user\'s e-mail address', 'group': '1'},
{'param': 'ldap_type', 'value': '0', 'section': 'ldap', 'desc': 'Use LDAP (0) or LDAPS (1)', 'group': '1'},
{'param': 'haproxy_enterprise', 'value': '0', 'section': 'haproxy',
'desc': 'Use this option if your HAProxy is enterprise. It changes service name for rebooting/reloading',
'group': '1'},
]
try:
Setting.insert_many(data_source).on_conflict_ignore().execute()

@ -12,7 +12,7 @@ if mysql_enable == '1':
mysql_port = funct.get_config_var('mysql', 'mysql_port')
conn = MySQLDatabase(mysql_db, user=mysql_user, password=mysql_password, host=mysql_host, port=mysql_port)
else:
db = "roxy-wi.db"
db = "/var/www/haproxy-wi/app/roxy-wi.db"
conn = SqliteDatabase(db)

@ -29,16 +29,27 @@ def get_config_var(sec, var):
print('<center><div class="alert alert-danger">Check the config file. Presence section %s and parameter %s</div>' % (sec, var))
def get_data(log_type):
from datetime import datetime
def get_data(log_type, **kwargs):
from datetime import datetime, timedelta
from pytz import timezone
import sql
fmt = "%Y-%m-%d.%H:%M:%S"
try:
now_utc = datetime.now(timezone(sql.get_setting('time_zone')))
except Exception:
now_utc = datetime.now(timezone('UTC'))
if kwargs.get('timedelta'):
try:
now_utc = datetime.now(timezone(sql.get_setting('time_zone'))) + timedelta(days=kwargs.get('timedelta'))
except Exception:
now_utc = datetime.now(timezone('UTC')) + timedelta(days=kwargs.get('timedelta'))
elif kwargs.get('timedelta_minus'):
try:
now_utc = datetime.now(timezone(sql.get_setting('time_zone'))) - timedelta(days=kwargs.get('timedelta_minus'))
except Exception:
now_utc = datetime.now(timezone('UTC')) - timedelta(days=kwargs.get('timedelta_minus'))
else:
try:
now_utc = datetime.now(timezone(sql.get_setting('time_zone')))
except Exception:
now_utc = datetime.now(timezone('UTC'))
if log_type == 'config':
fmt = "%Y-%m-%d.%H:%M:%S"
@ -597,8 +608,8 @@ def install_haproxy(serv, **kwargs):
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv +
" SOCK_PORT=" + hap_sock_p + " STAT_PORT=" + stats_port + " STAT_FILE="+server_state_file +
" SSH_PORT=" + ssh_port + " STATS_USER=" + stats_user +
" STATS_PASS=" + stats_password + " HAPVER=" + haproxy_ver + " SYN_FLOOD=" + syn_flood_protect +
" HOST=" + serv + " USER=" + ssh_user_name + " PASS=" + ssh_user_password + " KEY=" + ssh_key_name]
" STATS_PASS='" + stats_password + "' HAPVER=" + haproxy_ver + " SYN_FLOOD=" + syn_flood_protect +
" HOST=" + serv + " USER=" + ssh_user_name + " PASS='" + ssh_user_password + "' KEY=" + ssh_key_name]
output, error = subprocess_execute(commands[0])
if server_for_installing:
@ -670,9 +681,9 @@ def install_nginx(serv, **kwargs):
syn_flood_protect = '1' if form.getvalue('syn_flood') == "1" else ''
commands = ["chmod +x " + script + " && ./" + script + " PROXY=" + proxy_serv + " STATS_USER=" + stats_user +
" STATS_PASS=" + stats_password + " SSH_PORT=" + ssh_port + " CONFIG_PATH=" + config_path +
" STATS_PASS='" + stats_password + "' SSH_PORT=" + ssh_port + " CONFIG_PATH=" + config_path +
" STAT_PORT=" + stats_port + " STAT_PAGE=" + stats_page+" SYN_FLOOD=" + syn_flood_protect +
" HOST=" + serv + " USER=" + ssh_user_name + " PASS=" + ssh_user_password + " KEY=" + ssh_key_name]
" HOST=" + serv + " USER=" + ssh_user_name + " PASS='" + ssh_user_password + "' KEY=" + ssh_key_name]
output, error = subprocess_execute(commands[0])
if server_for_installing:
@ -692,7 +703,6 @@ def update_haproxy_wi(service):
service = service.split('_')[0]
except Exception:
pass
# service = 'roxy-wi-'+service
cmd = 'sudo -S yum -y update ' + service +' && sudo systemctl restart ' + service
output, stderr = subprocess_execute(cmd)
print(output)
@ -1211,15 +1221,6 @@ def get_hash(value):
p = h.hexdigest()
return p
def out_error(error):
error = str(error)
try:
logging('localhost', error, haproxywi=1, login=1)
except Exception:
logging('localhost', error, haproxywi=1)
print('error: '+error)
def get_users_params(**kwargs):
import http.cookies

File diff suppressed because it is too large Load Diff

@ -30,21 +30,22 @@
<tbody>
{% if port_scanner_settings != '' %}
{% for t in port_scanner_settings %}
{% set date_time = t.date|string %}
<tr>
<td class="padding10" style="width: 10%; padding: 7px 7px 7px 10px;">
{% if t.2 == 'opened' %}
{% if t.status == 'opened' %}
{% set color = '#5ad05a' %}
{% else %}
{% set color = '#be2424' %}
{% endif %}
<span style="color: {{color}};"><b>{{t.2 |upper}}</b></span>
<span style="color: {{color}};"><b>{{t.status |upper}}</b></span>
</td>
<td>{{t.0}}</td>
<td>{{t.1}}</td>
<td>{{t.3}}</td>
<td>{{t.4.split(' ')[0]}}
<td>{{t.serv}}</td>
<td>{{t.port}}</td>
<td>{{t.service_name}}</td>
<td>{{date_time.split(' ')[0]}}
</td>
<td>{{t.4.split(' ')[1]}}</td>
<td>{{date_time.split(' ')[1]}}</td>
</tr>
{% endfor %}
{% else %}

Loading…
Cancel
Save