Commit graph

74 commits

Author SHA1 Message Date
Alejandro Mery
ac3ec39bb1 Subject: [PATCH] Introduce lws_free2() helper to free and re-NULL pointers
Signed-off-by: Alejandro Mery <amery@geeks.cl>
2014-12-05 07:27:52 +08:00
Alejandro Mery
6ff28248aa Subject: [PATCH] Use custom allocator
Signed-off-by: Alejandro Mery <amery@geeks.cl>
2014-12-05 07:26:26 +08:00
Andy Green
62fe015455 revert 187
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-12-01 19:28:28 +08:00
Andy Green
47afcddccf 83674 dereference after NULL check
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 12:43:51 +08:00
Andy Green
77c209c412 ssl: improve client error message on server cert probs 2014-11-18 09:28:06 +08:00
Andy Green
44c116172d lws_union_transition
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-08 11:18:47 +08:00
kulwik
76fc5fc88d Subject: [PATCH] ssl fix self-singed certificate acceptation 2014-10-31 12:52:48 +08:00
Rene Jager
c0eb2c3e9d Subject: [PATCH] fixes for handling multiple protocols in handshake 2014-10-29 09:39:34 +08:00
Andy Green
1f5c9f0c31 ssl_capable_read add context param
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-09 08:14:30 +08:00
Andy Green
024eb6c80c http2 can keep upgraded connection up
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-08 12:00:53 +08:00
Andy Green
104316eb8f internal SHA1 users all use libwebsockets_SHA1
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-09-26 05:56:23 +08:00
Andrew Canaday
74b4a65745 Added optional per-header length limits:
- libwebsockets.h:
 - * added struct lws_token_limits
   * added token limits pointer to lws_context_creation_info
 - private-libwebsockets.h: added token limits pointer to lws_context_creation_info
 - context.c: copy token limits in create_context
 - client.c / server.c: pass context when invoking libwebsocket_parse
 - parsers.c:
 - * libwebsocket_parse takes context pointer
   * issue_char takes context pointer and checks header length against context limits, if defined
   * issue_char returns 1 (not -1/0) for header too long, and spill: sets the state to WSI_TOKEN_SKIPPING
2014-07-06 09:33:40 +08:00
vpeter4
590fb70102 Conditionally declare variable 2014-04-28 07:32:14 +08:00
vpeter4
e035f2ea3e Compile with older OpenSSL library (missing symbol SSL_set_tlsext_host_name) 2014-04-28 07:32:13 +08:00
Andy Green
d7340c141f clean=various ifdef reduction
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-10 14:08:10 +08:00
Andy Green
47e0c91e2f move SNI temp var back one
Reported as making trouble on Windows by spayton

https://github.com/warmcat/libwebsockets/issues/109

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-08 16:15:02 +01:00
Andy Green
78f266a525 refactor use unified ssl read write functions
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-06 07:24:45 +01:00
Andy Green
c57037a555 refactor ssl related code into ssl.c
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-03 10:17:00 +08:00
Andy Green
aad2eac48e refactor handshake client and server handling into client.c and server.c
Eliminate more #ifdefs

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-03 09:03:37 +08:00
Andy Green
e38031a394 refactor migrate client and server specific context init into client.c and server.c
Eliminate some NO_CLIENT and NO_SERVER

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-03 08:24:29 +08:00
Andy Green
2c24ec0211 refactor out most NO_EXTENSIONS
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 19:45:42 +08:00
Andy Green
158e804cb7 refactor out WIN32 tests from code
This gets rid of all the platform-dependent #ifdef stuff and
migrates it into the new lws-plat-xxx.c files.

These are then included in a one-time test in libwebsockets.c
according basically to Windows or not.

The idea is from now on, all Windows-specific code should go in
lws-plat-win.c, where any kind of Windows perversion like DWORD
is fine.

Any new functions going in there should be named lws_plat_...
and be defined in all the lws-plat-xxx.c file (currently just
win32 and unix platforms are supported).

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 14:25:10 +08:00
Patrick Gansterer
b47f87b04b Introduce LWS_POLLIN, LWS_POLLOUT and LWS_POLLHUP 2014-03-30 09:18:05 +02:00
Patrick Gansterer
73882e49fc Remove websock-w32.h 2014-03-29 08:25:58 +01:00
Andy Green
145ecece10 cyassl skip setting SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER
It's already the default and no "SSL_set_mode" in CYASSL

Reported by Chris Conlon <chris@wolfssl.com>

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-28 14:00:01 +08:00
erauhut
03203aba93 trac 58 ssl enable SNI per vhost certs
http://libwebsockets.org/trac/libwebsockets/ticket/58#no1
2014-03-23 12:24:40 +08:00
Andy Green
35c80f9885 ssl add SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER to server and client
gaby64 at githib found this option is necessary when using SSL with the
truncated send support

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-23 11:53:07 +08:00
Patrick Gansterer
2dbd837c41 WSAGetLastError() instead of errno on Windows
Error codes set by Windows Sockets are not made available through the errno
variable. Checking them via WSAGetLastError() is the corret solution.
2014-02-28 20:08:55 +08:00
Patrick Gansterer
e5720a347e Cleanup include statements
Remove useless includes and add some preprocessor conditions for platform specific headers.
2014-02-28 08:51:35 +08:00
Patrick Gansterer
ce8079c09b Add explicit cast to setsockopt() calls
Implicit cast from size_t* to const char* throws an error on some compilers.
2014-02-28 08:45:19 +08:00
Andy Green
91f19d8d79 unify all pollfd lock management
This provides a single place for pollfd event changing,
external locking for that and extpoll management.

