Commit Graph

73 Commits

Author SHA1 Message Date
Pierre Ossman 6caf23c067 Add type checking when sendning data
We use this in various ways so add an early check to make things clear
in case anything is called incorrectly.
2020-09-30 14:53:19 +02:00
Pierre Ossman d72ace2ae6 Allow sending empty messages
This is perfectly valid in the protocol, and may be meningful to some
applications. However send() is still stream oriented so it will ignore
an empty buffer.
2020-09-30 14:51:07 +02:00
Pierre Ossman 9b1780f068 Fix bad reset of fragmented frame
The Python 2/3 binary data type compatibility hack was backwards here.
2020-08-21 10:58:55 +02:00
totaam a348b8bf76 fix handling of code: invalid unpacking, undefined variable in error path, missing argument 2019-02-23 12:37:16 +07:00
Pierre Ossman 8eb5cb0cdc Explicitly deny text messages
We can't really handle them, but let's respond with an explicit error
rather than "unknown opcode".
2018-10-23 16:31:07 +02:00
Pierre Ossman 6b1d42e643 Merge branch 'empty-message' of https://github.com/andersk/websockify 2017-11-13 10:44:57 +01:00
Anders Kaseorg b0df514344 Clarify that WebSocket.{recv,recvmsg} may return empty messages
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2017-11-13 04:13:48 -05:00
Anders Kaseorg a29946e978 Do not confuse an empty message with a closed connection
Fixes #312.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2017-11-10 06:26:48 -05:00
Anders Kaseorg 3c1655322d Do not use base except: clauses
https://docs.python.org/2/howto/doanddont.html#except

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2017-11-10 05:48:20 -05:00
Pierre Ossman 8ea96a503a Handle ping/pong without payload properly
It has to be a data buffer, not None.
2017-04-19 13:30:10 +02:00
Felix J. Ogris 8f85c9661f typo in ping() and pong() 2017-04-12 18:01:13 +02:00
Pierre Ossman c7bde00a4e Force choice of sub-protocol
The WebSocket standard require us to choose one of the protocols
supported by the client. Enforce this with a specific check in the
base class rather than relying on generous clients.
2017-02-08 16:05:16 +01:00
Pierre Ossman 8a69762249 Separate out raw WebSocket protocol handling 2017-02-01 08:22:27 +01:00
Pierre Ossman 4099949984 Remove Base64 support
This is an older protocol used before browsers got native
support for Websockets.
2017-02-01 08:09:53 +01:00
Pierre Ossman 56a4ccbf74 Assume Python 2.6+ modules are always present
No relevant distribution has anything older anymore
2017-02-01 08:09:53 +01:00
Pierre Ossman 30942f12d3 Close connection after Websocket handshake
Otherwise we might misinterpret trailing binary data as a second
HTTP request. This happens when we return from the handler with
data still queued up in the socket.
2017-01-19 14:53:15 +01:00
Thomas Goirand 325e4efe00 TCP_KEEPCNT doesn't exist in non-linux
The TCP_KEEPCNT option for sockets only work with the Linux kernel,
this isn't available for example in FreeBSD and Hurd, which makes the
package fail to build on these platforms. See Debian bug here:

https://bugs.debian.org/840035
2016-10-10 12:06:49 +02:00
Abhishek Kekane 68b1587ada Make websockify respect SIGTERM
Child processes were not terminated when the parent websockify
was killed.

This commit makes websockify send a SIGTERM to all active children
when the parent process is terminated.

Fixes #138
2016-02-18 13:42:53 -05:00
Aliasgar Ginwala 6f0e06772a Remove additional signal calls in websockify that causes novnc to hang.
Openstack nova novnc-proxy services uses websockify to provide support
for nova vms using novnc proxy. At present, novnc hangs every couple of
weeks. It only resumes post restart of the novnc-proxy which is not
good. Hence, this code in websockify is updated to get rid of additional
signal calls to avoid novnc going in hang state even though process is
running. Basically, we are getting rid of existing msg and vmsg calls in
the websocket.py. This is kind of quick fix but we will need an
additional way of figuring out the logging to make it easy to trace in
case of any further failures in future.

