Browse Source

v7.0.0.0

Changelog: https://roxy-wi.org/changelog#7.0.0
pull/364/head
Aidaho 1 year ago
parent
commit
f4b7e67bc4
  1. 19
      app/modules/roxywi/roxy.py
  2. 4
      app/modules/roxywi/user.py
  3. 2
      app/routes/checker/routes.py
  4. 2
      app/routes/install/routes.py
  5. 5
      app/routes/service/routes.py
  6. 6
      app/routes/user/routes.py
  7. 2
      inc/users.js

19
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)

4
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:

2
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
)

2
app/routes/install/routes.py

@ -223,7 +223,7 @@ def install_grafana():
return f'{e}'
@bp.route('/waf/<service>/<server_ip>')
@bp.post('/waf/<service>/<server_ip>')
def install_waf(service, server_ip):
server_ip = common.is_ip_or_dns(server_ip)

5
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/<service>/<server_ip>/<action>', methods=['GET'])

6
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

2
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(),

Loading…
Cancel
Save