Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ private void handleProxyData(Channel channel, Object msg, boolean isHttp) throws
: new TunnelProxyInitializer(channel, proxyHandler);
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(getServerConfig().getProxyLoopGroup()) // 注册线程池
.channel(NioSocketChannel.class) // 使用NioSocketChannel来作为连接用的channel类
.channelFactory(getServerConfig().getChannelFactory())
.handler(channelInitializer);
if (proxyHandler != null) {
if (proxyHandler != null && !getServerConfig().getForceResolveDNS()) {
// 代理服务器解析DNS和连接
bootstrap.resolver(NoopAddressResolverGroup.INSTANCE);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import com.github.monkeywie.proxyee.server.accept.HttpProxyMitmMatcher;
import com.github.monkeywie.proxyee.server.auth.HttpProxyAuthenticationProvider;
import com.github.monkeywie.proxyee.config.IdleStateCheck;

import io.netty.channel.ChannelFactory;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.HttpObjectDecoder;
import io.netty.handler.ssl.SslContext;
import io.netty.resolver.AddressResolverGroup;
Expand Down Expand Up @@ -37,6 +41,8 @@ public class HttpProxyServerConfig {
private int maxHeaderSize = HttpObjectDecoder.DEFAULT_MAX_HEADER_SIZE;
private int maxChunkSize = HttpObjectDecoder.DEFAULT_MAX_CHUNK_SIZE;
private IdleStateCheck idleStateCheck;
private ChannelFactory<SocketChannel> channelFactory;
private boolean forceResolveDNS = false;

public HttpProxyServerConfig() {
this(DefaultAddressResolverGroup.INSTANCE);
Expand Down Expand Up @@ -67,6 +73,30 @@ private HttpProxyServerConfig(Builder builder) {
this.idleStateCheck = builder.idleStateCheck;
}

public void setForceResolveDNS(boolean forceResolveDNS) {
this.forceResolveDNS = forceResolveDNS;
}

public boolean getForceResolveDNS() {
return forceResolveDNS;
}

public ChannelFactory<SocketChannel> getChannelFactory() {
if (channelFactory == null) {
return (new ChannelFactory<SocketChannel>() {
@Override
public SocketChannel newChannel() {
return new NioSocketChannel(); // 使用NioSocketChannel来作为连接用的channel类
}
});
}
return channelFactory;
}

public void setChannelFactory(ChannelFactory<SocketChannel> channelFactory) {
this.channelFactory = channelFactory;
}

public SslContext getClientSslCtx() {
return clientSslCtx;
}
Expand Down