Wave-Net / wavenet-backend

packet capture logic using scapy library
0 stars 0 forks source link

feat: 네트워크 모니터링 웹소켓 연결시에만 하지 말고 애플리케이션 단에서 하도록 정확히 분리 #60 #61

Closed zhy2on closed 1 month ago

zhy2on commented 1 month ago

Issue

60

Details

from contextlib import asynccontextmanager

@asynccontextmanager
async def lifespan(app: FastAPI):
    await network_monitor.start()
    try:
        yield
    finally:
        pass

app = FastAPI(lifespan=lifespan)

FastAPI의 @asynccontextmanager 이용하여 lifespan 등록 시작시 network_monitor.start()를 하도록.

그리고 스니핑은 NetworkMonitor에서 하게 하고 나머지는 Sender로 분류함. 이미 스니핑 되고 있는 데이터를 전송하는 기능만 담당하게 함.