From b40c6b615eca1a7171d83e3a3f58c7d4d17e0fd5 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 14 Apr 2021 21:10:24 +0200 Subject: [PATCH] Add MPTCP check support --- debian/changelog | 6 ++++++ omr-admin.py | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/debian/changelog b/debian/changelog index ece9b53..a5bafc5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +omr-vps-admin (0.3+20210414) unstable; urgency=medium + + * Add check MPTCP support + + -- OpenMPTCProuter Thu, 14 Apr 2021 21:10:30 +0200 + omr-vps-admin (0.3+20210408) unstable; urgency=medium * Fix timing attack potential vulnerability diff --git a/omr-admin.py b/omr-admin.py index 9cf4395..3738e30 100755 --- a/omr-admin.py +++ b/omr-admin.py @@ -34,6 +34,7 @@ import uvicorn import jwt 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.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm, SecurityScopes, OAuth2 @@ -1009,6 +1010,18 @@ async def status(request: Request): client_host = request.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 @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)):