aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-03-16 19:46:44 -0700
committerAnton Tananaev <anton@traccar.org>2024-03-16 19:46:44 -0700
commit5b8b40faebf6996f1d2f5aef4c733dfe13d73b1b (patch)
tree74f9dd29ef50a79b6e0321e8c7fb3bf56d5e2565 /src/main/java/org/traccar/handler
parentd66174fc5ee33998b5b3960336a47de3d2f00196 (diff)
downloadtrackermap-server-5b8b40faebf6996f1d2f5aef4c733dfe13d73b1b.tar.gz
trackermap-server-5b8b40faebf6996f1d2f5aef4c733dfe13d73b1b.tar.bz2
trackermap-server-5b8b40faebf6996f1d2f5aef4c733dfe13d73b1b.zip
Add local address to connection key
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r--src/main/java/org/traccar/handler/StandardLoggingHandler.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/handler/StandardLoggingHandler.java b/src/main/java/org/traccar/handler/StandardLoggingHandler.java
index 5978d632e..513602dd8 100644
--- a/src/main/java/org/traccar/handler/StandardLoggingHandler.java
+++ b/src/main/java/org/traccar/handler/StandardLoggingHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 - 2023 Anton Tananaev (anton@traccar.org)
+ * Copyright 2019 - 2024 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,8 +28,6 @@ import org.traccar.helper.NetworkUtil;
import org.traccar.model.LogRecord;
import org.traccar.session.ConnectionManager;
-import java.net.InetSocketAddress;
-
public class StandardLoggingHandler extends ChannelDuplexHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(StandardLoggingHandler.class);
@@ -48,7 +46,7 @@ public class StandardLoggingHandler extends ChannelDuplexHandler {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
- LogRecord record = createLogRecord(msg);
+ LogRecord record = createLogRecord(ctx, msg);
log(ctx, false, record);
super.channelRead(ctx, msg);
if (record != null) {
@@ -58,16 +56,15 @@ public class StandardLoggingHandler extends ChannelDuplexHandler {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
- log(ctx, true, createLogRecord(msg));
+ log(ctx, true, createLogRecord(ctx, msg));
super.write(ctx, msg, promise);
}
- private LogRecord createLogRecord(Object msg) {
+ private LogRecord createLogRecord(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof NetworkMessage) {
NetworkMessage networkMessage = (NetworkMessage) msg;
if (networkMessage.getMessage() instanceof ByteBuf) {
- LogRecord record = new LogRecord();
- record.setAddress((InetSocketAddress) networkMessage.getRemoteAddress());
+ LogRecord record = new LogRecord(ctx.channel().localAddress(), networkMessage.getRemoteAddress());
record.setProtocol(protocol);
record.setData(ByteBufUtil.hexDump((ByteBuf) networkMessage.getMessage()));
return record;