1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.example.proxy;
17
18 import io.netty.channel.ChannelInitializer;
19 import io.netty.channel.socket.SocketChannel;
20 import io.netty.handler.logging.LogLevel;
21 import io.netty.handler.logging.LoggingHandler;
22
23 public class HexDumpProxyInitializer extends ChannelInitializer<SocketChannel> {
24
25 private final String remoteHost;
26 private final int remotePort;
27
28 public HexDumpProxyInitializer(String remoteHost, int remotePort) {
29 this.remoteHost = remoteHost;
30 this.remotePort = remotePort;
31 }
32
33 @Override
34 public void initChannel(SocketChannel ch) {
35 ch.pipeline().addLast(
36 new LoggingHandler(LogLevel.INFO),
37 new HexDumpProxyFrontendHandler(remoteHost, remotePort));
38 }
39 }