From e96a4d76817449058a62d27efa72ad1b33cd440b Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Wed, 20 Jan 2021 08:50:21 +0800 Subject: [PATCH] =?UTF-8?q?mongodb=E8=AE=BF=E9=97=AE=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dipperposition/handler/NettyServerHandler.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java index 0fe29bf..c5b80c1 100644 --- a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java +++ b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java @@ -105,15 +105,13 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { //接收msg消息与上一章节相比,此处已经不需要自己进行解码} SocketChannel channel = (SocketChannel) ctx.channel(); - String ipAddress = channel.remoteAddress().getHostString().toString(); - //String message = " 接收到消息:{0}, 客户端IP:{1}"; + String ipAddress = channel.remoteAddress().getHostString(); log.info("接收到消息:" + msg + ",客户端IP:" + ipAddress); -// if (nettyServerHandler.positionConfig != null) { -// log.info("config info is : " + nettyServerHandler.positionConfig.getCenterProvinceFilePath() + nettyServerHandler.positionConfig.getCenterProvince() + nettyServerHandler.positionConfig.getIpPositionRequestPath() + -// nettyServerHandler.positionConfig.getIpPositionRequestKey()); -// } else { -// log.info("positionConfig info is null!!!!!!!!!!!!!! "); -// } + if(ipAddress.contains(":")) { + String[] ipAddressArr = ipAddress.split(":"); + ipAddress = ipAddressArr[0].replace("/",""); + } + log.info("新客户端IP:" + ipAddress); String channelAns = ""; // 返回时间指令