Package com.sissi.server.netty.impl

Source Code of com.sissi.server.netty.impl.Socks5ProxyServerHandlerChannelInitializer

package com.sissi.server.netty.impl;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.socks.SocksCmdRequestDecoder;
import io.netty.handler.codec.socks.SocksInitRequestDecoder;
import io.netty.handler.timeout.IdleStateHandler;

import com.sissi.server.netty.ChannelHandlerBuilder;

/**
* @author kim 2013年12月22日
*/
public class Socks5ProxyServerHandlerChannelInitializer extends ChannelInitializer<SocketChannel> {

  private final int idleWrite;

  private final int idleRead;

  private final int idleAll;

  private final ChannelHandlerBuilder channelHandlerBuilder;

  public Socks5ProxyServerHandlerChannelInitializer(int idleWrite, int idleRead, int idleAll, ChannelHandlerBuilder channelHandlerBuilder) {
    super();
    this.idleAll = idleAll;
    this.idleRead = idleRead;
    this.idleWrite = idleWrite;
    this.channelHandlerBuilder = channelHandlerBuilder;
  }

  @Override
  protected void initChannel(SocketChannel ch) throws Exception {
    ch.pipeline().addLast(new SocksInitRequestDecoder()).addLast(new SocksCmdRequestDecoder()).addLast(new IdleStateHandler(this.idleRead, this.idleWrite, this.idleAll)).addLast(this.channelHandlerBuilder.build());
  }
}
TOP

Related Classes of com.sissi.server.netty.impl.Socks5ProxyServerHandlerChannelInitializer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.