1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/plugins/raw-proxy
Andy Green c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
..
protocol_lws_raw_proxy.c type comparisons: fixes 2021-01-05 10:56:38 +00:00
README.md role: raw-proxy 2018-12-01 11:05:59 +08:00

raw-proxy plugin

Enabling for build

$ cmake .. -DLWS_ROLE_RAW_PROXY=1

configuration pvo

pvo value meaning
onward The onward proxy destination, in the form ipv4:addr[:port]

Note for vhost selection

Notice that since it proxies the packets "raw", there's no SNI or Host: header to resolve amongst multiple vhosts on the same listen port. So the vhost you associate with this protocol must be alone on its own port.

It's also possible to apply this or other role + protocols as a fallback after http[s] processing rejected the first packet from an incoming connection. See ./READMEs/README-http-fallback.md

Note for packet size

For throughput, since often one side is localhost that can handle larger packets easily, you should create the context used with this plugin with

	info.pt_serv_buf_size = 8192;

lwsws already does this.

Using with C

See the minimal example ./minimal-example/raw/minimal-raw-proxy for a working example of a vhost that accepts connections and then proxies them using this plugin. The example is almost all boilerplate for setting up the context and the pvo.

Using with lwsws

For a usage where the plugin "owns" the whole vhost, you should enable the plugin protocol on the vhost as usual, and specify the "onward" pvo with:

                "ws-protocols": [{
                        "raw-proxy": {
                         "status": "ok",
                         "onward": "ipv4:remote.address.com:port"
                        }
                 }],

and then define the vhost with:

    "apply-listen-accept": "1",
    "listen-accept-role": "raw-proxy",
    "listen-accept-protocol": "raw-proxy"

which tells it to apply the role and protocol as soon as a connection is accepted on the vhost.