Commit Graph

773 Commits

Author SHA1 Message Date
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
wention ade9d61c22 fixed: ssl call error at function load_cert_chain.
If option '--key' is not specified. 'WebSockifyServer class' will
       inital self.key as empty string. but ssl load_cert_chain function
       will raise error 'no such file' with keyfile param empty string.
2017-11-09 16:13:15 +08:00
Pierre Ossman 8b2a949276 Merge branch 'ssl_clientdn_validation' of https://github.com/hoehermann/websockify 2017-10-30 13:12:18 +01:00
Pierre Ossman 5f7d28aeb6 Only start termination process once
We can't deal with the exception once we've started to shut down so
make sure it's only raised once.
2017-10-27 08:41:32 +02:00
Pierre Ossman 0a6e0c2d87 Don't log clients that don't send any request
They just fill up the logs with confusing data.
2017-10-27 08:25:35 +02:00
Hermann Höhne 914609fb5f Added SSL-certificate-based client authentication.
* Incorporates #190 without breaking compatibility towards old Python versions.
* A new plugin allows authenticating clients by the "common name" defined in their certificate.
* Added manual for certificate-based client authentication, including hints to which Python versions allow client certificate authentication.
* Adjusted test to work with new ssl.create_default_context.
2017-10-26 15:17:11 +02:00
Pierre Ossman abcf2cd4d4 Merge branch 'patch-1' of https://github.com/tillz/websockify 2017-10-18 16:36:43 +02:00
Pierre Ossman e69d4a4546 Properly declare websocket functions in header 2017-10-18 16:35:52 +02:00
Pierre Ossman 93842aa798 Avoid implicit int type 2017-10-18 16:35:42 +02:00
Pierre Ossman 89bbb64145 Include string.h where needed 2017-10-18 16:35:30 +02:00
Pierre Ossman 814279b83b Merge branch 'master' of https://github.com/leeyiw/websockify 2017-10-18 16:29:37 +02:00
Pierre Ossman 414d1d8b44 Merge branch 'fix-cygwin' of https://github.com/r1b/websockify 2017-10-18 16:25:37 +02:00
Giannis Kosmas 99198cface Send Content-Type headers with static files
Fixes a problem that occurs in Chrome 61 where the following error message appears in the console:

'Failed to load module script: The server responded with a non-JavaScript MIME type of "".
Strict MIME type checking is enforced for module scripts per HTML spec.'
2017-10-12 19:28:30 +03:00
Pierre Ossman 61879b175c Better error message for problems in token file 2017-10-10 10:10:10 +02:00
Pierre Ossman 0506b3431f Fix sub protocol handling when no protocol is specified
Some browsers are being difficult and won't let us pass on
undefined values for the protocols argument.
2017-09-04 14:11:55 +02:00
Pierre Ossman 5e19bc3f96 Merge branch 'master' of https://github.com/michalsrb/websockify 2017-08-14 17:12:19 +02:00
Michal Srb 2c0e8cb8f4 Fix inetd mode on Python 2.
In python 2 the ssl.wrap_socket doesn't work on sockets created using socket.fromfd.
The workaround is to wrap the socket returned by socket.fromfd into another socket
object using the private _sock constructor parameter.
2017-08-14 16:59:54 +02:00
Michal Srb 867cb21ba0 Add support for inetd.
With the --inetd parameter, websockify doesn't require the source_addr and
source_port paramters and it expects that stdin is already opened and listening
socket.

This way websockify can be used with (x)inetd or as a systemd socket-activated
service.
2017-08-14 16:59:54 +02:00
Pierre Ossman bfd7394cae Remove stray comma in signal handler setup
It was causing the handlers to be set up improperly.
2017-08-14 16:51:55 +02:00
Pierre Ossman 518e6e0e56 Prevent startup on Windows
There's way too many things to fix before this has any chance of working.
2017-06-15 15:18:29 +02:00
Solly Ross ddcec961ec Work around lack of SIGCHLD on Windows
This only enables the SIGCHLD handler if SIGCHLD
exists, such that platforms without SIGCHLD (such
as windows) can still run websockify natively.

