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:
parent
6197d2c127
commit
b40c6b615e
2 changed files with 19 additions and 0 deletions
13
omr-admin.py
13
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)):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue