aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-13 07:18:16 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-13 07:18:16 -0700
commit859b9d4aad68f4dafdee60ff14d3c9c0b32693a0 (patch)
tree99d96c5ccc1312a44ef62bc4552d1e7273065f38
parenta1ec223a7ee9ff86a881428f787c6f11d532432a (diff)
downloadtrackermap-server-859b9d4aad68f4dafdee60ff14d3c9c0b32693a0.tar.gz
trackermap-server-859b9d4aad68f4dafdee60ff14d3c9c0b32693a0.tar.bz2
trackermap-server-859b9d4aad68f4dafdee60ff14d3c9c0b32693a0.zip
Ignore own multicast packets
-rw-r--r--debug.xml5
-rw-r--r--src/main/java/org/traccar/broadcast/MulticastBroadcastService.java6
2 files changed, 7 insertions, 4 deletions
diff --git a/debug.xml b/debug.xml
index debbd06b7..a597d83c5 100644
--- a/debug.xml
+++ b/debug.xml
@@ -24,7 +24,8 @@
<entry key='atrack.custom'>true</entry>
<entry key='intellitrac.port'>6037</entry>
- <!--<entry key='broadcast.address'>230.0.0.0</entry>
- <entry key='broadcast.port'>5000</entry>-->
+ <!--<entry key='broadcast.interface'>en0</entry>
+ <entry key='broadcast.address'>230.3.3.3</entry>
+ <entry key='broadcast.port'>7001</entry>-->
</properties>
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);