aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar')
-rw-r--r--src/main/java/org/traccar/config/Keys.java7
-rw-r--r--src/main/java/org/traccar/session/ConnectionManager.java4
2 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index 1b4b3a5b4..491c724aa 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -495,6 +495,13 @@ public final class Keys {
List.of(KeyType.CONFIG));
/**
+ * Automatically register unknown devices with regex filter.
+ */
+ public static final ConfigKey<String> DATABASE_REGISTER_UNKNOWN_REGEX = new StringConfigKey(
+ "database.registerUnknown.regex",
+ List.of(KeyType.CONFIG), "\\w{3,15}");
+
+ /**
* Store empty messages as positions. For example, heartbeats.
*/
public static final ConfigKey<Boolean> DATABASE_SAVE_EMPTY = new BooleanConfigKey(
diff --git a/src/main/java/org/traccar/session/ConnectionManager.java b/src/main/java/org/traccar/session/ConnectionManager.java
index 37a42d827..e6f5d00cf 100644
--- a/src/main/java/org/traccar/session/ConnectionManager.java
+++ b/src/main/java/org/traccar/session/ConnectionManager.java
@@ -123,7 +123,9 @@ public class ConnectionManager implements BroadcastInterface {
Device device = deviceLookupService.lookup(uniqueIds);
if (device == null && config.getBoolean(Keys.DATABASE_REGISTER_UNKNOWN)) {
- device = addUnknownDevice(uniqueIds[0]);
+ if (uniqueIds[0].matches(config.getString(Keys.DATABASE_REGISTER_UNKNOWN_REGEX))) {
+ device = addUnknownDevice(uniqueIds[0]);
+ }
}
if (device != null) {