It saves about 85 lines of duplication and simplifies the callers.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-12-21 11:18:34 +08:00
Andy Green
7a1327977a add locking callback for fds
This adds two new callbacks in protocols[0] that are optional for allowing limited thread
access to libwebsockets, LWS_CALLBACK_LOCK_POLL and LWS_CALLBACK_UNLOCK_POLL.

If you use them, they protect internal and external poll list changes, but if you want to use
external thread access to libwebsocket_callback_on_writable() you have to implement your
locking here even if you don't use external poll support.

If you will use another thread for this, take a lot of care about managing your list of
live wsi by doing it from ESTABLISHED and CLOSED callbacks (with your own locking).

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-12-18 09:48:26 +08:00
Jonti
e01cb9a49d Subject: [PATCH] Fixed the logging of OpenSSL errors to report the correct
details for the current OpenSSL error
2013-11-24 14:24:02 +08:00
Markus Elfring
7521233176 make header protection unique remove __prefix
Signed-off-by: Markus Elfring <markus.elfring@web.de>
2013-10-26 20:23:00 +08:00
shys
cfa8ac34c7 cover-proxy-read-EAGAIN.patch
Subject: [PATCH] Because of nonblocking sockets reading from  proxy might not
 work in one turn. We should check for EAGAIN.
2013-10-25 22:30:25 +08:00
shys
6b5c1af439 Subject: [PATCH] On iOS with nonblocking sockets I experience SSL error which
is not really an error (
 http://lists.freeradius.org/pipermail/freeradius-users/2009-August/040155.html
 ). Added check for that. Additional fixes for comments and logging.
2013-10-25 22:26:36 +08:00
u0u0
44e260e004 fix origin
And fix client header of Origin, add prefix "http://" to make a valid URI, to make golang websocket server happy.
2013-10-25 22:17:21 +08:00
shys
24f4eb648b wait ssl connect completion on client proxy path
Subject: [PATCH] We can ran into situation (at least on iOS) when with openssl
 nonblocking BIO and http proxy we don't perform ssl_connect straight away so
 we need to retry until we finish ssl_connect. If we don't do that we will
 fail in LWS_CONNMODE_WS_CLIENT_WAITING_PROXY_REPLY when testing for "HTTP/1.0
 200" successful connection.

Signed-off-by: shys <shyswork@zoho.com>
2013-10-24 22:27:08 +08:00
Andy Green
5dc62ead9d trac 40 client connection properly nonblocking
As spotted by JM on Trac#40

http://libwebsockets.org/trac/libwebsockets/ticket/40

client connect didn't do anything about being truly nonblocking.  This patch
should hopefully solve that.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-09-20 20:26:12 +08:00
Fujii Bunichiroh
e92947680a force failed header parse to act
''...Websocket servers return failure responses other than HTTP Status 101 in the case of
mismatches of WebSocket version or additional header data etc...
It seems that libwebsockets shows "WARN: problems parsing header" error in such cases without
calling any callbacks or returning error code. Is this right?
I modified lib/client.c to handle this.''

Signed-off-by: Fujii Bunichiroh <Bunichiroh.Fujii@jp.sony.com>
2013-09-18 21:01:02 +08:00
Joachim Bauch
8294c1fa4f Request "send" not to trigger SIGPIPE on errors. 2013-06-29 10:22:09 +08:00
Bob Roberts
ac04911dde cygwin compatibility
Signed-off-by: Bob Roberts <bobroberts177@gmail.com>
2013-04-25 09:16:30 +08:00
Andy Green
01b206e804 SOL_SNDBUF set to protocol rx size
This tells the OS to reserve a TX buffer at least the size of the biggest RX frame
expected, for both server and client connections.

In Linux, the OS reserves 2 x the requested amount.

This is aimed at reducing the partial large atomic frame send problem to the point
it's only coming at large atomic frames the OS balks at reserving the size for.

If you have a lot of data to send, it is better to split it into multiple writes,
and use the FIN / CONTINUATION websocket stuff to manage it.

See the "fraggle" test app for example code of how to do that.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-23 09:53:17 +08:00
Andy Green
ca0a129065 rxflow remove recursion and simplify
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-16 11:24:23 +08:00
Andy Green
5a4f3ae7d0 POLLOUT during wait for server response not an error
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-09 09:09:46 +08:00
Joakim Soderberg
b82b0dd118 Print SSL error codes as well as the string.
CYASSL doesn't compile with the error strings in some configurations, so
it is nice to have the error code on SSL errors as well.
2013-02-22 09:28:15 +08:00
Andy Green
0c2f4d865a update missed extpoll calls to use correct args for ssl
http://libwebsockets.org/trac/ticket/15#comment:16

Reported-by: Joakim Soderberg <joakim.soderberg@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-19 19:19:51 +08:00
Andy Green
2af4d5b2e2 remove lws_ensure_user_space from public api change return
The function has a logical problem when the size of the requested
allocation is 0, it will return NULL which is overloaded as
failure.

Actually the whole function is evil as an api, this patch moves
it out of the public API space and fixes it to return 0 for
success or 1 for fail.  Private code does not need to to return
wsi->user_space and public code should only get that from the
callback as discussed on trac recently.

Thanks to Edwin for debugging the problem.

Reported-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-18 16:30:10 +08:00
Andy Green
a7521debde migrate client hs and c_port into ah
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-18 10:38:45 +08:00
Andy Green
cecf5e73cf eliminate snprintf
The two cases where I introduced snprintf are either already
safe for buffer overflow or can be made so with one extra
statement, allowing sprintf.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-12 10:13:12 +08:00