-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHttpProxyServerInitializer.java
More file actions
32 lines (26 loc) · 1.14 KB
/
HttpProxyServerInitializer.java
File metadata and controls
32 lines (26 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.arloor.forwardproxy;
import com.arloor.forwardproxy.monitor.GlobalTrafficMonitor;
import com.arloor.forwardproxy.vo.Config;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpRequestDecoder;
import io.netty.handler.codec.http.HttpResponseEncoder;
import io.netty.handler.codec.http.HttpServerExpectContinueHandler;
import java.io.IOException;
import java.security.GeneralSecurityException;
public class HttpProxyServerInitializer extends ChannelInitializer<SocketChannel> {
private final Config.Http http;
public HttpProxyServerInitializer(Config.Http http) throws IOException, GeneralSecurityException {
this.http = http;
}
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
p.addLast(GlobalTrafficMonitor.getInstance());
p.addLast(new HttpRequestDecoder());
p.addLast(new HttpResponseEncoder());
p.addLast(new HttpServerExpectContinueHandler());
p.addLast(new HttpProxyConnectHandler(http.getAuthMap()));
}
}