Commit Graph

41 Commits

Author SHA1 Message Date
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 9b940131d3 include/canvas.js: show full user agent in console. 2011-01-04 10:30:26 -06:00
Joel Martin bf5ee68828 Expose getKeysym and add keyboard test.
Related to issue Non-US keyboard layout option issue:
https://github.com/kanaka/noVNC/issues#issue/21
2011-01-03 12:34:41 -06:00
Joel Martin e46719100c Make compatible with jQuery. Slight API change.
Rename the $() selector to $D() so that it doesn't collide with
the jQuery name.

The API change is that the 'target' option for Canvas and RFB objects
must now be a DOM Canvas element. A string is no longer accepted
because this requires that a DOM lookup is done and the Canvas and RFB
should have no UI code in them. Modularity.
2010-12-10 08:25:36 -06:00
Joel Martin c1d008f1ee Fix flush with strict DOCTYPE.
- With a strict doctype, the margin size needs a "px" suffix.
2010-11-06 14:11:30 -05:00
Joel Martin cdb55d26e5 canvas.js: workaround WebKit bug, issue #28.
This is WebKit bug https://bugs.webkit.org/show_bug.cgi?id=46319

The workaround is to wrap Canvas render functions with a function that
sets a flush timer. The flush function sets the right margin and then
1ms later sets it back. This triggers the canvas to redraw with the
correct contents.

Two downsides:
- rendering is slower, but only on the busted versions of webkit.
  Correct and useful is better than fast and useless.
- There is a barely perceptible jitter of the control buttons because
  the canvas size is changing by one pixel.

