diff options
author | Anton Tananaev <anton@traccar.org> | 2022-07-16 20:47:59 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-07-16 20:47:59 -0700 |
commit | ee30e6e63f110476f557ed4ca8a081eb5b589101 (patch) | |
tree | e4a6deb28416b8aa613d5ecb383e6ebeecc79a6c /src/main/java/org/traccar/ServerManager.java | |
parent | ca4488bd093d25afa494ab30e117fdef98e20013 (diff) | |
download | trackermap-server-ee30e6e63f110476f557ed4ca8a081eb5b589101.tar.gz trackermap-server-ee30e6e63f110476f557ed4ca8a081eb5b589101.tar.bz2 trackermap-server-ee30e6e63f110476f557ed4ca8a081eb5b589101.zip |
Parameter to enable protocols (fix #3991)
Diffstat (limited to 'src/main/java/org/traccar/ServerManager.java')
-rw-r--r-- | src/main/java/org/traccar/ServerManager.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/ServerManager.java b/src/main/java/org/traccar/ServerManager.java index 8d6e615dc..57afb01fd 100644 --- a/src/main/java/org/traccar/ServerManager.java +++ b/src/main/java/org/traccar/ServerManager.java @@ -28,9 +28,12 @@ import java.io.IOException; import java.net.BindException; import java.net.ConnectException; import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @Singleton @@ -44,11 +47,18 @@ public class ServerManager implements LifecycleObject { @Inject public ServerManager( Injector injector, Config config) throws IOException, URISyntaxException, ReflectiveOperationException { + Set<String> enabledProtocols = null; + if (config.hasKey(Keys.PROTOCOLS_ENABLE)) { + enabledProtocols = new HashSet<>(Arrays.asList(config.getString(Keys.PROTOCOLS_ENABLE).split("[, ]"))); + } for (Class<?> protocolClass : ClassScanner.findSubclasses(BaseProtocol.class, "org.traccar.protocol")) { - if (config.hasKey(Keys.PROTOCOL_PORT.withPrefix(BaseProtocol.nameFromClass(protocolClass)))) { - BaseProtocol protocol = (BaseProtocol) injector.getInstance(protocolClass); - connectorList.addAll(protocol.getConnectorList()); - protocolList.put(protocol.getName(), protocol); + String protocolName = BaseProtocol.nameFromClass(protocolClass); + if (enabledProtocols == null || enabledProtocols.contains(protocolName)) { + if (config.hasKey(Keys.PROTOCOL_PORT.withPrefix(protocolName))) { + BaseProtocol protocol = (BaseProtocol) injector.getInstance(protocolClass); + connectorList.addAll(protocol.getConnectorList()); + protocolList.put(protocol.getName(), protocol); + } } } } |