From 18f16e21facff80fe91c62ba7b3ea5cfe587fcc3 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Mon, 7 Aug 2023 19:18:44 +0200 Subject: [PATCH] Add upload speedtest and replace deprecated regex by pattern --- debian/changelog | 7 +++++++ omr-admin.py | 17 +++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8b60349..1e36ff3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +omr-vps-admin (0.3+20230807) unstable; urgency=medium + + * Replace regex by pattern + * Add upload speedtest + + -- OpenMPTCProuter Mon, 07 Aug 2023 19:17:52 +0200 + omr-vps-admin (0.3+20230724) unstable; urgency=medium * Fix port redirection string to int diff --git a/omr-admin.py b/omr-admin.py index e4e98ab..1fa3e29 100755 --- a/omr-admin.py +++ b/omr-admin.py @@ -36,7 +36,7 @@ from jwt import PyJWTError from netaddr import * from ipaddress import ip_address, IPv4Address, IPv6Address from netjsonconfig import OpenWrt -from fastapi import Depends, FastAPI, HTTPException, Security, Query, Request +from fastapi import Depends, FastAPI, HTTPException, Security, Query, Request, UploadFile from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm, SecurityScopes, OAuth2 from passlib.context import CryptContext from fastapi.encoders import jsonable_encoder @@ -2090,7 +2090,7 @@ def proxy(*, proxyconfig: Proxy, current_user: User = Depends(get_current_user)) class GlorytunConfig(BaseModel): key: str port: int = Query(..., gt=0, lt=65535, title="Glorytun TCP and UDP port") - chacha: bool = Query(True, title="Enable of disable chacha20, if disable AEGIS is used") + chacha: bool = Query(True, title="Enable of disable chacha20, if disable AES is used") # Set Glorytun config @app.post('/glorytun', summary="Modify Glorytun configuration") @@ -2338,8 +2338,8 @@ def lan(*, lanconfig: Lanips, current_user: User = Depends(get_current_user)): return {'result': 'done', 'reason': 'changes applied', 'route': 'lan'} class VPNips(BaseModel): - remoteip: str = Query(..., regex='^(10(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){3}|((172\.(1[6-9]|2[0-9]|3[01]))|192\.168)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){2})$') - localip: str = Query(..., regex='^(10(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){3}|((172\.(1[6-9]|2[0-9]|3[01]))|192\.168)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){2})$') + remoteip: str = Query(..., pattern='^(10(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){3}|((172\.(1[6-9]|2[0-9]|3[01]))|192\.168)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){2})$') + localip: str = Query(..., pattern='^(10(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){3}|((172\.(1[6-9]|2[0-9]|3[01]))|192\.168)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){2})$') remoteip6: Optional[str] = None localip6: Optional[str] = None ula: Optional[str] = None @@ -2634,10 +2634,15 @@ async def list_users(current_user: User = Depends(get_current_user)): return content['users'][0] @app.get('/speedtest', summary="Test speed from the server") -async def list_users(current_user: User = Depends(get_current_user)): +async def speedtest(): return FileResponse('/usr/share/omr-server/speedtest/test.img') - +@app.post('/speedtest', summary="Test upload speed from the server") +async def speedtestul(file: UploadFile | None = None): + if not file: + return {'result': 'No upload file sent'} + else: + return {'filename': file.filename} def main(omrport: int, omrhost: str): LOG.debug("Main OMR-Admin launch")