vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
6.73k stars 259 forks source link

Feature request: server broadcast to all clients except for sender #100

Closed donnm closed 3 years ago

donnm commented 3 years ago

I'm looking for something like websocat -E ws-l:0.0.0.0:1234 broadcast:mirror-not-self: where a message received by the server from a client is broadcast to other connected clients but not mirrored back to the sender. More simply put, broadcast the message to all other parties except myself (the sender).

What I am trying to do is access DevTools behind a firewall (it's actually a bit more complicated than this), where the setup is such that with websocat -E ws-l:0.0.0.0:1234 broadcast:mirror: any responses or error messages from the client or DevTools server are mirrored back to the sender which quickly generate more error messages and snowball causing excess CPU usage and network traffic.

chromium DevTools <----> websocat server <----> chromium

The above looks like the perfect proxy server setup, but the complication is that chromium DevTools is itself connecting as a client to websocat server via a small WebSockets Javascript reverse proxy stub loaded locally.

Perhaps there is a configuration that already does what I want? If not, I would be happy to create a pull request, but am unsure of where to begin. So some hints would be appreciated.

vi commented 3 years ago

There is no such thing currently in Websocat and adding it could be problematic - when data reaches the "mirror:", information of what particular client has sent it is already lost.

Maybe you actually want my other project wsbroad?

It is dedicated for broadcasting WebSocket messages between connected clients. Each URL has a separate broadcast domain and messages are not sent back to source.

Unfortunately errors are not handled properly in wsbroad at the moment and it exits if non-WebSocket client tries to connect.

donnm commented 3 years ago

Hi! Thank you for the quick response. wsbroad does do exactly what I want. Thanks!

vi commented 3 years ago

Updated wsbroad to modern Rust things.

You can now easily customize it for your needs.