Use ip + port to identify the client

This commit is contained in:
DingZQ
2023-02-19 17:31:47 +08:00
parent 064b165678
commit ebe58aef14

View File

@@ -101,18 +101,18 @@ async def fastapi_dump_output(output: str) -> str:
@app.get("/isprojectlocked/")
async def fastapi_is_locked(network: str, req: Request):
client_host = req.client.host
client_host = f'{req.client.host}:{req.client.port}'
return lockedPrjs.get(network) != client_host
@app.post("/lockproject/")
async def fastapi_lock_project(network: str, req: Request):
client_host = req.client.host
client_host = f'{req.client.host}:{req.client.port}'
lockedPrjs[network] = client_host
return client_host
@app.post("/unlockproject/")
async def fastapi_unlock_project(network: str, req: Request):
client_host = req.client.host
client_host = f'{req.client.host}:{req.client.port}'
if lockedPrjs[network] == client_host:
del lockedPrjs[network]
return True