- Remove AMQP - Add convenience methods to ProxiedMessage - Iterate and abord JoinHandles when the client websocket closes |
7 months ago | |
---|---|---|
src | 7 months ago | |
.gitignore | 8 months ago | |
Cargo.lock | 7 months ago | |
Cargo.toml | 7 months ago | |
LICENSE-APACHE | 7 months ago | |
LICENSE-MIT | 7 months ago | |
README.md | 7 months ago |
README.md
Websocket Proxy - POC/WIP
This project exists out of a desire to prove it possible to maintain ownership of data flowing to a WebSocket service provided by an external party by way of proxying that data and extracting/storing that data as seen fit by the owner.
At present, this is a binary crate that provides one binary proxy that pushes all messages into an extraction channel, logs the message and which side of the proxy it was from.
Usage and Configuration
Environment Variables
WS_PROXY_BASE
defines the base URL for the upstream WebSocket server, ex:wss://foo.bar/websocket/
SEC_WEBSOCKET_PROTOCOL
defines the allowed protocols supported by the upstream WebSocket server. While the spec allows for there to be no protocol, this proxy does not and the author considers that a feature rather than a bug. Ex:hello,goodbye
Assume websocket-proxy
has been compiled, and is on $PATH
:
$ SEC_WEBSOCKET_PROTOCOL="hello,goodbye" WS_PROXY_BASE="wss://foo.bar/websocket/" websocket-proxy 0.0.0.0:3030
This will run the proxy with a local listener at ws://0.0.0.0:3030/websocket/
expecting a single path parameter.
Each successful Upgrade request will spawn a client websocket within the proxy to wss://foo.bar/websocket/{param}
,
and all messages to and from the client/server will be logged.
Goals and Non-Goals
This is largely just a POC, and as such there is neither desire nor motivation to cover every possible use case. At some point, I may refactor this towards a library crate, and then provide examples of using the library to build a proxy that does as you wish. It is generally my wish to appropriately handle all potential runtime errors of which I am aware (principally those related to dropped or failed network connections). It is not my intent to provide an audited, secure, and production grade proxy.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Contact
To discuss features, offer assistance, or get help please join the project's Matrix room.