aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setup/default.xml1
-rw-r--r--src/main/java/org/traccar/config/Keys.java11
-rw-r--r--src/main/java/org/traccar/session/ConnectionManager.java6
3 files changed, 14 insertions, 4 deletions
diff --git a/setup/default.xml b/setup/default.xml
index 48fd8c993..fbe63c873 100644
--- a/setup/default.xml
+++ b/setup/default.xml
@@ -14,6 +14,7 @@
<entry key='web.path'>./modern</entry>
<entry key='web.sanitize'>false</entry>
<entry key='web.persistSession'>false</entry>
+ <entry key='web.showUnknownDevices'>true</entry>
<entry key='geocoder.enable'>true</entry>
<entry key='geocoder.type'>locationiq</entry>
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index 3528dafa0..1da68e1c0 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 - 2023 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 2024 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1247,7 +1247,7 @@ public final class Keys {
/**
* Maximum time period for reports in seconds. Can be useful to prevent users to request unreasonably long reports.
- * By default there is no limit.
+ * By default, there is no limit.
*/
public static final ConfigKey<Long> REPORT_PERIOD_LIMIT = new LongConfigKey(
"report.periodLimit",
@@ -1799,6 +1799,13 @@ public final class Keys {
List.of(KeyType.CONFIG));
/**
+ * Show logs from unknown devices.
+ */
+ public static final ConfigKey<Boolean> WEB_SHOW_UNKNOWN_DEVICES = new BooleanConfigKey(
+ "web.showUnknownDevices",
+ List.of(KeyType.CONFIG));
+
+ /**
* Output logging to the standard terminal output instead of a log file.
*/
public static final ConfigKey<Boolean> LOGGER_CONSOLE = new BooleanConfigKey(
diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java
index a598260aa..1461c66ea 100644
--- a/src/main/java/org/traccar/session/ConnectionManager.java
+++ b/src/main/java/org/traccar/session/ConnectionManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2023 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2024 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -63,6 +63,7 @@ public class ConnectionManager implements BroadcastInterface {
private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionManager.class);
private final long deviceTimeout;
+ private final boolean showUnknownDevices;
private final Map<Long, DeviceSession> sessionsByDeviceId = new ConcurrentHashMap<>();
private final Map<SocketAddress, Map<String, DeviceSession>> sessionsByEndpoint = new ConcurrentHashMap<>();
@@ -95,6 +96,7 @@ public class ConnectionManager implements BroadcastInterface {
this.broadcastService = broadcastService;
this.deviceLookupService = deviceLookupService;
deviceTimeout = config.getLong(Keys.STATUS_TIMEOUT);
+ showUnknownDevices = config.getBoolean(Keys.WEB_SHOW_UNKNOWN_DEVICES);
broadcastService.registerListener(this);
}
@@ -344,7 +346,7 @@ public class ConnectionManager implements BroadcastInterface {
var sessions = sessionsByEndpoint.getOrDefault(record.getAddress(), Map.of());
if (sessions.isEmpty()) {
String unknownUniqueId = unknownByEndpoint.get(record.getAddress());
- if (unknownUniqueId != null) {
+ if (unknownUniqueId != null && showUnknownDevices) {
record.setUniqueId(unknownUniqueId);
listeners.values().stream()
.flatMap(Set::stream)