diff options
-rw-r--r-- | debug.xml | 2 | ||||
-rw-r--r-- | src/org/traccar/MainEventHandler.java | 4 | ||||
-rw-r--r-- | src/org/traccar/notification/NotificationMail.java | 37 | ||||
-rw-r--r-- | src/org/traccar/protocol/GatorProtocol.java | 4 | ||||
-rw-r--r-- | src/org/traccar/protocol/OsmAndProtocolDecoder.java | 13 | ||||
-rw-r--r-- | src/org/traccar/protocol/TzoneProtocol.java | 2 | ||||
-rw-r--r-- | test/org/traccar/protocol/CastelProtocolDecoderTest.java | 3 | ||||
-rw-r--r-- | test/org/traccar/protocol/GatorProtocolDecoderTest.java | 3 | ||||
-rw-r--r-- | test/org/traccar/protocol/OsmAndProtocolDecoderTest.java | 3 | ||||
-rw-r--r-- | test/org/traccar/protocol/TzoneProtocolDecoderTest.java | 6 | ||||
-rwxr-xr-x | tools/test-generator.py | 4 | ||||
-rw-r--r-- | web/app/view/Login.js | 6 | ||||
-rw-r--r-- | web/app/view/LoginController.js | 15 | ||||
-rw-r--r-- | web/l10n/en.json | 1 |
14 files changed, 74 insertions, 29 deletions
@@ -63,6 +63,8 @@ for SSL <entry key='mail.smtp.port'>465</entry> <entry key='mail.smtp.ssl.enable'>true</entry> + for self-signed server sertificates + <entry key='mail.smtp.ssl.trust'>smtp.example.com</entry> <entry key='mail.smtp.from'>traccar@example.com</entry> diff --git a/src/org/traccar/MainEventHandler.java b/src/org/traccar/MainEventHandler.java index c01760283..3f7e68b2a 100644 --- a/src/org/traccar/MainEventHandler.java +++ b/src/org/traccar/MainEventHandler.java @@ -25,6 +25,7 @@ import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler; import org.jboss.netty.handler.timeout.IdleStateEvent; import org.traccar.helper.Log; import org.traccar.model.Position; +import org.traccar.protocol.TeltonikaProtocolDecoder; import java.sql.SQLException; import java.text.SimpleDateFormat; @@ -78,7 +79,8 @@ public class MainEventHandler extends IdleStateAwareChannelHandler { Log.info(formatChannel(e.getChannel()) + " disconnected"); closeChannel(e.getChannel()); - if (ctx.getPipeline().get("httpDecoder") == null) { + if (ctx.getPipeline().get("httpDecoder") == null + && !(ctx.getPipeline().get("objectDecoder") instanceof TeltonikaProtocolDecoder)) { Context.getConnectionManager().removeActiveDevice(e.getChannel()); } } diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index 944200f2f..f9d42968f 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -48,19 +48,26 @@ public final class NotificationMail { result.put("mail.smtp.port", config.getString("mail.smtp.port", "25")); if (config.getBoolean("mail.smtp.starttls.enable")) { - result.put("mail.smtp.starttls.enable", - config.getBoolean("mail.smtp.starttls.enable")); + result.put("mail.smtp.starttls.enable", config.getBoolean("mail.smtp.starttls.enable")); } else if (config.getBoolean("mail.smtp.ssl.enable")) { - result.put("mail.smtp.socketFactory.port", - result.getProperty("mail.smtp.port")); - result.put("mail.smtp.socketFactory.class", - "javax.net.ssl.SSLSocketFactory"); + result.put("mail.smtp.ssl.enable", config.getBoolean("mail.smtp.ssl.enable")); } + result.put("mail.smtp.ssl.trust", config.getBoolean("mail.smtp.ssl.trust")); result.put("mail.smtp.auth", config.getBoolean("mail.smtp.auth")); - result.put("mail.smtp.user", config.getString("mail.smtp.username", null)); - result.put("mail.smtp.password", config.getString("mail.smtp.password", null)); - result.put("mail.smtp.from", config.getString("mail.smtp.from", null)); + + String username = config.getString("mail.smtp.username"); + if (username != null) { + result.put("mail.smtp.user", username); + } + String password = config.getString("mail.smtp.password"); + if (password != null) { + result.put("mail.smtp.password", password); + } + String from = config.getString("mail.smtp.from"); + if (from != null) { + result.put("mail.smtp.from", from); + } } return result; } @@ -77,12 +84,10 @@ public final class NotificationMail { result.put("mail.smtp.starttls.enable", tls); } else if (object.getAttributes().containsKey("mail.smtp.ssl.enable")) { boolean ssl = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.ssl.enable")); - if (ssl) { - result.put("mail.smtp.socketFactory.port", - result.getProperty("mail.smtp.port")); - result.put("mail.smtp.socketFactory.class", - "javax.net.ssl.SSLSocketFactory"); - } + result.put("mail.smtp.ssl.enable", ssl); + } + if (object.getAttributes().containsKey("mail.smtp.ssl.trust")) { + result.put("mail.smtp.ssl.trust", object.getAttributes().get("mail.smtp.ssl.trust")); } boolean auth = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.auth")); result.put("mail.smtp.auth", auth); @@ -117,7 +122,7 @@ public final class NotificationMail { return; } } - mailSession = Session.getDefaultInstance(mailServerProperties, null); + mailSession = Session.getInstance(mailServerProperties, null); mailMessage = new MimeMessage(mailSession); diff --git a/src/org/traccar/protocol/GatorProtocol.java b/src/org/traccar/protocol/GatorProtocol.java index 3776bcfd3..3d899fa1f 100644 --- a/src/org/traccar/protocol/GatorProtocol.java +++ b/src/org/traccar/protocol/GatorProtocol.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ public class GatorProtocol extends BaseProtocol { serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { - pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2, 1, 0)); + pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2)); pipeline.addLast("objectDecoder", new GatorProtocolDecoder(GatorProtocol.this)); } }); diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java index f9f04d7e3..c5884a4d0 100644 --- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -73,9 +73,7 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { case "deviceid": DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value); if (deviceSession == null) { - if (channel != null) { - sendResponse(channel, HttpResponseStatus.BAD_REQUEST); - } + sendResponse(channel, HttpResponseStatus.BAD_REQUEST); return null; } position.setDeviceId(deviceSession.getDeviceId()); @@ -132,11 +130,14 @@ public class OsmAndProtocolDecoder extends BaseProtocolDecoder { position.setTime(new Date()); } - if (channel != null) { + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress); + if (deviceSession != null) { sendResponse(channel, HttpResponseStatus.OK); + return position; + } else { + sendResponse(channel, HttpResponseStatus.BAD_REQUEST); + return null; } - - return position; } } diff --git a/src/org/traccar/protocol/TzoneProtocol.java b/src/org/traccar/protocol/TzoneProtocol.java index 2d98e3f79..fcf673a57 100644 --- a/src/org/traccar/protocol/TzoneProtocol.java +++ b/src/org/traccar/protocol/TzoneProtocol.java @@ -34,7 +34,7 @@ public class TzoneProtocol extends BaseProtocol { serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) { @Override protected void addSpecificHandlers(ChannelPipeline pipeline) { - pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 2)); + pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 2, 2, 0)); pipeline.addLast("objectDecoder", new TzoneProtocolDecoder(TzoneProtocol.this)); } }); diff --git a/test/org/traccar/protocol/CastelProtocolDecoderTest.java b/test/org/traccar/protocol/CastelProtocolDecoderTest.java index eafe80748..6df2fd387 100644 --- a/test/org/traccar/protocol/CastelProtocolDecoderTest.java +++ b/test/org/traccar/protocol/CastelProtocolDecoderTest.java @@ -12,6 +12,9 @@ public class CastelProtocolDecoderTest extends ProtocolTest { CastelProtocolDecoder decoder = new CastelProtocolDecoder(new CastelProtocol()); + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "4040d400043535333133350000000000000000000000000000100196d499574bd899570000000000000000010000000000000000000000002410000000004944445f3231334730325f532056322e332e345f4e004944445f3231334730325f482056322e332e345f4e0032000110021003100410051006100710081009100a100b100c100d100e1011100111021103110411051106110711011202120312041201130213031301160216011701180218011b011c011d011e011f021f031f041f051f061f071f012102210126012701285b410d0a")); + verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN, "24243f00676e6768656636313031313132393030313734002001840d0000d2deb556020602100b35360456cf09e6ebac0200000000030000000001abc10d0a")); diff --git a/test/org/traccar/protocol/GatorProtocolDecoderTest.java b/test/org/traccar/protocol/GatorProtocolDecoderTest.java index cf65d0dc6..8541f14b2 100644 --- a/test/org/traccar/protocol/GatorProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GatorProtocolDecoderTest.java @@ -18,6 +18,9 @@ public class GatorProtocolDecoderTest extends ProtocolTest { GatorProtocolDecoder decoder = new GatorProtocolDecoder(new GatorProtocol()); + verifyAttributes(decoder, binary( + "2424800026364101b31608041108380273453415301532000000008000010000122800000124000000c40d")); + verifyNothing(decoder, binary( "242421000658e3d851150d")); diff --git a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java index d035ba7ef..6ec885058 100644 --- a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java +++ b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class OsmAndProtocolDecoderTest extends ProtocolTest { OsmAndProtocolDecoder decoder = new OsmAndProtocolDecoder(new OsmAndProtocol()); + verifyNothing(decoder, request( + "/?timestamp=1377177267&lat=60.0&lon=30.0")); + verifyPosition(decoder, request( "/?id=902064&lat=42.06288&lon=-88.23412×tamp=2016-01-27T18%3A55%3A47Z&hdop=6.0&altitude=224.0&speed=0.0")); diff --git a/test/org/traccar/protocol/TzoneProtocolDecoderTest.java b/test/org/traccar/protocol/TzoneProtocolDecoderTest.java index 8d60bdfe4..2ae776f36 100644 --- a/test/org/traccar/protocol/TzoneProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TzoneProtocolDecoderTest.java @@ -12,6 +12,12 @@ public class TzoneProtocolDecoderTest extends ProtocolTest { TzoneProtocolDecoder decoder = new TzoneProtocolDecoder(new TzoneProtocol()); verifyPosition(decoder, binary( + "545a00582424010b022000000860041028904798100803030c2700160a007da96203356669100803030c2700000000000e000004002813730010aa4000000617017100000000000080000000000000000000000000000000007701fe0d0a")); + + verifyPosition(decoder, binary( + "545a00582424010b022000000860041028904798100803030d1a001609007da9620335666a100803030d1900000000000e000004002813730010aa400000063701720000000000008000000000000000000000000000000000787f0c0d0a")); + + verifyPosition(decoder, binary( "545a00582424010b021e000008637710239476270f080b0a3228001600000000000000000000000000000000000000000000000401a00822001088c00020183701a6053800000000800000000000000000000000000000000077c9860d0a"), position("1999-11-30 00:00:00.000", false, 0.0, 0.0)); diff --git a/tools/test-generator.py b/tools/test-generator.py index b4edbfbaf..41a32a565 100755 --- a/tools/test-generator.py +++ b/tools/test-generator.py @@ -37,7 +37,7 @@ def send(conn, lat, lon, course, alarm): if alarm: params = params + (('alarm', 'sos'),) conn.request('GET', '?' + urllib.urlencode(params)) - conn.getresponse() + conn.getresponse().read() def course(lat1, lon1, lat2, lon2): lat1 = lat1 * math.pi / 180 @@ -58,4 +58,4 @@ while True: alarm = ((index % 10) == 0) send(conn, lat1, lon1, course(lat1, lon1, lat2, lon2), alarm) time.sleep(period) - index += 1
\ No newline at end of file + index += 1 diff --git a/web/app/view/Login.js b/web/app/view/Login.js index 4f04a0f37..db3c55261 100644 --- a/web/app/view/Login.js +++ b/web/app/view/Login.js @@ -54,6 +54,7 @@ Ext.define('Traccar.view.Login', { }, { xtype: 'textfield', name: 'email', + reference: 'userField', fieldLabel: Strings.userEmail, allowBlank: false, enableKeyEvents: true, @@ -65,6 +66,7 @@ Ext.define('Traccar.view.Login', { }, { xtype: 'textfield', name: 'password', + reference: 'passwordField', fieldLabel: Strings.userPassword, inputType: 'password', allowBlank: false, @@ -74,6 +76,10 @@ Ext.define('Traccar.view.Login', { }, inputAttrTpl: ['autocomplete="on"'] }, { + xtype: 'checkboxfield', + reference: 'rememberField', + fieldLabel: Strings.userRemember + }, { xtype: 'component', html: '<iframe id="submitTarget" name="submitTarget" style="display:none"></iframe>' }, { diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js index 3dd8af082..7a78a6fb1 100644 --- a/web/app/view/LoginController.js +++ b/web/app/view/LoginController.js @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,13 @@ Ext.define('Traccar.view.LoginController', { this.lookupReference('registerButton').setDisabled( !Traccar.app.getServer().get('registration')); this.lookupReference('languageField').setValue(Locale.language); + var user = Ext.util.Cookies.get('user'); + var password = Ext.util.Cookies.get('password'); + if (user && password) { + this.lookupReference('userField').setValue(user); + this.lookupReference('passwordField').setValue(password); + this.login(); + } }, login: function () { @@ -40,6 +47,10 @@ Ext.define('Traccar.view.LoginController', { callback: function (options, success, response) { Ext.getBody().unmask(); if (success) { + if (this.lookupReference('rememberField').getValue()) { + Ext.util.Cookies.set('user', this.lookupReference('userField').getValue(), Ext.Date.add(new Date(), Ext.Date.YEAR, 1)); + Ext.util.Cookies.set('password', this.lookupReference('passwordField').getValue(), Ext.Date.add(new Date(), Ext.Date.YEAR, 1)); + } Traccar.app.setUser(Ext.decode(response.responseText)); this.fireViewEvent('login'); } else { @@ -51,6 +62,8 @@ Ext.define('Traccar.view.LoginController', { }, logout: function () { + Ext.util.Cookies.clear('user'); + Ext.util.Cookies.clear('password'); Ext.Ajax.request({ scope: this, method: 'DELETE', diff --git a/web/l10n/en.json b/web/l10n/en.json index e1866fe62..37e4537f2 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -30,6 +30,7 @@ "userEmail": "Email", "userPassword": "Password", "userAdmin": "Admin", + "userRemember": "Remember", "loginTitle": "Login", "loginLanguage": "Language", "loginRegister": "Register", |