goproxy icon indicating copy to clipboard operation
goproxy copied to clipboard

How to count bytes transferred by CONNECT tunnel without MITM?

Open milesrichardson opened this issue 9 years ago • 4 comments

I would like to log the bytes transferred for all connections, whether HTTP or HTTPS. For HTTP, I can write an OnResponse() handler that does this. But it seems like OnResponse() is not called for HTTPS responses unless MITM is configured.

I don't want to MITM connections, but I want to count bytes transferred across CONNECT tunnels.

Squidproxy is able to do this so I know it's possible.

How can I accomplish this with goproxy?

milesrichardson avatar Nov 28 '16 17:11 milesrichardson

Use a custom dialer that counts bytes in a connection.

On Mon, Nov 28, 2016, 7:02 PM Miles Richardson [email protected] wrote:

I would like to log the bytes transferred for all connections, whether HTTP or HTTPS. For HTTP, I can write an OnResponse() handler that does this. But it seems like OnResponse() is not called for HTTPS responses unless MITM is configured.

I don't want to MITM connections, but I want to count bytes transferred across CONNECT tunnels.

Squidproxy is able to do this so I know it's possible.

How can I accomplish this with goproxy?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/elazarl/goproxy/issues/199, or mute the thread https://github.com/notifications/unsubscribe-auth/AAP4oiVhgeWyPoiwohfrZElYP-ihjpa7ks5rCwkvgaJpZM4K-BBH .

elazarl avatar Nov 28 '16 17:11 elazarl

thanks for fast response.

I'm a bit confused (sorry, new to go).... should I create the custom dialer when starting the proxy, or for every new connect tunnel?

milesrichardson avatar Nov 28 '16 17:11 milesrichardson

For every new connect attempt set a dialer that would count bytes per connection.

See proxy.Dialer IIRC, from phone

On Mon, Nov 28, 2016, 7:15 PM Miles Richardson [email protected] wrote:

thanks for fast response.

I'm a bit confused (sorry, new to go).... should I create the custom dialer when starting the proxy, or for every new connect tunnel?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/elazarl/goproxy/issues/199#issuecomment-263332118, or mute the thread https://github.com/notifications/unsubscribe-auth/AAP4osRQ3tiXumLi5L2EScYJ3FeDPuJaks5rCwwbgaJpZM4K-BBH .

elazarl avatar Nov 28 '16 17:11 elazarl

Hi! I know this issue is quite old, but I am trying the same right now. I want to count bytes when using https, where do I set a new dialer for the connect attempts? Thanks!!

Code42Cate avatar Oct 27 '19 14:10 Code42Cate