Нативное указание подсети для сканирования по умолчанию (192.168.1.0/24). Обработка ошибок при очистке данных
This commit is contained in:
parent
5287a64587
commit
4257864b3d
3 changed files with 30 additions and 18 deletions
|
|
@ -1,6 +1,5 @@
|
|||
from fastapi import APIRouter, HTTPException
|
||||
from typing import List, Dict
|
||||
from models.subnet import SubnetScanResult
|
||||
from fastapi import APIRouter, HTTPException, Body
|
||||
from models.subnet import SubnetScanResult, SubnetScanRequest
|
||||
from models.wifi import WifiScanResult
|
||||
from models.request import NoteRequest, WifiConnectRequest, WifiDisconnectRequest
|
||||
from services.subnet_service import SubnetService
|
||||
|
|
@ -9,8 +8,8 @@ from services.connect_service import WifiConnectionService
|
|||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/devices", response_model=SubnetScanResult)
|
||||
def scan_subnet(subnet: str = "192.168.1.0/24", ports: List[int] = None):
|
||||
@router.post("/devices", response_model=SubnetScanResult)
|
||||
def scan_subnet(request: SubnetScanRequest = Body(...)):
|
||||
"""Сканирует локальную подсеть и возвращает данные об устройствах.
|
||||
|
||||
Выполняет сканирование указанной подсети для обнаружения активных устройств
|
||||
|
|
@ -29,7 +28,8 @@ def scan_subnet(subnet: str = "192.168.1.0/24", ports: List[int] = None):
|
|||
"""
|
||||
try:
|
||||
subnet_service = SubnetService()
|
||||
result = subnet_service.scan_subnet(subnet, ports)
|
||||
subnet = request.subnet or "192.168.1.0/24"
|
||||
result = subnet_service.scan_subnet(subnet)
|
||||
return result
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Ошибка сканирования: {str(e)}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue