Guidance on implementing server-first-message protocols?

I have seen this issue indicating that handling protocols in which the server sends the first message (like MySQL) was not possible as of Feb. 2016.

I would be interested in coding this feature so that I can snoop MySQL traffic using the --tcp option. I have a few questions:

  1. Would the owners/maintainers welcome such an addition?
  2. Has anything changed in the last year that would make this easier to implement than it was when that issue was filed?

Hi @smanzer,

You’re stumbling upon mitmproxy’s pain points it seems - sorry about that :wink:

Would the owners/maintainers welcome such an addition?

Definitely yes. The sans-io branch in fact already has this working (Sans-IO Proxy Implementation · Issue #1775 · mitmproxy/mitmproxy · GitHub / https://github.com/mitmproxy/mitmproxy/tree/sans-io), but there’s just a lot of work left before that can replace our current protocol implementation. If you have a decent workaround that works with the current protocol stack, I’d of course be happy to merge that, but see below.

Has anything changed in the last year that would make this easier to implement than it was when that issue was filed?

Not really, but I do have a workaround addon for exactly that problem: server_side_tcp.py · GitHub. That may actually be the most pragmatic approach for now.

Thank you very much :slight_smile:

Your workaround was quite easy to deploy for me, so I’m good for now. sans-io branch looks very cool I will keep an eye on that.