Commit Graph

54 Commits

Author SHA1 Message Date
samhed 082027dc87 Sync with websockify
Pull 90b519edf0c1857d
2014-04-14 14:45:15 +02:00
Joel Martin c3c51ed32b Sync with websockify.
Pull in websockify 4725aa7.

- Update to c0855c6cae of web-socket-js

- Update both the submodule and the swf build. The submodule now
  contains the unobfuscated source for swfobject.js which should make
  websockify more DFSG compliant.

- Remove Hixie support. iOS 6 now includes HyBi support which means
  there is no remaining platform that needs Hixie.
2013-04-25 09:52:10 -05:00
Joel Martin 705c54edb6 Sync with websockify.
Pull c33f0b52e7 from websockify.

- Fix for python2.4 with URL parsing.
- Set binaryType earlier in Opera 12.10 to avoid receiving a blob.
- Re-order client and target processing so that pending client data
  has an opportunity to be sent when the target closes.
2012-11-14 12:28:22 -05:00
Joel Martin 49578da448 sync with websockify
Pull in websockify 1669139
2012-10-26 18:07:25 -05:00
Joel Martin 204675c85d Update websockify/websock.js.
This change pulls websockify 6d9deda9c5.

Most note worthy changes:
- Pulls in web-socket-js 7677e7a954 which updates to IETF 6455 (from
  Hixie)
- Binary support detection and use in include/websock.js
- Add ssl and unix target support
- Add multiple target support via config file/dir.
- Idle timeout exit
2012-09-17 17:00:01 -05:00
Joel Martin fc003a13e7 Revert "Pull in latest websockify."
This reverts commit 4dd1bb1ecb.
2012-08-15 13:48:03 -05:00
Joel Martin 4dd1bb1ecb Pull in latest websockify.
Pull in version 376872d99.

Several changes including:
- binary/typed array support in websock.js
- unix socket support
- multiple target support via config file(s)
- prefer IPv6 option
2012-08-14 15:35:48 -05:00
Joel Martin 53dfab7fb7 Pull from websockify. Fix close code. 2012-05-10 22:10:01 -05:00
Joel Martin 02d1f19b5f Pull from websockify.
Fix python 2.4 CClose exception handling.
2012-05-10 08:06:43 -05:00
Joel Martin c390011099 Update websockify to pull in close code/reason fixes. 2012-04-25 13:46:30 -05:00
Joel Martin 0c4f4b598c Don't swallow SSL EOF errors. 2012-02-20 16:33:08 -06:00
Joel Martin 86ebeef709 Merge branch 'master' of github.com:kanaka/noVNC 2011-12-15 15:34:30 -06:00
Joel Martin f2d856767d websockify: better multi-python version support.
Pull from websockify: 008a5118e728.

Should address issue https://github.com/kanaka/noVNC/issues/107

- Also add ability to force use of web-socket-js using
  window.WEB_SOCKET_FORCE_FLASH

- in websock.js, for rQshift*, assume length is the full length if not
  specified.
2011-12-15 15:26:16 -06:00
Joel Martin 2fa565b375 Fix python3 wss (TLS/SSL) connection detection.
Compare the first byte of the handshake against numbers (character
code) as well as string characters.
2011-12-15 14:45:55 -06:00
Joel Martin 1e50871599 websockify --run-once, --timeout, numpy fallback
Pull websockify 724aa3a.

- Use array module for unmasking HyBi when no numpy module is
    available.

- Detect client close properly when using python 3.

- Print request URL path is specified.

- New option --run-once will exit after handling a single WebSocket
  connection (but not ater flash policy or normal web requests).

- New option --timeout TIME will stop listening for new connections
  after exit after TIME seconds (the master process shuts down).
  Existing WebSocket connections will continue but once all
  connections are closed all processes will terminate.
