Commit Graph

558 Commits

Author SHA1 Message Date
Joel Martin e11012437a Merge pull request #5 from desaintmartin/master
Add support for IPv6
2011-07-07 09:19:46 -07:00
Ed Schouten d0e1fe6a3c Remove a faulty attribution from the Copyright.
The Copyright notice was copied from another source file, where I only
changed the Copyright line at the top.
2011-06-29 23:48:15 +02:00
Joel Martin 367ebb5597 Reformat feature table for readability/expansion. 2011-06-29 10:53:13 -05:00
Ed Schouten 8039dddced Add monitoring support to wsproxy. 2011-06-29 11:07:31 +02:00
Vivien Alger 78697b9663 Added static method addrinfo() 2011-06-29 10:19:52 +02:00
Joel Martin b590289de5 Remove extraneous question mark.
Part of https://github.com/kanaka/noVNC/issues/69
2011-06-28 16:28:42 -05:00
Joel Martin 9a2b50d80b Only append random string to swf path in IE.
Issue https://github.com/kanaka/noVNC/issues/69

Thanks https://github.com/EdSchouten for the catch.
2011-06-28 16:21:15 -05:00
Ed Schouten 306eab28da Add README. 2011-06-28 16:41:31 +02:00
Ed Schouten 7057e31fa0 Add support for Flash headers. This makes wsproxy work with Firefox. 2011-06-28 15:41:06 +02:00
Ed Schouten 631c5990f7 Remove all casting from the sockaddr code. 2011-06-28 12:20:21 +02:00
Ed Schouten d97d1b72d7 Add copy of strndup() for Lenny. 2011-06-28 12:11:35 +02:00
Ed Schouten c42612643a Add Debian package infrastructure and license. 2011-06-28 12:05:50 +02:00
Ed Schouten 52b07abe21 Prevent division by zero. 2011-06-28 11:46:59 +02:00
Ed Schouten 2aa2376e3a Add initial version of wsproxy source code. 2011-06-28 11:44:35 +02:00
Algervivien 30681a7018 Use of socket.getaddrinfo() to replace ipv6 attributes. Corrected error with ssl-only option 2011-06-27 18:49:01 +02:00
Algervivien 077279fe0f Refactoring of parsing 2011-06-27 17:07:29 +02:00
Algervivien eb62b2af6e Added data attributes and ipv6 condition for target 2011-06-27 11:01:01 +02:00
Algervivien a09d18b234 Added ipv6 related attributes 2011-06-27 10:21:20 +02:00
Algervivien 8d71c243b1 Modified parsing for ipv6 support 2011-06-27 09:45:49 +02:00
Joel Martin 7f487fdbd5 Fix recording, generic and part of websocket.py.
WebSocketServer(...,  record='FILE_PREFIX')

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.

Recording required some restructing of the encode and decode function
to return more information so that the recording functions can record
just the payload data and ignore the WebSockets framing/headers.

Caveats:
- Not all messages recorded as sent to the client were necessarily
  received by the client. For example, if several messages are queued
  for the client, but the connection is shutdown before the messages
  are actually sent, these queued messages will still appear in the
  recording.
- If the server is also handling HTTP requests then the handler ID
  extensions for the recorded files will be monotonic but not
  contiguous because only WebSocket connections are recorded, not HTTP
  requests.
2011-06-26 13:55:52 -05:00
Joel Martin d91d89167f Do socket shutdown() of target before close(). 2011-06-26 13:26:59 -05:00
Algervivien 8ae73adbb7 Corrected wrong INET type in else condition 2011-06-24 19:01:47 +02:00
Cédric de Saint Martin d473f4b6d1 Use ipv6 socket when requested 2011-06-24 18:30:11 +02:00
Joel Martin c659bcb79e Refactor optional imports, make 'resource' optional.
Ticket #2: https://github.com/kanaka/websockify/issues/2 - win32
support. The 'resource' module is not available under Windows. We only
use it for daemonizing so make it optional and disable daemonizing
support on Windows for now.

Also, refactor how the optional imports to turn them into data instead
of code and iterate through them.

Add early warnings to indicate when modules are missing and
functionality is disabled.
2011-05-18 15:52:39 -05:00
Joel Martin c8587115bc Python 3.0 support. Use multiprocessing module.
Multiprocessing:
- Switch to using multiprocessing module for python >= 2.6. For python
  2.4 continue to use the os.fork() method.
- Move the new_client creation into top_new_client method to enable
  multiprocessing refactor.
- Only do SIGCHLD handling for os.fork/python 2.4. When doing our own
  SIGCHLD handling under python 3.0, we can run into a python futex
  hang when reloading a web page rapidly. Multiprocessing does it's
  own child reaping so we only need it with os.fork().

Python 3.0:
- Modify imports to reflect new locations: StringIO from io,
  SimpleHTTPRequestHandler from http.server, urlsplit from
  urllib.parse.
- Convert all print statements to print() calls. This also means no
  comma parameter idiom and only using string formatting.
- Define b2s (bytes-to-string) and s2b (string-to-bytes) which are
  no-ops on python versions prior to python 3. In python 3 these do
  the conversion between string and bytes.
- Use compatible try/except method. Exception variable must be
  extracted using sys.exc_info() rather than as part of the except
  statement.

Python 2.4:
- Now degrades more gracefully if ssl module is not found. It will
  still run, but will refuse SSL connections.
- Doesn't support HyBi-07 version due to numpy and struct.unpack_from
  requirement.
2011-05-18 11:09:10 -05:00
Joel Martin 85f84ef280 Refactor HTTP request/upgrade handling.
Instead of doing crazy things with file-descriptors in
SplitHTTPHandler, WSRequestHandler detects a WebSockets upgrade and
returns 101 as the 'last_code'. In addition to avoiding funkiness with
file-descriptors, this allows use of the already parsed headers and
removal of the parse_handshake routine.

