monkeyWie / proxyee

HTTP proxy server,support HTTPS&websocket.MITM impl,intercept and tamper HTTPS traffic.
MIT License
1.54k stars 574 forks source link

请问开启了https代理后,某些网址,如gihtub.com不希望被代理如何设置 #272

Closed zzmgc4 closed 1 year ago

zzmgc4 commented 1 year ago

public void channelRead(ChannelHandlerContext ctx, Object msg) 在channelRead里面判断直接return好像不生效

monkeyWie commented 1 year ago

不代理的话应该从客户端入手吧,比如pac规则这种

zzmgc4 commented 1 year ago

明白,我的问法有问题,应该是不希望截取被https解密的网址

monkeyWie commented 1 year ago

哦 你意思就是指定某些域名不走MITM,报文原始转发那种吧,目前还不支持,我看看怎么改下吧

zzmgc4 commented 1 year ago

我现在做了一个正则匹配 private static final Pattern URL_PATTERN = Pattern.compile("(?i)(?:https?://)?([a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,})(?::\d+)?(?:/\S*)?"); else { // ssl和websocket的握手处理 ByteBuf byteBuf = (ByteBuf) msg; Pattern pattern = Pattern.compile("^http"); String request = byteBuf.toString(CharsetUtil.UTF_8); // 使用正则表达式从请求内容中获取网址信息 Matcher matcher = URL_PATTERN.matcher(request); if (matcher.find()) { String url = matcher.group(1); System.out.println("Received request: " + request); System.out.println("URL: " + url); } // 处理原始的请求内容 System.out.println("Received request: " + request); //然后如果匹配成功,把HandleSsl设置为false if (getServerConfig().isHandleSsl() && byteBuf.getByte(0) == 22) {// ssl握手

monkeyWie commented 1 year ago

域名在握手信息里是有的,直接拿就行了

zzmgc4 commented 1 year ago

是在byteBuf 里面拿吗,因为这个https里面好像是加密的,拿不到

monkeyWie commented 1 year ago

刚刚提交了一版,你升级到1.7.5,可以参考下最新的示例:https://github.com/monkeyWie/proxyee/blob/master/src/test/java/com/github/monkeywie/proxyee/MimtMatchHttpProxyServer.java