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;
}
}
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);
}
Aggregations