From e45d007984c4979cfa7b6a8eae3cf897f24d1476 Mon Sep 17 00:00:00 2001 From: Richard Titmuss Date: Tue, 31 May 2022 21:23:42 +0200 Subject: [PATCH] Drop udp packets from unknown hosts Check that incoming udp packets have been sent from the system running nibegw, otherwise drop the packets. --- nibe/connection/nibegw.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nibe/connection/nibegw.py b/nibe/connection/nibegw.py index 3e24b75..1f944c5 100644 --- a/nibe/connection/nibegw.py +++ b/nibe/connection/nibegw.py @@ -61,6 +61,12 @@ def connection_made(self, transport): self._transport = transport def datagram_received(self, data, addr): + if addr[0] != self._remote_ip: + logger.warning( + f"Ignoring packet from unknown host: {addr}" + ) + return + logger.debug(f"Received {hexlify(data)} from {addr}") try: msg = Response.parse(data)