proxyee icon indicating copy to clipboard operation
proxyee copied to clipboard

在https连接中interceptPipeline = buildPipeline(); 不会执行吗?

Open SuiBianJun opened this issue 6 years ago • 8 comments

你好,在使用https代理的时候interceptPipeline 执行不到吗? image

当检测到请求的method为CONNECT的时候,函数直接返回了,定义的proxyIntercept拦截器初始化不了,响应拦截的函数也不会被执行。实际运行https代理的时候,访问https://www.baidu.com,响应的内容也没有被修改。

请问是哪个过程有问题呢?我是想测试在https代理中获取请求和响应的内容。谢谢

SuiBianJun avatar Dec 13 '18 08:12 SuiBianJun

你是不是没配置拦截ssl的选项啊?

HttpProxyServerConfig config =  new HttpProxyServerConfig();
config.setHandleSsl(true);
new HttpProxyServer()
    .serverConfig(config)
    .start(9999);

monkeyWie avatar Dec 13 '18 13:12 monkeyWie

我是用的项目中的这个test运行的程序:

`public class InterceptResponseContentHttpProxyServer {

static Logger logger = Logger.getLogger(InterceptResponseContentHttpProxyServer.class);

public static void main(String[] args) throws Exception {

  logger.info("httpProxyInterceptPipeline main");
  
HttpProxyServerConfig config =  new HttpProxyServerConfig();
config.setHandleSsl(true);
new HttpProxyServer()
    .serverConfig(config)
    .proxyInterceptInitializer(new HttpProxyInterceptInitializer() {
      @Override
      public void init(HttpProxyInterceptPipeline pipeline) {
    	  
    	  //logger.info("httpProxyInterceptPipeline init");
    	  
    	  System.out.println("httpProxyInterceptPipeline init");
    	  
        pipeline.addLast(new FullResponseIntercept() {

          @Override
          public boolean match(HttpRequest httpRequest, HttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) {
            //在匹配到百度首页时插入js
        	  logger.info("match website servername");
            return HttpUtil.checkUrl(pipeline.getHttpRequest(), "^www.baidu.com$")
                && isHtml(httpRequest, httpResponse);
          }

          @Override
          public void handelResponse(HttpRequest httpRequest, FullHttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) {
            //打印原始响应信息
            System.out.println(httpResponse.toString());
            System.out.println(httpResponse.content().toString(Charset.defaultCharset()));
            //修改响应头和响应体
            httpResponse.headers().set("handel", "edit head");
            int index = ByteUtil.findText(httpResponse.content(), "<head>");
            ByteUtil.insertText(httpResponse.content(), index, "<script>alert(1)</script>");
            httpResponse.content().writeBytes("<script>alert('hello proxyee')</script>".getBytes());
          }
        });
      }
    })
    .start(9999);

} }`

HttpProxyInterceptInitializer中的init方法没有被执行到, 但是https的代理是正常的。下面是在程序运行后,访问https://www.baidu.com打印的一些参数:

-INFO-2018/12/15 13:39:25,854-com.github.monkeywie.proxyee.InterceptResponseContentHttpProxyServer.main(InterceptResponseContentHttpProxyServer.java:23)-23-httpProxyInterceptPipeline main -INFO-2018/12/15 13:39:26,078-com.github.monkeywie.proxyee.server.HttpProxyServer.start(HttpProxyServer.java:129)-129-httpproxyserver start -INFO-2018/12/15 13:39:26,078-com.github.monkeywie.proxyee.server.HttpProxyServer.init(HttpProxyServer.java:49)-49-httpproxyserver init -INFO-2018/12/15 13:39:27,312-com.github.monkeywie.proxyee.server.HttpProxyServer.init(HttpProxyServer.java:59)-59-serverconfig ishandlessl -INFO-2018/12/15 13:39:28,948-com.github.monkeywie.proxyee.server.HttpProxyServer.init(HttpProxyServer.java:96)-96-httpProxyExceptionHandle == null -INFO-2018/12/15 13:39:35,005-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:39:35,202-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:39:35,203-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:39:35,203-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:39:40,974-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerRemoved(HttpProxyServerHandle.java:86)-86-handlerRemoved -INFO-2018/12/15 13:40:00,179-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:40:00,180-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:40:00,181-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:40:00,181-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:40:00,520-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:126)-126-request info : DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) CONNECT www.baidu.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 Proxy-Connection: keep-alive Connection: keep-alive Host: www.baidu.com:443 -INFO-2018/12/15 13:40:00,520-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:131)-131-status == 0 -INFO-2018/12/15 13:40:00,581-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:142)-142-request address: www.baidu.com:443 -INFO-2018/12/15 13:40:00,582-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:145)-145-request method == connect -INFO-2018/12/15 13:40:00,595-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:173)-173-msg is HttpContent -INFO-2018/12/15 13:40:00,596-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:189)-189-set status = 1 -INFO-2018/12/15 13:40:00,596-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:00,597-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:00,597-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:237)-237-cf == null -INFO-2018/12/15 13:40:00,788-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.lambda$0(HttpProxyServerHandle.java:265)-265-future is Success, writeAndFlush: PooledUnsafeDirectByteBuf(ridx: 0, widx: 180, cap: 1024) -INFO-2018/12/15 13:40:00,947-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:00,947-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,272-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:40:01,273-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:40:01,273-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:40:01,274-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:40:01,276-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:126)-126-request info : DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) CONNECT www.baidu.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 Proxy-Connection: keep-alive Connection: keep-alive Host: www.baidu.com:443 -INFO-2018/12/15 13:40:01,277-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:131)-131-status == 0 -INFO-2018/12/15 13:40:01,278-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:142)-142-request address: www.baidu.com:443 -INFO-2018/12/15 13:40:01,278-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:145)-145-request method == connect -INFO-2018/12/15 13:40:01,279-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:173)-173-msg is HttpContent -INFO-2018/12/15 13:40:01,279-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:189)-189-set status = 1 -INFO-2018/12/15 13:40:01,297-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,298-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:40:01,298-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,298-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:40:01,299-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:237)-237-cf == null -INFO-2018/12/15 13:40:01,299-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:40:01,301-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:40:01,301-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:40:01,303-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:40:01,303-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:40:01,304-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:40:01,304-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:40:01,304-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:126)-126-request info : DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) CONNECT www.baidu.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 Proxy-Connection: keep-alive Connection: keep-alive Host: www.baidu.com:443 -INFO-2018/12/15 13:40:01,306-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:131)-131-status == 0 -INFO-2018/12/15 13:40:01,305-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:40:01,305-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:40:01,307-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:40:01,306-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:142)-142-request address: www.baidu.com:443 -INFO-2018/12/15 13:40:01,308-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:145)-145-request method == connect -INFO-2018/12/15 13:40:01,309-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:126)-126-request info : DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) CONNECT www.baidu.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 Proxy-Connection: keep-alive Connection: keep-alive Host: www.baidu.com:443 -INFO-2018/12/15 13:40:01,309-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:131)-131-status == 0 -INFO-2018/12/15 13:40:01,309-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:126)-126-request info : DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) CONNECT ss1.bdstatic.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 Proxy-Connection: keep-alive Connection: keep-alive Host: ss1.bdstatic.com:443 -INFO-2018/12/15 13:40:01,310-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:131)-131-status == 0 -INFO-2018/12/15 13:40:01,309-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:173)-173-msg is HttpContent -INFO-2018/12/15 13:40:01,311-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:142)-142-request address: ss1.bdstatic.com:443 -INFO-2018/12/15 13:40:01,310-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:142)-142-request address: www.baidu.com:443 -INFO-2018/12/15 13:40:01,311-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:145)-145-request method == connect -INFO-2018/12/15 13:40:01,311-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:189)-189-set status = 1 -INFO-2018/12/15 13:40:01,311-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:145)-145-request method == connect -INFO-2018/12/15 13:40:01,313-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,313-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,313-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:237)-237-cf == null -INFO-2018/12/15 13:40:01,313-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:173)-173-msg is HttpContent -INFO-2018/12/15 13:40:01,315-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:189)-189-set status = 1 -INFO-2018/12/15 13:40:01,313-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:173)-173-msg is HttpContent -INFO-2018/12/15 13:40:01,316-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:189)-189-set status = 1 -INFO-2018/12/15 13:40:01,316-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,316-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,316-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,317-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:237)-237-cf == null -INFO-2018/12/15 13:40:01,317-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,318-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:237)-237-cf == null -INFO-2018/12/15 13:40:01,386-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:40:01,387-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:40:01,387-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:40:01,391-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:40:01,391-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:40:01,392-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:40:01,393-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:40:01,392-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:126)-126-request info : DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) CONNECT www.baidu.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 Proxy-Connection: keep-alive Connection: keep-alive Host: www.baidu.com:443 -INFO-2018/12/15 13:40:01,394-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:131)-131-status == 0 -INFO-2018/12/15 13:40:01,394-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:142)-142-request address: www.baidu.com:443 -INFO-2018/12/15 13:40:01,395-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:145)-145-request method == connect -INFO-2018/12/15 13:40:01,396-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:173)-173-msg is HttpContent -INFO-2018/12/15 13:40:01,397-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:189)-189-set status = 1 -INFO-2018/12/15 13:40:01,397-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:40:01,397-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,398-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,398-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:237)-237-cf == null -INFO-2018/12/15 13:40:01,398-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:126)-126-request info : DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) CONNECT www.baidu.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 Proxy-Connection: keep-alive Connection: keep-alive Host: www.baidu.com:443 -INFO-2018/12/15 13:40:01,399-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:131)-131-status == 0 -INFO-2018/12/15 13:40:01,399-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:142)-142-request address: www.baidu.com:443 -INFO-2018/12/15 13:40:01,400-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:145)-145-request method == connect -INFO-2018/12/15 13:40:01,401-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.lambda$0(HttpProxyServerHandle.java:265)-265-future is Success, writeAndFlush: PooledUnsafeDirectByteBuf(ridx: 0, widx: 517, cap: 1024) -INFO-2018/12/15 13:40:01,402-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:173)-173-msg is HttpContent -INFO-2018/12/15 13:40:01,403-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:189)-189-set status = 1 -INFO-2018/12/15 13:40:01,412-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.lambda$0(HttpProxyServerHandle.java:265)-265-future is Success, writeAndFlush: PooledUnsafeDirectByteBuf(ridx: 0, widx: 517, cap: 1024) -INFO-2018/12/15 13:40:01,412-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,413-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,413-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:237)-237-cf == null -INFO-2018/12/15 13:40:01,418-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.lambda$0(HttpProxyServerHandle.java:265)-265-future is Success, writeAndFlush: PooledUnsafeDirectByteBuf(ridx: 0, widx: 517, cap: 1024) -INFO-2018/12/15 13:40:01,432-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.lambda$0(HttpProxyServerHandle.java:265)-265-future is Success, writeAndFlush: PooledUnsafeDirectByteBuf(ridx: 0, widx: 183, cap: 1024) -INFO-2018/12/15 13:40:01,502-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.lambda$0(HttpProxyServerHandle.java:265)-265-future is Success, writeAndFlush: PooledUnsafeDirectByteBuf(ridx: 0, widx: 517, cap: 1024) -INFO-2018/12/15 13:40:01,506-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,506-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,507-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,508-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,509-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,509-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,511-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,512-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,513-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,513-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,514-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,514-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.lambda$0(HttpProxyServerHandle.java:265)-265-future is Success, writeAndFlush: PooledUnsafeDirectByteBuf(ridx: 0, widx: 517, cap: 1024) -INFO-2018/12/15 13:40:01,520-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,556-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,557-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,561-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,561-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,562-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,562-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,600-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,600-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,610-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,610-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,612-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,613-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,618-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,618-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,628-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,628-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,632-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,632-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,632-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,633-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,633-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,634-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,636-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,636-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,645-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,646-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,646-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,647-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,914-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,914-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:01,940-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:01,940-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,043-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,044-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,136-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,137-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,146-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,146-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,513-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,513-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,514-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,514-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,530-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,531-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,533-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,533-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,547-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,548-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,617-com.github.monkeywie.proxyee.server.HttpProxyServer$1.initChannel(HttpProxyServer.java:145)-145-init channel -INFO-2018/12/15 13:40:02,617-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.<init>(HttpProxyServerHandle.java:118)-118-interceptInitializer not null: -INFO-2018/12/15 13:40:02,618-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handlerAdded(HttpProxyServerHandle.java:78)-78-handlerAdded -INFO-2018/12/15 13:40:02,618-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelActive(HttpProxyServerHandle.java:93)-93-channelActive -INFO-2018/12/15 13:40:02,620-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:126)-126-request info : DefaultHttpRequest(decodeResult: success, version: HTTP/1.1) CONNECT sp0.baidu.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:32.0) Gecko/20100101 Firefox/32.0 Proxy-Connection: keep-alive Connection: keep-alive Host: sp0.baidu.com:443 -INFO-2018/12/15 13:40:02,620-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:131)-131-status == 0 -INFO-2018/12/15 13:40:02,621-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:142)-142-request address: sp0.baidu.com:443 -INFO-2018/12/15 13:40:02,621-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:145)-145-request method == connect -INFO-2018/12/15 13:40:02,622-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:173)-173-msg is HttpContent -INFO-2018/12/15 13:40:02,623-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:189)-189-set status = 1 -INFO-2018/12/15 13:40:02,629-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,629-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,629-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:237)-237-cf == null -INFO-2018/12/15 13:40:02,705-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,705-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,706-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,706-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,738-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,739-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,739-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.lambda$0(HttpProxyServerHandle.java:265)-265-future is Success, writeAndFlush: PooledUnsafeDirectByteBuf(ridx: 0, widx: 180, cap: 1024) -INFO-2018/12/15 13:40:02,874-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,874-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,886-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,886-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,886-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,887-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,887-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,887-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false -INFO-2018/12/15 13:40:02,889-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.channelRead(HttpProxyServerHandle.java:210)-210-handleProxyData -INFO-2018/12/15 13:40:02,890-com.github.monkeywie.proxyee.handler.HttpProxyServerHandle.handleProxyData(HttpProxyServerHandle.java:235)-235-handleProxyData, isHttp=false