2011-09-29 16:12:19 -05:00
Joel Martin afecb83988 Pull websockify: python3 numpy buffer/string fix.
Pull from websockify 1c39c7f1f001.
2011-09-10 16:03:39 -05:00
Joel Martin 7b10dc8a48 utils/websocket.py: add HyBi 13 support.
Pull from websockify 6e26306.
2011-08-31 18:06:58 -05:00
Joel Martin 94568bc08d utils/websocket.py: silence partial unmask debug.
Pull from websockify ada02f2.
2011-08-31 15:33:30 -05:00
Joel Martin fa74a6e60c websocket.py: fix payload length calculation.
Pull from websockify 0da91c7.
2011-08-31 15:08:03 -05:00
Joel Martin 48f26d799f websockify: pull HyBi fixes.
Pull 86af0b614d and 7b496ce5b from websockify.

    Fix HyBi support on 64-bit systems.

    https://github.com/kanaka/noVNC/issues/76

    - cleanup/update TODO.
    - remove explicit check for ctypes module for HyBi.

    Clarify that we support HyBi 07-10.

    HyBi 07 reports version 7 in the handshake.
    HyBi 08-10 report version 8 in the handshake.

    Remove version 9 since that is not yet actually defined.
2011-08-24 13:26:28 -05:00
Joel Martin c0c143a153 Version 0.1, debian packaging, license text.
noVNC version 0.1

Add debian packaging directory loosely based on
http://trac.zentyal.org/browser/trunk/extra/novnc/debian

Show web root directory on startup (pulled from websockify f1c8223).

Lintian fixups:
    - Some license text clarifications.
    - remove executable permission on utils/launch.sh and
      include/web-socket-js/web_socket.js
    - Add executable permission to utils/launch.sh
2011-07-14 15:57:01 -05:00
Joel Martin 4f8c746518 Pull websockify socket() static method.
Pull websockify 46e2fbe.

WebSocketServer.socket() is a static method takes a host and port and
an optional connect parameter. If connect is not set then it returns
a socket listening on host and port. If connect is set then
a connection will be made host and port and the socket returned. This
has IPv6 support like the addrinfo method it replaces.

Also, prefer IPv4 resolutions if they are in the list. This can be
overriden to prefer IPv6 resolutions for the same host using the
optional prefer_ipv6 parameter.
2011-07-09 13:39:04 -05:00
Joel Martin 3a39bf60f3 Pull IPv6 and HyBi fixes from websockify.
Pull 7ae8711 from websockify.
2011-07-07 15:14:41 -05:00
Joel Martin 123e5e7445 Pull IPv6 support from websockify.
Pull from websockify 247b74950d.
2011-07-07 11:47:11 -05:00
Joel Martin 8c305c60ad Pull fix of recording from websockify.
Pull websockify 7f487fdbd.

The reocrd parameter will turn on recording of all messages sent
to and from the client. The record parameter is a file prefix. The
full file-name will be the prefix with an extension '.HANDLER_ID'
based on the handler ID.
2011-06-26 14:21:56 -05:00
Joel Martin 557efaf856 utils/websocket.py: disable debug output. 2011-05-12 12:55:04 -05:00
Joel Martin 7d14602759 Pull websockify 284ef3cc1a54
Including HyBi-07 support and refactor of send/recv.
2011-05-12 12:33:57 -05:00
Joel Martin 41b9ae6ec9 Sync with websockify. Save handshake headers.
Derived classes will almost certainly want to make use of the raw
info.
2011-04-19 09:37:43 -05:00
Phil Phillips e9155818c8 Make scripts more compatible across OSes 2011-03-27 04:18:08 +08:00
Joel Martin 215ae8e564 Better reaper, catch occasional bad WS header line.
Call waitpid in loop to catch SIGCHLD signals that happen while
handling the original SIGCHLD signal.

Pulled from websockify.
2011-02-01 10:47:45 -06:00
Joel Martin ec2b614037 Pull websockify: zombie reap, ignore unready clients. 2011-01-31 12:13:30 -06:00
Joel Martin 40f281ebbd Add DOCTYPE. Misc cleanup. 2011-01-30 23:42:28 -06:00
Joel Martin 66937e399a wsproxy.py: python2.4 fixes. 2011-01-12 18:12:17 -06:00
Joel Martin f2538f337d wsproxy, wstelnet: wrap command, WS telnet client.
wswrapper:

    Getting the wswrapper.c LD_PRELOAD model working has turned out to
    involve too many dark corners of the glibc/POSIX file descriptor
    space. I realized that 95% of what I want can be accomplished by
    adding a "wrap command" mode to wsproxy.

    The code is still there for now, but consider it experimental at
    best. Minor fix to dup2 and add dup and dup3 logging.