See #108
2017-06-15 14:23:29 +02:00
Pierre Ossman d029e451cf Merge branch 'test_websockifyserver_python3.6' of https://github.com/zmedico/websockify 2017-05-24 16:14:33 +02:00
Zac Medico a45b960983 test_websockifyserver: add send_error stub
The socket.sendall method is called indirectly via calls
to the python3.6 BaseHTTPRequestHandler.send_error method
which is called by both the Web*RequestHandler classes as
shown below:

======================================================================
ERROR: test_list_dir_with_file_only_returns_error (test_websockifyserver.WebSockifyRequestHandlerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/test_websockifyserver.py", line 115, in test_list_dir_with_file_only_returns_error
    FakeSocket('GET / HTTP/1.1'), '127.0.0.1', server)
  File "websockify/websockifyserver.py", line 94, in __init__
    WebSocketRequestHandler.__init__(self, req, addr, server)
  File "websockify/websocketserver.py", line 34, in __init__
    BaseHTTPRequestHandler.__init__(self, request, client_address, server)
  File "/usr/lib64/python3.6/socketserver.py", line 696, in __init__
    self.handle()
  File "websockify/websockifyserver.py", line 293, in handle
    SimpleHTTPRequestHandler.handle(self)
  File "/usr/lib64/python3.6/http/server.py", line 418, in handle
    self.handle_one_request()
  File "websockify/websocketserver.py", line 46, in handle_one_request
    BaseHTTPRequestHandler.handle_one_request(self)
  File "/usr/lib64/python3.6/http/server.py", line 406, in handle_one_request
    method()
  File "websockify/websocketserver.py", line 58, in _websocket_do_GET
    self.do_GET()
  File "websockify/websockifyserver.py", line 259, in do_GET
    SimpleHTTPRequestHandler.do_GET(self)
  File "/usr/lib64/python3.6/http/server.py", line 636, in do_GET
    f = self.send_head()
  File "/usr/lib64/python3.6/http/server.py", line 679, in send_head
    return self.list_directory(path)
  File "websockify/websockifyserver.py", line 263, in list_directory
    self.send_error(404, "No such file")
  File "/usr/lib64/python3.6/http/server.py", line 470, in send_error
    self.end_headers()
  File "/usr/lib64/python3.6/http/server.py", line 520, in end_headers
    self.flush_headers()
  File "/usr/lib64/python3.6/http/server.py", line 524, in flush_headers
    self.wfile.write(b"".join(self._headers_buffer))
  File "/usr/lib64/python3.6/socketserver.py", line 775, in write
    self._sock.sendall(b)
AttributeError: 'FakeSocket' object has no attribute 'sendall'

======================================================================
ERROR: test_normal_get_with_only_upgrade_returns_error (test_websockifyserver.WebSockifyRequestHandlerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/test_websockifyserver.py", line 101, in test_normal_get_with_only_upgrade_returns_error
    FakeSocket('GET /tmp.txt HTTP/1.1'), '127.0.0.1', server)
  File "websockify/websockifyserver.py", line 94, in __init__
    WebSocketRequestHandler.__init__(self, req, addr, server)
  File "websockify/websocketserver.py", line 34, in __init__
    BaseHTTPRequestHandler.__init__(self, request, client_address, server)
  File "/usr/lib64/python3.6/socketserver.py", line 696, in __init__
    self.handle()
  File "websockify/websockifyserver.py", line 293, in handle
    SimpleHTTPRequestHandler.handle(self)
  File "/usr/lib64/python3.6/http/server.py", line 418, in handle
    self.handle_one_request()
  File "websockify/websocketserver.py", line 46, in handle_one_request
    BaseHTTPRequestHandler.handle_one_request(self)
  File "/usr/lib64/python3.6/http/server.py", line 406, in handle_one_request
    method()
  File "websockify/websocketserver.py", line 58, in _websocket_do_GET
    self.do_GET()
  File "websockify/websockifyserver.py", line 257, in do_GET
    self.send_error(405, "Method Not Allowed")
  File "/usr/lib64/python3.6/http/server.py", line 470, in send_error
    self.end_headers()
  File "/usr/lib64/python3.6/http/server.py", line 520, in end_headers
    self.flush_headers()
  File "/usr/lib64/python3.6/http/server.py", line 524, in flush_headers
    self.wfile.write(b"".join(self._headers_buffer))
  File "/usr/lib64/python3.6/socketserver.py", line 775, in write
    self._sock.sendall(b)