This also makes it easier to explore adding python 3.X support
(https://github.com/kanaka/websockify/issues/1) since the
file-descriptor/string splitting is very difficult to integrate with
python 3.X.
2011-05-17 12:08:30 -05:00
Joel Martin 284ef3cc1a Send 'base64' sub-protocol. JSLint.
- Also report back sub-protocol that the server chooses.
2011-05-11 15:14:46 -05:00
Joel Martin 8c3fc55124 Extract close code and reason in decode_hybi.
Also, make it a bit more robust if no code and/or reason is given.
2011-05-02 16:50:17 -05:00
Joel Martin a339a4856a Stop sending empty frames. 2011-05-02 15:15:08 -05:00
Joel Martin c4b6e77127 README.md: formatting, note broken recording. 2011-05-01 22:30:26 -05:00
Joel Martin d82aeac93a README.md: note protocols supported by each variant. 2011-05-01 22:26:59 -05:00
Joel Martin 88b71ce171 Refactor and add IETF-07 protocol version support.
- Add initial IETF-07 (HyBi-07) protocol version support. This version
  still uses base64 encoding since the API for binary support is not
  yet finalized.

- Move socket send and recieve functions into the WebSocketServer
  class instead of having the sub-class do this. This simplifies
  sub-classes somewhat. The send_frame routine now returns the number
  of frames that were unable to be sent. If this value is non-zero
  then the sub-class should call again when the socket is ready until
  the pending frames count is 0.

- Do traffic reporting in the main class instead.

- When the client is HyBi style (i.e. IETF-07) then use the
  sub-protocol header to select whether to do base64 encoding or
  simply send the frame data raw (binary). Update include/websock.js
  to send a 'base64' protocol selector. Once the API support binary,
  then the client will need to detect this and set the protocol to
  'binary'.
2011-05-01 22:17:04 -05:00
Joel Martin ff470ad704 Make daemonize a real static method.
Add chdir option that defaults to '/' instead of passing self and
referencing self.web.
2011-04-30 16:34:56 -05:00
Joel Martin 65c1d8073c Update TODO. Add 'websockify' as protocol. 2011-04-26 09:16:03 -05:00
Joel Martin 2bb1252666 Save handshake headers and path.
Derived classes will almost certainly want to make use of the raw
info.
2011-04-19 09:36:42 -05:00
Joel Martin 7307be683f Fix chdir call to use string instead of character. 2011-04-12 22:46:32 -05:00
Joel Martin 7858c194ca Merge commit 'ccustine/master' 2011-04-12 22:46:03 -05:00
Joel Martin 76e25898bb Couple of misc utf8, base64 python tests. 2011-04-12 22:39:28 -05:00
Chris Custine 82d35c619c Include unistd.h to compile websockify on Mac OS X 2011-04-10 23:37:29 -06:00
Joel Martin 8765971e06 Use /usr/bin/env shebang to make more crossplatform.
Based on noVNC pull request from Decorum.
2011-03-26 15:27:08 -05:00
Joel Martin 7534574a2f Update web-socket-js to bb5797cad.
Primary change is removal of FABridge interface.

Seems to improve overall latency by perhaps 10%. Also, the slowdown
over time in Opera is about half as bad (but still there).
2011-03-16 10:22:31 -05:00
Joel Martin fe6b1f9e7f Pull JSLint'ing from noVNC. 2011-03-15 11:37:59 -05:00
Joel Martin 6954e4641d Better reaper, catch occasional bad WS header line.
Call waitpid in loop to catch SIGCHLD signals that happen while
handling the original SIGCHLD signal.
2011-02-01 10:46:28 -06:00
Joel Martin 0a2f850267 Reap websockify zombies. Add IE9 fix for websock.js.
Reap websockify zombies. Fixes:
https://github.com/kanaka/noVNC/issues#issue/47. Thanks NeilW.

Changes to get web-socket-js to work with IE9. Right now it's a hack to get
around: https://github.com/gimite/web-socket-js/issues#issue/41. The hack is to
disable caching of the flash objects by appending "?" + Math.random() to the
end of the flash object path (but only when using IE).
2011-01-31 10:34:42 -06:00
Joel Martin 58995c6f10 Typo. 2011-01-23 20:00:08 -06:00
Joel Martin 49b47baf13 Add some notes about the methodology of the test data. 2011-01-23 19:58:27 -06:00
Joel Martin cbc01b3f16 Re-order and fix sections. 2011-01-23 19:52:31 -06:00
Joel Martin 3d91fd3492 Use websock.js in latency test. Fixes for Opera.
Convert latency test to use include/websock.js instead of direct
WebSockets handling.

Add support for configuring the maximum bufferedAmount. This allows us
to configure it high enough to get around a bug in bufferedAmount
reporting in Opera.

Add some latency test results for Opera 11 with WebSockets turned on.
2011-01-23 19:30:51 -06:00
Joel Martin 307dda1ad0 Tolerate some bufferedAmount and send() return value.
- Only delay sending data if bufferedAmount is greater than 1000.

This seems to match the intention of the spec better. bufferedAmount
does not mean that we can't send, it's just an indication that the
network is becoming saturated. But Opera 11 native WebSockets seems to
have a bug that bufferedAmount isn't set back to zero correctly so

- websock.send returns true/false.

If all send data was flushed from the send queue then return true,
otherwise false. This doesn't mean the data won't be sent, just that
it wasn't sent this time and is queued.
2011-01-23 19:23:28 -06:00
Joel Martin d8c90aea88 Fix web-socket-js commit hash. 2011-01-19 15:35:21 -06:00