From 859b9d4aad68f4dafdee60ff14d3c9c0b32693a0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 13 Jul 2022 07:18:16 -0700 Subject: Ignore own multicast packets --- src/main/java/org/traccar/broadcast/MulticastBroadcastService.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/traccar/broadcast') diff --git a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java index c4ba0e059..be24989dd 100644 --- a/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java +++ b/src/main/java/org/traccar/broadcast/MulticastBroadcastService.java @@ -167,8 +167,10 @@ public class MulticastBroadcastService implements BroadcastService { while (!service.isShutdown()) { DatagramPacket packet = new DatagramPacket(receiverBuffer, receiverBuffer.length); socket.receive(packet); - String data = new String(packet.getData(), 0, packet.getLength(), StandardCharsets.UTF_8); - handleMessage(objectMapper.readValue(data, BroadcastMessage.class)); + if (networkInterface.inetAddresses().noneMatch(a -> a.equals(packet.getAddress()))) { + String data = new String(packet.getData(), 0, packet.getLength(), StandardCharsets.UTF_8); + handleMessage(objectMapper.readValue(data, BroadcastMessage.class)); + } } publisherSocket = null; socket.leaveGroup(group, networkInterface); -- cgit v1.2.3