A simple WebSocket Proxy Server implemented in Python 3.
This server can run in one of three modes:
- OPEN_URL, where the connecting client provides a url to connect to via the proxy
- FORCED_URL, where the server is hardwired to connect to one and only one url
- FORCED_URL_NO_PASSWORD, where the server is hardwired to connect to one and only one url and no password is required.
== Requirements ==
- Python 3 (tested on Python 3.4, 3.6, 3.9)
- The 'websockets' module (pip install websockets)
- The 'yaml' module (pip install pyyaml)
== Instructions ==
-
In config.yaml, ensure serverType is set to OPEN_URL, FORCED_URL, or FORCED_URL_NO_PASSWORD
-
If you are using FORCED_URL or FORCED_URL_NO_PASSWORD, uncomment and set proxiedUrl to a valid websocket url. Otherwise it should be commented out with a "#"
-
Set the other configuration options, such as host, post, passphrase
-
From within the project root, launch proxy.py and connect from a websocket client to the host/port in config.yaml.
-
If you are using FORCED_URL_NO_PASSWORD, skip to step 7. Otherwise, send the password in json like so:
{"password": "12345"}
You will receive a json response where "status" is either "ok" or "error" with an elaboration in "message.
-
If you are using FORCED_URL or FORCED_URL_NO_PASSWORD, skip this step. Otherwise send the url you wish to connect to in json, like so: ws:https://localhost:8081/test {"url": ""}
You will receive a json response where "status" is either "ok" or "error" with an elaboration in "message.
-
Send X amount of websocket requests, which will be passed along to the proxied websocket.
-
When you are done and want the connection terminated, send: {"action": "close"}