Refine search
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { if (!acceptForeignIp) { if (!((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().isLoopbackAddress()) { ByteBuf cb = Unpooled.wrappedBuffer((QosConstants.BR_STR + "Foreign Ip Not Permitted." + QosConstants.BR_STR).getBytes()); ctx.writeAndFlush(cb).addListener(ChannelFutureListener.CLOSE); } } } }
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { if (!acceptForeignIp) { if (!((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().isLoopbackAddress()) { ByteBuf cb = Unpooled.wrappedBuffer((QosConstants.BR_STR + "Foreign Ip Not Permitted." + QosConstants.BR_STR).getBytes()); ctx.writeAndFlush(cb).addListener(ChannelFutureListener.CLOSE); } } } }
public String remoteName() { InetSocketAddress addr = (InetSocketAddress) chctx.channel().remoteAddress(); if (addr == null) return null; // Use hostString that does not trigger a DNS resolution return addr.getHostString(); }
private String getRemoteAddress(ChannelHandlerContext ctx) { if (ctx.channel().remoteAddress() == null) { return null; } InetSocketAddress inetAddress = (InetSocketAddress) ctx.channel().remoteAddress(); return inetAddress.getAddress().getHostAddress() + ":" + inetAddress.getPort(); } }
private String getRemoteAddress(ChannelHandlerContext ctx) { if (ctx.channel().remoteAddress() == null) { return null; } InetSocketAddress inetAddress = (InetSocketAddress) ctx.channel().remoteAddress(); return inetAddress.getAddress().getHostAddress() + ":" + inetAddress.getPort(); }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { if (sourceInputLog.isTraceEnabled()) { sourceInputLog.trace("Recv network data: {} bytes via input '{}' <{}> from remote address {}", msg.readableBytes(), sourceInputName, sourceInputId, ctx.channel().remoteAddress()); } } }
public SocketAddress remoteAddress() { InetSocketAddress addr = (InetSocketAddress) chctx.channel().remoteAddress(); if (addr == null) return null; return new SocketAddressImpl(addr); }
@Override public void run() { ctx.channel().close(); log.debug("Client with ip {} opened channel but doesn't send any data! Channel closed!", ctx.channel().remoteAddress()); } }, configuration.getFirstDataTimeout(), TimeUnit.MILLISECONDS);
static SocketAddress remote(ChannelHandlerContext ctx) { if (ctx.channel() != null && ctx.channel().remoteAddress() != null) { return ctx.channel().remoteAddress(); } return new LocalAddress("unknown"); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { LoggerUtil.error("NettyChannelHandler exceptionCaught: remote={} local={} event={}", ctx.channel().remoteAddress(), ctx.channel().localAddress(), cause.getMessage(), cause); ctx.channel().close(); }
private String getRemoteIp(ChannelHandlerContext ctx) { String ip = ""; SocketAddress remote = ctx.channel().remoteAddress(); if (remote != null) { try { ip = ((InetSocketAddress) remote).getAddress().getHostAddress(); } catch (Exception e) { LoggerUtil.warn("get remoteIp error! default will use. msg:{}, remote:{}", e.getMessage(), remote.toString()); } } return ip; }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { super.channelInactive(ctx); LOGGER.info("channel inactive for ServerProxyHandler at :[{}],[{}]", ctx.channel(),ctx.channel().remoteAddress()); }
@Override public void onCheckMessage(long msgId, ChannelHandlerContext ctx, ServerMessageSender sender) { try { sender.sendResponse(msgId, ctx.channel(), HeartbeatMessage.PONG); } catch (Throwable throwable) { LOGGER.error("", "send response error", throwable); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("received PING from " + ctx.channel().remoteAddress()); } }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(), url, handler); try { if (channel != null) { channels.put(NetUtils.toAddressString((InetSocketAddress) ctx.channel().remoteAddress()), channel); } handler.connected(channel); } finally { NettyChannel.removeChannelIfDisconnected(ctx.channel()); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { NettyChannel channel = NettyChannel.getOrAddChannel(ctx.channel(), url, handler); try { channels.remove(NetUtils.toAddressString((InetSocketAddress) ctx.channel().remoteAddress())); handler.disconnected(channel); } finally { NettyChannel.removeChannelIfDisconnected(ctx.channel()); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { LoggerUtil.info("NettyChannelHandler channelInactive: remote={} local={}", ctx.channel().remoteAddress(), ctx.channel().localAddress()); ctx.fireChannelInactive(); }
@Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { Channel channel = ctx.channel(); String channelKey = getChannelKey((InetSocketAddress) channel.localAddress(), (InetSocketAddress) channel.remoteAddress()); channels.remove(channelKey); ctx.fireChannelUnregistered(); }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { LoggerUtil.info("NettyChannelHandler channelActive: remote={} local={}", ctx.channel().remoteAddress(), ctx.channel().localAddress()); ctx.fireChannelActive(); }
@Override protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception { final byte[] bytes = new byte[msg.readableBytes()]; msg.readBytes(bytes); final RawMessage raw = new RawMessage(bytes, (InetSocketAddress) ctx.channel().remoteAddress()); input.processRawMessage(raw); }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { if (messageExecutor.isShutdown()) { return; } if (LOGGER.isInfoEnabled()) { LOGGER.info("channel inactive:" + ctx.channel()); } releaseChannel(ctx.channel(), NetUtil.toStringAddress(ctx.channel().remoteAddress())); super.channelInactive(ctx); }