由于每次的请求都是CONNECT, 导致interceptPipeline = buildPipeline(); 都没法执行到。不知道是不是这个请求的问题。

SuiBianJun avatar Dec 15 '18 05:12 SuiBianJun

再次看了一遍代码,我似乎把拦截https内容的流程搞错了。拦截https的响应是不是应该在TunnelProxyInitializer中做呢?

SuiBianJun avatar Dec 16 '18 03:12 SuiBianJun

额 你ca证书装了吗?

monkeyWie avatar Dec 16 '18 17:12 monkeyWie

ca.crt导入浏览器了,https是可以正常通信的。嗯,我现在想要用这个代理做的一个功能是 截获https的请求和响应,并且能够 修改https的请求和响应。之前 尝试在 HttpProxyServerHandle中 截获https报文,然后就是上面的问题,不能截获到https的报文。这两天在 TunnelProxyInitializer中添加了 查看https通信的代码,但是数据全是加密的,并且从打印的通信报文来看,还有握手的报文,并不是纯的只有https响应的报文,暂时是分析到这里了。对于代理要做的这个功能,您能不能给些建议呢?或者简单的处理流程?谢谢

SuiBianJun avatar Dec 17 '18 03:12 SuiBianJun

这个测试类InterceptResponseContentHttpProxyServer.java有你需要的功能呀,而且也可以做拦截和修改

monkeyWie avatar Dec 20 '18 01:12 monkeyWie

很感谢您的回复,再次review again, 才发现是那个程序中的证书路径错误导致异常,就是这个: image

异常处理代码之前就只有一句代码呀(感觉代码在这里还是打印一下异常原因比较好):serverConfig.setHandleSsl(false); 导致虽然代理正常工作,但是对截获https代理是有点小问题,才有前面的问题。

证书路径正确后,https代理截获正常了:). 再次感谢。

SuiBianJun avatar Dec 20 '18 03:12 SuiBianJun

原来这样啊,我还是改成指定了拦截ssl的话,如果证书那里出问题了应该直接抛异常不运行server了

monkeyWie avatar Dec 20 '18 04:12 monkeyWie