v6.3.10.0

Changelog: https://roxy-wi.org/changelog#6_3_10
pull/364/head
Aidaho 2023-04-16 16:43:05 +03:00
parent afea8cbd1d
commit db22bf0884
4 changed files with 45 additions and 27 deletions

View File

@ -115,8 +115,11 @@ def check_permit_to_server(server_id, service='haproxy'):
token = request.headers.get('token')
login, group_id, role_id = sql.get_username_groupid_from_api_token(token)
for s in servers:
server = roxywi_common.get_dick_permit(username=login, group_id=group_id, ip=s[2], token=token, service=service)
try:
for s in servers:
server = roxywi_common.get_dick_permit(username=login, group_id=group_id, ip=s[2], token=token, service=service)
except Exception as e:
raise Exception(f'error: {e}')
return server
@ -299,31 +302,43 @@ def show_backends(server_id):
def get_config(server_id, **kwargs):
service = kwargs.get('service')
if service != 'apache' and service != 'nginx' and service != 'haproxy' and service != 'keepalived':
if service not in ('apache', 'nginx', 'haproxy', 'keepalived'):
return dict(status='wrong service')
data = {}
try:
servers = check_permit_to_server(server_id)
for s in servers:
cfg = '/tmp/' + s[2] + '.cfg'
config_mod.get_config(s[2], cfg, service=service, config_file_name=kwargs.get('config_path'))
os.system("sed -i 's/\\n/\n/g' " + cfg)
try:
conf = open(cfg, "r")
config_read = conf.read()
conf.close
except IOError:
conf = '<br />Cannot read import config file'
data = {server_id: config_read}
servers = check_permit_to_server(server_id, service=service)
except Exception as e:
data = {server_id: {"error": "Cannot find the server " + str(e)}}
data = {server_id: {"error": f"Cannot find the server {e}"}}
return dict(error=data)
for s in servers:
server_ip = s[2]
try:
cfg = f'/tmp/{server_ip}.cfg'
except Exception as e:
data = {server_id: {"error": f"Cannot find the server with the service {service}: {e}"}}
return dict(error=data)
try:
config_mod.get_config(server_ip, cfg, service=service, config_file_name=kwargs.get('config_path'))
except Exception as e:
data = {server_id: {"error": f"Cannot get config {e}"}}
return dict(error=data)
try:
os.system("sed -i 's/\\n/\n/g' " + cfg)
except Exception as e:
data = {server_id: {"error": f"Cannot edit config {e}"}}
return dict(error=data)
try:
conf = open(cfg, "r")
config_read = conf.read()
conf.close()
except IOError as e:
data = {server_id: {"error": f"Cannot read config {e}"}}
return dict(error=data)
data = {server_id: config_read}
return dict(config=data)

View File

@ -924,8 +924,8 @@ def get_dick_permit(**kwargs):
""".format(group=grp, disable=disable, type_ip=type_ip, ip=ip, haproxy=haproxy, nginx=nginx, keepalived=keepalived, apache=apache)
except Exception as e:
print(str(e))
print('<meta http-equiv="refresh" content="0; url=/app/login.py">')
raise Exception(f'error: {e}')
try:
cursor.execute(sql)
except Exception as e:

View File

@ -220,7 +220,12 @@ def get_dick_permit(**kwargs):
token = ''
if check_user_group(token=token):
return sql.get_dick_permit(**kwargs)
try:
servers = sql.get_dick_permit(**kwargs)
except Exception as e:
raise Exception(e)
else:
return servers
else:
print('Atata!')

View File

@ -2056,9 +2056,7 @@ if form.getvalue('loadopenvpn'):
openvpn_sess, stderr = server_mod.subprocess_execute(cmd)
openvpn = stdout[0]
template = template.render(openvpn=openvpn,
openvpn_sess=openvpn_sess,
openvpn_configs=openvpn_configs)
template = template.render(openvpn=openvpn, openvpn_sess=openvpn_sess, openvpn_configs=openvpn_configs)
print(template)
if form.getvalue('check_receiver'):