closes bug: https://github.com/kanaka/noVNC/issues/556
2016-01-08 17:46:35 -08:00
Miguel Xavier Penha Neto dc979f042c Fix log files when daemonizing
Save log file descriptor so it's not closed when calling daemonize()
2015-12-02 15:21:21 -02:00
Miguel Xavier Penha Neto d947fb6e30 Add support for log files
Override log_message in websocket.py so messages from send_error are properly saved into the log files

Closes #204
2015-12-01 15:25:17 -02:00
Solly 714aa34e4e Merge pull request #194 from kanaka/feature/http-auth-plugins
Rework Auth Plugins to Support HTTP Auth
2015-08-28 13:52:58 -04:00
Arata Notsu f693871c58 Avoid UnboundLocalError for exc
Previously exc was set only when an exception occurs in the inner
try (the one contains call to self.poll), so an error in the other
part causes an UnboundLocalError.

Closes #178
2015-08-27 18:03:38 -04:00
Solly Ross 1e2b5c2256 Rework Auth Plugins to Support HTTP Auth
This commit reworks auth plugins slightly to enable
support for HTTP authentication.  By raising an
AuthenticationError, auth plugins can now return
HTTP responses to the upgrade request (such as 401).

Related to kanaka/noVNC#522
2015-08-25 17:52:20 -04:00
Solly Ross 1221960baa Introduce strict mode
This commit introduces strict mode, which is on by default.  Currently
strict mode only enforces client-to-server frame masking.  However,
in the future, it might enforce other parts of the RFC as well.

Closes #164
2015-05-13 16:03:57 -04:00
Solly Ross 04fd789a67 Update Tests and Test Plugins
This commit updates the unit tests to work with the current code
and adds in tests for the auth and token plugin functionality.
2015-05-13 16:03:57 -04:00
Solly Ross d94b944f93 Restore functionaltiy to file_only.
There was a bug in WebSocketServer that prevented the `file_only`
parameter from actually being set as an instance property, causing
directory listings to appear even with `file_only=True`.  This
commit fixes that.

See-Also: https://bugs.launchpad.net/nova/+bug/1447675
2015-05-13 16:03:37 -04:00
Aric Stewart 52adf957b3 Add ping heartbeat option
With this option we will ping the client with a heartbeat.
Helpful for connection through firewalls that may disable inactive
connections.
2015-04-14 16:09:26 -05:00
Aric Stewart 731fd20796 Add option to turn on auto-pong
This allows the websockify server to respond to heart beat ping
messages sent by clients
2015-04-13 14:57:24 -05:00
Rafael Folco af10f458a1 BUGFIX: Websocket frame corruption on big-endian #150
This patch fixes noVNC endianess problem on handshake.
It affects noVNC sessions on Big Endian platforms.

Fixes #150
2015-04-07 09:36:21 -03:00
Radek Podgorny 303a71310c python3 compatibility fixes 2014-10-02 11:42:17 +02:00
Matthew M. Boedicker 12191d266b Fix typo in reaping zombies message. 2014-05-20 14:43:35 -07:00
samhed 6c526fd645 remove some trailing whitespaces 2014-04-14 14:20:00 +02:00
samhed 6c1a2e9032 Avoid using the %-operator, URL-escaped strings can contain extra %'s which can cause bugs. 2014-03-18 15:21:13 +01:00
Peter Åstrand (astrand) 6de6933819 Minor whitespace and layout tweaks, to reduce diff against
upstream/master.
2013-12-17 14:20:14 +01:00
Peter Åstrand (astrand) f64e3dea51 Merge remote branch 'upstream/master', after #110 was merged. 2013-12-16 16:18:41 +01:00
Peter Åstrand (astrand) 047ce47742 Rename new_client to new_websocket_client, in order to have a better
name in the SocketServer/HTTPServer request handler hierarchy. Prepare
for merge pull request #72. This work has been picked out of
7b3dd8a6f5 .
2013-11-28 13:33:28 +01:00
Peter Åstrand (astrand) 558402848e Rename self.client to self.request, in preparation for merging pull
request #72. The standard Python SocketServer/BaseRequestHandler
requires this name.
2013-11-28 13:23:50 +01:00
Peter Åstrand (astrand) db93395061 Follow up on 131f9ea645ac6f00d98743a420d168033f99063a: Proper logging
in request handler class.
2013-11-28 12:37:57 +01:00
Peter Åstrand (astrand) 7ecfa4f384 Merge commit 'a04edfe80f54b44df5a3579f71710560c6b7b4fc'
* commit 'a04edfe80f54b44df5a3579f71710560c6b7b4fc':
  Added temp dir for unit test data and cleanup