wsproxy Wrap Command:

    In wsproxy wrap command mode, a command line is specified instead
    of a target address and port. wsproxy then uses a much simpler
    LD_PRELOAD library, rebind.so, to move intercept any bind() system
    calls made by the program. If the bind() call is for the wsproxy
    listen port number then the real bind() system call is issued for
    an alternate (free high) port on loopback/localhost.  wsproxy then
    forwards from the listen address/port to the moved port.

    The --wrap-mode argument takes three options that determine the
    behavior of wsproxy when the wrapped command returns an exit code
    (exit or daemonizing): ignore, exit, respawn.

    For example, this runs vncserver on turns port 5901 into
    a WebSockets port (rebind.so must be built first):

        ./utils/wsproxy.py --wrap-mode=ignore 5901 -- vncserver :1

    The vncserver command backgrounds itself so the wrap mode is set
    to "ignore" so that wsproxy keeps running even after it receives
    an exit code from vncserver.

wstelnet:

    To demonstrate the wrap command mode, I added WebSockets telnet
    client.

    For example, this runs telnetd (krb5-telnetd) on turns port 2023
    into a WebSockets port (using "respawn" mode since telnetd exits
    after each connection closes):

        sudo ./utils/wsproxy.py --wrap-mode=respawn 2023 -- telnetd -debug 2023

    Then the utils/wstelnet.html page can be used to connect to the
    telnetd server on port 2023. The telnet client includes VT100.js
    (from http://code.google.com/p/sshconsole) which handles the
    terminal emulation and rendering.

rebind:

    The rebind LD_PRELOAD library is used by wsproxy in wrap command
    mode to intercept bind() system calls and move the port to
    a different port on loopback/localhost. The rebind.so library can
    be built by running make in the utils directory.

    The rebind library can be used separately from wsproxy by setting
    the REBIND_OLD_PORT and REBIND_NEW_PORT environment variables
    prior to executing a command. For example:

        export export REBIND_PORT_OLD="23"
        export export REBIND_PORT_NEW="65023"
        LD_PRELOAD=./rebind.so telnetd -debug 23

    Alternately, the rebind script does the same thing:

        rebind 23 65023 telnetd -debug 23

Other changes/notes:

- wsproxy no longer daemonizes by default. Remove -f/--foreground
  option and add -D/--deamon option.

- When wsproxy is used to wrap a command in "respawn" mode, the
  command will not be respawn more often than 3 times within 10
  seconds.

- Move getKeysym routine out of Canvas object so that it can be called
  directly.
2011-01-12 13:15:11 -06:00
Joel Martin 6a88340929 Refactor and cleanup websocket.py and deps.
Moved websocket.py code into a class WebSocketServer. WebSockets
server implementations will sub-class and define a handler() method
which is passed the client socket after. Global variable settings have been
changed to be parameters for WebSocketServer when created.

Subclass implementations still have to handle queueing and sending but
the parent class handles everything else (daemonizing, websocket
handshake, encode/decode, etc). It would be better if the parent class
could handle queueing and sending. This adds some buffering and
polling complexity to the parent class but it would be better to do so
at some point. However, the result is still much cleaner as can be
seen in wsecho.py.

Refactored wsproxy.py and wstest.py (formerly ws.py) to use the new
class. Added wsecho.py as a simple echo server.

- rename tests/ws.py to utils/wstest.py and add a symlink from
  tests/wstest.py

- rename tests/ws.html to tests/wstest.html to match utils/wstest.py.

- add utils/wsecho.py

- add tests/wsecho.html which communicates with wsecho.py and simply
  sends periodic messages and shows what is received.
2011-01-08 15:29:01 -06:00
Joel Martin 96bc3d3088 wsproxy.py: add web serving capability.
- Added ability to respond to normal web requests. This is basically
  integrating web.py functionality into wsproxy. This is only in the
  python version and it is off by default when calling wsproxy. Turn
  it on with --web DIR where DIR is the web root directory.

Next task is to clean up wsproxy.py. It's gotten unwieldy and it
really no longer needs to be parallel to the C version.
2011-01-06 18:26:54 -06:00
Joel Martin 58dc1947de wsproxy: warn when no cert. C sock close cleanup.
Warn early about no SSL cert and add clearer warning when a connection
comes in as SSL but no cert file exists.

For the C version, cleanup closing of the connection socket. Use
shutdown for a cleaner cleanup with the client.
2011-01-04 13:14:46 -06:00
Joel Martin 3205a3dee8 Add --key option for separate cert and key file.
If only --cert is specified then continue to assume both certificate
and key are in the same file (key first).
2010-11-06 10:55:09 -05:00
Joel Martin 7e63919e6d proxy: Issue #14: detect and allow wss:// from Safari.
Addresses this issue:
http://github.com/kanaka/noVNC/issues#issue/14

Safari starts with '\x80' rather than '\x16' like Chrome and Firefox
and having PROTOCOL_TLSv1 doesn't work with Safari. But just removing
the ssl_version allows things to work with Safari wss:// connections.

Also, if the handshake (after SSL wrapping) is null then terminate the
connection. This probably means the certificate was refused by the
client. Unfortunately Safari (the version I have) doesn't cleanly
shutdown WebSockets connections until the page is reloaded (even if
the object is no longer referenced).
2010-09-15 12:19:17 -05:00
Joel Martin cc374cd61a proxy: always multiprocess and add --verbose.
Always fork handlers processes. Instead printing traffic when
single-processing, print traffic if verbose flag given.
2010-09-11 15:10:54 -05:00
Joel Martin edc4725260 proxy: do handshake in forked process too. 2010-09-10 14:31:34 -05:00
Joel Martin a0315ab1dc wsproxy: multiprocess capable.
Add -m, --multiprocess option which forks a handler for each
connection allowing multiple connections to the same target using the
same proxy instance.

Cleaned up the output of the handler process. Each process' output is
prefixed with an ordinal value.

Changed both the C and python versions of the proxy.
2010-09-10 13:05:48 -05:00
Joel Martin 55dee43279 Remove psuedo-UTF8 encoding.
It's less efficient on average that base64 (150% vs 133%). It's
non-standard (0 shifted to 256 before encoding). And I rarely use it.
2010-08-27 12:10:09 -05:00
Joel Martin 5958fb4996 Python 2.4 compatible imports.
- Fallback to md5 module if hashlib not there.
- Import parse_qsl from cgi where it is in both 2.4 and 2.6
2010-08-04 14:32:10 -05:00
Joel Martin c95c24e743 Fix #19: python2.4 support.
- Replace URL parsing using "".partition() with urlparse module.
2010-08-04 14:18:55 -05:00
Joel Martin 31407abc25 Issue #11: daemonize after opening listen port.
The listen port should be opened before daemonizing otherwise if
opening the port fails, the user will get no feedback. The only
complication was that the listen socket needs to not be closed as part
of daemonizing.

Thanks to http://github.com/rickr for finding it.
2010-07-17 12:05:58 -05:00
Joel Martin a94699265e Remove sequence code in client and proxies. 2010-07-01 12:13:17 -05:00
Joel Martin 1eba7b4279 Update C proxy to WS protocol version 76.
Pull in LGPL md5.c and md5.h files (written by Ulrich Drepper).

Now both python and C version of the proxy support both protocol 75
and protocol 76 (hybi 00).

Reorganize websocket.py slightly to match websocket.c.
2010-06-30 20:39:41 -05:00
Joel Martin c3785ae12b Remove proxy handshake debug. 2010-06-24 18:45:30 -05:00
Joel Martin 486cd527f2 Support WebSockets 76 (hixie-76, hybi-00).
Looks like disabling web-socket-js debug messages by default that we
get a minor speedup.

Python proxy should support both 75 and 76 (00) modes. Also, update ws
test to more reliably hit the WebSockets ordering/drop issue.
2010-06-24 17:04:57 -05:00