use of io.netty.handler.codec.socksx.v5.Socks5InitialRequestDecoder 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);
}
use of io.netty.handler.codec.socksx.v5.Socks5InitialRequestDecoder in project netty by netty.
the class Socks5ProxyServer method configure.
@Override
protected void configure(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
switch(testMode) {
case INTERMEDIARY:
p.addLast(DECODER, new Socks5InitialRequestDecoder());
p.addLast(ENCODER, Socks5ServerEncoder.DEFAULT);
p.addLast(new Socks5IntermediaryHandler());
break;
case TERMINAL:
p.addLast(DECODER, new Socks5InitialRequestDecoder());
p.addLast(ENCODER, Socks5ServerEncoder.DEFAULT);
p.addLast(new Socks5TerminalHandler());
break;
case UNRESPONSIVE:
p.addLast(UnresponsiveHandler.INSTANCE);
break;
}
}
Aggregations