From 31c4daf083e9f4b799d73d4a1ccb9158505aea70 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 29 Dec 2020 22:57:37 -0800 Subject: Migrate more keys --- src/main/java/org/traccar/BaseProtocolDecoder.java | 6 +++--- src/main/java/org/traccar/config/Keys.java | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'src/main/java/org/traccar') diff --git a/src/main/java/org/traccar/BaseProtocolDecoder.java b/src/main/java/org/traccar/BaseProtocolDecoder.java index 71e43df5c..a40756796 100644 --- a/src/main/java/org/traccar/BaseProtocolDecoder.java +++ b/src/main/java/org/traccar/BaseProtocolDecoder.java @@ -63,7 +63,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { } public String getServer(Channel channel, char delimiter) { - String server = config.getString(getProtocolName() + ".server"); + String server = config.getString(Keys.PROTOCOL_SERVER.withPrefix(getProtocolName())); if (server == null && channel != null) { InetSocketAddress address = (InetSocketAddress) channel.localAddress(); server = address.getAddress().getHostAddress() + ":" + address.getPort(); @@ -148,8 +148,8 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { public DeviceSession getDeviceSession( Channel channel, SocketAddress remoteAddress, boolean ignoreCache, String... uniqueIds) { if (channel != null && BasePipelineFactory.getHandler(channel.pipeline(), HttpRequestDecoder.class) != null - || ignoreCache || config.getBoolean(getProtocolName() + ".ignoreSessionCache") - || config.getBoolean("decoder.ignoreSessionCache")) { + || ignoreCache || config.getBoolean(Keys.PROTOCOL_IGNORE_SESSIONS_CACHE.withPrefix(getProtocolName())) + || config.getBoolean(Keys.DECODER_IGNORE_SESSIONS_CACHE)) { long deviceId = findDeviceId(remoteAddress, uniqueIds); if (deviceId != 0) { if (connectionManager != null) { diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java index d443509e5..598cac66f 100644 --- a/src/main/java/org/traccar/config/Keys.java +++ b/src/main/java/org/traccar/config/Keys.java @@ -137,6 +137,27 @@ public final class Keys { ".alarmMap", Collections.singletonList(KeyType.GLOBAL)); + /** + * Some devices require server address confirmation. Use this parameter to configure correct public address. + */ + public static final ConfigSuffix PROTOCOL_SERVER = new ConfigSuffix<>( + ".server", + Collections.singletonList(KeyType.GLOBAL)); + + /** + * Skip device connection session cache. Per protocol configuration. + */ + public static final ConfigSuffix PROTOCOL_IGNORE_SESSIONS_CACHE = new ConfigSuffix<>( + ".ignoreSessionCache", + Collections.singletonList(KeyType.GLOBAL)); + + /** + * Skip device connection session cache. Global configuration. + */ + public static final ConfigKey DECODER_IGNORE_SESSIONS_CACHE = new ConfigKey<>( + "decoder.ignoreSessionCache", + Collections.singletonList(KeyType.GLOBAL)); + /** * Server wide connection timeout value in seconds. See protocol timeout for more information. */ -- cgit v1.2.3