To support this functionality, we also have to read out the exact
webkit version from the user agent in the render engine detection code
in include/util.js.
2010-11-06 12:23:23 -05:00
Joel Martin 455e4657f6 default_controls.js: canvas fail fix. Misc cleanup.
- Make sure that canvas exists (i.e. didn't throw an error) before
  trying to call canvas method get_canvas_uri.

- Typos in HTML render engine debug output.
2010-11-06 12:15:08 -05:00
Joel Martin 65bca0c904 Fix style caching. Canvas cleanup from Diet-noVNC.
- Style caching gives a small performance speedup in firefox, but not
  much. Might not be worth complexity, but leave it in for now.
2010-10-18 14:30:50 -05:00
Joel Martin 3b20e7a90f rfb.js, canvas.js: status feedback on Canvas functionality.
Read the render mode selected by canvas and report it in the initial
page loaded status message.
2010-09-24 10:47:39 -05:00
Joel Martin ff36b1270b Refactor settings object, add connectTimeout setting.
- include/util.js: Add type and desc field to conf_default routine.
  Make comment descriptions of settings into desc parameters that can
  be queried. Also, use set_FOO in conf_default to set or coerce the
  current setting so that we always have the right type for the value.

- include/rfb.js, include/default_config.js: add connectTimeout
  setting to address situations with slow connections that may need
  more than 2 seconds.
2010-09-23 09:39:24 -05:00
Joel Martin 005d9ee999 Misc cleanup: debug logging, record filename, etc.
- include/canvas.js: When 'debug' logging, show browser detection
  values.
- test/canvas.html: Only restore the canvas to it's starting state if
  the logging level is not 'debug'.
- wsproxy.py: Append the session number to the record filename so that
  multiple sessions don't stomp on each other.
2010-09-23 08:17:00 -05:00
Joel Martin 5f409eeeeb License header cleanup. 2010-09-08 15:06:34 -05:00
Joel Martin 3cc74720f0 canvas.js: Fix ignore for scrolled window.
When the documement/window is scrolled, the onMouseDisable routine was
not properly calculating the position to test whether to ignore the
event or not.
2010-08-31 13:36:14 -05:00
Joel Martin 67b4e9879a Indexed receive queue. Up to 2X speedup in Chrome.
Generally, most servers send hextile updates as single updates
containing many rects. Some servers send hextile updates as many small
framebuffer updates with a few rects each (such as QEMU). This latter
cases revealed that shifting off the beginning of the receive queue
(which happens after each hextile FBU) performs poorly.

This change switches to using an indexed receive queue (instead of
actually shifting off the array). When the receive queue has grown to
a certain size, then it is compacted all at once.

The code is not as clean, but this change results in more than 2X
speedup under Chrome for the pessimal case and 10-20% in firefox.
2010-08-26 10:22:29 -05:00
primalmotion b7155950d3 * take care of kanaka's suggestions
(cherry picked from commit 11f3271a52505dccbf38bea422e7c9a79dddd478)

Signed-off-by: Joel Martin <github@martintribe.org>
2010-08-04 15:29:42 -05:00
primalmotion 6425f611d8 * Adding a way to set the DOM document to use.
This is very usefull when you need to open a new window (with a new document) from javascript,
without having to reload the script.js.
(cherry picked from commit 8ded53c1de06d01e50d58543c19e73926f0fbbd4)

Signed-off-by: Joel Martin <github@martintribe.org>
2010-08-04 15:18:17 -05:00
Joel Martin 8db09746b7 New API. Refactor Canvas and RFB objects.
New API:

To use the RFB object, you now must instantiate it (this allows more
than one instance of it on the same page).

    rfb = new RFB(settings);

The 'settings' variable is a namespace that contains initial default
settings. These can also be set and read using 'rfb.set_FOO()' and
'rfb.get_FOO()' where FOO is the setting name. The current settings
are (and defaults) are:
    - target: the DOM Canvas element to use ('VNC_canvas').
    - encrypt: whether to encrypt the connection (false)
    - true_color: true_color or palette (true)
    - b64encode: base64 encode the WebSockets data (true)
    - local_cursor: use local cursor rendering (true if supported)
    - connectTimeout: milliseconds to wait for connect (2000)
    - updateState: callback when RFB state changes (none)
    - clipboardReceive: callback when clipboard data received (none)

The parameters to the updateState callback have also changed. The
function spec is now updateState(rfb, state, oldstate, msg):
    - rfb: the RFB object that this state change is for.
    - state: the new state
    - oldstate: the previous state
    - msg: a message associate with the state (not always set).

The clipboardReceive spec is clipboardReceive(rfb, text):
    - rfb: the RFB object that this text is from.
    - text: the clipboard text received.

Changes:

- The RFB and Canvas namespaces are now more proper objects. Private
  implementation is no longer exposed and the public API has been made
  explicit. Also, instantiation allows more than one VNC connection
  on the same page (to complete this, DefaultControls will also need
  this same refactoring).

- Added 'none' logging level.

- Removed automatic stylesheet selection workaround in util.js and
  move it to defaultcontrols so that it doesn't interfere with
  intergration.

- Also, some major JSLinting.

- Fix input, canvas, and cursor tests to work with new model.
2010-08-02 17:07:27 -05:00
Joel Martin 8171f4d818 Catch exceptions in cursor detection.
If cursor Data URI scheme detection threw an exception, it would cause
canvas initialization to fail. cursor detection exceptions should just
disable local cursor change support, not cause canvas init to fail.
2010-08-02 10:11:47 -05:00
Joel Martin 125d8bbb8f Preliminary scaling code (deactivated).
Uses the CSS "scale()" operation. The main problem is that the DOM
container is not rescaled, only the size of the displayed content
within it so there will need to be some sort of mechanism to handle
this better so other elements reflow to the new size. Or it might just
not work and be removed later. The zoom property seems to do the right
behavior, but it's not widely supported. Worth exploring though.
2010-07-30 09:53:33 -05:00
Joel Martin a7a8962676 JSLint. RFB obj to rfb.js; vnc.js the 'loader'.
Move the whole RFB object to rfb.js. vnc.js is now just the loader
file. This allows an integrating project to easily replace vnc.js with
an alternate loader mechanism (or just do it directly in the html
file). Thanks for the idea primalmotion (http://github.com/primalmotion).

Also, JSLint the various files.
2010-07-22 10:54:47 -05:00
Joel Martin da6dd8932e API changes. Client cursor and settings menu.
The following API changes may affect integrators:

    - Settings have been moved out of the RFB.connect() call. Each
      setting now has it's own setter function: setEncrypt, setBase64,
      setTrueColor, setCursor.

    - Encrypt and cursor settings now default to on.

    - CSS changes:
        - VNC_status_bar for input buttons switched to a element class.

        - VNC_buttons split into VNC_buttons_right and
          VNC_buttons_left

        - New id styles for VNC_settings_menu and VNC_setting

Note: the encrypt, true_color and cursor, logging setting can all be
  set on load using query string variables (in addition to host, port
  and password).

Client cursor (cursor pseudo-encoding) support has been polished and
activated.

The RFB settings are now presented as radio button list items in
a drop-down "Settings" menu when using the default controls.

Also, in the settings menu is the ability to select between alternate
style-sheets.

Cookie and stylesheet selection support added to util.js.
2010-07-21 20:34:23 -05:00
Joel Martin 2c2b492c0c Add Cursor pseudo-encoding support (disabled for now).
To change the appearance of the cursor, we use the CSS cursor style
and set the url to a data URI scheme. The image data sent via the
cursor pseudo-encoding has to be encoded to a CUR format file before
being used in the data URI.

During Canvas initialization we try and set a simple cursor to see if
the browser has support. Opera is missing support for data URI scheme
in cursor URLs.

Disabled for now until we have a better way of specifying settings
overall (too many settings for control bar now).
2010-07-20 14:34:44 -05:00
Joel Martin 81e5adafef Refactor console logging code.
Util.Debug, Util.Info, Util.Warn, Util.Error routines instead of
direct calls to console.*. Add "logging=XXX" query variable that sets
the logging level (default is "warn").

Logging values:
    debug: code debug logging (many calls in performance path are also
           commented for performance reasons).
    info: informative messages including timing information.
    warn: significant events
    error: something has gone wrong
2010-07-06 11:56:13 -05:00
Joel Martin ae0ecca2e4 Disable excanvas experiment.
Also, move bugs from TODO to github issues.
2010-07-02 14:25:12 -05:00
Joel Martin 6713418413 Always prefer JS ops if we have imageData.
All browsers with Canvas imageData are faster with JS ops instead of
canvas ops. This gives significant performance improvement in Opera.
Except for missing web-socet-js message notifications, Opera 10.60 is
now faster than firefox 3.5.
2010-07-01 10:30:07 -05:00
Joel Martin 5235b29ddf Significant firefox perf improvement. Update TODOs.
Interesting. Enough has changed in the Canvas tile operations, that
Canvas.prefer_js=true is better for firefox/gecko too. Approximately
2X improvement in firefox for large hextile renders.
2010-06-29 14:36:18 -05:00
Joel Martin 48eed1ac05 Refactor canvas imageData test slightly. 2010-06-24 17:09:54 -05:00
Joel Martin d93d3e09ab Various cross-browser fixes.
Now working under Arora 0.5.

But not Konqueror 4.2.2 (WebSockets never connects).

IE support with excanvas still pending.
2010-06-23 16:08:36 -05:00
Joel Martin 15046f0042 No mootools dep outside of default_controls.js.
Some basic functions from mootools implemented in util.js.

Also, some more DOM separation. Move clipboard focus logic into
default_controls and canvas and out of vnc.js.

JSLint cleanup.
2010-06-15 15:21:41 -05:00
Joel Martin 61dd52c983 Add mouse position routines to util.js.
On path towards removing dependency on mootools in non-UI code.
2010-06-15 11:10:18 -05:00
Joel Martin e2e7c22494 Move DOM event handling from vnc.js to canvas.js. 2010-06-15 09:36:23 -05:00
Joel Martin 30e5396326 Less debug output. 2010-06-14 14:42:34 -05:00
Joel Martin 888d5813ed Fix scrolled mouse position. 2010-06-10 16:05:15 -05:00
Joel Martin 4b4496ad67 DesktopResize and compression level pseudo-encodings.
- Implement resizing of desktop pseudo-encoding.

- Also send lowest (fastest) compression level pseudo-encoding.
  Ought be user tweakable.
2010-06-10 15:44:42 -05:00
Joel Martin 2e041cf225 Fix Alt keysym.
From kevinychan/vnc-html5 ebfffdc36.
2010-06-03 09:28:44 -05:00
Joel Martin d41c33e4b7 Add colour map support (non-true-color).
In colourMap mode there are 256 colours in a colour palette sent from
the server via the SetColourMapEntries message. This reduces the
bandwidth by about 1/4. However, appearance can be somewhat less than
ideal (pinks instead of gray, etc).

It also increases client side rendering performance especially on
firefox. Rendering a full 800x600 update takes about 950ms in
firefox on my system compared to about 1400ms. Round-trip time for
a full frame buffer update is even better on firefox (due to
performance of the flash WebSocket emulator). Reduced from about
1800ms to 1100ms on firefox (for 800x600 full update).
2010-06-01 14:34:27 -05:00
Joel Martin af6b17ce06 Change license to LGPL-3 and add some implementation notes.
The purpose of the code is to be incorporated into other web projects
(whether those are free or not). AGPL prevents combination with other
HTML and javascript that is under a weaker (or proprietary) license.
Better would be a lesser AGPL, but there is not GNU standard for that.
So LGPL-3 meets most of my requirements. If somebody modifies the
actual client code and conveys it, then they must release the changes
under LGPL-3 also.

Add some implementation notes in docs/notes.
2010-05-26 15:43:00 -05:00
Joel Martin a575a383fb Add mouse wheel support and input test page. 2010-05-25 11:05:55 -05:00
Joel Martin 7f4f41b0c7 Don't shift off subencoding in hextile. 2010-05-20 17:13:59 -05:00
Joel Martin 97763d0eb8 Double Chrome hextile perf again. Add canvas test.
- By dereferencing the 'data' field of the imageData object before the
  loop, the hextile performance on Chrome is down to 140ms or so for
  a full 800x600 update. Still have to fall back to Canvas operations
  for firefox.

- Fix RQ empty after reorder bug.
2010-05-17 13:07:53 -05:00
Joel Martin f9583f1f98 Move canvas.js to include/canvas.js. 2010-05-15 15:45:09 -05:00
Renamed from canvas.js (Browse further)