diff --git a/api/api.py b/api/api.py index 7cb16ba2..bc49ab8e 100644 --- a/api/api.py +++ b/api/api.py @@ -222,7 +222,7 @@ def haproxy_section_add(haproxy_id): @route('/haproxy//section/delete', method=['POST']) @route('/haproxy//section/delete', method=['POST']) -def haproxy_section_add(haproxy_id): +def haproxy_section_delete(haproxy_id): if not check_login(required_service=1): return dict(error=_error_auth) return api_funct.edit_section(haproxy_id, delete=1) diff --git a/app/modules/service/action.py b/app/modules/service/action.py index 5bb3e1df..f7ec18a2 100644 --- a/app/modules/service/action.py +++ b/app/modules/service/action.py @@ -124,8 +124,9 @@ def action_haproxy_waf(server_ip: str, action: str) -> str: except Exception as e: return str(e) - roxywi_common.logging(server_ip, f'HAProxy WAF service has been {action}ed', roxywi=1, login=1, keep_history=1, - service='haproxy') + roxywi_common.logging( + server_ip, f'HAProxy WAF service has been {action}ed', roxywi=1, login=1, keep_history=1, service='haproxy' + ) commands = [f"sudo systemctl {action} waf"] server_mod.ssh_command(server_ip, commands) return f"success: WAF has been {action}" diff --git a/app/modules/service/installation.py b/app/modules/service/installation.py index 6c3044e4..592a0b34 100644 --- a/app/modules/service/installation.py +++ b/app/modules/service/installation.py @@ -227,7 +227,7 @@ def install_service(server_ip: str, service: str, docker: str, syn_flood_protect show_installation_output(return_out['error'], return_out['output'], service_name, rc=return_out['rc']) except Exception as e: raise Exception(e) - + if service == 'nginx': try: sql.update_nginx(server_ip) @@ -322,8 +322,10 @@ def grafana_install(): return f'success: Grafana and Prometheus servers were installed. You can find Grafana on http://{host}:3000
' -def keepalived_master_install(master: str, eth: str, eth_slave: str, vrrp_ip: str, virt_server: int, syn_flood: int, - return_to_master: int, haproxy: int, nginx: int, router_id: int, api=0) -> str: +def keepalived_master_install( + master: str, eth: str, eth_slave: str, vrrp_ip: str, virt_server: int, syn_flood: int, return_to_master: int, + haproxy: int, nginx: int, router_id: int, api=0 +) -> str: script = "install_keepalived.sh" proxy = sql.get_setting('proxy') keepalived_path_logs = sql.get_setting('keepalived_path_logs') @@ -373,8 +375,9 @@ def keepalived_master_install(master: str, eth: str, eth_slave: str, vrrp_ip: st return show_success_installation(service) -def keepalived_slave_install(master: str, slave: str, eth: str, eth_slave: str, vrrp_ip: str, syn_flood: int, - haproxy: int, nginx: int, router_id: int, api=0) -> str: +def keepalived_slave_install( + master: str, slave: str, eth: str, eth_slave: str, vrrp_ip: str, syn_flood: int, haproxy: int, nginx: int, router_id: int, api=0 +) -> str: script = "install_keepalived.sh" proxy = sql.get_setting('proxy') keepalived_path_logs = sql.get_setting('keepalived_path_logs') diff --git a/app/modules/tools/alerting.py b/app/modules/tools/alerting.py index 178de601..a3047f45 100644 --- a/app/modules/tools/alerting.py +++ b/app/modules/tools/alerting.py @@ -173,6 +173,7 @@ def telegram_send_mess(mess, level, **kwargs): try: bot = telebot.TeleBot(token=token_bot) bot.send_message(chat_id=channel_name, text=f'{level}: {mess}') + return 'ok' except Exception as e: roxywi_common.logging('Roxy-WI server', str(e), roxywi=1) raise Exception(f'error: {e}') @@ -206,6 +207,7 @@ def slack_send_mess(mess, level, **kwargs): try: client.chat_postMessage(channel=f'#{channel_name}', text=f'{level}: {mess}') + return 'ok' except SlackApiError as e: roxywi_common.logging('Roxy-WI server', str(e), roxywi=1) raise Exception(f'error: {e}') @@ -250,6 +252,7 @@ def pd_send_mess(mess, level, server_ip=None, service_id=None, alert_type=None, session.resolve(dedup_key) else: session.trigger(mess, 'Roxy-WI', dedup_key=dedup_key, severity=level, custom_details={'server': server_ip, 'alert': mess}) + return 'ok' except Exception as e: roxywi_common.logging('Roxy-WI server', str(e), roxywi=1) raise Exception(f'error: {e}') diff --git a/app/modules/tools/checker.py b/app/modules/tools/checker.py index 3ffb65f5..2055e9a0 100644 --- a/app/modules/tools/checker.py +++ b/app/modules/tools/checker.py @@ -28,7 +28,6 @@ def load_checker() -> None: try: user_params = roxywi_common.get_users_params() - user = user_params['user'] except Exception: return redirect(url_for('login_page')) diff --git a/app/routes/checker/routes.py b/app/routes/checker/routes.py index fbc66bbb..c4f8bd93 100644 --- a/app/routes/checker/routes.py +++ b/app/routes/checker/routes.py @@ -102,7 +102,7 @@ def receiver(receiver_name): group = common.checkAjaxInput(request.form.get('group')) page = common.checkAjaxInput(request.form.get('page')) page = page.split("#")[0] - + return alerting.add_receiver_channel(receiver_name, token, channel, group, page) elif request.method == 'PUT': token = common.checkAjaxInput(request.form.get('receiver_token')) diff --git a/app/routes/config/routes.py b/app/routes/config/routes.py index e62cec52..d2ee07cd 100644 --- a/app/routes/config/routes.py +++ b/app/routes/config/routes.py @@ -192,6 +192,7 @@ def versions(service, server_ip): if 'No such file or directory' in str(e): pass else: + configs_dir = get_config.get_config_var('configs', f'{service}_save_configs_dir') os.remove(os.path.join(configs_dir, get)) try: file.add(get + "\n") diff --git a/app/routes/runtime/routes.py b/app/routes/runtime/routes.py index 31aed7d9..c31ec10f 100644 --- a/app/routes/runtime/routes.py +++ b/app/routes/runtime/routes.py @@ -175,6 +175,7 @@ def get_list(server_ip, list_id, list_name): def delete_ip_from_list(): ip_id = common.checkAjaxInput(request.form.get('list_ip_id_for_delete')) ip = common.is_ip_or_dns(request.form.get('list_ip_for_delete')) + serv = common.is_ip_or_dns(request.form.get('serv')) list_id = common.checkAjaxInput(request.form.get('list_id_for_delete')) list_name = common.checkAjaxInput(request.form.get('list_name'))