1# lws minimal ws - raw proxy 2 3This demonstrates how to use a proxy connection object to bind together two or 4more connections in a proxy. This particular example has a ws server that 5creates an onward "raw" client connection to 127.0.0.1:1234. 6 7You can make a suitable "raw server" with 8 9``` 10$ nc -l 127.0.0.1 1234 11``` 12 13## build 14 15``` 16 $ cmake . && make 17``` 18 19## Commandline Options 20 21Option|Meaning 22---|--- 23-d|Set logging verbosity 24 25 26## usage 27 28``` 29 $ ./lws-minimal-ws-raw-proxy 30[2021/03/04 21:14:45:0540] U: LWS minimal ws-raw proxy | visit http://localhost:7681 (-s = use TLS / https) 31[2021/03/04 21:14:45:0898] N: LWS: 4.1.99-v4.1.0-294-g2776b4ce65, loglevel 1031 32[2021/03/04 21:14:45:0902] N: NET CLI SRV H1 H2 WS SS-JSON-POL SSPROX IPV6-on 33[2021/03/04 21:14:45:1146] N: ++ [3224086|wsi|0|pipe] (1) 34[2021/03/04 21:14:45:1203] N: ++ [3224086|vh|0|netlink] (1) 35[2021/03/04 21:14:45:1284] N: ++ [3224086|vh|1|localhost||7681] (2) 36[2021/03/04 21:14:45:1401] N: lws_socket_bind: nowsi: source ads :: 37[2021/03/04 21:14:45:1425] N: ++ [3224086|wsi|1|listen|localhost||7681] (2) 38[2021/03/04 21:14:46:1164] N: ++ [3224086|wsisrv|0|adopted] (1) 39[2021/03/04 21:14:46:2771] N: ++ [3224086|wsisrv|1|adopted] (2) 40[2021/03/04 21:14:46:3159] N: ++ [3224086|wsicli|0|RAW/raw-skt/127.0.0.1] (1) 41[2021/03/04 21:14:46:3451] N: ++ [3224086|wsisrv|2|adopted] (3) 42 43``` 44 45Visit http://localhost:7681 in a browser... it loads JS that opens a ws 46connection to the proxy's ws server side. That causes the proxy to open a 47raw client connection to 127.0.0.1:1234, and forward anything you type in the 48browser to the raw server, and anything typed in the raw server (you must 49press enter on netcat to get it sent) is proxied back to the browser. 50 51The proxy can handle many ws connections each with their individual onward 52raw client connections, so you could open multiple browser windows. But you 53will need a better "raw server" than netcat, which is restricted to just the 54one peer at a time.