diff --git a/app/modules/roxywi/roxy.py b/app/modules/roxywi/roxy.py index c4ac555d..d44b4938 100644 --- a/app/modules/roxywi/roxy.py +++ b/app/modules/roxywi/roxy.py @@ -66,6 +66,8 @@ def versions(): current_ver_without_dots = current_ver.split('.') current_ver_without_dots = ''.join(current_ver_without_dots) current_ver_without_dots = current_ver_without_dots.replace('\n', '') + if len(current_ver_without_dots) == 4: + current_ver_without_dots += '0' current_ver_without_dots = int(current_ver_without_dots) except Exception: current_ver = "Sorry cannot get current version" @@ -150,6 +152,7 @@ def check_new_version(service): proxy = sql.get_setting('proxy') res = '' user_name = sql.select_user_name() + proxy_dict = {} retry_strategy = Retry( total=3, status_forcelist=[429, 500, 502, 503, 504], @@ -162,24 +165,18 @@ def check_new_version(service): try: if proxy is not None and proxy != '' and proxy != 'None': proxy_dict = {"https": proxy, "http": proxy} - response = requests.get(f'https://roxy-wi.org/version/get/{service}', timeout=1, proxies=proxy_dict) - if service == 'roxy-wi': - requests.get(f'https://roxy-wi.org/version/send/{current_ver}', timeout=1, proxies=proxy_dict) - roxy_wi_get_plan = requests.get(f'https://roxy-wi.org/user-name/{user_name}', timeout=1, proxies=proxy_dict) - else: - response = requests.get(f'https://roxy-wi.org/version/get/{service}', timeout=1) - if service == 'roxy-wi': - requests.get(f'https://roxy-wi.org/version/send/{current_ver}', timeout=1) - roxy_wi_get_plan = requests.get(f'https://roxy-wi.org/user-name/{user_name}', timeout=1) - - res = response.content.decode(encoding='UTF-8') + response = requests.get(f'https://roxy-wi.org/version/get/{service}', timeout=1, proxies=proxy_dict) if service == 'roxy-wi': + requests.get(f'https://roxy-wi.org/version/send/{current_ver}', timeout=1, proxies=proxy_dict) + roxy_wi_get_plan = requests.get(f'https://roxy-wi.org/user-name/{user_name}', timeout=1, proxies=proxy_dict) try: status = roxy_wi_get_plan.content.decode(encoding='UTF-8') status = status.split(' ') sql.update_user_status(status[0], status[1].strip(), status[2].strip()) except Exception: pass + + res = response.content.decode(encoding='UTF-8') except requests.exceptions.RequestException as e: roxywi_common.logging('Roxy-WI server', f' {e}', roxywi=1) diff --git a/app/modules/roxywi/user.py b/app/modules/roxywi/user.py index 517d8e3e..9a013a45 100644 --- a/app/modules/roxywi/user.py +++ b/app/modules/roxywi/user.py @@ -7,7 +7,7 @@ import modules.roxywi.common as roxywi_common import modules.tools.alerting as alerting -def create_user(new_user: str, email: str, password: str, role: str, activeuser: int, group: int) -> bool: +def create_user(new_user: str, email: str, password: str, role: str, activeuser: int, group: int) -> None: try: user_id = sql.add_user(new_user, email, password, role, activeuser, group) sql.update_user_role(user_id, group, role) @@ -30,8 +30,6 @@ def create_user(new_user: str, email: str, password: str, role: str, activeuser: except Exception as e: roxywi_common.logging('error: Cannot create a new user', e, roxywi=1, login=1) raise Exception(f'error: Cannot create a new user: {e}') - else: - return True def delete_user(user_id: int) -> str: diff --git a/app/routes/checker/routes.py b/app/routes/checker/routes.py index 3ab56fe8..7db963ab 100644 --- a/app/routes/checker/routes.py +++ b/app/routes/checker/routes.py @@ -46,12 +46,12 @@ def update_settings(): email = int(request.form.get('email')) service_alert = int(request.form.get('server')) backend_alert = int(request.form.get('backend')) - maxconn_alert = int(request.form.get('maxconn')) telegram_id = int(request.form.get('telegram_id')) slack_id = int(request.form.get('slack_id')) pd_id = int(request.form.get('pd_id')) if service == 'haproxy': + maxconn_alert = int(request.form.get('maxconn')) return checker_mod.update_haproxy_settings( setting_id, email, service_alert, backend_alert, maxconn_alert, telegram_id, slack_id, pd_id ) diff --git a/app/routes/install/routes.py b/app/routes/install/routes.py index 65413bdf..cb61feef 100644 --- a/app/routes/install/routes.py +++ b/app/routes/install/routes.py @@ -223,7 +223,7 @@ def install_grafana(): return f'{e}' -@bp.route('/waf//') +@bp.post('/waf//') def install_waf(service, server_ip): server_ip = common.is_ip_or_dns(server_ip) diff --git a/app/routes/service/routes.py b/app/routes/service/routes.py index d3389257..79a4d5f2 100644 --- a/app/routes/service/routes.py +++ b/app/routes/service/routes.py @@ -217,7 +217,10 @@ def check_service(): server_ip = common.checkAjaxInput(request.form.get('server_ip')) service = common.checkAjaxInput(request.form.get('service')) - return service_action.check_service(server_ip, user_uuid, service) + try: + return service_action.check_service(server_ip, user_uuid, service) + except Exception: + pass @bp.route('/action///', methods=['GET']) diff --git a/app/routes/user/routes.py b/app/routes/user/routes.py index 20b229a4..84e09a8a 100644 --- a/app/routes/user/routes.py +++ b/app/routes/user/routes.py @@ -42,7 +42,11 @@ def create_user(): if roxywi_auth.is_admin(level=2, role_id=role): roxywi_common.logging(new_user, ' tried to privilege escalation: user creation', roxywi=1, login=1) return 'error: Wrong role' - if roxywi_user.create_user(new_user, email, password, role, activeuser, group): + try: + roxywi_user.create_user(new_user, email, password, role, activeuser, group) + except Exception as e: + return str(e) + else: return render_template( 'ajax/new_user.html', users=sql.select_users(user=new_user), groups=sql.select_groups(), page=page, roles=sql.select_roles(), adding=1, lang=lang diff --git a/inc/users.js b/inc/users.js index bf10addb..99415d52 100644 --- a/inc/users.js +++ b/inc/users.js @@ -2775,7 +2775,7 @@ function updateServiceCheckerSettings(id, service_name) { url: "/app/checker/settings/update", data: { service: service_name, - settings_id: id, + setting_id: id, email: email, server: server, telegram_id: $('#' + service_name + '_server_telegram_channel-' + id + ' option:selected').val(),