From 93c4e0ef2f882c4818b542b7792e9b02975f9da7 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 17 Apr 2024 20:53:14 -0700 Subject: Migrate default ports to code --- debug.xml | 4 - setup/default.xml | 271 -------------------- setup/traccar.xml | 16 +- src/main/java/org/traccar/ServerManager.java | 2 +- src/main/java/org/traccar/config/Keys.java | 2 +- .../java/org/traccar/config/PortConfigSuffix.java | 278 +++++++++++++++++++++ 6 files changed, 281 insertions(+), 292 deletions(-) delete mode 100644 setup/default.xml create mode 100644 src/main/java/org/traccar/config/PortConfigSuffix.java diff --git a/debug.xml b/debug.xml index 89b5a5ba3..15fa57324 100644 --- a/debug.xml +++ b/debug.xml @@ -1,11 +1,7 @@ - - - ./setup/default.xml - ./traccar-web/simple true true diff --git a/setup/default.xml b/setup/default.xml deleted file mode 100644 index 02c0650c3..000000000 --- a/setup/default.xml +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - 5001 - 5002 - 5003 - 5004 - 5005 - 5006 - false - 5007 - 5008 - 5009 - 5010 - 5011 - 5012 - 5013 - 5014 - 5015 - 5016 - 5017 - 5018 - 5019 - 5020 - 5021 - 5022 - 5023 - 5024 - 5025 - 5026 - 5027 - 5028 - 5029 - 5030 - 5031 - 5032 - 5033 - 5034 - 5035 - 5036 - 5037 - 5038 - 5039 - 5040 - 5041 - 5042 - 5043 - 5044 - 5045 - 5046 - 5047 - 5048 - 5049 - 5050 - 5051 - 5052 - 5053 - 5054 - 5055 - 5056 - 5057 - 5058 - 5059 - 5060 - 5061 - 5062 - 5063 - 5064 - 5065 - 5066 - 5067 - 5068 - 5069 - 5070 - 5071 - 5072 - 5073 - 5074 - 5075 - 5076 - 5077 - 5078 - 5079 - 5080 - 5081 - 5082 - 5083 - 5084 - 5085 - 5086 - 5087 - 5088 - 5089 - 5090 - 5091 - 5092 - 5093 - 5094 - 5095 - 5096 - 5097 - 5098 - 5099 - 5100 - 5101 - 5102 - 5103 - 5104 - 5105 - 5106 - 5107 - 5108 - 5109 - 5110 - 5111 - 5112 - 5113 - 5114 - 5115 - 5116 - 5117 - 5118 - 5119 - 5120 - 5121 - 5122 - 5123 - 5124 - 5125 - 5126 - 5127 - 5128 - 5129 - 5130 - 5131 - 5132 - 5133 - 5134 - 5135 - 5136 - 5137 - 5138 - 5139 - 5140 - 5141 - 5142 - 5143 - 5144 - 5145 - 5146 - 5147 - 5148 - 5149 - 5150 - 5151 - 5152 - 5153 - 5154 - 5155 - 5156 - 5157 - 5158 - 5159 - 5160 - 5161 - 5162 - 5163 - 5164 - 5165 - 5166 - 5167 - 5168 - 5169 - 5170 - 5171 - 5172 - 5173 - 5174 - 5175 - 5176 - 5177 - 5178 - 5179 - 5180 - 5181 - 5182 - 5183 - 5184 - 5185 - 5186 - 5187 - 5188 - 5189 - 5190 - 5191 - 5192 - 5193 - 5194 - 5195 - 5196 - 5197 - 5198 - 5199 - 5200 - 5201 - 5202 - 5203 - 5204 - 5205 - 5206 - 5207 - 5208 - 5209 - 5210 - 5211 - 5212 - 5213 - 5214 - 5215 - 5216 - 5217 - 5218 - 5219 - 5220 - 5221 - 5222 - 5223 - 5224 - 5225 - 5226 - 5227 - 5228 - 5229 - 5230 - 5231 - 5232 - 5233 - 5234 - 5235 - 5236 - 5237 - 5238 - 5239 - 5240 - 5241 - 5242 - 5243 - 5244 - 5245 - 5246 - 5247 - 5248 - 5249 - 5250 - 5251 - 5252 - 5253 - 5254 - 5255 - 5256 - - diff --git a/setup/traccar.xml b/setup/traccar.xml index aab9ba311..d5bd87e9c 100644 --- a/setup/traccar.xml +++ b/setup/traccar.xml @@ -1,22 +1,8 @@ - - - ./conf/default.xml - - + org.h2.Driver jdbc:h2:./data/database diff --git a/src/main/java/org/traccar/ServerManager.java b/src/main/java/org/traccar/ServerManager.java index 22af66b41..1b0c441cf 100644 --- a/src/main/java/org/traccar/ServerManager.java +++ b/src/main/java/org/traccar/ServerManager.java @@ -54,7 +54,7 @@ public class ServerManager implements LifecycleObject { for (Class protocolClass : ClassScanner.findSubclasses(BaseProtocol.class, "org.traccar.protocol")) { String protocolName = BaseProtocol.nameFromClass(protocolClass); if (enabledProtocols == null || enabledProtocols.contains(protocolName)) { - if (config.hasKey(Keys.PROTOCOL_PORT.withPrefix(protocolName))) { + if (config.getInteger(Keys.PROTOCOL_PORT.withPrefix(protocolName)) > 0) { BaseProtocol protocol = (BaseProtocol) injector.getInstance(protocolClass); connectorList.addAll(protocol.getConnectorList()); protocolList.put(protocol.getName(), protocol); diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java index 44037fb2e..a2aa42e1c 100644 --- a/src/main/java/org/traccar/config/Keys.java +++ b/src/main/java/org/traccar/config/Keys.java @@ -33,7 +33,7 @@ public final class Keys { * Port number for the protocol. Most protocols use TCP on the transport layer. Some protocols use UDP. Some * support both TCP and UDP. */ - public static final ConfigSuffix PROTOCOL_PORT = new IntegerConfigSuffix( + public static final ConfigSuffix PROTOCOL_PORT = new PortConfigSuffix( ".port", List.of(KeyType.CONFIG)); diff --git a/src/main/java/org/traccar/config/PortConfigSuffix.java b/src/main/java/org/traccar/config/PortConfigSuffix.java new file mode 100644 index 000000000..11d6f2dbb --- /dev/null +++ b/src/main/java/org/traccar/config/PortConfigSuffix.java @@ -0,0 +1,278 @@ +package org.traccar.config; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class PortConfigSuffix extends ConfigSuffix { + + private static final Map PORTS = new HashMap<>(); + + static { + PORTS.put("gps103", 5001); + PORTS.put("tk103", 5002); + PORTS.put("gl100", 5003); + PORTS.put("gl200", 5004); + PORTS.put("t55", 5005); + PORTS.put("xexun", 5006); + PORTS.put("totem", 5007); + PORTS.put("enfora", 5008); + PORTS.put("meiligao", 5009); + PORTS.put("trv", 5010); + PORTS.put("suntech", 5011); + PORTS.put("progress", 5012); + PORTS.put("h02", 5013); + PORTS.put("jt600", 5014); + PORTS.put("huabao", 5015); + PORTS.put("v680", 5016); + PORTS.put("pt502", 5017); + PORTS.put("tr20", 5018); + PORTS.put("navis", 5019); + PORTS.put("meitrack", 5020); + PORTS.put("skypatrol", 5021); + PORTS.put("gt02", 5022); + PORTS.put("gt06", 5023); + PORTS.put("megastek", 5024); + PORTS.put("navigil", 5025); + PORTS.put("gpsgate", 5026); + PORTS.put("teltonika", 5027); + PORTS.put("mta6", 5028); + PORTS.put("tzone", 5029); + PORTS.put("tlt2h", 5030); + PORTS.put("taip", 5031); + PORTS.put("wondex", 5032); + PORTS.put("cellocator", 5033); + PORTS.put("galileo", 5034); + PORTS.put("ywt", 5035); + PORTS.put("tk102", 5036); + PORTS.put("intellitrac", 5037); + PORTS.put("gpsmta", 5038); + PORTS.put("wialon", 5039); + PORTS.put("carscop", 5040); + PORTS.put("apel", 5041); + PORTS.put("manpower", 5042); + PORTS.put("globalsat", 5043); + PORTS.put("atrack", 5044); + PORTS.put("pt3000", 5045); + PORTS.put("ruptela", 5046); + PORTS.put("topflytech", 5047); + PORTS.put("laipac", 5048); + PORTS.put("aplicom", 5049); + PORTS.put("gotop", 5050); + PORTS.put("sanav", 5051); + PORTS.put("gator", 5052); + PORTS.put("noran", 5053); + PORTS.put("m2m", 5054); + PORTS.put("osmand", 5055); + PORTS.put("easytrack", 5056); + PORTS.put("gpsmarker", 5057); + PORTS.put("khd", 5058); + PORTS.put("piligrim", 5059); + PORTS.put("stl060", 5060); + PORTS.put("cartrack", 5061); + PORTS.put("minifinder", 5062); + PORTS.put("haicom", 5063); + PORTS.put("eelink", 5064); + PORTS.put("box", 5065); + PORTS.put("freedom", 5066); + PORTS.put("telic", 5067); + PORTS.put("trackbox", 5068); + PORTS.put("visiontek", 5069); + PORTS.put("orion", 5070); + PORTS.put("riti", 5071); + PORTS.put("ulbotech", 5072); + PORTS.put("tramigo", 5073); + PORTS.put("tr900", 5074); + PORTS.put("ardi01", 5075); + PORTS.put("xt013", 5076); + PORTS.put("autofon", 5077); + PORTS.put("gosafe", 5078); + PORTS.put("tt8850", 5079); + PORTS.put("bce", 5080); + PORTS.put("xirgo", 5081); + PORTS.put("calamp", 5082); + PORTS.put("mtx", 5083); + PORTS.put("tytan", 5084); + PORTS.put("avl301", 5085); + PORTS.put("castel", 5086); + PORTS.put("mxt", 5087); + PORTS.put("cityeasy", 5088); + PORTS.put("aquila", 5089); + PORTS.put("flextrack", 5090); + PORTS.put("blackkite", 5091); + PORTS.put("adm", 5092); + PORTS.put("watch", 5093); + PORTS.put("t800x", 5094); + PORTS.put("upro", 5095); + PORTS.put("auro", 5096); + PORTS.put("disha", 5097); + PORTS.put("thinkrace", 5098); + PORTS.put("pathaway", 5099); + PORTS.put("arnavi", 5100); + PORTS.put("nvs", 5101); + PORTS.put("kenji", 5102); + PORTS.put("astra", 5103); + PORTS.put("homtecs", 5104); + PORTS.put("fox", 5105); + PORTS.put("gnx", 5106); + PORTS.put("arknav", 5107); + PORTS.put("supermate", 5108); + PORTS.put("appello", 5109); + PORTS.put("idpl", 5110); + PORTS.put("huasheng", 5111); + PORTS.put("l100", 5112); + PORTS.put("granit", 5113); + PORTS.put("carcell", 5114); + PORTS.put("obddongle", 5115); + PORTS.put("hunterpro", 5116); + PORTS.put("raveon", 5117); + PORTS.put("cradlepoint", 5118); + PORTS.put("arknavx8", 5119); + PORTS.put("autograde", 5120); + PORTS.put("oigo", 5121); + PORTS.put("jpkorjar", 5122); + PORTS.put("cguard", 5123); + PORTS.put("fifotrack", 5124); + PORTS.put("smokey", 5125); + PORTS.put("extremtrac", 5126); + PORTS.put("trakmate", 5127); + PORTS.put("at2000", 5128); + PORTS.put("maestro", 5129); + PORTS.put("ais", 5130); + PORTS.put("gt30", 5131); + PORTS.put("tmg", 5132); + PORTS.put("pretrace", 5133); + PORTS.put("pricol", 5134); + PORTS.put("siwi", 5135); + PORTS.put("starlink", 5136); + PORTS.put("dmt", 5137); + PORTS.put("xt2400", 5138); + PORTS.put("dmthttp", 5139); + PORTS.put("alematics", 5140); + PORTS.put("gps056", 5141); + PORTS.put("flexcomm", 5142); + PORTS.put("vt200", 5143); + PORTS.put("owntracks", 5144); + PORTS.put("vtfms", 5145); + PORTS.put("tlv", 5146); + PORTS.put("esky", 5147); + PORTS.put("genx", 5148); + PORTS.put("flespi", 5149); + PORTS.put("dway", 5150); + PORTS.put("recoda", 5151); + PORTS.put("oko", 5152); + PORTS.put("ivt401", 5153); + PORTS.put("sigfox", 5154); + PORTS.put("t57", 5155); + PORTS.put("spot", 5156); + PORTS.put("m2c", 5157); + PORTS.put("austinnb", 5158); + PORTS.put("opengts", 5159); + PORTS.put("cautela", 5160); + PORTS.put("continental", 5161); + PORTS.put("egts", 5162); + PORTS.put("robotrack", 5163); + PORTS.put("pt60", 5164); + PORTS.put("telemax", 5165); + PORTS.put("sabertek", 5166); + PORTS.put("retranslator", 5167); + PORTS.put("svias", 5168); + PORTS.put("eseal", 5169); + PORTS.put("freematics", 5170); + PORTS.put("avema", 5171); + PORTS.put("autotrack", 5172); + PORTS.put("tek", 5173); + PORTS.put("wristband", 5174); + PORTS.put("lacak", 5175); + PORTS.put("milesmate", 5176); + PORTS.put("anytrek", 5177); + PORTS.put("smartsole", 5178); + PORTS.put("its", 5179); + PORTS.put("xrb28", 5180); + PORTS.put("c2stek", 5181); + PORTS.put("nyitech", 5182); + PORTS.put("neos", 5183); + PORTS.put("satsol", 5184); + PORTS.put("globalstar", 5185); + PORTS.put("sanul", 5186); + PORTS.put("minifinder2", 5187); + PORTS.put("radar", 5188); + PORTS.put("techtlt", 5189); + PORTS.put("starcom", 5190); + PORTS.put("mictrack", 5191); + PORTS.put("plugin", 5192); + PORTS.put("leafspy", 5193); + PORTS.put("naviset", 5194); + PORTS.put("racedynamics", 5195); + PORTS.put("rst", 5196); + PORTS.put("pt215", 5197); + PORTS.put("pacifictrack", 5198); + PORTS.put("topin", 5199); + PORTS.put("outsafe", 5200); + PORTS.put("solarpowered", 5201); + PORTS.put("motor", 5202); + PORTS.put("omnicomm", 5203); + PORTS.put("s168", 5204); + PORTS.put("vnet", 5205); + PORTS.put("blue", 5206); + PORTS.put("pst", 5207); + PORTS.put("dingtek", 5208); + PORTS.put("wli", 5209); + PORTS.put("niot", 5210); + PORTS.put("portman", 5211); + PORTS.put("moovbox", 5212); + PORTS.put("futureway", 5213); + PORTS.put("polte", 5214); + PORTS.put("net", 5215); + PORTS.put("mobilogix", 5216); + PORTS.put("swiftech", 5217); + PORTS.put("iotm", 5218); + PORTS.put("dolphin", 5219); + PORTS.put("ennfu", 5220); + PORTS.put("navtelecom", 5221); + PORTS.put("startek", 5222); + PORTS.put("gs100", 5223); + PORTS.put("mavlink2", 5224); + PORTS.put("uux", 5225); + PORTS.put("r12w", 5226); + PORTS.put("flexiblereport", 5227); + PORTS.put("thinkpower", 5228); + PORTS.put("stb", 5229); + PORTS.put("b2316", 5230); + PORTS.put("hoopo", 5231); + PORTS.put("dualcam", 5232); + PORTS.put("xexun2", 5233); + PORTS.put("techtocruz", 5234); + PORTS.put("flexapi", 5235); + PORTS.put("dsf22", 5236); + PORTS.put("jido", 5237); + PORTS.put("armoli", 5238); + PORTS.put("teratrack", 5239); + PORTS.put("envotech", 5240); + PORTS.put("bstpl", 5241); + PORTS.put("thuraya", 5242); + PORTS.put("ndtpv6", 5243); + PORTS.put("g1rus", 5244); + PORTS.put("rftrack", 5245); + PORTS.put("vlt", 5246); + PORTS.put("transync", 5247); + PORTS.put("t622iridium", 5248); + PORTS.put("pui", 5249); + PORTS.put("nto", 5250); + PORTS.put("ramac", 5251); + PORTS.put("positrex", 5252); + PORTS.put("dragino", 5253); + PORTS.put("fleetguide", 5254); + PORTS.put("valtrack", 5255); + PORTS.put("snapper", 5256); + } + + PortConfigSuffix(String key, List types) { + super(key, types, null); + } + + @Override + public ConfigKey withPrefix(String protocol) { + return new IntegerConfigKey(protocol + keySuffix, types, PORTS.get(protocol)); + } +} -- cgit v1.2.3