aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/Server.java25
-rw-r--r--src/org/traccar/TrackerServer.java25
2 files changed, 47 insertions, 3 deletions
diff --git a/src/org/traccar/Server.java b/src/org/traccar/Server.java
index 288719834..e4541aa43 100644
--- a/src/org/traccar/Server.java
+++ b/src/org/traccar/Server.java
@@ -217,6 +217,10 @@ public class Server {
return false;
}
+ private String getProtocolInterface(Properties properties, String protocol) {
+ return properties.getProperty(protocol + ".address");
+ }
+
private Integer getProtocolPort(Properties properties, String protocol) {
String port = properties.getProperty(protocol + ".port");
if (port != null) {
@@ -242,6 +246,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -265,6 +270,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -291,6 +297,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -317,6 +324,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -343,6 +351,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -369,6 +378,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -395,6 +405,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -420,6 +431,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -445,6 +457,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -467,6 +480,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -485,6 +499,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -507,6 +522,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -528,6 +544,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -551,6 +568,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -576,6 +594,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -598,6 +617,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -623,6 +643,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -648,6 +669,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -674,6 +696,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
@@ -700,6 +723,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
server.setEndianness(ByteOrder.LITTLE_ENDIAN);
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
@@ -723,6 +747,7 @@ public class Server {
if (isProtocolEnabled(properties, protocol)) {
TrackerServer server = new TrackerServer(getProtocolPort(properties, protocol));
+ server.setAddress(getProtocolInterface(properties, protocol));
final Integer resetDelay = getProtocolResetDelay(properties, protocol);
server.setPipelineFactory(new GenericPipelineFactory(server, dataManager, isLoggerEnabled(), resetDelay, geocoder) {
diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java
index b2e8c0a7f..56a9a2946 100644
--- a/src/org/traccar/TrackerServer.java
+++ b/src/org/traccar/TrackerServer.java
@@ -53,8 +53,21 @@ public class TrackerServer extends ServerBootstrap {
return port;
}
- private void setPort(Integer newPort) {
- port = newPort;
+ private void setPort(Integer port) {
+ this.port = port;
+ }
+
+ /**
+ * Server listening interface
+ */
+ private String address;
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
}
/**
@@ -77,7 +90,13 @@ public class TrackerServer extends ServerBootstrap {
* Start server
*/
public void start() {
- Channel channel = bind(new InetSocketAddress(getPort()));
+ InetSocketAddress endpoint;
+ if (address == null) {
+ endpoint = new InetSocketAddress(port);
+ } else {
+ endpoint = new InetSocketAddress(address, port);
+ }
+ Channel channel = bind(endpoint);
getChannelGroup().add(channel);
}