Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WebSockets in proxy package #6

Open
dstotijn opened this issue Sep 27, 2020 · 11 comments
Open

Fix WebSockets in proxy package #6

dstotijn opened this issue Sep 27, 2020 · 11 comments
Labels
bug Something isn't working

Comments

@dstotijn
Copy link
Owner

Proxying WebSockets (e.g. the upgrade process and handling frames) is not working at all. Should check if it's feasible with httputil.ReverseProxy and what the solution can be.

@dstotijn dstotijn added the bug Something isn't working label Sep 27, 2020
@ubogdan
Copy link

ubogdan commented Sep 28, 2020

Why don't you use github.com/gorilla/websocket ?

@dstotijn
Copy link
Owner Author

AFAIK, that package is for managing WS conns with a client, I'm not sure if it helps with MITM proxying between a client and a server. But if you have ideas on how to implement it in the proxy package of Hetty, let me know!

@ubogdan
Copy link

ubogdan commented Sep 28, 2020

I can give it a try you want.
And yes httputil package seems to have support for websocket.

@ubogdan
Copy link

ubogdan commented Sep 29, 2020

I've made it in a working state. see github.com/ubogdan/hetty . Please let me know where does the websocket communication should be stored since we have requests and responses.

@ubogdan
Copy link

ubogdan commented Sep 29, 2020

websocket.go may require a rewrite since it's very messy at this time. The returning header may be important since websocket has a text protocol and a binary protocol. see: gorilla/websocket as reference

@dstotijn
Copy link
Owner Author

I've made it in a working state. see github.com/ubogdan/hetty . Please let me know where does the websocket communication should be stored since we have requests and responses.

Wow, nice! I'll have a look later this week, but quickly thinking about it: we probably need to first make some changes to the proxy package, e.g. add additional middleware for WS frames in addition to these. After that, we can then update the reqlog package and implement the middleware to log WS frame content (e.g. URL, direction, body) to the database.

I'll circle back later this week to propose how to fit it in, OK?

@ubogdan
Copy link

ubogdan commented Sep 29, 2020

OK. Take your time.

@dstotijn
Copy link
Owner Author

Not sure if these are suitable for MITM, but maybe https://github.com/koding/websocketproxy and https://github.com/yhat/wsutil/blob/master/wsutil.go can be helpful to look into.

@ubogdan
Copy link

ubogdan commented Sep 30, 2020

@dstotijn
Both packages are doing a Connection Upgrade and they are joining the connections but they have 0 knowledge of the data they pass in or out.
I guess the scope of hetty is to be able to view the WebSocket messages not only to leave them to pass.

@zevlag
Copy link

zevlag commented Oct 5, 2020

I agree, viewing and editing individual web socket messages would be completely in scope, appropriate, and useful.

@ubogdan
Copy link

ubogdan commented Jan 8, 2021

@dstotijn I guess there is no update for the interceptor module or a place where I can connect the WebSocket decoder in order to store the communication into the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants