Skip to content

Commit

Permalink
messagemanager: Don't RST incoming unknown ACK responses
Browse files Browse the repository at this point in the history
Closes: #175
  • Loading branch information
chrysn committed Nov 21, 2022
1 parent 4216cec commit 96eeb67
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions aiocoap/messagemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ def dispatch_message(self, message):
if message.mtype is CON:
self._send_empty_ack(message.remote, message.mid, reason="acknowledging incoming response")
else:
if message.remote.is_multicast_locally:
self.log.info("Ignoring response incoming with multicast destination.")
else:
# A peer mustn't send a CON to multicast, but if a malicious
# peer does, we better not answer
if message.mtype == CON and not message.remote.is_multicast_locally:
self.log.info("Response not recognized - sending RST.")
rst = Message(mtype=RST, mid=message.mid, code=EMPTY, payload='')
rst.remote = message.remote.as_response_address()
self._send_initially(rst)
else:
self.log.info("Ignoring unknown response (which is not a unicast CON)")
else:
self.log.warning("Received a message with code %s and type %s (those don't fit) from %s, ignoring it.", message.code, message.mtype, message.remote)

Expand Down

0 comments on commit 96eeb67

Please sign in to comment.