mirror of https://github.com/Aidaho12/haproxy-wi
parent
a4af25a91e
commit
c3c12f8d4d
13
app/funct.py
13
app/funct.py
|
@ -272,7 +272,10 @@ def check_login(**kwargs):
|
||||||
import sql
|
import sql
|
||||||
import http.cookies
|
import http.cookies
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
|
try:
|
||||||
user_uuid = cookie.get('uuid')
|
user_uuid = cookie.get('uuid')
|
||||||
|
except Exception:
|
||||||
|
print('<meta http-equiv="refresh" content="0; url=/app/login.py">')
|
||||||
ref = os.environ.get("REQUEST_URI")
|
ref = os.environ.get("REQUEST_URI")
|
||||||
|
|
||||||
sql.delete_old_uuid()
|
sql.delete_old_uuid()
|
||||||
|
@ -492,7 +495,6 @@ def get_remote_sections(server_ip: str, service: str) -> str:
|
||||||
elif service == 'apache':
|
elif service == 'apache':
|
||||||
section_name = 'ServerName'
|
section_name = 'ServerName'
|
||||||
commands = ['sudo grep {} {}* -R |grep -v \'$server_name\|#\'|awk \'{{print $1, $3}}\''.format(section_name, config_dir)]
|
commands = ['sudo grep {} {}* -R |grep -v \'$server_name\|#\'|awk \'{{print $1, $3}}\''.format(section_name, config_dir)]
|
||||||
|
|
||||||
backends = ssh_command(server_ip, commands)
|
backends = ssh_command(server_ip, commands)
|
||||||
|
|
||||||
return backends
|
return backends
|
||||||
|
@ -1526,18 +1528,17 @@ def get_users_params(**kwargs):
|
||||||
import http.cookies
|
import http.cookies
|
||||||
import sql
|
import sql
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
user_uuid = cookie.get('uuid')
|
|
||||||
try:
|
try:
|
||||||
|
user_uuid = cookie.get('uuid')
|
||||||
user = sql.get_user_name_by_uuid(user_uuid.value)
|
user = sql.get_user_name_by_uuid(user_uuid.value)
|
||||||
role = sql.get_user_role_by_uuid(user_uuid.value)
|
role = sql.get_user_role_by_uuid(user_uuid.value)
|
||||||
user_id = sql.get_user_id_by_uuid(user_uuid.value)
|
user_id = sql.get_user_id_by_uuid(user_uuid.value)
|
||||||
user_services = sql.select_user_services(user_id)
|
user_services = sql.select_user_services(user_id)
|
||||||
token = sql.get_token(user_uuid.value)
|
token = sql.get_token(user_uuid.value)
|
||||||
except:
|
except:
|
||||||
user = ''
|
print('<meta http-equiv="refresh" content="0; url=/app/login.py">')
|
||||||
role = ''
|
|
||||||
user_services = ''
|
|
||||||
token = ''
|
|
||||||
if kwargs.get('virt') and kwargs.get('haproxy'):
|
if kwargs.get('virt') and kwargs.get('haproxy'):
|
||||||
servers = sql.get_dick_permit(virt=1, haproxy=1)
|
servers = sql.get_dick_permit(virt=1, haproxy=1)
|
||||||
elif kwargs.get('virt'):
|
elif kwargs.get('virt'):
|
||||||
|
|
14
app/sql.py
14
app/sql.py
|
@ -135,7 +135,7 @@ def add_setting_for_new_group(group_id):
|
||||||
{'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main',
|
{'param': 'cert_path', 'value': '/etc/ssl/certs/', 'section': 'main',
|
||||||
'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. The path must be valid',
|
'desc': 'Path to SSL dir. Folder owner must be a user which set in the SSH settings. The path must be valid',
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
{'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/access.log', 'section': 'haproxy',
|
{'param': 'haproxy_path_logs', 'value': '/var/log/haproxy/', 'section': 'haproxy',
|
||||||
'desc': 'The default local path for saving logs', 'group': group_id},
|
'desc': 'The default local path for saving logs', 'group': group_id},
|
||||||
{'param': 'syslog_server_enable', 'value': '0', 'section': 'logs',
|
{'param': 'syslog_server_enable', 'value': '0', 'section': 'logs',
|
||||||
'desc': 'Enable getting logs from a syslog server; (0 - no, 1 - yes)', 'group': group_id},
|
'desc': 'Enable getting logs from a syslog server; (0 - no, 1 - yes)', 'group': group_id},
|
||||||
|
@ -159,7 +159,7 @@ def add_setting_for_new_group(group_id):
|
||||||
'desc': 'Path to the HAProxy sock file', 'group': group_id},
|
'desc': 'Path to the HAProxy sock file', 'group': group_id},
|
||||||
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'Socket port for HAProxy',
|
{'param': 'haproxy_sock_port', 'value': '1999', 'section': 'haproxy', 'desc': 'Socket port for HAProxy',
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
{'param': 'nginx_path_error_logs', 'value': '/var/log/nginx/error.log', 'section': 'nginx',
|
{'param': 'nginx_path_logs', 'value': '/var/log/nginx/', 'section': 'nginx',
|
||||||
'desc': 'Nginx error log', 'group': group_id},
|
'desc': 'Nginx error log', 'group': group_id},
|
||||||
{'param': 'nginx_stats_user', 'value': 'admin', 'section': 'nginx', 'desc': 'Username for accessing Nginx stats page',
|
{'param': 'nginx_stats_user', 'value': 'admin', 'section': 'nginx', 'desc': 'Username for accessing Nginx stats page',
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
|
@ -169,7 +169,7 @@ def add_setting_for_new_group(group_id):
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
{'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx',
|
{'param': 'nginx_stats_page', 'value': 'stats', 'section': 'nginx', 'desc': 'URI Stats for web page Nginx',
|
||||||
'group': group_id},
|
'group': group_id},
|
||||||
{'param': 'nginx_dir', 'value': '/etc/nginx/conf.d/', 'section': 'nginx',
|
{'param': 'nginx_dir', 'value': '/etc/nginx/', 'section': 'nginx',
|
||||||
'desc': 'Path to the Nginx directory with config files', 'group': group_id},
|
'desc': 'Path to the Nginx directory with config files', 'group': group_id},
|
||||||
{'param': 'nginx_config_path', 'value': '/etc/nginx/nginx.conf', 'section': 'nginx',
|
{'param': 'nginx_config_path', 'value': '/etc/nginx/nginx.conf', 'section': 'nginx',
|
||||||
'desc': 'Path to the main Nginx configuration file', 'group': group_id},
|
'desc': 'Path to the main Nginx configuration file', 'group': group_id},
|
||||||
|
@ -738,18 +738,19 @@ def get_slack_by_id(slack_id):
|
||||||
|
|
||||||
|
|
||||||
def get_dick_permit(**kwargs):
|
def get_dick_permit(**kwargs):
|
||||||
import http.cookies
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
if kwargs.get('username'):
|
if kwargs.get('username'):
|
||||||
grp = kwargs.get('group_id')
|
grp = kwargs.get('group_id')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
import http.cookies
|
||||||
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
cookie = http.cookies.SimpleCookie(os.environ.get("HTTP_COOKIE"))
|
||||||
group = cookie.get('group')
|
group = cookie.get('group')
|
||||||
grp = group.value
|
grp = group.value
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('error: ' + str(e))
|
print('<meta http-equiv="refresh" content="0; url=/app/login.py">')
|
||||||
|
return
|
||||||
if kwargs.get('token'):
|
if kwargs.get('token'):
|
||||||
token = kwargs.get('token')
|
token = kwargs.get('token')
|
||||||
else:
|
else:
|
||||||
|
@ -779,11 +780,14 @@ def get_dick_permit(**kwargs):
|
||||||
|
|
||||||
if funct.check_user_group(token=token):
|
if funct.check_user_group(token=token):
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
try:
|
||||||
if grp == '1' and not only_group:
|
if grp == '1' and not only_group:
|
||||||
sql = """ select * from servers where {} {} {} {} {} {} order by pos""" .format(disable, type_ip, nginx, haproxy, keepalived, ip)
|
sql = """ select * from servers where {} {} {} {} {} {} order by pos""" .format(disable, type_ip, nginx, haproxy, keepalived, ip)
|
||||||
else:
|
else:
|
||||||
sql = """ select * from servers where groups = '{group}' and ({disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived} order by pos
|
sql = """ select * from servers where groups = '{group}' and ({disable}) {type_ip} {ip} {haproxy} {nginx} {keepalived} order by pos
|
||||||
""".format(group=grp, disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived)
|
""".format(group=grp, disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived)
|
||||||
|
except Exception:
|
||||||
|
print('<meta http-equiv="refresh" content="0; url=/app/login.py">')
|
||||||
try:
|
try:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -58,10 +58,13 @@
|
||||||
<a href="/app/waf.py?manage_rules=1&serv={{service.1}}" class="ui-button ui-widget ui-corner-all">Open</a>
|
<a href="/app/waf.py?manage_rules=1&serv={{service.1}}" class="ui-button ui-widget ui-corner-all">Open</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="/app/logs.py?serv={{ service.1 }}&rows=10&grep=&hour=00&minut=00&hour1=24&minut1=00&waf=1" class="ui-button ui-widget ui-corner-all" title="View log">View</a>
|
||||||
|
</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if role <= 2 %}
|
{% if role <= 2 %}
|
||||||
<td colspan="5">
|
<td colspan="6">
|
||||||
<a title="Install WAF"><button onclick="installWaf('{{ service.1 }}')">Install</button></a>
|
<a title="Install WAF"><button onclick="installWaf('{{ service.1 }}')">Install</button></a>
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue