This adds win32 build compatability to libwebsockets.
The patch is from Peter Hinz, Andy Green has cleaned it up a bit and
possibly broken win32 compatability since I can't test it, so there
may be followup patches. It compiles fine under Linux after this
patch anyway.
Much of the patch is changing a reserved keyword for Visual C compiler
"this" to "context", but there is no real C99 support in the MSFT
compiler even though it is 2011 so C99 style array declarations
have been mangled back into "ancient C" style.
Some windows-isms are also added like closesocket() but these are
quite localized. Win32 random is just using C library random() call
at the moment vs Linux /dev/urandom. canonical hostname detection is
broken in win32 at the moment.
Signed-off-by: Peter Hinz <cerebusrc@gmail.com>
Signed-off-by: Andy Green <andy@warmcat.com>
This adds a callback to protocols[0] which happens when the
Client HTTP handshake packet is being composed. After all the
headers for the websocket handshake to the server have been
added, the callback is called with a pointer to a char *
that allows extra headers to be added. See the comments in
libwebsocket.h or the api documentation for example code.
Signed-off-by: Andy Green <andy@warmcat.com>
This adds 76/00 client support to libwebsockets. It's still shipped
by browsers and more importantly still the only version supported by
server stuff like socket.io.
Signed-off-by: Andy Green <andy@warmcat.com>
Christopher Baker sent in a working OSX configure string,
add it to the README
Reported-by: Christopher Baker <me@christopherbaker.net>
Signed-off-by: Andy Green <andy@warmcat.com>
Thanks to Christopher Baker for pointing out that when we close a session,
if the close is coming before a protocol was negotiated for the connection
or when the protocol was otherwise left at NULL, we'll blow a segfault.
This implements his proposed fix.
Reported-by: Christopher Baker <me@christopherbaker.net>
Signed-off-by: Andy Green <andy@warmcat.com>
This adds a LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS callback
which offers a chance for the server context to be loaded with additional
certtificates allowing it to verify incoming client certs. The callback
always comes to protocol[0].
It also introduces the context option LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT
which will enforce client cert checking on any ssl connection.
Signed-off-by: Andy Green <andy@warmcat.com>
Doing a client connect was atomic until now, blocking
all the other service while it waited for proxy and / or
server response.
This patch uses the new timeout system and breaks the
client connect sequence into three states handled by
the normal poll() processing. It means that there are
now no blocking network delays and it's all handled
by the main state machine.
Signed-off-by: Andy Green <andy@warmcat.com>
This adds a concept of timeouts for operations enforced by
connection closure if the timeout is reached.
Once a second all sockets are checked for timing out, every time
there is a service call it checks to see if a second has passed since
the last check and checks if so.
You can also call libwebsocket_service_fd() with a NULL fd to give
the timeouts a chance to be detected; if it's less than a second since
the last check it returns immediately.
Signed-off-by: Andy Green <andy@warmcat.com>
Just a quick follow up there is a compile error at the moment, which I
think is resolved as the following?
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
This patch removes the relationship between position in the
pollfd[] array and any meaning about the type of socket.
It also refactors the service loop so there is a per-fd
function that detects the mode of the connection and services
it accordingly.
The context wsi * array is removed and a hashtable introduced
allowing fast wsi lookup from just the fd that it is
associated with
Signed-off-by: Andy Green <andy@warmcat.com>
This adds 05 support, and -v switches on test-client and test-ping
to allow setting their ietf protocol version to 4 or 5.
It also optimizes the masking to us a function pointer, which
takes some conditionals out of the fast path.
Signed-off-by: Andy Green <andy@warmcat.com>