AttributeError: 'FakeSocket' object has no attribute 'sendall'
2017-05-22 07:27:28 -07:00
Sam Frances 141ba0088e Change logging of URL to be compatible with both old and new versions
of ws
2017-05-18 10:08:54 +01:00
Sam Frances 3e17187216 Fix bug caused by upgrade to ws version 3 2017-05-17 15:37:07 +01:00
Pierre Ossman f3a0ce06a9 Add unittests for ping() and pong() 2017-04-19 13:30:47 +02: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 5b7f7224ed Don't try to install Flash handling code
The actual code was removed in 10e13d7.
2017-03-10 12:46:45 +01:00
Pierre Ossman 61b1b8aef7 Remove base64.js from setup.py
Overlooked in the removal of base64.js in 4099949.
2017-03-09 10:21:29 +01:00
Pierre Ossman 600f4e154c Avoid assertIn for Python 2.6 compatibility
It was added in 2.7, but we want to support older Python a while
longer.
2017-02-09 10:38:53 +01:00
Pierre Ossman df317822d6 Be backwards compatible with older websockify clients
They will specify a sub-protocol, and the specification requires
us to choose one of the specified protocols.
2017-02-08 16:06:14 +01: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 94783ea0cd Remove --auto-pong argument
The underlying code has been removed, so remove the argument
as well.
2017-02-07 15:38:07 +01:00
Pierre Ossman 795552e418 Update websock.js description 2017-02-03 17:02:27 +01:00
Pierre Ossman 40238b00b6 Don't delay flushing
The native WebSocket is in a much better position to do queue
management than us. Many callers also failed to notice this part
of the API, causing stalls.
2017-02-03 17:00:15 +01:00
Pierre Ossman 3f8f301d7f Update websock.js from noVNC
Sync with noVNC as of commit ae510306b5094b55aa08a2a0d15a151704f70993.

The main change is to make it a more proper object that you can
instantiate multiple times.
2017-02-03 16:59:54 +01:00
Pierre Ossman 10e13d7a7e Remove last bits of Flash WebSocket emulation
We require native support from the browsers now.
2017-02-03 16:09:08 +01:00
Pierre Ossman e47591f4aa Split out basic WebSocket server template 2017-02-01 08:33:07 +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
Solly Ross cb1508fa49 Merge pull request #251 from thomasgoirand/master
TCP_KEEPCNT doesn't exist in non-linux
2016-10-10 15:53:40 -04: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
Solly Ross 72ce5c1ae8 Merge pull request #228 from jrziviani/master
Enable unix socket to work with token plugin
2016-06-30 16:54:35 -04:00
Solly Ross 7d5d73873a Merge pull request #239 from javacruft/mox3
Switch test dependency to mox3
2016-06-30 16:40:03 -04:00
James Page 156b08ae68 Switch test dependency to mox3
mox is pretty much unmaintained these days, however the OpenStack
project are actively maintaining mox3 (a Python 3 compatibile fork
with some other improvements).

websockify seems quite happy to use mox3 instead, so switch the
test dependency and associated imports to use mox3.
2016-06-30 09:59:50 +01:00
samhed f23780eb42 Disable Nagle for proxied connections
Most of the proxy stuff will be latency sensitive traffic so we
disable Nagle because it introduces delays.
2016-06-02 14:45:51 +02:00
Gernot Tenchio 192ec6f5f9 C websockify: free memory after failed handshake
Conflicts:
	other/websocket.c
2016-04-22 12:04:31 -05:00