2013-11-28 09:34:33 +01:00
Peter Åstrand (astrand) bc216fb7d1 Merge commit 'a47be21f9fa69ddf8d888ff9e3c75cdfc9e31c00'
* commit 'a47be21f9fa69ddf8d888ff9e3c75cdfc9e31c00':
  Added unit tests for websocket and websocketproxy
2013-11-28 09:32:49 +01:00
Peter Åstrand (astrand) b92528aeba Merge commit 'c3acdc2e38f871e28ffda1847b4338c4b02296b8'
* commit 'c3acdc2e38f871e28ffda1847b4338c4b02296b8':
  Adds optional TCP_KEEPALIVE to WebSocketServer
2013-11-28 09:32:30 +01:00
Peter Åstrand (astrand) 972b30ddc2 Merge commit '0e5c3ecfda3b1506b41412052db75d84df2b4ae7'
* commit '0e5c3ecfda3b1506b41412052db75d84df2b4ae7':
  Handle SIGCHLD properly for multiprocessing
2013-11-28 09:07:41 +01:00
Peter Åstrand (astrand) 131f9ea645 Merge commit '477dce6cf86d61b20a394f3cbf3170e60d199658'
* commit '477dce6cf86d61b20a394f3cbf3170e60d199658':
  websocket: use python logging module
  websocket: fix exception statement introduced by comment 903e3f06ee557

Adapted to new standard SocketServer RequestHandler design. For
example, this means that self.i_am_client is not needed.
2013-11-28 09:05:24 +01:00
Peter Åstrand (astrand) cbf05f84fe Merge commit '4459824cc8196ad78fe9258b6c560ad46fe4cd52'
* commit '4459824cc8196ad78fe9258b6c560ad46fe4cd52':
  websocket: do not exit at the middle of process
  websocket: restore signals after processing
  websocket: support SIGTERM as exit signal
2013-11-27 14:49:54 +01:00
Peter Åstrand (astrand) 063c7de783 Merge commit 'bff3c373b32ebf707085e3c677bfad19b44fa054' 2013-11-27 13:34:17 +01:00
Peter Åstrand (astrand) ff30e5461f Merge commit 'ab389d4e7114d7ddbfd085591d336ea5cc06c00d'
* commit 'ab389d4e7114d7ddbfd085591d336ea5cc06c00d':
  Collect zombie child processes within server loop
2013-11-27 13:30:30 +01:00
Peter Åstrand (astrand) 19c8482236 Merge commit '6d27b5d321978586ea1601f757ead73dfba03da7'
* commit '6d27b5d321978586ea1601f757ead73dfba03da7':
  Add 2 arguments to websockify.WSRequestHandler

As of now, only implemented the first command; see #83 for details.
2013-11-27 13:27:38 +01:00
Peter Åstrand (astrand) 33a1bd2337 Merge commit 'b7f255ce0b21dc42189205b1f0e46b4f1d9854f9'
* commit 'b7f255ce0b21dc42189205b1f0e46b4f1d9854f9':
  Clarify messages when optional modules are not found.
2013-11-27 12:27:43 +01:00
Edward Hope-Morley 32c1abd5d9 Added temp dir for unit test data and cleanup
Unit test data will now go to a temporary dir that will be deleted
once the test completes. The unit tests also setup a logger which
will persist so that it can be inspected once tests complete.

Also fixes a bug where instance var is missing from decode_hybi()

Co-authored-by: natsume.takashi@lab.ntt.co.jp
2013-11-14 12:38:03 +00:00