diff --git a/CHANGELOG.md b/CHANGELOG.md index ad2f0f5..b39f0b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixed + +- Messages are sent via the correct socket to comply with the intended/specified message flow. This also eases the firewall configuration (#72). + ## [0.6.2] - 2020-10-18 ### Changed diff --git a/README.md b/README.md index 8ee9fc9..11ff0d7 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,8 @@ actual distribution/installation where they are to be used. Both incoming and outgoing multicast traffic on port 3702 must be allowed. For IPv4, the multicast address is `239.255.255.250`, for IPv6 the link local SSDP -multicast address (`ff02::c`) is used. +multicast address (`ff02::c`) is used. Outgoing unicast UDP traffic from port +3702 must be allowed too. Incoming TCP traffic (and related outgoing traffic) on port 5357 must be allowed. diff --git a/man/wsdd.1 b/man/wsdd.1 index 2d97747..49261d0 100644 --- a/man/wsdd.1 +++ b/man/wsdd.1 @@ -136,7 +136,8 @@ domain socket to which a client can connect to. .PP Both incoming and outgoing multicast traffic on port 3702 must be allowed. For IPv4, the multicast address is `239.255.255.250`, for IPv6 the link local SSDP -multicast address (`fe02::c`) is used. +multicast address (`fe02::c`) is used. Outgoing unicast UDP traffic from port +3702 must be allowed too. .PP Incoming TCP traffic (and related outgoing traffic) on port 5357 must be allowed. diff --git a/src/wsdd.py b/src/wsdd.py index 3574cf1..0abfb04 100755 --- a/src/wsdd.py +++ b/src/wsdd.py @@ -183,6 +183,15 @@ def handle_request(self, key): for handler in self.message_handlers[s]: handler.handle_request(msg, address) + def send(self, msg, addr): + # Request from a client must be answered from a socket that is bound + # to the WSD port, i.e. the recv_socket. Messages to multicast + # addresses are sent over the dedicated send socket. + if addr == self.multicast_address: + self.send_socket.sendto(msg, addr) + else: + self.recv_socket.sendto(msg, addr) + # constants for WSD XML/SOAP parsing WSA_URI = 'http://schemas.xmlsoap.org/ws/2004/08/addressing' @@ -1536,7 +1545,7 @@ def send_outstanding_messages(block=False): addr = send_queue[-1][2] msg = send_queue[-1][3] try: - mch.send_socket.sendto(msg, addr) + mch.send(msg, addr) except Exception as e: logger.error('error while sending packet on {}: {}'.format( mch.interface.name, e))