1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-vps-admin.git synced 2025-03-09 15:40:05 +00:00

Add MPTCP check support

This commit is contained in:
Ycarus (Yannick Chabanois) 2021-04-14 21:10:24 +02:00
parent 6197d2c127
commit b40c6b615e
2 changed files with 19 additions and 0 deletions

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
omr-vps-admin (0.3+20210414) unstable; urgency=medium
* Add check MPTCP support
-- OpenMPTCProuter <contact@openmptcprouter.com> Thu, 14 Apr 2021 21:10:30 +0200
omr-vps-admin (0.3+20210408) unstable; urgency=medium omr-vps-admin (0.3+20210408) unstable; urgency=medium
* Fix timing attack potential vulnerability * Fix timing attack potential vulnerability

View file

@ -34,6 +34,7 @@ import uvicorn
import jwt import jwt
from jwt import PyJWTError from jwt import PyJWTError
from netaddr import * from netaddr import *
from ipaddress import ip_address, IPv4Address, IPv6Address
from netjsonconfig import OpenWrt from netjsonconfig import OpenWrt
from fastapi import Depends, FastAPI, HTTPException, Security, Query, Request from fastapi import Depends, FastAPI, HTTPException, Security, Query, Request
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm, SecurityScopes, OAuth2 from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm, SecurityScopes, OAuth2
@ -1009,6 +1010,18 @@ async def status(request: Request):
client_host = request.client.host client_host = request.client.host
return {"client_host": client_host} return {"client_host": client_host}
# Check if MPTCP is enabled on this connection
@app.get('/mptcpsupport')
async def mptcpsupport(request: Request):
ip = request.client.host
if type(ip_address(ip)) is IPv4Address:
ipr = list(reversed(ip.split('.')))
iptohex = '{:02X}{:02X}{:02X}{:02X}'.format(*map(int, ipr))
with open('/proc/net/mptcp_net/mptcp') as f:
if iptohex in f.read():
return {"mptcp": "working"}
return {"mptcp": "not working"}
# Get VPS status # Get VPS status
@app.get('/status', summary="Get current server load average, uptime and release") @app.get('/status', summary="Get current server load average, uptime and release")
async def status(userid: Optional[int] = Query(None), serial: Optional[str] = Query(None), current_user: User = Depends(get_current_user)): async def status(userid: Optional[int] = Query(None), serial: Optional[str] = Query(None), current_user: User = Depends(get_current_user)):