Search in sources :

Example 1 with Socks4ServerDecoder

use of io.netty.handler.codec.socksx.v4.Socks4ServerDecoder in project netty by netty.

the class Socks4ProxyServer method configure.

@Override
protected void configure(SocketChannel ch) throws Exception {
    ChannelPipeline p = ch.pipeline();
    switch(testMode) {
        case INTERMEDIARY:
            p.addLast(new Socks4ServerDecoder());
            p.addLast(Socks4ServerEncoder.INSTANCE);
            p.addLast(new Socks4IntermediaryHandler());
            break;
        case TERMINAL:
            p.addLast(new Socks4ServerDecoder());
            p.addLast(Socks4ServerEncoder.INSTANCE);
            p.addLast(new Socks4TerminalHandler());
            break;
        case UNRESPONSIVE:
            p.addLast(UnresponsiveHandler.INSTANCE);
            break;
    }
}
Also used : Socks4ServerDecoder(io.netty.handler.codec.socksx.v4.Socks4ServerDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 2 with Socks4ServerDecoder

use of io.netty.handler.codec.socksx.v4.Socks4ServerDecoder in project netty by netty.

the class SocksPortUnificationServerHandler method decode.

@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
    final int readerIndex = in.readerIndex();
    if (in.writerIndex() == readerIndex) {
        return;
    }
    ChannelPipeline p = ctx.pipeline();
    final byte versionVal = in.getByte(readerIndex);
    SocksVersion version = SocksVersion.valueOf(versionVal);
    switch(version) {
        case SOCKS4a:
            logKnownVersion(ctx, version);
            p.addAfter(ctx.name(), null, Socks4ServerEncoder.INSTANCE);
            p.addAfter(ctx.name(), null, new Socks4ServerDecoder());
            break;
        case SOCKS5:
            logKnownVersion(ctx, version);
            p.addAfter(ctx.name(), null, socks5encoder);
            p.addAfter(ctx.name(), null, new Socks5InitialRequestDecoder());
            break;
        default:
            logUnknownVersion(ctx, versionVal);
            in.skipBytes(in.readableBytes());
            ctx.close();
            return;
    }
    p.remove(this);
}
Also used : Socks5InitialRequestDecoder(io.netty.handler.codec.socksx.v5.Socks5InitialRequestDecoder) Socks4ServerDecoder(io.netty.handler.codec.socksx.v4.Socks4ServerDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Aggregations

ChannelPipeline (io.netty.channel.ChannelPipeline)2 Socks4ServerDecoder (io.netty.handler.codec.socksx.v4.Socks4ServerDecoder)2 Socks5InitialRequestDecoder (io.netty.handler.codec.socksx.v5.Socks5InitialRequestDecoder)1