Search in sources :

Example 6 with IpConnectionContext

use of loghub.IpConnectionContext in project LogHub by fbacchella.

the class NettyIpReceiver method getConnectionContext.

@Override
public ConnectionContext getConnectionContext(ChannelHandlerContext ctx, SM message) {
    InetSocketAddress remoteaddr = null;
    InetSocketAddress localaddr = null;
    SocketAddress remoteddr = ctx.channel().remoteAddress();
    SocketAddress localddr = ctx.channel().localAddress();
    if (remoteddr instanceof InetSocketAddress) {
        remoteaddr = (InetSocketAddress) remoteddr;
    }
    if (localddr instanceof InetSocketAddress) {
        remoteaddr = (InetSocketAddress) remoteddr;
    }
    return new IpConnectionContext(localaddr, remoteaddr, null);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) IpConnectionContext(loghub.IpConnectionContext) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

IpConnectionContext (loghub.IpConnectionContext)6 InetSocketAddress (java.net.InetSocketAddress)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 InetAddress (java.net.InetAddress)2 Decoder (loghub.Decoder)2 Event (loghub.Event)2 Test (org.junit.Test)2 ByteBuf (io.netty.buffer.ByteBuf)1 Unpooled (io.netty.buffer.Unpooled)1 InputStream (java.io.InputStream)1 SocketAddress (java.net.SocketAddress)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Enumeration (java.util.Enumeration)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ConnectionContext (loghub.ConnectionContext)1 LogUtils (loghub.LogUtils)1