noVNC -> latest
1
public/novnc/.eslintignore
Normal file
@@ -0,0 +1 @@
|
||||
**/xtscancodes.js
|
||||
51
public/novnc/.eslintrc
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2020": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"sourceType": "module",
|
||||
"ecmaVersion": 2020
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
// Unsafe or confusing stuff that we forbid
|
||||
|
||||
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
|
||||
"no-constant-condition": ["error", { "checkLoops": false }],
|
||||
"no-var": "error",
|
||||
"no-useless-constructor": "error",
|
||||
"object-shorthand": ["error", "methods", { "avoidQuotes": true }],
|
||||
"prefer-arrow-callback": "error",
|
||||
"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": false } ],
|
||||
"arrow-parens": ["error", "as-needed", { "requireForBlockBody": true }],
|
||||
"arrow-spacing": ["error"],
|
||||
"no-confusing-arrow": ["error", { "allowParens": true }],
|
||||
|
||||
// Enforced coding style
|
||||
|
||||
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
||||
"indent": ["error", 4, { "SwitchCase": 1,
|
||||
"FunctionDeclaration": { "parameters": "first" },
|
||||
"CallExpression": { "arguments": "first" },
|
||||
"ArrayExpression": "first",
|
||||
"ObjectExpression": "first",
|
||||
"ignoreComments": true }],
|
||||
"comma-spacing": ["error"],
|
||||
"comma-style": ["error"],
|
||||
"curly": ["error", "multi-line"],
|
||||
"func-call-spacing": ["error"],
|
||||
"func-names": ["error"],
|
||||
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
|
||||
"key-spacing": ["error"],
|
||||
"keyword-spacing": ["error"],
|
||||
"no-trailing-spaces": ["error"],
|
||||
"semi": ["error"],
|
||||
"space-before-blocks": ["error"],
|
||||
"space-before-function-paren": ["error", { "anonymous": "always",
|
||||
"named": "never",
|
||||
"asyncArrow": "always" }],
|
||||
"switch-colon-spacing": ["error"],
|
||||
"camelcase": ["error", { allow: ["^XK_", "^XF86XK_"] }],
|
||||
}
|
||||
}
|
||||
11
public/novnc/.gitignore
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
*.pyc
|
||||
*.o
|
||||
tests/data_*.js
|
||||
utils/rebind.so
|
||||
/node_modules
|
||||
/build
|
||||
/lib
|
||||
recordings
|
||||
*.swp
|
||||
*~
|
||||
noVNC-*.tgz
|
||||
0
public/novnc/.gitmodules
vendored
Normal file
@@ -1,54 +0,0 @@
|
||||
How to contribute to noVNC
|
||||
==========================
|
||||
|
||||
We accept code via pull requests on GitHub. There are several guidelines that
|
||||
we expect contributors submitting code requests to follow. If you have issues
|
||||
following any of these guidelines, feel free to drop us a line by leaving a
|
||||
comment in the code request or sending us an email.
|
||||
|
||||
Contributing Guidelines
|
||||
-----------------------
|
||||
|
||||
* While we don't have an official coding style guide, please try to follow
|
||||
the general coding style of the existing code.
|
||||
** Use four spaces instead of tabs
|
||||
** prefix private variables and functions with an `_`
|
||||
|
||||
* Please try to include unit tests for your code. For instance, if you
|
||||
introduce a new encoding, add a test to `tests/test.rfb.js` under the
|
||||
"Encoding Handlers" section (basically, input a small pattern in your
|
||||
encoding and make sure the pattern gets displayed correctly). If you
|
||||
fix a bug, try to add a unit test that would have caught that bug
|
||||
(if possible -- some bugs, especially visual ones, are hard to test for).
|
||||
|
||||
* Squash your commits down in to a clean commit history. For instance, there
|
||||
should not be "cleanup" commits where you fix issues in previous commits in
|
||||
the same pull request. Before you go to commit, use `git rebase -i` to
|
||||
squash these changes into the relevant commits. For instance, a good commit
|
||||
history might look like "Added support for FOO encoding, Added support for
|
||||
BAR message, Placed Button in UI to Trigger BAR" (where each comma denotes
|
||||
a separate commit).
|
||||
|
||||
* Add both a title and description to your commit, if possible. Place more
|
||||
detail on what you did in the description.
|
||||
|
||||
Running the unit tests
|
||||
----------------------
|
||||
|
||||
There are two ways to run the unit tests. For both ways, you should first run
|
||||
`npm install` (not as root).
|
||||
|
||||
The first way to run the tests is to run `npm test`. This will run all the
|
||||
tests in the headless PhantomJS browser (which uses WebKit).
|
||||
|
||||
The second way to run the tests is using the `tests/run_from_console.js` file.
|
||||
This way is a bit more flexible, and can provide more information about what
|
||||
went wrong. To run all the tests, simply run `tests/run_from_console.js`.
|
||||
To run a specific test file, you can use the `-t path/to/test/file.js` option.
|
||||
If you wish to simply generate the HTML for the test, use the `-g` option, and
|
||||
the path to the temporary HTML file will be written to standard out. To open
|
||||
this file in your default browser automatically, pass the `-o` option as well.
|
||||
More information can be found by passing the `--help` or `-h` option.
|
||||
|
||||
|
||||
Thanks, and happy coding!
|
||||
@@ -114,7 +114,12 @@ proxy.
|
||||
|
||||
`./utils/novnc_proxy --vnc localhost:5901`
|
||||
|
||||
* Point your browser to the cut-and-paste URL that is output by the `novnc_procy`
|
||||
* If you don't need to expose the web server to public internet, you can
|
||||
bind to localhost:
|
||||
|
||||
`./utils/novnc_proxy --vnc localhost:5901 --listen localhost:6081`
|
||||
|
||||
* Point your browser to the cut-and-paste URL that is output by the `novnc_proxy`
|
||||
script. Hit the Connect button, enter a password if the VNC server has one
|
||||
configured, and enjoy!
|
||||
|
||||
@@ -123,13 +128,17 @@ Running the command below will install the latest release of noVNC from Snap:
|
||||
|
||||
`sudo snap install novnc`
|
||||
|
||||
#### Running noVNC
|
||||
#### Running noVNC from Snap Directly
|
||||
|
||||
You can run the Snap-package installed novnc directly with, for example:
|
||||
|
||||
`novnc --listen 6081 --vnc localhost:5901 # /snap/bin/novnc if /snap/bin is not in your PATH`
|
||||
|
||||
#### Running as a Service (Daemon)
|
||||
If you want to use certificate files, due to standard Snap confinement restrictions you need to have them in the /home/\<user\>/snap/novnc/current/ directory. If your username is jsmith an example command would be:
|
||||
|
||||
`novnc --listen 8443 --cert ~jsmith/snap/novnc/current/self.crt --key ~jsmith/snap/novnc/current/self.key --vnc ubuntu.example.com:5901`
|
||||
|
||||
#### Running noVNC from Snap as a Service (Daemon)
|
||||
The Snap package also has the capability to run a 'novnc' service which can be
|
||||
configured to listen on multiple ports connecting to multiple VNC servers
|
||||
(effectively a service runing multiple instances of novnc).
|
||||
@@ -203,6 +212,7 @@ that list and you think you should be, feel free to send a PR to fix that.
|
||||
* UI and Icons : Pierre Ossman, Chris Gordon
|
||||
* Original Logo : Michael Sersen
|
||||
* tight encoding : Michael Tinglof (Mercuri.ca)
|
||||
* RealVNC RSA AES authentication : USTC Vlab Team
|
||||
|
||||
* Included libraries:
|
||||
* base64 : Martijn Pieters (Digital Creations 2), Samuel Sieb (sieb.net)
|
||||
|
||||
@@ -6,21 +6,17 @@
|
||||
* See README.md for usage and integration instructions.
|
||||
*/
|
||||
|
||||
// NB: this should *not* be included as a module until we have
|
||||
// native support in the browsers, so that our error handler
|
||||
// can catch script-loading errors.
|
||||
|
||||
// No ES6 can be used in this file since it's used for the translation
|
||||
/* eslint-disable prefer-arrow-callback */
|
||||
|
||||
(function _scope() {
|
||||
"use strict";
|
||||
|
||||
// Fallback for all uncought errors
|
||||
function handleError(event, err) {
|
||||
// Fallback for all uncought errors
|
||||
function handleError(event, err) {
|
||||
try {
|
||||
const msg = document.getElementById('noVNC_fallback_errormsg');
|
||||
|
||||
// Work around Firefox bug:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1685038
|
||||
if (event.message === "ResizeObserver loop completed with undelivered notifications.") {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only show the initial error
|
||||
if (msg.hasChildNodes()) {
|
||||
return false;
|
||||
@@ -60,7 +56,7 @@
|
||||
// Don't return true since this would prevent the error
|
||||
// from being printed to the browser console.
|
||||
return false;
|
||||
}
|
||||
window.addEventListener('error', function onerror(evt) { handleError(evt, evt.error); });
|
||||
window.addEventListener('unhandledrejection', function onreject(evt) { handleError(evt.reason, evt.reason); });
|
||||
})();
|
||||
}
|
||||
|
||||
window.addEventListener('error', evt => handleError(evt, evt.error));
|
||||
window.addEventListener('unhandledrejection', evt => handleError(evt.reason, evt.reason));
|
||||
|
||||
@@ -841,6 +841,23 @@ select:active {
|
||||
height: 1.3em;
|
||||
}
|
||||
|
||||
/* ----------------------------------------
|
||||
* Server verification Dialog
|
||||
* ----------------------------------------
|
||||
*/
|
||||
|
||||
#noVNC_verify_server_dlg {
|
||||
position: relative;
|
||||
|
||||
transform: translateY(-50px);
|
||||
}
|
||||
#noVNC_verify_server_dlg.noVNC_open {
|
||||
transform: translateY(0);
|
||||
}
|
||||
#noVNC_fingerprint_block {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
/* ----------------------------------------
|
||||
* Password Dialog
|
||||
* ----------------------------------------
|
||||
@@ -854,12 +871,8 @@ select:active {
|
||||
#noVNC_credentials_dlg.noVNC_open {
|
||||
transform: translateY(0);
|
||||
}
|
||||
#noVNC_credentials_dlg ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
.noVNC_hidden {
|
||||
#noVNC_username_block.noVNC_hidden,
|
||||
#noVNC_password_block.noVNC_hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -871,7 +884,11 @@ select:active {
|
||||
|
||||
/* Transition screen */
|
||||
#noVNC_transition {
|
||||
display: none;
|
||||
transition: 0.5s ease-in-out;
|
||||
|
||||
display: flex;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
|
||||
position: fixed;
|
||||
top: 0;
|
||||
@@ -892,7 +909,8 @@ select:active {
|
||||
:root.noVNC_connecting #noVNC_transition,
|
||||
:root.noVNC_disconnecting #noVNC_transition,
|
||||
:root.noVNC_reconnecting #noVNC_transition {
|
||||
display: flex;
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
:root:not(.noVNC_reconnecting) #noVNC_cancel_reconnect_button {
|
||||
display: none;
|
||||
|
||||
@@ -61,6 +61,14 @@ const UI = {
|
||||
// Translate the DOM
|
||||
l10n.translateDOM();
|
||||
|
||||
// We rely on modern APIs which might not be available in an
|
||||
// insecure context
|
||||
if (!window.isSecureContext) {
|
||||
// FIXME: This gets hidden when connecting
|
||||
UI.showStatus(_("HTTPS is required for full functionality"), 'error');
|
||||
}
|
||||
|
||||
// Try to fetch version number
|
||||
fetch('./package.json')
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
@@ -316,6 +324,10 @@ const UI = {
|
||||
document.getElementById("noVNC_cancel_reconnect_button")
|
||||
.addEventListener('click', UI.cancelReconnect);
|
||||
|
||||
document.getElementById("noVNC_approve_server_button")
|
||||
.addEventListener('click', UI.approveServer);
|
||||
document.getElementById("noVNC_reject_server_button")
|
||||
.addEventListener('click', UI.rejectServer);
|
||||
document.getElementById("noVNC_credentials_button")
|
||||
.addEventListener('click', UI.setCredentials);
|
||||
},
|
||||
@@ -445,6 +457,8 @@ const UI = {
|
||||
// State change closes dialogs as they may not be relevant
|
||||
// anymore
|
||||
UI.closeAllPanels();
|
||||
document.getElementById('noVNC_verify_server_dlg')
|
||||
.classList.remove('noVNC_open');
|
||||
document.getElementById('noVNC_credentials_dlg')
|
||||
.classList.remove('noVNC_open');
|
||||
},
|
||||
@@ -1030,6 +1044,7 @@ const UI = {
|
||||
credentials: { password: password } });
|
||||
UI.rfb.addEventListener("connect", UI.connectFinished);
|
||||
UI.rfb.addEventListener("disconnect", UI.disconnectFinished);
|
||||
UI.rfb.addEventListener("serververification", UI.serverVerify);
|
||||
UI.rfb.addEventListener("credentialsrequired", UI.credentials);
|
||||
UI.rfb.addEventListener("securityfailure", UI.securityFailed);
|
||||
UI.rfb.addEventListener("capabilities", UI.updatePowerButton);
|
||||
@@ -1152,6 +1167,37 @@ const UI = {
|
||||
/* ------^-------
|
||||
* /CONNECTION
|
||||
* ==============
|
||||
* SERVER VERIFY
|
||||
* ------v------*/
|
||||
|
||||
async serverVerify(e) {
|
||||
const type = e.detail.type;
|
||||
if (type === 'RSA') {
|
||||
const publickey = e.detail.publickey;
|
||||
let fingerprint = await window.crypto.subtle.digest("SHA-1", publickey);
|
||||
// The same fingerprint format as RealVNC
|
||||
fingerprint = Array.from(new Uint8Array(fingerprint).slice(0, 8)).map(
|
||||
x => x.toString(16).padStart(2, '0')).join('-');
|
||||
document.getElementById('noVNC_verify_server_dlg').classList.add('noVNC_open');
|
||||
document.getElementById('noVNC_fingerprint').innerHTML = fingerprint;
|
||||
}
|
||||
},
|
||||
|
||||
approveServer(e) {
|
||||
e.preventDefault();
|
||||
document.getElementById('noVNC_verify_server_dlg').classList.remove('noVNC_open');
|
||||
UI.rfb.approveServer();
|
||||
},
|
||||
|
||||
rejectServer(e) {
|
||||
e.preventDefault();
|
||||
document.getElementById('noVNC_verify_server_dlg').classList.remove('noVNC_open');
|
||||
UI.disconnect();
|
||||
},
|
||||
|
||||
/* ------^-------
|
||||
* /SERVER VERIFY
|
||||
* ==============
|
||||
* PASSWORD
|
||||
* ------v------*/
|
||||
|
||||
|
||||
141
public/novnc/core/decoders/jpeg.js
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2019 The noVNC Authors
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*
|
||||
* See README.md for usage and integration instructions.
|
||||
*
|
||||
*/
|
||||
|
||||
export default class JPEGDecoder {
|
||||
constructor() {
|
||||
// RealVNC will reuse the quantization tables
|
||||
// and Huffman tables, so we need to cache them.
|
||||
this._quantTables = [];
|
||||
this._huffmanTables = [];
|
||||
this._cachedQuantTables = [];
|
||||
this._cachedHuffmanTables = [];
|
||||
|
||||
this._jpegLength = 0;
|
||||
this._segments = [];
|
||||
}
|
||||
|
||||
decodeRect(x, y, width, height, sock, display, depth) {
|
||||
// A rect of JPEG encodings is simply a JPEG file
|
||||
if (!this._parseJPEG(sock.rQslice(0))) {
|
||||
return false;
|
||||
}
|
||||
const data = sock.rQshiftBytes(this._jpegLength);
|
||||
if (this._quantTables.length != 0 && this._huffmanTables.length != 0) {
|
||||
// If there are quantization tables and Huffman tables in the JPEG
|
||||
// image, we can directly render it.
|
||||
display.imageRect(x, y, width, height, "image/jpeg", data);
|
||||
return true;
|
||||
} else {
|
||||
// Otherwise we need to insert cached tables.
|
||||
const sofIndex = this._segments.findIndex(
|
||||
x => x[1] == 0xC0 || x[1] == 0xC2
|
||||
);
|
||||
if (sofIndex == -1) {
|
||||
throw new Error("Illegal JPEG image without SOF");
|
||||
}
|
||||
let segments = this._segments.slice(0, sofIndex);
|
||||
segments = segments.concat(this._quantTables.length ?
|
||||
this._quantTables :
|
||||
this._cachedQuantTables);
|
||||
segments.push(this._segments[sofIndex]);
|
||||
segments = segments.concat(this._huffmanTables.length ?
|
||||
this._huffmanTables :
|
||||
this._cachedHuffmanTables,
|
||||
this._segments.slice(sofIndex + 1));
|
||||
let length = 0;
|
||||
for (let i = 0; i < segments.length; i++) {
|
||||
length += segments[i].length;
|
||||
}
|
||||
const data = new Uint8Array(length);
|
||||
length = 0;
|
||||
for (let i = 0; i < segments.length; i++) {
|
||||
data.set(segments[i], length);
|
||||
length += segments[i].length;
|
||||
}
|
||||
display.imageRect(x, y, width, height, "image/jpeg", data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_parseJPEG(buffer) {
|
||||
if (this._quantTables.length != 0) {
|
||||
this._cachedQuantTables = this._quantTables;
|
||||
}
|
||||
if (this._huffmanTables.length != 0) {
|
||||
this._cachedHuffmanTables = this._huffmanTables;
|
||||
}
|
||||
this._quantTables = [];
|
||||
this._huffmanTables = [];
|
||||
this._segments = [];
|
||||
let i = 0;
|
||||
let bufferLength = buffer.length;
|
||||
while (true) {
|
||||
let j = i;
|
||||
if (j + 2 > bufferLength) {
|
||||
return false;
|
||||
}
|
||||
if (buffer[j] != 0xFF) {
|
||||
throw new Error("Illegal JPEG marker received (byte: " +
|
||||
buffer[j] + ")");
|
||||
}
|
||||
const type = buffer[j+1];
|
||||
j += 2;
|
||||
if (type == 0xD9) {
|
||||
this._jpegLength = j;
|
||||
this._segments.push(buffer.slice(i, j));
|
||||
return true;
|
||||
} else if (type == 0xDA) {
|
||||
// start of scan
|
||||
let hasFoundEndOfScan = false;
|
||||
for (let k = j + 3; k + 1 < bufferLength; k++) {
|
||||
if (buffer[k] == 0xFF && buffer[k+1] != 0x00 &&
|
||||
!(buffer[k+1] >= 0xD0 && buffer[k+1] <= 0xD7)) {
|
||||
j = k;
|
||||
hasFoundEndOfScan = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasFoundEndOfScan) {
|
||||
return false;
|
||||
}
|
||||
this._segments.push(buffer.slice(i, j));
|
||||
i = j;
|
||||
continue;
|
||||
} else if (type >= 0xD0 && type < 0xD9 || type == 0x01) {
|
||||
// No length after marker
|
||||
this._segments.push(buffer.slice(i, j));
|
||||
i = j;
|
||||
continue;
|
||||
}
|
||||
if (j + 2 > bufferLength) {
|
||||
return false;
|
||||
}
|
||||
const length = (buffer[j] << 8) + buffer[j+1] - 2;
|
||||
if (length < 0) {
|
||||
throw new Error("Illegal JPEG length received (length: " +
|
||||
length + ")");
|
||||
}
|
||||
j += 2;
|
||||
if (j + length > bufferLength) {
|
||||
return false;
|
||||
}
|
||||
j += length;
|
||||
const segment = buffer.slice(i, j);
|
||||
if (type == 0xC4) {
|
||||
// Huffman tables
|
||||
this._huffmanTables.push(segment);
|
||||
} else if (type == 0xDB) {
|
||||
// Quantization tables
|
||||
this._quantTables.push(segment);
|
||||
}
|
||||
this._segments.push(segment);
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export default class RawDecoder {
|
||||
|
||||
// Max sure the image is fully opaque
|
||||
for (let i = 0; i < pixels; i++) {
|
||||
data[i * 4 + 3] = 255;
|
||||
data[index + i * 4 + 3] = 255;
|
||||
}
|
||||
|
||||
display.blitImage(x, curY, width, currHeight, data, index);
|
||||
|
||||
185
public/novnc/core/decoders/zrle.js
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2021 The noVNC Authors
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*
|
||||
* See README.md for usage and integration instructions.
|
||||
*
|
||||
*/
|
||||
|
||||
import Inflate from "../inflator.js";
|
||||
|
||||
const ZRLE_TILE_WIDTH = 64;
|
||||
const ZRLE_TILE_HEIGHT = 64;
|
||||
|
||||
export default class ZRLEDecoder {
|
||||
constructor() {
|
||||
this._length = 0;
|
||||
this._inflator = new Inflate();
|
||||
|
||||
this._pixelBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
||||
this._tileBuffer = new Uint8Array(ZRLE_TILE_WIDTH * ZRLE_TILE_HEIGHT * 4);
|
||||
}
|
||||
|
||||
decodeRect(x, y, width, height, sock, display, depth) {
|
||||
if (this._length === 0) {
|
||||
if (sock.rQwait("ZLib data length", 4)) {
|
||||
return false;
|
||||
}
|
||||
this._length = sock.rQshift32();
|
||||
}
|
||||
if (sock.rQwait("Zlib data", this._length)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const data = sock.rQshiftBytes(this._length);
|
||||
|
||||
this._inflator.setInput(data);
|
||||
|
||||
for (let ty = y; ty < y + height; ty += ZRLE_TILE_HEIGHT) {
|
||||
let th = Math.min(ZRLE_TILE_HEIGHT, y + height - ty);
|
||||
|
||||
for (let tx = x; tx < x + width; tx += ZRLE_TILE_WIDTH) {
|
||||
let tw = Math.min(ZRLE_TILE_WIDTH, x + width - tx);
|
||||
|
||||
const tileSize = tw * th;
|
||||
const subencoding = this._inflator.inflate(1)[0];
|
||||
if (subencoding === 0) {
|
||||
// raw data
|
||||
const data = this._readPixels(tileSize);
|
||||
display.blitImage(tx, ty, tw, th, data, 0, false);
|
||||
} else if (subencoding === 1) {
|
||||
// solid
|
||||
const background = this._readPixels(1);
|
||||
display.fillRect(tx, ty, tw, th, [background[0], background[1], background[2]]);
|
||||
} else if (subencoding >= 2 && subencoding <= 16) {
|
||||
const data = this._decodePaletteTile(subencoding, tileSize, tw, th);
|
||||
display.blitImage(tx, ty, tw, th, data, 0, false);
|
||||
} else if (subencoding === 128) {
|
||||
const data = this._decodeRLETile(tileSize);
|
||||
display.blitImage(tx, ty, tw, th, data, 0, false);
|
||||
} else if (subencoding >= 130 && subencoding <= 255) {
|
||||
const data = this._decodeRLEPaletteTile(subencoding - 128, tileSize);
|
||||
display.blitImage(tx, ty, tw, th, data, 0, false);
|
||||
} else {
|
||||
throw new Error('Unknown subencoding: ' + subencoding);
|
||||
}
|
||||
}
|
||||
}
|
||||
this._length = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
_getBitsPerPixelInPalette(paletteSize) {
|
||||
if (paletteSize <= 2) {
|
||||
return 1;
|
||||
} else if (paletteSize <= 4) {
|
||||
return 2;
|
||||
} else if (paletteSize <= 16) {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
_readPixels(pixels) {
|
||||
let data = this._pixelBuffer;
|
||||
const buffer = this._inflator.inflate(3*pixels);
|
||||
for (let i = 0, j = 0; i < pixels*4; i += 4, j += 3) {
|
||||
data[i] = buffer[j];
|
||||
data[i + 1] = buffer[j + 1];
|
||||
data[i + 2] = buffer[j + 2];
|
||||
data[i + 3] = 255; // Add the Alpha
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
_decodePaletteTile(paletteSize, tileSize, tilew, tileh) {
|
||||
const data = this._tileBuffer;
|
||||
const palette = this._readPixels(paletteSize);
|
||||
const bitsPerPixel = this._getBitsPerPixelInPalette(paletteSize);
|
||||
const mask = (1 << bitsPerPixel) - 1;
|
||||
|
||||
let offset = 0;
|
||||
let encoded = this._inflator.inflate(1)[0];
|
||||
|
||||
for (let y=0; y<tileh; y++) {
|
||||
let shift = 8-bitsPerPixel;
|
||||
for (let x=0; x<tilew; x++) {
|
||||
if (shift<0) {
|
||||
shift=8-bitsPerPixel;
|
||||
encoded = this._inflator.inflate(1)[0];
|
||||
}
|
||||
let indexInPalette = (encoded>>shift) & mask;
|
||||
|
||||
data[offset] = palette[indexInPalette * 4];
|
||||
data[offset + 1] = palette[indexInPalette * 4 + 1];
|
||||
data[offset + 2] = palette[indexInPalette * 4 + 2];
|
||||
data[offset + 3] = palette[indexInPalette * 4 + 3];
|
||||
offset += 4;
|
||||
shift-=bitsPerPixel;
|
||||
}
|
||||
if (shift<8-bitsPerPixel && y<tileh-1) {
|
||||
encoded = this._inflator.inflate(1)[0];
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
_decodeRLETile(tileSize) {
|
||||
const data = this._tileBuffer;
|
||||
let i = 0;
|
||||
while (i < tileSize) {
|
||||
const pixel = this._readPixels(1);
|
||||
const length = this._readRLELength();
|
||||
for (let j = 0; j < length; j++) {
|
||||
data[i * 4] = pixel[0];
|
||||
data[i * 4 + 1] = pixel[1];
|
||||
data[i * 4 + 2] = pixel[2];
|
||||
data[i * 4 + 3] = pixel[3];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
_decodeRLEPaletteTile(paletteSize, tileSize) {
|
||||
const data = this._tileBuffer;
|
||||
|
||||
// palette
|
||||
const palette = this._readPixels(paletteSize);
|
||||
|
||||
let offset = 0;
|
||||
while (offset < tileSize) {
|
||||
let indexInPalette = this._inflator.inflate(1)[0];
|
||||
let length = 1;
|
||||
if (indexInPalette >= 128) {
|
||||
indexInPalette -= 128;
|
||||
length = this._readRLELength();
|
||||
}
|
||||
if (indexInPalette > paletteSize) {
|
||||
throw new Error('Too big index in palette: ' + indexInPalette + ', palette size: ' + paletteSize);
|
||||
}
|
||||
if (offset + length > tileSize) {
|
||||
throw new Error('Too big rle length in palette mode: ' + length + ', allowed length is: ' + (tileSize - offset));
|
||||
}
|
||||
|
||||
for (let j = 0; j < length; j++) {
|
||||
data[offset * 4] = palette[indexInPalette * 4];
|
||||
data[offset * 4 + 1] = palette[indexInPalette * 4 + 1];
|
||||
data[offset * 4 + 2] = palette[indexInPalette * 4 + 2];
|
||||
data[offset * 4 + 3] = palette[indexInPalette * 4 + 3];
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
_readRLELength() {
|
||||
let length = 0;
|
||||
let current = 0;
|
||||
do {
|
||||
current = this._inflator.inflate(1)[0];
|
||||
length += current;
|
||||
} while (current === 255);
|
||||
return length + 1;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,9 @@ export const encodings = {
|
||||
encodingRRE: 2,
|
||||
encodingHextile: 5,
|
||||
encodingTight: 7,
|
||||
encodingZRLE: 16,
|
||||
encodingTightPNG: -260,
|
||||
encodingJPEG: 21,
|
||||
|
||||
pseudoEncodingQualityLevel9: -23,
|
||||
pseudoEncodingQualityLevel0: -32,
|
||||
@@ -38,7 +40,9 @@ export function encodingName(num) {
|
||||
case encodings.encodingRRE: return "RRE";
|
||||
case encodings.encodingHextile: return "Hextile";
|
||||
case encodings.encodingTight: return "Tight";
|
||||
case encodings.encodingZRLE: return "ZRLE";
|
||||
case encodings.encodingTightPNG: return "TightPNG";
|
||||
case encodings.encodingJPEG: return "JPEG";
|
||||
default: return "[unknown encoding " + num + "]";
|
||||
}
|
||||
}
|
||||
|
||||
567
public/novnc/core/ra2.js
Normal file
@@ -0,0 +1,567 @@
|
||||
import Base64 from './base64.js';
|
||||
import { encodeUTF8 } from './util/strings.js';
|
||||
import EventTargetMixin from './util/eventtarget.js';
|
||||
|
||||
export class AESEAXCipher {
|
||||
constructor() {
|
||||
this._rawKey = null;
|
||||
this._ctrKey = null;
|
||||
this._cbcKey = null;
|
||||
this._zeroBlock = new Uint8Array(16);
|
||||
this._prefixBlock0 = this._zeroBlock;
|
||||
this._prefixBlock1 = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
this._prefixBlock2 = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]);
|
||||
}
|
||||
|
||||
async _encryptBlock(block) {
|
||||
const encrypted = await window.crypto.subtle.encrypt({
|
||||
name: "AES-CBC",
|
||||
iv: this._zeroBlock,
|
||||
}, this._cbcKey, block);
|
||||
return new Uint8Array(encrypted).slice(0, 16);
|
||||
}
|
||||
|
||||
async _initCMAC() {
|
||||
const k1 = await this._encryptBlock(this._zeroBlock);
|
||||
const k2 = new Uint8Array(16);
|
||||
const v = k1[0] >>> 6;
|
||||
for (let i = 0; i < 15; i++) {
|
||||
k2[i] = (k1[i + 1] >> 6) | (k1[i] << 2);
|
||||
k1[i] = (k1[i + 1] >> 7) | (k1[i] << 1);
|
||||
}
|
||||
const lut = [0x0, 0x87, 0x0e, 0x89];
|
||||
k2[14] ^= v >>> 1;
|
||||
k2[15] = (k1[15] << 2) ^ lut[v];
|
||||
k1[15] = (k1[15] << 1) ^ lut[v >> 1];
|
||||
this._k1 = k1;
|
||||
this._k2 = k2;
|
||||
}
|
||||
|
||||
async _encryptCTR(data, counter) {
|
||||
const encrypted = await window.crypto.subtle.encrypt({
|
||||
"name": "AES-CTR",
|
||||
counter: counter,
|
||||
length: 128
|
||||
}, this._ctrKey, data);
|
||||
return new Uint8Array(encrypted);
|
||||
}
|
||||
|
||||
async _decryptCTR(data, counter) {
|
||||
const decrypted = await window.crypto.subtle.decrypt({
|
||||
"name": "AES-CTR",
|
||||
counter: counter,
|
||||
length: 128
|
||||
}, this._ctrKey, data);
|
||||
return new Uint8Array(decrypted);
|
||||
}
|
||||
|
||||
async _computeCMAC(data, prefixBlock) {
|
||||
if (prefixBlock.length !== 16) {
|
||||
return null;
|
||||
}
|
||||
const n = Math.floor(data.length / 16);
|
||||
const m = Math.ceil(data.length / 16);
|
||||
const r = data.length - n * 16;
|
||||
const cbcData = new Uint8Array((m + 1) * 16);
|
||||
cbcData.set(prefixBlock);
|
||||
cbcData.set(data, 16);
|
||||
if (r === 0) {
|
||||
for (let i = 0; i < 16; i++) {
|
||||
cbcData[n * 16 + i] ^= this._k1[i];
|
||||
}
|
||||
} else {
|
||||
cbcData[(n + 1) * 16 + r] = 0x80;
|
||||
for (let i = 0; i < 16; i++) {
|
||||
cbcData[(n + 1) * 16 + i] ^= this._k2[i];
|
||||
}
|
||||
}
|
||||
let cbcEncrypted = await window.crypto.subtle.encrypt({
|
||||
name: "AES-CBC",
|
||||
iv: this._zeroBlock,
|
||||
}, this._cbcKey, cbcData);
|
||||
|
||||
cbcEncrypted = new Uint8Array(cbcEncrypted);
|
||||
const mac = cbcEncrypted.slice(cbcEncrypted.length - 32, cbcEncrypted.length - 16);
|
||||
return mac;
|
||||
}
|
||||
|
||||
async setKey(key) {
|
||||
this._rawKey = key;
|
||||
this._ctrKey = await window.crypto.subtle.importKey(
|
||||
"raw", key, {"name": "AES-CTR"}, false, ["encrypt", "decrypt"]);
|
||||
this._cbcKey = await window.crypto.subtle.importKey(
|
||||
"raw", key, {"name": "AES-CBC"}, false, ["encrypt", "decrypt"]);
|
||||
await this._initCMAC();
|
||||
}
|
||||
|
||||
async encrypt(message, associatedData, nonce) {
|
||||
const nCMAC = await this._computeCMAC(nonce, this._prefixBlock0);
|
||||
const encrypted = await this._encryptCTR(message, nCMAC);
|
||||
const adCMAC = await this._computeCMAC(associatedData, this._prefixBlock1);
|
||||
const mac = await this._computeCMAC(encrypted, this._prefixBlock2);
|
||||
for (let i = 0; i < 16; i++) {
|
||||
mac[i] ^= nCMAC[i] ^ adCMAC[i];
|
||||
}
|
||||
const res = new Uint8Array(16 + encrypted.length);
|
||||
res.set(encrypted);
|
||||
res.set(mac, encrypted.length);
|
||||
return res;
|
||||
}
|
||||
|
||||
async decrypt(encrypted, associatedData, nonce, mac) {
|
||||
const nCMAC = await this._computeCMAC(nonce, this._prefixBlock0);
|
||||
const adCMAC = await this._computeCMAC(associatedData, this._prefixBlock1);
|
||||
const computedMac = await this._computeCMAC(encrypted, this._prefixBlock2);
|
||||
for (let i = 0; i < 16; i++) {
|
||||
computedMac[i] ^= nCMAC[i] ^ adCMAC[i];
|
||||
}
|
||||
if (computedMac.length !== mac.length) {
|
||||
return null;
|
||||
}
|
||||
for (let i = 0; i < mac.length; i++) {
|
||||
if (computedMac[i] !== mac[i]) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
const res = await this._decryptCTR(encrypted, nCMAC);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
export class RA2Cipher {
|
||||
constructor() {
|
||||
this._cipher = new AESEAXCipher();
|
||||
this._counter = new Uint8Array(16);
|
||||
}
|
||||
|
||||
async setKey(key) {
|
||||
await this._cipher.setKey(key);
|
||||
}
|
||||
|
||||
async makeMessage(message) {
|
||||
const ad = new Uint8Array([(message.length & 0xff00) >>> 8, message.length & 0xff]);
|
||||
const encrypted = await this._cipher.encrypt(message, ad, this._counter);
|
||||
for (let i = 0; i < 16 && this._counter[i]++ === 255; i++);
|
||||
const res = new Uint8Array(message.length + 2 + 16);
|
||||
res.set(ad);
|
||||
res.set(encrypted, 2);
|
||||
return res;
|
||||
}
|
||||
|
||||
async receiveMessage(length, encrypted, mac) {
|
||||
const ad = new Uint8Array([(length & 0xff00) >>> 8, length & 0xff]);
|
||||
const res = await this._cipher.decrypt(encrypted, ad, this._counter, mac);
|
||||
for (let i = 0; i < 16 && this._counter[i]++ === 255; i++);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
export class RSACipher {
|
||||
constructor(keyLength) {
|
||||
this._key = null;
|
||||
this._keyLength = keyLength;
|
||||
this._keyBytes = Math.ceil(keyLength / 8);
|
||||
this._n = null;
|
||||
this._e = null;
|
||||
this._d = null;
|
||||
this._nBigInt = null;
|
||||
this._eBigInt = null;
|
||||
this._dBigInt = null;
|
||||
}
|
||||
|
||||
_base64urlDecode(data) {
|
||||
data = data.replace(/-/g, "+").replace(/_/g, "/");
|
||||
data = data.padEnd(Math.ceil(data.length / 4) * 4, "=");
|
||||
return Base64.decode(data);
|
||||
}
|
||||
|
||||
_u8ArrayToBigInt(arr) {
|
||||
let hex = '0x';
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
hex += arr[i].toString(16).padStart(2, '0');
|
||||
}
|
||||
return BigInt(hex);
|
||||
}
|
||||
|
||||
_padArray(arr, length) {
|
||||
const res = new Uint8Array(length);
|
||||
res.set(arr, length - arr.length);
|
||||
return res;
|
||||
}
|
||||
|
||||
_bigIntToU8Array(bigint, padLength=0) {
|
||||
let hex = bigint.toString(16);
|
||||
if (padLength === 0) {
|
||||
padLength = Math.ceil(hex.length / 2) * 2;
|
||||
}
|
||||
hex = hex.padStart(padLength * 2, '0');
|
||||
const length = hex.length / 2;
|
||||
const arr = new Uint8Array(length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
arr[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
_modPow(b, e, m) {
|
||||
if (m === 1n) {
|
||||
return 0;
|
||||
}
|
||||
let r = 1n;
|
||||
b = b % m;
|
||||
while (e > 0) {
|
||||
if (e % 2n === 1n) {
|
||||
r = (r * b) % m;
|
||||
}
|
||||
e = e / 2n;
|
||||
b = (b * b) % m;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
async generateKey() {
|
||||
this._key = await window.crypto.subtle.generateKey(
|
||||
{
|
||||
name: "RSA-OAEP",
|
||||
modulusLength: this._keyLength,
|
||||
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
|
||||
hash: {name: "SHA-256"},
|
||||
},
|
||||
true, ["encrypt", "decrypt"]);
|
||||
const privateKey = await window.crypto.subtle.exportKey("jwk", this._key.privateKey);
|
||||
this._n = this._padArray(this._base64urlDecode(privateKey.n), this._keyBytes);
|
||||
this._nBigInt = this._u8ArrayToBigInt(this._n);
|
||||
this._e = this._padArray(this._base64urlDecode(privateKey.e), this._keyBytes);
|
||||
this._eBigInt = this._u8ArrayToBigInt(this._e);
|
||||
this._d = this._padArray(this._base64urlDecode(privateKey.d), this._keyBytes);
|
||||
this._dBigInt = this._u8ArrayToBigInt(this._d);
|
||||
}
|
||||
|
||||
setPublicKey(n, e) {
|
||||
if (n.length !== this._keyBytes || e.length !== this._keyBytes) {
|
||||
return;
|
||||
}
|
||||
this._n = new Uint8Array(this._keyBytes);
|
||||
this._e = new Uint8Array(this._keyBytes);
|
||||
this._n.set(n);
|
||||
this._e.set(e);
|
||||
this._nBigInt = this._u8ArrayToBigInt(this._n);
|
||||
this._eBigInt = this._u8ArrayToBigInt(this._e);
|
||||
}
|
||||
|
||||
encrypt(message) {
|
||||
if (message.length > this._keyBytes - 11) {
|
||||
return null;
|
||||
}
|
||||
const ps = new Uint8Array(this._keyBytes - message.length - 3);
|
||||
window.crypto.getRandomValues(ps);
|
||||
for (let i = 0; i < ps.length; i++) {
|
||||
ps[i] = Math.floor(ps[i] * 254 / 255 + 1);
|
||||
}
|
||||
const em = new Uint8Array(this._keyBytes);
|
||||
em[1] = 0x02;
|
||||
em.set(ps, 2);
|
||||
em.set(message, ps.length + 3);
|
||||
const emBigInt = this._u8ArrayToBigInt(em);
|
||||
const c = this._modPow(emBigInt, this._eBigInt, this._nBigInt);
|
||||
return this._bigIntToU8Array(c, this._keyBytes);
|
||||
}
|
||||
|
||||
decrypt(message) {
|
||||
if (message.length !== this._keyBytes) {
|
||||
return null;
|
||||
}
|
||||
const msgBigInt = this._u8ArrayToBigInt(message);
|
||||
const emBigInt = this._modPow(msgBigInt, this._dBigInt, this._nBigInt);
|
||||
const em = this._bigIntToU8Array(emBigInt, this._keyBytes);
|
||||
if (em[0] !== 0x00 || em[1] !== 0x02) {
|
||||
return null;
|
||||
}
|
||||
let i = 2;
|
||||
for (; i < em.length; i++) {
|
||||
if (em[i] === 0x00) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === em.length) {
|
||||
return null;
|
||||
}
|
||||
return em.slice(i + 1, em.length);
|
||||
}
|
||||
|
||||
get keyLength() {
|
||||
return this._keyLength;
|
||||
}
|
||||
|
||||
get n() {
|
||||
return this._n;
|
||||
}
|
||||
|
||||
get e() {
|
||||
return this._e;
|
||||
}
|
||||
|
||||
get d() {
|
||||
return this._d;
|
||||
}
|
||||
}
|
||||
|
||||
export default class RSAAESAuthenticationState extends EventTargetMixin {
|
||||
constructor(sock, getCredentials) {
|
||||
super();
|
||||
this._hasStarted = false;
|
||||
this._checkSock = null;
|
||||
this._checkCredentials = null;
|
||||
this._approveServerResolve = null;
|
||||
this._sockReject = null;
|
||||
this._credentialsReject = null;
|
||||
this._approveServerReject = null;
|
||||
this._sock = sock;
|
||||
this._getCredentials = getCredentials;
|
||||
}
|
||||
|
||||
_waitSockAsync(len) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const hasData = () => !this._sock.rQwait('RA2', len);
|
||||
if (hasData()) {
|
||||
resolve();
|
||||
} else {
|
||||
this._checkSock = () => {
|
||||
if (hasData()) {
|
||||
resolve();
|
||||
this._checkSock = null;
|
||||
this._sockReject = null;
|
||||
}
|
||||
};
|
||||
this._sockReject = reject;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_waitApproveKeyAsync() {
|
||||
return new Promise((resolve, reject) => {
|
||||
this._approveServerResolve = resolve;
|
||||
this._approveServerReject = reject;
|
||||
});
|
||||
}
|
||||
|
||||
_waitCredentialsAsync(subtype) {
|
||||
const hasCredentials = () => {
|
||||
if (subtype === 1 && this._getCredentials().username !== undefined &&
|
||||
this._getCredentials().password !== undefined) {
|
||||
return true;
|
||||
} else if (subtype === 2 && this._getCredentials().password !== undefined) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
if (hasCredentials()) {
|
||||
resolve();
|
||||
} else {
|
||||
this._checkCredentials = () => {
|
||||
if (hasCredentials()) {
|
||||
resolve();
|
||||
this._checkCredentials = null;
|
||||
this._credentialsReject = null;
|
||||
}
|
||||
};
|
||||
this._credentialsReject = reject;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
checkInternalEvents() {
|
||||
if (this._checkSock !== null) {
|
||||
this._checkSock();
|
||||
}
|
||||
if (this._checkCredentials !== null) {
|
||||
this._checkCredentials();
|
||||
}
|
||||
}
|
||||
|
||||
approveServer() {
|
||||
if (this._approveServerResolve !== null) {
|
||||
this._approveServerResolve();
|
||||
this._approveServerResolve = null;
|
||||
}
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
if (this._sockReject !== null) {
|
||||
this._sockReject(new Error("disconnect normally"));
|
||||
this._sockReject = null;
|
||||
}
|
||||
if (this._credentialsReject !== null) {
|
||||
this._credentialsReject(new Error("disconnect normally"));
|
||||
this._credentialsReject = null;
|
||||
}
|
||||
if (this._approveServerReject !== null) {
|
||||
this._approveServerReject(new Error("disconnect normally"));
|
||||
this._approveServerReject = null;
|
||||
}
|
||||
}
|
||||
|
||||
async negotiateRA2neAuthAsync() {
|
||||
this._hasStarted = true;
|
||||
// 1: Receive server public key
|
||||
await this._waitSockAsync(4);
|
||||
const serverKeyLengthBuffer = this._sock.rQslice(0, 4);
|
||||
const serverKeyLength = this._sock.rQshift32();
|
||||
if (serverKeyLength < 1024) {
|
||||
throw new Error("RA2: server public key is too short: " + serverKeyLength);
|
||||
} else if (serverKeyLength > 8192) {
|
||||
throw new Error("RA2: server public key is too long: " + serverKeyLength);
|
||||
}
|
||||
const serverKeyBytes = Math.ceil(serverKeyLength / 8);
|
||||
await this._waitSockAsync(serverKeyBytes * 2);
|
||||
const serverN = this._sock.rQshiftBytes(serverKeyBytes);
|
||||
const serverE = this._sock.rQshiftBytes(serverKeyBytes);
|
||||
const serverRSACipher = new RSACipher(serverKeyLength);
|
||||
serverRSACipher.setPublicKey(serverN, serverE);
|
||||
const serverPublickey = new Uint8Array(4 + serverKeyBytes * 2);
|
||||
serverPublickey.set(serverKeyLengthBuffer);
|
||||
serverPublickey.set(serverN, 4);
|
||||
serverPublickey.set(serverE, 4 + serverKeyBytes);
|
||||
|
||||
// verify server public key
|
||||
this.dispatchEvent(new CustomEvent("serververification", {
|
||||
detail: { type: "RSA", publickey: serverPublickey }
|
||||
}));
|
||||
await this._waitApproveKeyAsync();
|
||||
|
||||
// 2: Send client public key
|
||||
const clientKeyLength = 2048;
|
||||
const clientKeyBytes = Math.ceil(clientKeyLength / 8);
|
||||
const clientRSACipher = new RSACipher(clientKeyLength);
|
||||
await clientRSACipher.generateKey();
|
||||
const clientN = clientRSACipher.n;
|
||||
const clientE = clientRSACipher.e;
|
||||
const clientPublicKey = new Uint8Array(4 + clientKeyBytes * 2);
|
||||
clientPublicKey[0] = (clientKeyLength & 0xff000000) >>> 24;
|
||||
clientPublicKey[1] = (clientKeyLength & 0xff0000) >>> 16;
|
||||
clientPublicKey[2] = (clientKeyLength & 0xff00) >>> 8;
|
||||
clientPublicKey[3] = clientKeyLength & 0xff;
|
||||
clientPublicKey.set(clientN, 4);
|
||||
clientPublicKey.set(clientE, 4 + clientKeyBytes);
|
||||
this._sock.send(clientPublicKey);
|
||||
|
||||
// 3: Send client random
|
||||
const clientRandom = new Uint8Array(16);
|
||||
window.crypto.getRandomValues(clientRandom);
|
||||
const clientEncryptedRandom = serverRSACipher.encrypt(clientRandom);
|
||||
const clientRandomMessage = new Uint8Array(2 + serverKeyBytes);
|
||||
clientRandomMessage[0] = (serverKeyBytes & 0xff00) >>> 8;
|
||||
clientRandomMessage[1] = serverKeyBytes & 0xff;
|
||||
clientRandomMessage.set(clientEncryptedRandom, 2);
|
||||
this._sock.send(clientRandomMessage);
|
||||
|
||||
// 4: Receive server random
|
||||
await this._waitSockAsync(2);
|
||||
if (this._sock.rQshift16() !== clientKeyBytes) {
|
||||
throw new Error("RA2: wrong encrypted message length");
|
||||
}
|
||||
const serverEncryptedRandom = this._sock.rQshiftBytes(clientKeyBytes);
|
||||
const serverRandom = clientRSACipher.decrypt(serverEncryptedRandom);
|
||||
if (serverRandom === null || serverRandom.length !== 16) {
|
||||
throw new Error("RA2: corrupted server encrypted random");
|
||||
}
|
||||
|
||||
// 5: Compute session keys and set ciphers
|
||||
let clientSessionKey = new Uint8Array(32);
|
||||
let serverSessionKey = new Uint8Array(32);
|
||||
clientSessionKey.set(serverRandom);
|
||||
clientSessionKey.set(clientRandom, 16);
|
||||
serverSessionKey.set(clientRandom);
|
||||
serverSessionKey.set(serverRandom, 16);
|
||||
clientSessionKey = await window.crypto.subtle.digest("SHA-1", clientSessionKey);
|
||||
clientSessionKey = new Uint8Array(clientSessionKey).slice(0, 16);
|
||||
serverSessionKey = await window.crypto.subtle.digest("SHA-1", serverSessionKey);
|
||||
serverSessionKey = new Uint8Array(serverSessionKey).slice(0, 16);
|
||||
const clientCipher = new RA2Cipher();
|
||||
await clientCipher.setKey(clientSessionKey);
|
||||
const serverCipher = new RA2Cipher();
|
||||
await serverCipher.setKey(serverSessionKey);
|
||||
|
||||
// 6: Compute and exchange hashes
|
||||
let serverHash = new Uint8Array(8 + serverKeyBytes * 2 + clientKeyBytes * 2);
|
||||
let clientHash = new Uint8Array(8 + serverKeyBytes * 2 + clientKeyBytes * 2);
|
||||
serverHash.set(serverPublickey);
|
||||
serverHash.set(clientPublicKey, 4 + serverKeyBytes * 2);
|
||||
clientHash.set(clientPublicKey);
|
||||
clientHash.set(serverPublickey, 4 + clientKeyBytes * 2);
|
||||
serverHash = await window.crypto.subtle.digest("SHA-1", serverHash);
|
||||
clientHash = await window.crypto.subtle.digest("SHA-1", clientHash);
|
||||
serverHash = new Uint8Array(serverHash);
|
||||
clientHash = new Uint8Array(clientHash);
|
||||
this._sock.send(await clientCipher.makeMessage(clientHash));
|
||||
await this._waitSockAsync(2 + 20 + 16);
|
||||
if (this._sock.rQshift16() !== 20) {
|
||||
throw new Error("RA2: wrong server hash");
|
||||
}
|
||||
const serverHashReceived = await serverCipher.receiveMessage(
|
||||
20, this._sock.rQshiftBytes(20), this._sock.rQshiftBytes(16));
|
||||
if (serverHashReceived === null) {
|
||||
throw new Error("RA2: failed to authenticate the message");
|
||||
}
|
||||
for (let i = 0; i < 20; i++) {
|
||||
if (serverHashReceived[i] !== serverHash[i]) {
|
||||
throw new Error("RA2: wrong server hash");
|
||||
}
|
||||
}
|
||||
|
||||
// 7: Receive subtype
|
||||
await this._waitSockAsync(2 + 1 + 16);
|
||||
if (this._sock.rQshift16() !== 1) {
|
||||
throw new Error("RA2: wrong subtype");
|
||||
}
|
||||
let subtype = (await serverCipher.receiveMessage(
|
||||
1, this._sock.rQshiftBytes(1), this._sock.rQshiftBytes(16)));
|
||||
if (subtype === null) {
|
||||
throw new Error("RA2: failed to authenticate the message");
|
||||
}
|
||||
subtype = subtype[0];
|
||||
if (subtype === 1) {
|
||||
if (this._getCredentials().username === undefined ||
|
||||
this._getCredentials().password === undefined) {
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
"credentialsrequired",
|
||||
{ detail: { types: ["username", "password"] } }));
|
||||
}
|
||||
} else if (subtype === 2) {
|
||||
if (this._getCredentials().password === undefined) {
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
"credentialsrequired",
|
||||
{ detail: { types: ["password"] } }));
|
||||
}
|
||||
} else {
|
||||
throw new Error("RA2: wrong subtype");
|
||||
}
|
||||
await this._waitCredentialsAsync(subtype);
|
||||
let username;
|
||||
if (subtype === 1) {
|
||||
username = encodeUTF8(this._getCredentials().username).slice(0, 255);
|
||||
} else {
|
||||
username = "";
|
||||
}
|
||||
const password = encodeUTF8(this._getCredentials().password).slice(0, 255);
|
||||
const credentials = new Uint8Array(username.length + password.length + 2);
|
||||
credentials[0] = username.length;
|
||||
credentials[username.length + 1] = password.length;
|
||||
for (let i = 0; i < username.length; i++) {
|
||||
credentials[i + 1] = username.charCodeAt(i);
|
||||
}
|
||||
for (let i = 0; i < password.length; i++) {
|
||||
credentials[username.length + 2 + i] = password.charCodeAt(i);
|
||||
}
|
||||
this._sock.send(await clientCipher.makeMessage(credentials));
|
||||
}
|
||||
|
||||
get hasStarted() {
|
||||
return this._hasStarted;
|
||||
}
|
||||
|
||||
set hasStarted(s) {
|
||||
this._hasStarted = s;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,8 @@ import DES from "./des.js";
|
||||
import KeyTable from "./input/keysym.js";
|
||||
import XtScancode from "./input/xtscancodes.js";
|
||||
import { encodings } from "./encodings.js";
|
||||
import RSAAESAuthenticationState from "./ra2.js";
|
||||
import { MD5 } from "./util/md5.js";
|
||||
|
||||
import RawDecoder from "./decoders/raw.js";
|
||||
import CopyRectDecoder from "./decoders/copyrect.js";
|
||||
@@ -32,6 +34,8 @@ import RREDecoder from "./decoders/rre.js";
|
||||
import HextileDecoder from "./decoders/hextile.js";
|
||||
import TightDecoder from "./decoders/tight.js";
|
||||
import TightPNGDecoder from "./decoders/tightpng.js";
|
||||
import ZRLEDecoder from "./decoders/zrle.js";
|
||||
import JPEGDecoder from "./decoders/jpeg.js";
|
||||
|
||||
// How many seconds to wait for a disconnect to finish
|
||||
const DISCONNECT_TIMEOUT = 3;
|
||||
@@ -75,6 +79,12 @@ export default class RFB extends EventTargetMixin {
|
||||
throw new Error("Must specify URL, WebSocket or RTCDataChannel");
|
||||
}
|
||||
|
||||
// We rely on modern APIs which might not be available in an
|
||||
// insecure context
|
||||
if (!window.isSecureContext) {
|
||||
Log.Error("noVNC requires a secure context (TLS). Expect crashes!");
|
||||
}
|
||||
|
||||
super();
|
||||
|
||||
this._target = target;
|
||||
@@ -98,6 +108,7 @@ export default class RFB extends EventTargetMixin {
|
||||
this._rfbInitState = '';
|
||||
this._rfbAuthScheme = -1;
|
||||
this._rfbCleanDisconnect = true;
|
||||
this._rfbRSAAESAuthenticationState = null;
|
||||
|
||||
// Server capabilities
|
||||
this._rfbVersion = 0;
|
||||
@@ -176,6 +187,8 @@ export default class RFB extends EventTargetMixin {
|
||||
handleMouse: this._handleMouse.bind(this),
|
||||
handleWheel: this._handleWheel.bind(this),
|
||||
handleGesture: this._handleGesture.bind(this),
|
||||
handleRSAAESCredentialsRequired: this._handleRSAAESCredentialsRequired.bind(this),
|
||||
handleRSAAESServerVerification: this._handleRSAAESServerVerification.bind(this),
|
||||
};
|
||||
|
||||
// main setup
|
||||
@@ -218,6 +231,8 @@ export default class RFB extends EventTargetMixin {
|
||||
this._decoders[encodings.encodingHextile] = new HextileDecoder();
|
||||
this._decoders[encodings.encodingTight] = new TightDecoder();
|
||||
this._decoders[encodings.encodingTightPNG] = new TightPNGDecoder();
|
||||
this._decoders[encodings.encodingZRLE] = new ZRLEDecoder();
|
||||
this._decoders[encodings.encodingJPEG] = new JPEGDecoder();
|
||||
|
||||
// NB: nothing that needs explicit teardown should be done
|
||||
// before this point, since this can throw an exception
|
||||
@@ -240,6 +255,8 @@ export default class RFB extends EventTargetMixin {
|
||||
this._sock.on('message', this._handleMessage.bind(this));
|
||||
this._sock.on('error', this._socketError.bind(this));
|
||||
|
||||
this._expectedClientWidth = null;
|
||||
this._expectedClientHeight = null;
|
||||
this._resizeObserver = new ResizeObserver(this._eventHandlers.handleResize);
|
||||
|
||||
// All prepared, kick off the connection
|
||||
@@ -372,6 +389,15 @@ export default class RFB extends EventTargetMixin {
|
||||
this._sock.off('error');
|
||||
this._sock.off('message');
|
||||
this._sock.off('open');
|
||||
if (this._rfbRSAAESAuthenticationState !== null) {
|
||||
this._rfbRSAAESAuthenticationState.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
approveServer() {
|
||||
if (this._rfbRSAAESAuthenticationState !== null) {
|
||||
this._rfbRSAAESAuthenticationState.approveServer();
|
||||
}
|
||||
}
|
||||
|
||||
sendCredentials(creds) {
|
||||
@@ -432,8 +458,8 @@ export default class RFB extends EventTargetMixin {
|
||||
}
|
||||
}
|
||||
|
||||
focus() {
|
||||
this._canvas.focus();
|
||||
focus(options) {
|
||||
this._canvas.focus(options);
|
||||
}
|
||||
|
||||
blur() {
|
||||
@@ -609,7 +635,7 @@ export default class RFB extends EventTargetMixin {
|
||||
return;
|
||||
}
|
||||
|
||||
this.focus();
|
||||
this.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
_setDesktopName(name) {
|
||||
@@ -619,7 +645,26 @@ export default class RFB extends EventTargetMixin {
|
||||
{ detail: { name: this._fbName } }));
|
||||
}
|
||||
|
||||
_saveExpectedClientSize() {
|
||||
this._expectedClientWidth = this._screen.clientWidth;
|
||||
this._expectedClientHeight = this._screen.clientHeight;
|
||||
}
|
||||
|
||||
_currentClientSize() {
|
||||
return [this._screen.clientWidth, this._screen.clientHeight];
|
||||
}
|
||||
|
||||
_clientHasExpectedSize() {
|
||||
const [currentWidth, currentHeight] = this._currentClientSize();
|
||||
return currentWidth == this._expectedClientWidth &&
|
||||
currentHeight == this._expectedClientHeight;
|
||||
}
|
||||
|
||||
_handleResize() {
|
||||
// Don't change anything if the client size is already as expected
|
||||
if (this._clientHasExpectedSize()) {
|
||||
return;
|
||||
}
|
||||
// If the window resized then our screen element might have
|
||||
// as well. Update the viewport dimensions.
|
||||
window.requestAnimationFrame(() => {
|
||||
@@ -660,6 +705,12 @@ export default class RFB extends EventTargetMixin {
|
||||
this._display.viewportChangeSize(size.w, size.h);
|
||||
this._fixScrollbars();
|
||||
}
|
||||
|
||||
// When changing clipping we might show or hide scrollbars.
|
||||
// This causes the expected client dimensions to change.
|
||||
if (curClip !== newClip) {
|
||||
this._saveExpectedClientSize();
|
||||
}
|
||||
}
|
||||
|
||||
_updateScale() {
|
||||
@@ -684,6 +735,7 @@ export default class RFB extends EventTargetMixin {
|
||||
}
|
||||
|
||||
const size = this._screenSize();
|
||||
|
||||
RFB.messages.setDesktopSize(this._sock,
|
||||
Math.floor(size.w), Math.floor(size.h),
|
||||
this._screenID, this._screenFlags);
|
||||
@@ -699,12 +751,13 @@ export default class RFB extends EventTargetMixin {
|
||||
}
|
||||
|
||||
_fixScrollbars() {
|
||||
// This is a hack because Chrome screws up the calculation
|
||||
// for when scrollbars are needed. So to fix it we temporarily
|
||||
// toggle them off and on.
|
||||
// This is a hack because Safari on macOS screws up the calculation
|
||||
// for when scrollbars are needed. We get scrollbars when making the
|
||||
// browser smaller, despite remote resize being enabled. So to fix it
|
||||
// we temporarily toggle them off and on.
|
||||
const orig = this._screen.style.overflow;
|
||||
this._screen.style.overflow = 'hidden';
|
||||
// Force Chrome to recalculate the layout by asking for
|
||||
// Force Safari to recalculate the layout by asking for
|
||||
// an element's dimensions
|
||||
this._screen.getBoundingClientRect();
|
||||
this._screen.style.overflow = orig;
|
||||
@@ -1242,13 +1295,13 @@ export default class RFB extends EventTargetMixin {
|
||||
break;
|
||||
case "003.003":
|
||||
case "003.006": // UltraVNC
|
||||
case "003.889": // Apple Remote Desktop
|
||||
this._rfbVersion = 3.3;
|
||||
break;
|
||||
case "003.007":
|
||||
this._rfbVersion = 3.7;
|
||||
break;
|
||||
case "003.008":
|
||||
case "003.889": // Apple Remote Desktop
|
||||
case "004.000": // Intel AMT KVM
|
||||
case "004.001": // RealVNC 4.6
|
||||
case "005.000": // RealVNC 5.3
|
||||
@@ -1302,8 +1355,12 @@ export default class RFB extends EventTargetMixin {
|
||||
this._rfbAuthScheme = 22; // XVP
|
||||
} else if (types.includes(16)) {
|
||||
this._rfbAuthScheme = 16; // Tight
|
||||
} else if (types.includes(6)) {
|
||||
this._rfbAuthScheme = 6; // RA2ne Auth
|
||||
} else if (types.includes(2)) {
|
||||
this._rfbAuthScheme = 2; // VNC Auth
|
||||
} else if (types.includes(30)) {
|
||||
this._rfbAuthScheme = 30; // ARD Auth
|
||||
} else if (types.includes(19)) {
|
||||
this._rfbAuthScheme = 19; // VeNCrypt Auth
|
||||
} else {
|
||||
@@ -1496,6 +1553,117 @@ export default class RFB extends EventTargetMixin {
|
||||
return true;
|
||||
}
|
||||
|
||||
_negotiateARDAuth() {
|
||||
|
||||
if (this._rfbCredentials.username === undefined ||
|
||||
this._rfbCredentials.password === undefined) {
|
||||
this.dispatchEvent(new CustomEvent(
|
||||
"credentialsrequired",
|
||||
{ detail: { types: ["username", "password"] } }));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._rfbCredentials.ardPublicKey != undefined &&
|
||||
this._rfbCredentials.ardCredentials != undefined) {
|
||||
// if the async web crypto is done return the results
|
||||
this._sock.send(this._rfbCredentials.ardCredentials);
|
||||
this._sock.send(this._rfbCredentials.ardPublicKey);
|
||||
this._rfbCredentials.ardCredentials = null;
|
||||
this._rfbCredentials.ardPublicKey = null;
|
||||
this._rfbInitState = "SecurityResult";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this._sock.rQwait("read ard", 4)) { return false; }
|
||||
|
||||
let generator = this._sock.rQshiftBytes(2); // DH base generator value
|
||||
|
||||
let keyLength = this._sock.rQshift16();
|
||||
|
||||
if (this._sock.rQwait("read ard keylength", keyLength*2, 4)) { return false; }
|
||||
|
||||
// read the server values
|
||||
let prime = this._sock.rQshiftBytes(keyLength); // predetermined prime modulus
|
||||
let serverPublicKey = this._sock.rQshiftBytes(keyLength); // other party's public key
|
||||
|
||||
let clientPrivateKey = window.crypto.getRandomValues(new Uint8Array(keyLength));
|
||||
let padding = Array.from(window.crypto.getRandomValues(new Uint8Array(64)), byte => String.fromCharCode(65+byte%26)).join('');
|
||||
|
||||
this._negotiateARDAuthAsync(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
_modPow(base, exponent, modulus) {
|
||||
|
||||
let baseHex = "0x"+Array.from(base, byte => ('0' + (byte & 0xFF).toString(16)).slice(-2)).join('');
|
||||
let exponentHex = "0x"+Array.from(exponent, byte => ('0' + (byte & 0xFF).toString(16)).slice(-2)).join('');
|
||||
let modulusHex = "0x"+Array.from(modulus, byte => ('0' + (byte & 0xFF).toString(16)).slice(-2)).join('');
|
||||
|
||||
let b = BigInt(baseHex);
|
||||
let e = BigInt(exponentHex);
|
||||
let m = BigInt(modulusHex);
|
||||
let r = 1n;
|
||||
b = b % m;
|
||||
while (e > 0) {
|
||||
if (e % 2n === 1n) {
|
||||
r = (r * b) % m;
|
||||
}
|
||||
e = e / 2n;
|
||||
b = (b * b) % m;
|
||||
}
|
||||
let hexResult = r.toString(16);
|
||||
|
||||
while (hexResult.length/2<exponent.length || (hexResult.length%2 != 0)) {
|
||||
hexResult = "0"+hexResult;
|
||||
}
|
||||
|
||||
let bytesResult = [];
|
||||
for (let c = 0; c < hexResult.length; c += 2) {
|
||||
bytesResult.push(parseInt(hexResult.substr(c, 2), 16));
|
||||
}
|
||||
return bytesResult;
|
||||
}
|
||||
|
||||
async _aesEcbEncrypt(string, key) {
|
||||
// perform AES-ECB blocks
|
||||
let keyString = Array.from(key, byte => String.fromCharCode(byte)).join('');
|
||||
let aesKey = await window.crypto.subtle.importKey("raw", MD5(keyString), {name: "AES-CBC"}, false, ["encrypt"]);
|
||||
let data = new Uint8Array(string.length);
|
||||
for (let i = 0; i < string.length; ++i) {
|
||||
data[i] = string.charCodeAt(i);
|
||||
}
|
||||
let encrypted = new Uint8Array(data.length);
|
||||
for (let i=0;i<data.length;i+=16) {
|
||||
let block = data.slice(i, i+16);
|
||||
let encryptedBlock = await window.crypto.subtle.encrypt({name: "AES-CBC", iv: block},
|
||||
aesKey, new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
||||
);
|
||||
encrypted.set((new Uint8Array(encryptedBlock)).slice(0, 16), i);
|
||||
}
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
async _negotiateARDAuthAsync(generator, keyLength, prime, serverPublicKey, clientPrivateKey, padding) {
|
||||
// calculate the DH keys
|
||||
let clientPublicKey = this._modPow(generator, clientPrivateKey, prime);
|
||||
let sharedKey = this._modPow(serverPublicKey, clientPrivateKey, prime);
|
||||
|
||||
let username = encodeUTF8(this._rfbCredentials.username).substring(0, 63);
|
||||
let password = encodeUTF8(this._rfbCredentials.password).substring(0, 63);
|
||||
|
||||
let paddedUsername = username + '\0' + padding.substring(0, 63);
|
||||
let paddedPassword = password + '\0' + padding.substring(0, 63);
|
||||
let credentials = paddedUsername.substring(0, 64) + paddedPassword.substring(0, 64);
|
||||
|
||||
let encrypted = await this._aesEcbEncrypt(credentials, sharedKey);
|
||||
|
||||
this._rfbCredentials.ardCredentials = encrypted;
|
||||
this._rfbCredentials.ardPublicKey = clientPublicKey;
|
||||
|
||||
setTimeout(this._initMsg.bind(this), 0);
|
||||
}
|
||||
|
||||
_negotiateTightUnixAuth() {
|
||||
if (this._rfbCredentials.username === undefined ||
|
||||
this._rfbCredentials.password === undefined) {
|
||||
@@ -1619,6 +1787,44 @@ export default class RFB extends EventTargetMixin {
|
||||
return this._fail("No supported sub-auth types!");
|
||||
}
|
||||
|
||||
_handleRSAAESCredentialsRequired(event) {
|
||||
this.dispatchEvent(event);
|
||||
}
|
||||
|
||||
_handleRSAAESServerVerification(event) {
|
||||
this.dispatchEvent(event);
|
||||
}
|
||||
|
||||
_negotiateRA2neAuth() {
|
||||
if (this._rfbRSAAESAuthenticationState === null) {
|
||||
this._rfbRSAAESAuthenticationState = new RSAAESAuthenticationState(this._sock, () => this._rfbCredentials);
|
||||
this._rfbRSAAESAuthenticationState.addEventListener(
|
||||
"serververification", this._eventHandlers.handleRSAAESServerVerification);
|
||||
this._rfbRSAAESAuthenticationState.addEventListener(
|
||||
"credentialsrequired", this._eventHandlers.handleRSAAESCredentialsRequired);
|
||||
}
|
||||
this._rfbRSAAESAuthenticationState.checkInternalEvents();
|
||||
if (!this._rfbRSAAESAuthenticationState.hasStarted) {
|
||||
this._rfbRSAAESAuthenticationState.negotiateRA2neAuthAsync()
|
||||
.catch((e) => {
|
||||
if (e.message !== "disconnect normally") {
|
||||
this._fail(e.message);
|
||||
}
|
||||
}).then(() => {
|
||||
this.dispatchEvent(new CustomEvent('securityresult'));
|
||||
this._rfbInitState = "SecurityResult";
|
||||
this._initMsg();
|
||||
}).finally(() => {
|
||||
this._rfbRSAAESAuthenticationState.removeEventListener(
|
||||
"serververification", this._eventHandlers.handleRSAAESServerVerification);
|
||||
this._rfbRSAAESAuthenticationState.removeEventListener(
|
||||
"credentialsrequired", this._eventHandlers.handleRSAAESCredentialsRequired);
|
||||
this._rfbRSAAESAuthenticationState = null;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_negotiateAuthentication() {
|
||||
switch (this._rfbAuthScheme) {
|
||||
case 1: // no auth
|
||||
@@ -1632,6 +1838,9 @@ export default class RFB extends EventTargetMixin {
|
||||
case 22: // XVP auth
|
||||
return this._negotiateXvpAuth();
|
||||
|
||||
case 30: // ARD auth
|
||||
return this._negotiateARDAuth();
|
||||
|
||||
case 2: // VNC authentication
|
||||
return this._negotiateStdVNCAuth();
|
||||
|
||||
@@ -1644,6 +1853,9 @@ export default class RFB extends EventTargetMixin {
|
||||
case 129: // TightVNC UNIX Security Type
|
||||
return this._negotiateTightUnixAuth();
|
||||
|
||||
case 6: // RA2ne Security Type
|
||||
return this._negotiateRA2neAuth();
|
||||
|
||||
default:
|
||||
return this._fail("Unsupported auth scheme (scheme: " +
|
||||
this._rfbAuthScheme + ")");
|
||||
@@ -1772,6 +1984,8 @@ export default class RFB extends EventTargetMixin {
|
||||
if (this._fbDepth == 24) {
|
||||
encs.push(encodings.encodingTight);
|
||||
encs.push(encodings.encodingTightPNG);
|
||||
encs.push(encodings.encodingZRLE);
|
||||
encs.push(encodings.encodingJPEG);
|
||||
encs.push(encodings.encodingHextile);
|
||||
encs.push(encodings.encodingRRE);
|
||||
}
|
||||
@@ -2500,6 +2714,9 @@ export default class RFB extends EventTargetMixin {
|
||||
this._updateScale();
|
||||
|
||||
this._updateContinuousUpdates();
|
||||
|
||||
// Keep this size until browser client size changes
|
||||
this._saveExpectedClientSize();
|
||||
}
|
||||
|
||||
_xvpOp(ver, op) {
|
||||
|
||||
79
public/novnc/core/util/md5.js
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2021 The noVNC Authors
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*
|
||||
* See README.md for usage and integration instructions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Performs MD5 hashing on a string of binary characters, returns an array of bytes
|
||||
*/
|
||||
|
||||
export function MD5(d) {
|
||||
let r = M(V(Y(X(d), 8 * d.length)));
|
||||
return r;
|
||||
}
|
||||
|
||||
function M(d) {
|
||||
let f = new Uint8Array(d.length);
|
||||
for (let i=0;i<d.length;i++) {
|
||||
f[i] = d.charCodeAt(i);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
function X(d) {
|
||||
let r = Array(d.length >> 2);
|
||||
for (let m = 0; m < r.length; m++) r[m] = 0;
|
||||
for (let m = 0; m < 8 * d.length; m += 8) r[m >> 5] |= (255 & d.charCodeAt(m / 8)) << m % 32;
|
||||
return r;
|
||||
}
|
||||
|
||||
function V(d) {
|
||||
let r = "";
|
||||
for (let m = 0; m < 32 * d.length; m += 8) r += String.fromCharCode(d[m >> 5] >>> m % 32 & 255);
|
||||
return r;
|
||||
}
|
||||
|
||||
function Y(d, g) {
|
||||
d[g >> 5] |= 128 << g % 32, d[14 + (g + 64 >>> 9 << 4)] = g;
|
||||
let m = 1732584193, f = -271733879, r = -1732584194, i = 271733878;
|
||||
for (let n = 0; n < d.length; n += 16) {
|
||||
let h = m,
|
||||
t = f,
|
||||
g = r,
|
||||
e = i;
|
||||
f = ii(f = ii(f = ii(f = ii(f = hh(f = hh(f = hh(f = hh(f = gg(f = gg(f = gg(f = gg(f = ff(f = ff(f = ff(f = ff(f, r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 0], 7, -680876936), f, r, d[n + 1], 12, -389564586), m, f, d[n + 2], 17, 606105819), i, m, d[n + 3], 22, -1044525330), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 4], 7, -176418897), f, r, d[n + 5], 12, 1200080426), m, f, d[n + 6], 17, -1473231341), i, m, d[n + 7], 22, -45705983), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 8], 7, 1770035416), f, r, d[n + 9], 12, -1958414417), m, f, d[n + 10], 17, -42063), i, m, d[n + 11], 22, -1990404162), r = ff(r, i = ff(i, m = ff(m, f, r, i, d[n + 12], 7, 1804603682), f, r, d[n + 13], 12, -40341101), m, f, d[n + 14], 17, -1502002290), i, m, d[n + 15], 22, 1236535329), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 1], 5, -165796510), f, r, d[n + 6], 9, -1069501632), m, f, d[n + 11], 14, 643717713), i, m, d[n + 0], 20, -373897302), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 5], 5, -701558691), f, r, d[n + 10], 9, 38016083), m, f, d[n + 15], 14, -660478335), i, m, d[n + 4], 20, -405537848), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 9], 5, 568446438), f, r, d[n + 14], 9, -1019803690), m, f, d[n + 3], 14, -187363961), i, m, d[n + 8], 20, 1163531501), r = gg(r, i = gg(i, m = gg(m, f, r, i, d[n + 13], 5, -1444681467), f, r, d[n + 2], 9, -51403784), m, f, d[n + 7], 14, 1735328473), i, m, d[n + 12], 20, -1926607734), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 5], 4, -378558), f, r, d[n + 8], 11, -2022574463), m, f, d[n + 11], 16, 1839030562), i, m, d[n + 14], 23, -35309556), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 1], 4, -1530992060), f, r, d[n + 4], 11, 1272893353), m, f, d[n + 7], 16, -155497632), i, m, d[n + 10], 23, -1094730640), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 13], 4, 681279174), f, r, d[n + 0], 11, -358537222), m, f, d[n + 3], 16, -722521979), i, m, d[n + 6], 23, 76029189), r = hh(r, i = hh(i, m = hh(m, f, r, i, d[n + 9], 4, -640364487), f, r, d[n + 12], 11, -421815835), m, f, d[n + 15], 16, 530742520), i, m, d[n + 2], 23, -995338651), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 0], 6, -198630844), f, r, d[n + 7], 10, 1126891415), m, f, d[n + 14], 15, -1416354905), i, m, d[n + 5], 21, -57434055), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 12], 6, 1700485571), f, r, d[n + 3], 10, -1894986606), m, f, d[n + 10], 15, -1051523), i, m, d[n + 1], 21, -2054922799), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 8], 6, 1873313359), f, r, d[n + 15], 10, -30611744), m, f, d[n + 6], 15, -1560198380), i, m, d[n + 13], 21, 1309151649), r = ii(r, i = ii(i, m = ii(m, f, r, i, d[n + 4], 6, -145523070), f, r, d[n + 11], 10, -1120210379), m, f, d[n + 2], 15, 718787259), i, m, d[n + 9], 21, -343485551), m = add(m, h), f = add(f, t), r = add(r, g), i = add(i, e);
|
||||
}
|
||||
return Array(m, f, r, i);
|
||||
}
|
||||
|
||||
function cmn(d, g, m, f, r, i) {
|
||||
return add(rol(add(add(g, d), add(f, i)), r), m);
|
||||
}
|
||||
|
||||
function ff(d, g, m, f, r, i, n) {
|
||||
return cmn(g & m | ~g & f, d, g, r, i, n);
|
||||
}
|
||||
|
||||
function gg(d, g, m, f, r, i, n) {
|
||||
return cmn(g & f | m & ~f, d, g, r, i, n);
|
||||
}
|
||||
|
||||
function hh(d, g, m, f, r, i, n) {
|
||||
return cmn(g ^ m ^ f, d, g, r, i, n);
|
||||
}
|
||||
|
||||
function ii(d, g, m, f, r, i, n) {
|
||||
return cmn(m ^ (g | ~f), d, g, r, i, n);
|
||||
}
|
||||
|
||||
function add(d, g) {
|
||||
let m = (65535 & d) + (65535 & g);
|
||||
return (d >> 16) + (g >> 16) + (m >> 16) << 16 | 65535 & m;
|
||||
}
|
||||
|
||||
function rol(d, g) {
|
||||
return d << g | d >>> 32 - g;
|
||||
}
|
||||
89
public/novnc/docs/API-internal.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# 1. Internal Modules
|
||||
|
||||
The noVNC client is composed of several internal modules that handle
|
||||
rendering, input, networking, etc. Each of the modules is designed to
|
||||
be cross-browser and independent from each other.
|
||||
|
||||
Note however that the API of these modules is not guaranteed to be
|
||||
stable, and this documentation is not maintained as well as the
|
||||
official external API.
|
||||
|
||||
|
||||
## 1.1 Module List
|
||||
|
||||
* __Keyboard__ (core/input/keyboard.js): Keyboard input event handler with
|
||||
non-US keyboard support. Translates keyDown and keyUp events to X11
|
||||
keysym values.
|
||||
|
||||
* __Display__ (core/display.js): Efficient 2D rendering abstraction
|
||||
layered on the HTML5 canvas element.
|
||||
|
||||
* __Websock__ (core/websock.js): Websock client from websockify
|
||||
with transparent binary data support.
|
||||
[Websock API](https://github.com/novnc/websockify-js/wiki/websock.js) wiki page.
|
||||
|
||||
|
||||
## 1.2 Callbacks
|
||||
|
||||
For the Mouse, Keyboard and Display objects the callback functions are
|
||||
assigned to configuration attributes, just as for the RFB object. The
|
||||
WebSock module has a method named 'on' that takes two parameters: the
|
||||
callback event name, and the callback function.
|
||||
|
||||
## 2. Modules
|
||||
|
||||
## 2.1 Keyboard Module
|
||||
|
||||
### 2.1.1 Configuration Attributes
|
||||
|
||||
None
|
||||
|
||||
### 2.1.2 Methods
|
||||
|
||||
| name | parameters | description
|
||||
| ------ | ---------- | ------------
|
||||
| grab | () | Begin capturing keyboard events
|
||||
| ungrab | () | Stop capturing keyboard events
|
||||
|
||||
### 2.1.3 Callbacks
|
||||
|
||||
| name | parameters | description
|
||||
| ---------- | -------------------- | ------------
|
||||
| onkeypress | (keysym, code, down) | Handler for key press/release
|
||||
|
||||
|
||||
## 2.2 Display Module
|
||||
|
||||
### 2.2.1 Configuration Attributes
|
||||
|
||||
| name | type | mode | default | description
|
||||
| ------------ | ----- | ---- | ------- | ------------
|
||||
| scale | float | RW | 1.0 | Display area scale factor 0.0 - 1.0
|
||||
| clipViewport | bool | RW | false | Use viewport clipping
|
||||
| width | int | RO | | Display area width
|
||||
| height | int | RO | | Display area height
|
||||
|
||||
### 2.2.2 Methods
|
||||
|
||||
| name | parameters | description
|
||||
| ------------------ | ------------------------------------------------------- | ------------
|
||||
| viewportChangePos | (deltaX, deltaY) | Move the viewport relative to the current location
|
||||
| viewportChangeSize | (width, height) | Change size of the viewport
|
||||
| absX | (x) | Return X relative to the remote display
|
||||
| absY | (y) | Return Y relative to the remote display
|
||||
| resize | (width, height) | Set width and height
|
||||
| flip | (from_queue) | Update the visible canvas with the contents of the rendering canvas
|
||||
| pending | () | Check if there are waiting items in the render queue
|
||||
| flush | () | Resume processing the render queue unless it's empty
|
||||
| fillRect | (x, y, width, height, color, from_queue) | Draw a filled in rectangle
|
||||
| copyImage | (old_x, old_y, new_x, new_y, width, height, from_queue) | Copy a rectangular area
|
||||
| imageRect | (x, y, width, height, mime, arr) | Draw a rectangle with an image
|
||||
| blitImage | (x, y, width, height, arr, offset, from_queue) | Blit pixels (of R,G,B,A) to the display
|
||||
| drawImage | (img, x, y) | Draw image and track damage
|
||||
| autoscale | (containerWidth, containerHeight) | Scale the display
|
||||
|
||||
### 2.2.3 Callbacks
|
||||
|
||||
| name | parameters | description
|
||||
| ------- | ---------- | ------------
|
||||
| onflush | () | A display flush has been requested and we are now ready to resume FBU processing
|
||||
425
public/novnc/docs/API.md
Normal file
@@ -0,0 +1,425 @@
|
||||
# noVNC API
|
||||
|
||||
The interface of the noVNC client consists of a single RFB object that
|
||||
is instantiated once per connection.
|
||||
|
||||
## RFB
|
||||
|
||||
The `RFB` object represents a single connection to a VNC server. It
|
||||
communicates using a WebSocket that must provide a standard RFB
|
||||
protocol stream.
|
||||
|
||||
### Constructor
|
||||
|
||||
[`RFB()`](#rfb-1)
|
||||
- Creates and returns a new `RFB` object.
|
||||
|
||||
### Properties
|
||||
|
||||
`viewOnly`
|
||||
- Is a `boolean` indicating if any events (e.g. key presses or mouse
|
||||
movement) should be prevented from being sent to the server.
|
||||
Disabled by default.
|
||||
|
||||
`focusOnClick`
|
||||
- Is a `boolean` indicating if keyboard focus should automatically be
|
||||
moved to the remote session when a `mousedown` or `touchstart`
|
||||
event is received. Enabled by default.
|
||||
|
||||
`clipViewport`
|
||||
- Is a `boolean` indicating if the remote session should be clipped
|
||||
to its container. When disabled scrollbars will be shown to handle
|
||||
the resulting overflow. Disabled by default.
|
||||
|
||||
`dragViewport`
|
||||
- Is a `boolean` indicating if mouse events should control the
|
||||
relative position of a clipped remote session. Only relevant if
|
||||
`clipViewport` is enabled. Disabled by default.
|
||||
|
||||
`scaleViewport`
|
||||
- Is a `boolean` indicating if the remote session should be scaled
|
||||
locally so it fits its container. When disabled it will be centered
|
||||
if the remote session is smaller than its container, or handled
|
||||
according to `clipViewport` if it is larger. Disabled by default.
|
||||
|
||||
`resizeSession`
|
||||
- Is a `boolean` indicating if a request to resize the remote session
|
||||
should be sent whenever the container changes dimensions. Disabled
|
||||
by default.
|
||||
|
||||
`showDotCursor`
|
||||
- Is a `boolean` indicating whether a dot cursor should be shown
|
||||
instead of a zero-sized or fully-transparent cursor if the server
|
||||
sets such invisible cursor. Disabled by default.
|
||||
|
||||
`background`
|
||||
- Is a valid CSS [background](https://developer.mozilla.org/en-US/docs/Web/CSS/background)
|
||||
style value indicating which background style should be applied
|
||||
to the element containing the remote session screen. The default value is `rgb(40, 40, 40)`
|
||||
(solid gray color).
|
||||
|
||||
`qualityLevel`
|
||||
- Is an `int` in range `[0-9]` controlling the desired JPEG quality.
|
||||
Value `0` implies low quality and `9` implies high quality.
|
||||
Default value is `6`.
|
||||
|
||||
`compressionLevel`
|
||||
- Is an `int` in range `[0-9]` controlling the desired compression
|
||||
level. Value `0` means no compression. Level 1 uses a minimum of CPU
|
||||
resources and achieves weak compression ratios, while level 9 offers
|
||||
best compression but is slow in terms of CPU consumption on the server
|
||||
side. Use high levels with very slow network connections.
|
||||
Default value is `2`.
|
||||
|
||||
`capabilities` *Read only*
|
||||
- Is an `Object` indicating which optional extensions are available
|
||||
on the server. Some methods may only be called if the corresponding
|
||||
capability is set. The following capabilities are defined:
|
||||
|
||||
| name | type | description
|
||||
| -------- | --------- | -----------
|
||||
| `power` | `boolean` | Machine power control is available
|
||||
|
||||
### Events
|
||||
|
||||
[`connect`](#connect)
|
||||
- The `connect` event is fired when the `RFB` object has completed
|
||||
the connection and handshaking with the server.
|
||||
|
||||
[`disconnect`](#disconnect)
|
||||
- The `disconnect` event is fired when the `RFB` object disconnects.
|
||||
|
||||
[`serververification`](#serververification)
|
||||
- The `serververification` event is fired when the server identity
|
||||
must be confirmed by the user.
|
||||
|
||||
[`credentialsrequired`](#credentialsrequired)
|
||||
- The `credentialsrequired` event is fired when more credentials must
|
||||
be given to continue.
|
||||
|
||||
[`securityfailure`](#securityfailure)
|
||||
- The `securityfailure` event is fired when the security negotiation
|
||||
with the server fails.
|
||||
|
||||
[`clipboard`](#clipboard)
|
||||
- The `clipboard` event is fired when clipboard data is received from
|
||||
the server.
|
||||
|
||||
[`bell`](#bell)
|
||||
- The `bell` event is fired when a audible bell request is received
|
||||
from the server.
|
||||
|
||||
[`desktopname`](#desktopname)
|
||||
- The `desktopname` event is fired when the remote desktop name
|
||||
changes.
|
||||
|
||||
[`capabilities`](#capabilities)
|
||||
- The `capabilities` event is fired when `RFB.capabilities` is
|
||||
updated.
|
||||
|
||||
### Methods
|
||||
|
||||
[`RFB.disconnect()`](#rfbdisconnect)
|
||||
- Disconnect from the server.
|
||||
|
||||
[`RFB.approveServer()`](#rfbapproveserver)
|
||||
- Proceed connecting to the server. Should be called after the
|
||||
[`serververification`](#serververification) event has fired and the
|
||||
user has verified the identity of the server.
|
||||
|
||||
[`RFB.sendCredentials()`](#rfbsendcredentials)
|
||||
- Send credentials to server. Should be called after the
|
||||
[`credentialsrequired`](#credentialsrequired) event has fired.
|
||||
|
||||
[`RFB.sendKey()`](#rfbsendkey)
|
||||
- Send a key event.
|
||||
|
||||
[`RFB.sendCtrlAltDel()`](#rfbsendctrlaltdel)
|
||||
- Send Ctrl-Alt-Del key sequence.
|
||||
|
||||
[`RFB.focus()`](#rfbfocus)
|
||||
- Move keyboard focus to the remote session.
|
||||
|
||||
[`RFB.blur()`](#rfbblur)
|
||||
- Remove keyboard focus from the remote session.
|
||||
|
||||
[`RFB.machineShutdown()`](#rfbmachineshutdown)
|
||||
- Request a shutdown of the remote machine.
|
||||
|
||||
[`RFB.machineReboot()`](#rfbmachinereboot)
|
||||
- Request a reboot of the remote machine.
|
||||
|
||||
[`RFB.machineReset()`](#rfbmachinereset)
|
||||
- Request a reset of the remote machine.
|
||||
|
||||
[`RFB.clipboardPasteFrom()`](#rfbclipboardpastefrom)
|
||||
- Send clipboard contents to server.
|
||||
|
||||
### Details
|
||||
|
||||
#### RFB()
|
||||
|
||||
The `RFB()` constructor returns a new `RFB` object and initiates a new
|
||||
connection to a specified VNC server.
|
||||
|
||||
##### Syntax
|
||||
|
||||
let rfb = new RFB( target, url [, options] );
|
||||
|
||||
###### Parameters
|
||||
|
||||
**`target`**
|
||||
- A block [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement)
|
||||
that specifies where the `RFB` object should attach itself. The
|
||||
existing contents of the `HTMLElement` will be untouched, but new
|
||||
elements will be added during the lifetime of the `RFB` object.
|
||||
|
||||
**`urlOrDataChannel`**
|
||||
- A `DOMString` specifying the VNC server to connect to. This must be
|
||||
a valid WebSocket URL. This can also be a `WebSocket` or `RTCDataChannel`.
|
||||
|
||||
**`options`** *Optional*
|
||||
- An `Object` specifying extra details about how the connection
|
||||
should be made.
|
||||
|
||||
Possible options:
|
||||
|
||||
`shared`
|
||||
- A `boolean` indicating if the remote server should be shared or
|
||||
if any other connected clients should be disconnected. Enabled
|
||||
by default.
|
||||
|
||||
`credentials`
|
||||
- An `Object` specifying the credentials to provide to the server
|
||||
when authenticating. The following credentials are possible:
|
||||
|
||||
| name | type | description
|
||||
| ------------ | ----------- | -----------
|
||||
| `"username"` | `DOMString` | The user that authenticates
|
||||
| `"password"` | `DOMString` | Password for the user
|
||||
| `"target"` | `DOMString` | Target machine or session
|
||||
|
||||
`repeaterID`
|
||||
- A `DOMString` specifying the ID to provide to any VNC repeater
|
||||
encountered.
|
||||
|
||||
`wsProtocols`
|
||||
- An `Array` of `DOMString`s specifying the sub-protocols to use
|
||||
in the WebSocket connection. Empty by default.
|
||||
|
||||
#### connect
|
||||
|
||||
The `connect` event is fired after all the handshaking with the server
|
||||
is completed and the connection is fully established. After this event
|
||||
the `RFB` object is ready to recieve graphics updates and to send input.
|
||||
|
||||
#### disconnect
|
||||
|
||||
The `disconnect` event is fired when the connection has been
|
||||
terminated. The `detail` property is an `Object` that contains the
|
||||
property `clean`. `clean` is a `boolean` indicating if the termination
|
||||
was clean or not. In the event of an unexpected termination or an error
|
||||
`clean` will be set to false.
|
||||
|
||||
#### serververification
|
||||
|
||||
The `serververification` event is fired when the server provides
|
||||
information that allows the user to verify that it is the correct server
|
||||
and protect against a man-in-the-middle attack. The `detail` property is
|
||||
an `Object` containing the property `type` which is a `DOMString`
|
||||
specifying which type of information the server has provided. Other
|
||||
properties are also available, depending on the value of `type`:
|
||||
|
||||
`"RSA"`
|
||||
- The server identity is verified using just a RSA key. The property
|
||||
`publickey` is a `Uint8Array` containing the public key in a unsigned
|
||||
big endian representation.
|
||||
|
||||
#### credentialsrequired
|
||||
|
||||
The `credentialsrequired` event is fired when the server requests more
|
||||
credentials than were specified to [`RFB()`](#rfb-1). The `detail`
|
||||
property is an `Object` containing the property `types` which is an
|
||||
`Array` of `DOMString` listing the credentials that are required.
|
||||
|
||||
#### securityfailure
|
||||
|
||||
The `securityfailure` event is fired when the handshaking process with
|
||||
the server fails during the security negotiation step. The `detail`
|
||||
property is an `Object` containing the following properties:
|
||||
|
||||
| Property | Type | Description
|
||||
| -------- | ----------- | -----------
|
||||
| `status` | `long` | The failure status code
|
||||
| `reason` | `DOMString` | The **optional** reason for the failure
|
||||
|
||||
The property `status` corresponds to the
|
||||
[SecurityResult](https://github.com/rfbproto/rfbproto/blob/master/rfbproto.rst#securityresult)
|
||||
status code in cases of failure. A status of zero will not be sent in
|
||||
this event since that indicates a successful security handshaking
|
||||
process. The optional property `reason` is provided by the server and
|
||||
thus the language of the string is not known. However most servers will
|
||||
probably send English strings. The server can choose to not send a
|
||||
reason and in these cases the `reason` property will be omitted.
|
||||
|
||||
#### clipboard
|
||||
|
||||
The `clipboard` event is fired when the server has sent clipboard data.
|
||||
The `detail` property is an `Object` containing the property `text`
|
||||
which is a `DOMString` with the clipboard data.
|
||||
|
||||
#### bell
|
||||
|
||||
The `bell` event is fired when the server has requested an audible
|
||||
bell.
|
||||
|
||||
#### desktopname
|
||||
|
||||
The `desktopname` event is fired when the name of the remote desktop
|
||||
changes. The `detail` property is an `Object` with the property `name`
|
||||
which is a `DOMString` specifying the new name.
|
||||
|
||||
#### capabilities
|
||||
|
||||
The `capabilities` event is fired whenever an entry is added or removed
|
||||
from `RFB.capabilities`. The `detail` property is an `Object` with the
|
||||
property `capabilities` containing the new value of `RFB.capabilities`.
|
||||
|
||||
#### RFB.disconnect()
|
||||
|
||||
The `RFB.disconnect()` method is used to disconnect from the currently
|
||||
connected server.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.disconnect( );
|
||||
|
||||
#### RFB.approveServer()
|
||||
|
||||
The `RFB.approveServer()` method is used to signal that the user has
|
||||
verified the server identity provided in a `serververification` event
|
||||
and that the connection can continue.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.approveServer( );
|
||||
|
||||
#### RFB.sendCredentials()
|
||||
|
||||
The `RFB.sendCredentials()` method is used to provide the missing
|
||||
credentials after a `credentialsrequired` event has been fired.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.sendCredentials( credentials );
|
||||
|
||||
###### Parameters
|
||||
|
||||
**`credentials`**
|
||||
- An `Object` specifying the credentials to provide to the server
|
||||
when authenticating. See [`RFB()`](#rfb-1) for details.
|
||||
|
||||
#### RFB.sendKey()
|
||||
|
||||
The `RFB.sendKey()` method is used to send a key event to the server.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.sendKey( keysym, code [, down] );
|
||||
|
||||
###### Parameters
|
||||
|
||||
**`keysym`**
|
||||
- A `long` specifying the RFB keysym to send. Can be `0` if a valid
|
||||
**`code`** is specified.
|
||||
|
||||
**`code`**
|
||||
- A `DOMString` specifying the physical key to send. Valid values are
|
||||
those that can be specified to
|
||||
[`KeyboardEvent.code`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code).
|
||||
If the physical key cannot be determined then `null` shall be
|
||||
specified.
|
||||
|
||||
**`down`** *Optional*
|
||||
- A `boolean` specifying if a press or a release event should be
|
||||
sent. If omitted then both a press and release event are sent.
|
||||
|
||||
#### RFB.sendCtrlAltDel()
|
||||
|
||||
The `RFB.sendCtrlAltDel()` method is used to send the key sequence
|
||||
*left Control*, *left Alt*, *Delete*. This is a convenience wrapper
|
||||
around [`RFB.sendKey()`](#rfbsendkey).
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.sendCtrlAltDel( );
|
||||
|
||||
#### RFB.focus()
|
||||
|
||||
The `RFB.focus()` method sets the keyboard focus on the remote session.
|
||||
Keyboard events will be sent to the remote server after this point.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.focus( [options] );
|
||||
|
||||
###### Parameters
|
||||
|
||||
**`options`** *Optional*
|
||||
- A `object` providing options to control how the focus will be
|
||||
performed. Please see [`HTMLElement.focus()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus)
|
||||
for available options.
|
||||
|
||||
#### RFB.blur()
|
||||
|
||||
The `RFB.blur()` method remove keyboard focus on the remote session.
|
||||
Keyboard events will no longer be sent to the remote server after this
|
||||
point.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.blur( );
|
||||
|
||||
#### RFB.machineShutdown()
|
||||
|
||||
The `RFB.machineShutdown()` method is used to request to shut down the
|
||||
remote machine. The capability `power` must be set for this method to
|
||||
have any effect.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.machineShutdown( );
|
||||
|
||||
#### RFB.machineReboot()
|
||||
|
||||
The `RFB.machineReboot()` method is used to request a clean reboot of
|
||||
the remote machine. The capability `power` must be set for this method
|
||||
to have any effect.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.machineReboot( );
|
||||
|
||||
#### RFB.machineReset()
|
||||
|
||||
The `RFB.machineReset()` method is used to request a forced reset of
|
||||
the remote machine. The capability `power` must be set for this method
|
||||
to have any effect.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.machineReset( );
|
||||
|
||||
#### RFB.clipboardPasteFrom()
|
||||
|
||||
The `RFB.clipboardPasteFrom()` method is used to send clipboard data
|
||||
to the remote server.
|
||||
|
||||
##### Syntax
|
||||
|
||||
RFB.clipboardPasteFrom( text );
|
||||
|
||||
###### Parameters
|
||||
|
||||
**`text`**
|
||||
- A `DOMString` specifying the clipboard data to send.
|
||||
105
public/novnc/docs/EMBEDDING.md
Normal file
@@ -0,0 +1,105 @@
|
||||
# Embedding and Deploying noVNC Application
|
||||
|
||||
This document describes how to embed and deploy the noVNC application, which
|
||||
includes settings and a full user interface. If you are looking for
|
||||
documentation on how to use the core noVNC library in your own application,
|
||||
then please see our [library documentation](LIBRARY.md).
|
||||
|
||||
## Files
|
||||
|
||||
The noVNC application consists of the following files and directories:
|
||||
|
||||
* `vnc.html` - The main page for the application and where users should go. It
|
||||
is possible to rename this file.
|
||||
|
||||
* `app/` - Support files for the application. Contains code, images, styles and
|
||||
translations.
|
||||
|
||||
* `core/` - The core noVNC library.
|
||||
|
||||
* `vendor/` - Third party support libraries used by the application and the
|
||||
core library.
|
||||
|
||||
The most basic deployment consists of simply serving these files from a web
|
||||
server and setting up a WebSocket proxy to the VNC server.
|
||||
|
||||
## Parameters
|
||||
|
||||
The noVNC application can be controlled by including certain settings in the
|
||||
query string. Currently the following options are available:
|
||||
|
||||
* `autoconnect` - Automatically connect as soon as the page has finished
|
||||
loading.
|
||||
|
||||
* `reconnect` - If noVNC should automatically reconnect if the connection is
|
||||
dropped.
|
||||
|
||||
* `reconnect_delay` - How long to wait in milliseconds before attempting to
|
||||
reconnect.
|
||||
|
||||
* `host` - The WebSocket host to connect to.
|
||||
|
||||
* `port` - The WebSocket port to connect to.
|
||||
|
||||
* `encrypt` - If TLS should be used for the WebSocket connection.
|
||||
|
||||
* `path` - The WebSocket path to use.
|
||||
|
||||
* `password` - The password sent to the server, if required.
|
||||
|
||||
* `repeaterID` - The repeater ID to use if a VNC repeater is detected.
|
||||
|
||||
* `shared` - If other VNC clients should be disconnected when noVNC connects.
|
||||
|
||||
* `bell` - If the keyboard bell should be enabled or not.
|
||||
|
||||
* `view_only` - If the remote session should be in non-interactive mode.
|
||||
|
||||
* `view_clip` - If the remote session should be clipped or use scrollbars if
|
||||
it cannot fit in the browser.
|
||||
|
||||
* `resize` - How to resize the remote session if it is not the same size as
|
||||
the browser window. Can be one of `off`, `scale` and `remote`.
|
||||
|
||||
* `quality` - The session JPEG quality level. Can be `0` to `9`.
|
||||
|
||||
* `compression` - The session compression level. Can be `0` to `9`.
|
||||
|
||||
* `show_dot` - If a dot cursor should be shown when the remote server provides
|
||||
no local cursor, or provides a fully-transparent (invisible) cursor.
|
||||
|
||||
* `logging` - The console log level. Can be one of `error`, `warn`, `info` or
|
||||
`debug`.
|
||||
|
||||
## HTTP Serving Considerations
|
||||
### Browser Cache Issue
|
||||
|
||||
If you serve noVNC files using a web server that provides an ETag header, and
|
||||
include any options in the query string, a nasty browser cache issue can bite
|
||||
you on upgrade, resulting in a red error box. The issue is caused by a mismatch
|
||||
between the new vnc.html (which is reloaded because the user has used it with
|
||||
new query string after the upgrade) and the old javascript files (that the
|
||||
browser reuses from its cache). To avoid this issue, the browser must be told
|
||||
to always revalidate cached files using conditional requests. The correct
|
||||
semantics are achieved via the (confusingly named) `Cache-Control: no-cache`
|
||||
header that needs to be provided in the web server responses.
|
||||
|
||||
### Example Server Configurations
|
||||
|
||||
Apache:
|
||||
|
||||
```
|
||||
# In the main configuration file
|
||||
# (Debian/Ubuntu users: use "a2enmod headers" instead)
|
||||
LoadModule headers_module modules/mod_headers.so
|
||||
|
||||
# In the <Directory> or <Location> block related to noVNC
|
||||
Header set Cache-Control "no-cache"
|
||||
```
|
||||
|
||||
Nginx:
|
||||
|
||||
```
|
||||
# In the location block related to noVNC
|
||||
add_header Cache-Control no-cache;
|
||||
```
|
||||
31
public/novnc/docs/LIBRARY.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Using the noVNC JavaScript library
|
||||
|
||||
This document describes how to make use of the noVNC JavaScript library for
|
||||
integration in your own VNC client application. If you wish to embed the more
|
||||
complete noVNC application with its included user interface then please see
|
||||
our [embedding documentation](EMBEDDING.md).
|
||||
|
||||
## API
|
||||
|
||||
The API of noVNC consists of a single object called `RFB`. The formal
|
||||
documentation for that object can be found in our [API documentation](API.md).
|
||||
|
||||
## Example
|
||||
|
||||
noVNC includes a small example application called `vnc_lite.html`. This does
|
||||
not make use of all the features of noVNC, but is a good start to see how to
|
||||
do things.
|
||||
|
||||
## Conversion of Modules
|
||||
|
||||
noVNC is written using ECMAScript 6 modules. This is not supported by older
|
||||
versions of Node.js. To use noVNC with those older versions of Node.js the
|
||||
library must first be converted.
|
||||
|
||||
Fortunately noVNC includes a script to handle this conversion. Please follow
|
||||
the following steps:
|
||||
|
||||
1. Install Node.js
|
||||
2. Run `npm install` in the noVNC directory
|
||||
|
||||
The result of the conversion is available in the `lib/` directory.
|
||||
@@ -1,202 +0,0 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,621 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -1,165 +0,0 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
@@ -1,21 +0,0 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (C) 2014 by Vitaly Puzrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,27 +0,0 @@
|
||||
Copyright (c) <year>, <copyright holder>
|
||||
All rights reserved.
|
||||
|
||||
This software is provided 'as-is', without any express
|
||||
or implied warranty. In no event will the authors be
|
||||
held liable for any damages arising from the use of
|
||||
this software.
|
||||
|
||||
Permission is granted to anyone to use this software
|
||||
for any purpose, including commercial applications,
|
||||
and to alter it and redistribute it freely, subject to
|
||||
the following restrictions:
|
||||
|
||||
1. The origin of this software must not be
|
||||
misrepresented; you must not claim that you
|
||||
wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in
|
||||
the product documentation would be appreciated
|
||||
but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked
|
||||
as such, and must not be misrepresented as
|
||||
being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from
|
||||
any source distribution.
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
0.6.2
|
||||
@@ -2,4 +2,4 @@ Rebuilding inflator.js
|
||||
|
||||
- Download pako from npm
|
||||
- Install browserify using npm
|
||||
- browserify utils/inflator.partial.js -o include/inflator.js -s inflator
|
||||
- browserify core/inflator.mod.js -o core/inflator.js -s Inflator
|
||||
|
||||
37
public/novnc/docs/novnc_proxy.1
Normal file
@@ -0,0 +1,37 @@
|
||||
.TH novnc_proxy 1 "June 25, 2020" "version 1.2.0" "USER COMMANDS"
|
||||
|
||||
.SH NAME
|
||||
novnc_proxy - noVNC proxy server
|
||||
.SH SYNOPSIS
|
||||
.B novnc_proxy [--listen PORT] [--vnc VNC_HOST:PORT] [--cert CERT] [--ssl-only]
|
||||
|
||||
Starts the WebSockets proxy and a mini-webserver and
|
||||
provides a cut-and-paste URL to go to.
|
||||
|
||||
--listen PORT Port for proxy/webserver to listen on
|
||||
Default: 6080
|
||||
--vnc VNC_HOST:PORT VNC server host:port proxy target
|
||||
Default: localhost:5900
|
||||
--cert CERT Path to combined cert/key file, or just
|
||||
the cert file if used with --key
|
||||
Default: self.pem
|
||||
--key KEY Path to key file, when not combined with cert
|
||||
--web WEB Path to web files (e.g. vnc.html)
|
||||
Default: ./
|
||||
--ssl-only Disable non-https connections.
|
||||
|
||||
--record FILE Record traffic to FILE.session.js
|
||||
|
||||
--syslog SERVER Can be local socket such as /dev/log, or a UDP host:port pair.
|
||||
|
||||
--heartbeat SEC send a ping to the client every SEC seconds
|
||||
--timeout SEC after SEC seconds exit when not connected
|
||||
--idle-timeout SEC server exits after SEC seconds if there are no
|
||||
active connections
|
||||
|
||||
.SH AUTHOR
|
||||
The noVNC Authors
|
||||
https://github.com/novnc/noVNC
|
||||
|
||||
.SH SEE ALSO
|
||||
websockify(1), nova-novncproxy(1)
|
||||
@@ -1,34 +0,0 @@
|
||||
- Decide a new version number X.Y.Z (follow SemVer)
|
||||
- Update version in package.json
|
||||
- Update version in docs/VERSION
|
||||
- Commit the change with a commit like "Release X.Y.Z"
|
||||
- Add a new release on GitHub called "vX.Y.Z", and populate it with
|
||||
release notes of the following form (where A.B.C is the last release):
|
||||
|
||||
Major Changes Since A.B.C
|
||||
=========================
|
||||
|
||||
*Insert warnings here about incompatibilities*
|
||||
|
||||
*Thanks to all the contributors who filed bugs, added features, and fixed bugs
|
||||
during this release :tada:*
|
||||
|
||||
App-visible Changes
|
||||
-------------------
|
||||
|
||||
- *feature* a feature which improves the app usage (#PRNUM)
|
||||
- *bugfix* a bug fix which fixes the app usage (#PRNUM)
|
||||
- *refactor* a refactor which changes the app usage (#PRNUM)
|
||||
|
||||
Library-visible Changes
|
||||
-----------------------
|
||||
|
||||
- *feature* a feature which improves the noVNC APIs (#PRNUM)
|
||||
- *bugfix* a bug fix which fixes the noVNC APIs (#PRNUM)
|
||||
- *refactor* a refactor which changes the noVNC APIs (#PRNUM)
|
||||
|
||||
App-internals Changes
|
||||
---------------------
|
||||
|
||||
- *bugfix* a bug fix with affects the internals of noVNC only (#PRNUM)
|
||||
- *refactor* a refactor which affects the internals of noVNC only (#PRNUM)
|
||||
@@ -1 +0,0 @@
|
||||
images/favicon.ico
|
||||
|
Before Width: | Height: | Size: 339 B |
|
Before Width: | Height: | Size: 501 B |
|
Before Width: | Height: | Size: 404 B |
|
Before Width: | Height: | Size: 354 B |
|
Before Width: | Height: | Size: 317 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 963 B |
|
Before Width: | Height: | Size: 385 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 453 B |
|
Before Width: | Height: | Size: 851 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 511 B |
|
Before Width: | Height: | Size: 517 B |
|
Before Width: | Height: | Size: 497 B |
|
Before Width: | Height: | Size: 513 B |
|
Before Width: | Height: | Size: 390 B |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 735 B |
@@ -1,527 +0,0 @@
|
||||
/*
|
||||
* noVNC base CSS
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Copyright (C) 2016 Samuel Mannehed for Cendio AB
|
||||
* noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
|
||||
* This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
|
||||
*/
|
||||
|
||||
body {
|
||||
margin:0;
|
||||
padding:0;
|
||||
font-family: Helvetica;
|
||||
/*Background image with light grey curve.*/
|
||||
background-color:#494949;
|
||||
background-repeat:no-repeat;
|
||||
background-position:right bottom;
|
||||
height:100%;
|
||||
}
|
||||
|
||||
html {
|
||||
height:100%;
|
||||
}
|
||||
|
||||
#noVNC_controls ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
#noVNC_controls li {
|
||||
padding-bottom:8px;
|
||||
}
|
||||
|
||||
#noVNC_setting_host {
|
||||
width:150px;
|
||||
}
|
||||
#noVNC_setting_port {
|
||||
width: 80px;
|
||||
}
|
||||
#noVNC_setting_password {
|
||||
width: 150px;
|
||||
}
|
||||
#noVNC_setting_encrypt {
|
||||
}
|
||||
#noVNC_setting_path {
|
||||
width: 100px;
|
||||
}
|
||||
#noVNC_connect_button {
|
||||
width: 110px;
|
||||
float:right;
|
||||
}
|
||||
|
||||
#noVNC_buttons {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#noVNC_view_drag_button {
|
||||
display: none;
|
||||
}
|
||||
#noVNC_sendCtrlAltDel_button {
|
||||
display: none;
|
||||
}
|
||||
#noVNC_fullscreen_button {
|
||||
display: none;
|
||||
}
|
||||
#noVNC_xvp_buttons {
|
||||
display: none;
|
||||
}
|
||||
#noVNC_mobile_buttons {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#noVNC_extra_keys {
|
||||
display: inline;
|
||||
list-style-type: none;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.noVNC_buttons_left {
|
||||
float: left;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.noVNC_buttons_right {
|
||||
float:right;
|
||||
right: 0px;
|
||||
z-index: 2;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#noVNC_status {
|
||||
font-size: 12px;
|
||||
padding-top: 4px;
|
||||
height:32px;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#noVNC_settings_menu {
|
||||
margin: 3px;
|
||||
text-align: left;
|
||||
}
|
||||
#noVNC_settings_menu ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#noVNC_settings_apply {
|
||||
float:right;
|
||||
}
|
||||
|
||||
#noVNC_container {
|
||||
display: table;
|
||||
width:100%;
|
||||
height:100%;
|
||||
background-color:#313131;
|
||||
border-bottom-right-radius: 800px 600px;
|
||||
/*border-top-left-radius: 800px 600px;*/
|
||||
}
|
||||
|
||||
#noVNC_screen {
|
||||
display: none;
|
||||
position: absolute;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
bottom: 0px;
|
||||
top: 36px; /* the height of the control bar */
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/* Do not set width/height for VNC_canvas or incorrect
|
||||
* scaling will occur. Canvas size depends on remote VNC
|
||||
* settings and noVNC settings. */
|
||||
#noVNC_canvas {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
#VNC_clipboard_clear_button {
|
||||
float:right;
|
||||
}
|
||||
#VNC_clipboard_text {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#noVNC_clipboard_clear_button {
|
||||
float:right;
|
||||
}
|
||||
|
||||
/*Bubble contents divs*/
|
||||
#noVNC_settings {
|
||||
display:none;
|
||||
margin-top:73px;
|
||||
right:20px;
|
||||
position:fixed;
|
||||
}
|
||||
|
||||
#noVNC_controls {
|
||||
display:none;
|
||||
margin-top:73px;
|
||||
right:12px;
|
||||
position:fixed;
|
||||
}
|
||||
#noVNC_controls.top:after {
|
||||
right:15px;
|
||||
}
|
||||
|
||||
#noVNC_description {
|
||||
display:none;
|
||||
position:fixed;
|
||||
|
||||
margin-top:73px;
|
||||
right:20px;
|
||||
left:20px;
|
||||
padding:15px;
|
||||
color:#000;
|
||||
background:#eee; /* default background for browsers without gradient support */
|
||||
|
||||
border:2px solid #E0E0E0;
|
||||
-webkit-border-radius:10px;
|
||||
-moz-border-radius:10px;
|
||||
border-radius:10px;
|
||||
}
|
||||
|
||||
#noVNC_popup_status {
|
||||
display:none;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
|
||||
margin:15px;
|
||||
margin-top:60px;
|
||||
padding:15px;
|
||||
width:auto;
|
||||
|
||||
text-align:center;
|
||||
font-weight:bold;
|
||||
word-wrap:break-word;
|
||||
color:#fff;
|
||||
background:rgba(0,0,0,0.65);
|
||||
|
||||
-webkit-border-radius:10px;
|
||||
-moz-border-radius:10px;
|
||||
border-radius:10px;
|
||||
}
|
||||
|
||||
#noVNC_xvp {
|
||||
display:none;
|
||||
margin-top:73px;
|
||||
right:30px;
|
||||
position:fixed;
|
||||
}
|
||||
#noVNC_xvp.top:after {
|
||||
right:125px;
|
||||
}
|
||||
|
||||
#noVNC_clipboard {
|
||||
display:none;
|
||||
margin-top:73px;
|
||||
right:30px;
|
||||
position:fixed;
|
||||
}
|
||||
#noVNC_clipboard.top:after {
|
||||
right:85px;
|
||||
}
|
||||
|
||||
#noVNC_keyboardinput {
|
||||
width:1px;
|
||||
height:1px;
|
||||
background-color:#fff;
|
||||
color:#fff;
|
||||
border:0;
|
||||
position: relative;
|
||||
left: -40px;
|
||||
z-index: -1;
|
||||
ime-mode: disabled;
|
||||
}
|
||||
|
||||
/*
|
||||
* Advanced Styling
|
||||
*/
|
||||
|
||||
.noVNC_status_normal {
|
||||
background: #b2bdcd; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #b2bdcd 0%, #899cb3 49%, #7e93af 51%, #6e84a3 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b2bdcd), color-stop(49%,#899cb3), color-stop(51%,#7e93af), color-stop(100%,#6e84a3)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* IE10+ */
|
||||
background: linear-gradient(top, #b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* W3C */
|
||||
}
|
||||
.noVNC_status_error {
|
||||
background: #f04040; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #f04040 0%, #899cb3 49%, #7e93af 51%, #6e84a3 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f04040), color-stop(49%,#899cb3), color-stop(51%,#7e93af), color-stop(100%,#6e84a3)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #f04040 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #f04040 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #f04040 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* IE10+ */
|
||||
background: linear-gradient(top, #f04040 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* W3C */
|
||||
}
|
||||
.noVNC_status_warn {
|
||||
background: #f0f040; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #f0f040 0%, #899cb3 49%, #7e93af 51%, #6e84a3 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f0f040), color-stop(49%,#899cb3), color-stop(51%,#7e93af), color-stop(100%,#6e84a3)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #f0f040 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #f0f040 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #f0f040 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* IE10+ */
|
||||
background: linear-gradient(top, #f0f040 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* W3C */
|
||||
}
|
||||
|
||||
/* Control bar */
|
||||
#noVNC_control_bar {
|
||||
position:fixed;
|
||||
|
||||
display:block;
|
||||
height:36px;
|
||||
left:0;
|
||||
top:0;
|
||||
width:100%;
|
||||
z-index:200;
|
||||
}
|
||||
|
||||
.noVNC_status_button {
|
||||
padding: 4px 4px;
|
||||
vertical-align: middle;
|
||||
border:1px solid #869dbc;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
background: #b2bdcd; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #b2bdcd 0%, #899cb3 49%, #7e93af 51%, #6e84a3 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b2bdcd), color-stop(49%,#899cb3), color-stop(51%,#7e93af), color-stop(100%,#6e84a3)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* IE10+ */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b2bdcd', endColorstr='#6e84a3',GradientType=0 ); /* IE6-9 */
|
||||
background: linear-gradient(top, #b2bdcd 0%,#899cb3 49%,#7e93af 51%,#6e84a3 100%); /* W3C */
|
||||
/*box-shadow:inset 0.4px 0.4px 0.4px #000000;*/
|
||||
}
|
||||
|
||||
.noVNC_status_button_selected {
|
||||
padding: 4px 4px;
|
||||
vertical-align: middle;
|
||||
border:1px solid #4366a9;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
background: #779ced; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #779ced 0%, #3970e0 49%, #2160dd 51%, #2463df 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#779ced), color-stop(49%,#3970e0), color-stop(51%,#2160dd), color-stop(100%,#2463df)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #779ced 0%,#3970e0 49%,#2160dd 51%,#2463df 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #779ced 0%,#3970e0 49%,#2160dd 51%,#2463df 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #779ced 0%,#3970e0 49%,#2160dd 51%,#2463df 100%); /* IE10+ */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#779ced', endColorstr='#2463df',GradientType=0 ); /* IE6-9 */
|
||||
background: linear-gradient(top, #779ced 0%,#3970e0 49%,#2160dd 51%,#2463df 100%); /* W3C */
|
||||
/*box-shadow:inset 0.4px 0.4px 0.4px #000000;*/
|
||||
}
|
||||
|
||||
.noVNC_status_button:disabled {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
|
||||
/*Settings Bubble*/
|
||||
.triangle-right {
|
||||
position:relative;
|
||||
padding:15px;
|
||||
margin:1em 0 3em;
|
||||
color:#fff;
|
||||
background:#fff; /* default background for browsers without gradient support */
|
||||
/* css3 */
|
||||
/*background:-webkit-gradient(linear, 0 0, 0 100%, from(#2e88c4), to(#075698));
|
||||
background:-moz-linear-gradient(#2e88c4, #075698);
|
||||
background:-o-linear-gradient(#2e88c4, #075698);
|
||||
background:linear-gradient(#2e88c4, #075698);*/
|
||||
-webkit-border-radius:10px;
|
||||
-moz-border-radius:10px;
|
||||
border-radius:10px;
|
||||
color:#000;
|
||||
border:2px solid #E0E0E0;
|
||||
}
|
||||
|
||||
.triangle-right.top:after {
|
||||
border-color: transparent #E0E0E0;
|
||||
border-width: 20px 20px 0 0;
|
||||
bottom: auto;
|
||||
left: auto;
|
||||
right: 50px;
|
||||
top: -20px;
|
||||
}
|
||||
|
||||
.triangle-right:after {
|
||||
content:"";
|
||||
position:absolute;
|
||||
bottom:-20px; /* value = - border-top-width - border-bottom-width */
|
||||
left:50px; /* controls horizontal position */
|
||||
border-width:20px 0 0 20px; /* vary these values to change the angle of the vertex */
|
||||
border-style:solid;
|
||||
border-color:#E0E0E0 transparent;
|
||||
/* reduce the damage in FF3.0 */
|
||||
display:block;
|
||||
width:0;
|
||||
}
|
||||
|
||||
.triangle-right.top:after {
|
||||
top:-40px; /* value = - border-top-width - border-bottom-width */
|
||||
right:50px; /* controls horizontal position */
|
||||
bottom:auto;
|
||||
left:auto;
|
||||
border-width:40px 40px 0 0; /* vary these values to change the angle of the vertex */
|
||||
border-color:transparent #E0E0E0;
|
||||
}
|
||||
|
||||
/*Default noVNC logo.*/
|
||||
/* From: http://fonts.googleapis.com/css?family=Orbitron:700 */
|
||||
@font-face {
|
||||
font-family: 'Orbitron';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('?'), url('Orbitron700.woff') format('woff'),
|
||||
url('Orbitron700.ttf') format('truetype');
|
||||
}
|
||||
|
||||
#noVNC_logo {
|
||||
margin-top: 170px;
|
||||
margin-left: 10px;
|
||||
color:yellow;
|
||||
text-align:left;
|
||||
font-family: 'Orbitron', 'OrbitronTTF', sans-serif;
|
||||
line-height:90%;
|
||||
text-shadow:
|
||||
5px 5px 0 #000,
|
||||
-1px -1px 0 #000,
|
||||
1px -1px 0 #000,
|
||||
-1px 1px 0 #000,
|
||||
1px 1px 0 #000;
|
||||
}
|
||||
|
||||
|
||||
#noVNC_logo span{
|
||||
color:green;
|
||||
}
|
||||
|
||||
/* ----------------------------------------
|
||||
* Media sizing
|
||||
* ----------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
.noVNC_status_button {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#noVNC_clipboard_text {
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#noVNC_logo {
|
||||
font-size: 180px;
|
||||
}
|
||||
|
||||
.noVNC_buttons_left {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.noVNC_buttons_right {
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
#noVNC_status {
|
||||
z-index: 0;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
margin-left: 0px;
|
||||
}
|
||||
|
||||
#noVNC_toggleExtraKeys_button { display: none; }
|
||||
#noVNC_toggleCtrl_button { display: inline; }
|
||||
#noVNC_toggleAlt_button { display: inline; }
|
||||
#noVNC_sendTab_button { display: inline; }
|
||||
#noVNC_sendEsc_button { display: inline; }
|
||||
|
||||
/* left-align the status text on lower resolutions */
|
||||
@media screen and (max-width: 800px){
|
||||
#noVNC_status {
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
width: auto;
|
||||
float: left;
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 640px){
|
||||
#noVNC_clipboard_text {
|
||||
width: 410px;
|
||||
}
|
||||
#noVNC_logo {
|
||||
font-size: 150px;
|
||||
}
|
||||
.noVNC_status_button {
|
||||
font-size: 10px;
|
||||
}
|
||||
.noVNC_buttons_left {
|
||||
padding-left: 0px;
|
||||
}
|
||||
.noVNC_buttons_right {
|
||||
padding-right: 0px;
|
||||
}
|
||||
/* collapse the extra keys on lower resolutions */
|
||||
#noVNC_toggleExtraKeys_button {
|
||||
display: inline;
|
||||
}
|
||||
#noVNC_toggleCtrl_button {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
left: 0px;
|
||||
}
|
||||
#noVNC_toggleAlt_button {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 65px;
|
||||
left: 0px;
|
||||
}
|
||||
#noVNC_sendTab_button {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
left: 0px;
|
||||
}
|
||||
#noVNC_sendEsc_button {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 135px;
|
||||
left: 0px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 321px) and (max-width: 480px) {
|
||||
#noVNC_clipboard_text {
|
||||
width: 250px;
|
||||
}
|
||||
#noVNC_logo {
|
||||
font-size: 110px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 320px) {
|
||||
.noVNC_status_button {
|
||||
font-size: 9px;
|
||||
}
|
||||
#noVNC_clipboard_text {
|
||||
width: 220px;
|
||||
}
|
||||
#noVNC_logo {
|
||||
font-size: 90px;
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// From: http://hg.mozilla.org/mozilla-central/raw-file/ec10630b1a54/js/src/devtools/jint/sunspider/string-base64.js
|
||||
|
||||
/*jslint white: false */
|
||||
/*global console */
|
||||
|
||||
var Base64 = {
|
||||
/* Convert data (an array of integers) to a Base64 string. */
|
||||
toBase64Table : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split(''),
|
||||
base64Pad : '=',
|
||||
|
||||
encode: function (data) {
|
||||
"use strict";
|
||||
var result = '';
|
||||
var toBase64Table = Base64.toBase64Table;
|
||||
var length = data.length;
|
||||
var lengthpad = (length % 3);
|
||||
// Convert every three bytes to 4 ascii characters.
|
||||
|
||||
for (var i = 0; i < (length - 2); i += 3) {
|
||||
result += toBase64Table[data[i] >> 2];
|
||||
result += toBase64Table[((data[i] & 0x03) << 4) + (data[i + 1] >> 4)];
|
||||
result += toBase64Table[((data[i + 1] & 0x0f) << 2) + (data[i + 2] >> 6)];
|
||||
result += toBase64Table[data[i + 2] & 0x3f];
|
||||
}
|
||||
|
||||
// Convert the remaining 1 or 2 bytes, pad out to 4 characters.
|
||||
var j = 0;
|
||||
if (lengthpad === 2) {
|
||||
j = length - lengthpad;
|
||||
result += toBase64Table[data[j] >> 2];
|
||||
result += toBase64Table[((data[j] & 0x03) << 4) + (data[j + 1] >> 4)];
|
||||
result += toBase64Table[(data[j + 1] & 0x0f) << 2];
|
||||
result += toBase64Table[64];
|
||||
} else if (lengthpad === 1) {
|
||||
j = length - lengthpad;
|
||||
result += toBase64Table[data[j] >> 2];
|
||||
result += toBase64Table[(data[j] & 0x03) << 4];
|
||||
result += toBase64Table[64];
|
||||
result += toBase64Table[64];
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/* Convert Base64 data to a string */
|
||||
/* jshint -W013 */
|
||||
toBinaryTable : [
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
|
||||
-1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63,
|
||||
52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1, 0,-1,-1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
|
||||
15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
|
||||
-1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
|
||||
41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
|
||||
],
|
||||
/* jshint +W013 */
|
||||
|
||||
decode: function (data, offset) {
|
||||
"use strict";
|
||||
offset = typeof(offset) !== 'undefined' ? offset : 0;
|
||||
var toBinaryTable = Base64.toBinaryTable;
|
||||
var base64Pad = Base64.base64Pad;
|
||||
var result, result_length;
|
||||
var leftbits = 0; // number of bits decoded, but yet to be appended
|
||||
var leftdata = 0; // bits decoded, but yet to be appended
|
||||
var data_length = data.indexOf('=') - offset;
|
||||
|
||||
if (data_length < 0) { data_length = data.length - offset; }
|
||||
|
||||
/* Every four characters is 3 resulting numbers */
|
||||
result_length = (data_length >> 2) * 3 + Math.floor((data_length % 4) / 1.5);
|
||||
result = new Array(result_length);
|
||||
|
||||
// Convert one by one.
|
||||
for (var idx = 0, i = offset; i < data.length; i++) {
|
||||
var c = toBinaryTable[data.charCodeAt(i) & 0x7f];
|
||||
var padding = (data.charAt(i) === base64Pad);
|
||||
// Skip illegal characters and whitespace
|
||||
if (c === -1) {
|
||||
console.error("Illegal character code " + data.charCodeAt(i) + " at position " + i);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Collect data into leftdata, update bitcount
|
||||
leftdata = (leftdata << 6) | c;
|
||||
leftbits += 6;
|
||||
|
||||
// If we have 8 or more bits, append 8 bits to the result
|
||||
if (leftbits >= 8) {
|
||||
leftbits -= 8;
|
||||
// Append if not padding.
|
||||
if (!padding) {
|
||||
result[idx++] = (leftdata >> leftbits) & 0xff;
|
||||
}
|
||||
leftdata &= (1 << leftbits) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
// If there are any bits left, the base64 string was corrupted
|
||||
if (leftbits) {
|
||||
err = new Error('Corrupted base64 string');
|
||||
err.name = 'Base64-Error';
|
||||
throw err;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}; /* End of Base64 namespace */
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* noVNC black CSS
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Copyright (C) 2013 Samuel Mannehed for Cendio AB
|
||||
* noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
|
||||
* This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
|
||||
*/
|
||||
|
||||
#noVNC_keyboardinput {
|
||||
background-color:#000;
|
||||
}
|
||||
|
||||
.noVNC_status_normal {
|
||||
background: #4c4c4c; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #4c4c4c 0%, #2c2c2c 50%, #000000 51%, #131313 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4c4c4c), color-stop(50%,#2c2c2c), color-stop(51%,#000000), color-stop(100%,#131313)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #4c4c4c 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #4c4c4c 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #4c4c4c 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* IE10+ */
|
||||
background: linear-gradient(top, #4c4c4c 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* W3C */
|
||||
}
|
||||
.noVNC_status_error {
|
||||
background: #f04040; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #f04040 0%, #2c2c2c 50%, #000000 51%, #131313 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f04040), color-stop(50%,#2c2c2c), color-stop(51%,#000000), color-stop(100%,#131313)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #f04040 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #f04040 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #f04040 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* IE10+ */
|
||||
background: linear-gradient(top, #f04040 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* W3C */
|
||||
}
|
||||
.noVNC_status_warn {
|
||||
background: #f0f040; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #f0f040 0%, #2c2c2c 50%, #000000 51%, #131313 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f0f040), color-stop(50%,#2c2c2c), color-stop(51%,#000000), color-stop(100%,#131313)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #f0f040 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #f0f040 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #f0f040 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* IE10+ */
|
||||
background: linear-gradient(top, #f0f040 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* W3C */
|
||||
}
|
||||
|
||||
.triangle-right {
|
||||
border:2px solid #fff;
|
||||
background:#000;
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
.noVNC_status_button {
|
||||
font-size: 12px;
|
||||
vertical-align: middle;
|
||||
border:1px solid #4c4c4c;
|
||||
|
||||
background: #4c4c4c; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #4c4c4c 0%, #2c2c2c 50%, #000000 51%, #131313 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4c4c4c), color-stop(50%,#2c2c2c), color-stop(51%,#000000), color-stop(100%,#131313)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #4c4c4c 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #4c4c4c 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #4c4c4c 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* IE10+ */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313',GradientType=0 ); /* IE6-9 */
|
||||
background: linear-gradient(top, #4c4c4c 0%,#2c2c2c 50%,#000000 51%,#131313 100%); /* W3C */
|
||||
}
|
||||
|
||||
.noVNC_status_button_selected {
|
||||
background: #9dd53a; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #9dd53a 0%, #a1d54f 50%, #80c217 51%, #7cbc0a 100%); /* FF3.6+ */
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#9dd53a), color-stop(50%,#a1d54f), color-stop(51%,#80c217), color-stop(100%,#7cbc0a)); /* Chrome,Safari4+ */
|
||||
background: -webkit-linear-gradient(top, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%); /* Opera11.10+ */
|
||||
background: -ms-linear-gradient(top, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%); /* IE10+ */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#9dd53a', endColorstr='#7cbc0a',GradientType=0 ); /* IE6-9 */
|
||||
background: linear-gradient(top, #9dd53a 0%,#a1d54f 50%,#80c217 51%,#7cbc0a 100%); /* W3C */
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* noVNC blue CSS
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Copyright (C) 2013 Samuel Mannehed for Cendio AB
|
||||
* noVNC is licensed under the MPL 2.0 (see LICENSE.txt)
|
||||
* This file is licensed under the 2-Clause BSD license (see LICENSE.txt).
|
||||
*/
|
||||
|
||||
.noVNC_status_normal {
|
||||
background-color:#04073d;
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.54, rgb(10,15,79)),
|
||||
color-stop(0.5, rgb(4,7,61))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(10,15,79) 54%,
|
||||
rgb(4,7,61) 50%
|
||||
);
|
||||
}
|
||||
.noVNC_status_error {
|
||||
background-color:#f04040;
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.54, rgb(240,64,64)),
|
||||
color-stop(0.5, rgb(4,7,61))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(4,7,61) 54%,
|
||||
rgb(249,64,64) 50%
|
||||
);
|
||||
}
|
||||
.noVNC_status_warn {
|
||||
background-color:#f0f040;
|
||||
background-image: -webkit-gradient(
|
||||
linear,
|
||||
left bottom,
|
||||
left top,
|
||||
color-stop(0.54, rgb(240,240,64)),
|
||||
color-stop(0.5, rgb(4,7,61))
|
||||
);
|
||||
background-image: -moz-linear-gradient(
|
||||
center bottom,
|
||||
rgb(4,7,61) 54%,
|
||||
rgb(240,240,64) 50%
|
||||
);
|
||||
}
|
||||
|
||||
.triangle-right {
|
||||
border:2px solid #fff;
|
||||
background:#04073d;
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
#noVNC_keyboardinput {
|
||||
background-color:#04073d;
|
||||
}
|
||||
|
||||
@@ -1,321 +0,0 @@
|
||||
/*
|
||||
Copyright 2012 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Author: Boris Smus (smus@chromium.org)
|
||||
*/
|
||||
|
||||
(function(exports) {
|
||||
|
||||
// Define some local variables here.
|
||||
var socket = chrome.socket || chrome.experimental.socket;
|
||||
var dns = chrome.experimental.dns;
|
||||
|
||||
/**
|
||||
* Creates an instance of the client
|
||||
*
|
||||
* @param {String} host The remote host to connect to
|
||||
* @param {Number} port The port to connect to at the remote host
|
||||
*/
|
||||
function TcpClient(host, port, pollInterval) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.pollInterval = pollInterval || 15;
|
||||
|
||||
// Callback functions.
|
||||
this.callbacks = {
|
||||
connect: null, // Called when socket is connected.
|
||||
disconnect: null, // Called when socket is disconnected.
|
||||
recvBuffer: null, // Called (as ArrayBuffer) when client receives data from server.
|
||||
recvString: null, // Called (as string) when client receives data from server.
|
||||
sent: null // Called when client sends data to server.
|
||||
};
|
||||
|
||||
// Socket.
|
||||
this.socketId = null;
|
||||
this.isConnected = false;
|
||||
|
||||
log('initialized tcp client');
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the TCP socket, and creates an open socket.
|
||||
*
|
||||
* @see http://developer.chrome.com/trunk/apps/socket.html#method-create
|
||||
* @param {Function} callback The function to call on connection
|
||||
*/
|
||||
TcpClient.prototype.connect = function(callback) {
|
||||
// First resolve the hostname to an IP.
|
||||
dns.resolve(this.host, function(result) {
|
||||
this.addr = result.address;
|
||||
socket.create('tcp', {}, this._onCreate.bind(this));
|
||||
|
||||
// Register connect callback.
|
||||
this.callbacks.connect = callback;
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends an arraybuffer/view down the wire to the remote side
|
||||
*
|
||||
* @see http://developer.chrome.com/trunk/apps/socket.html#method-write
|
||||
* @param {String} msg The arraybuffer/view to send
|
||||
* @param {Function} callback The function to call when the message has sent
|
||||
*/
|
||||
TcpClient.prototype.sendBuffer = function(buf, callback) {
|
||||
if (buf.buffer) {
|
||||
buf = buf.buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
// Debug
|
||||
var bytes = [], u8 = new Uint8Array(buf);
|
||||
for (var i = 0; i < u8.length; i++) {
|
||||
bytes.push(u8[i]);
|
||||
}
|
||||
log("sending bytes: " + (bytes.join(',')));
|
||||
*/
|
||||
|
||||
socket.write(this.socketId, buf, this._onWriteComplete.bind(this));
|
||||
|
||||
// Register sent callback.
|
||||
this.callbacks.sent = callback;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sends a string down the wire to the remote side
|
||||
*
|
||||
* @see http://developer.chrome.com/trunk/apps/socket.html#method-write
|
||||
* @param {String} msg The string to send
|
||||
* @param {Function} callback The function to call when the message has sent
|
||||
*/
|
||||
TcpClient.prototype.sendString = function(msg, callback) {
|
||||
/*
|
||||
// Debug
|
||||
log("sending string: " + msg);
|
||||
*/
|
||||
|
||||
this._stringToArrayBuffer(msg, function(arrayBuffer) {
|
||||
socket.write(this.socketId, arrayBuffer, this._onWriteComplete.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
// Register sent callback.
|
||||
this.callbacks.sent = callback;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the callback for when a message is received
|
||||
*
|
||||
* @param {Function} callback The function to call when a message has arrived
|
||||
* @param {String} type The callback argument type: "arraybuffer" or "string"
|
||||
*/
|
||||
TcpClient.prototype.addResponseListener = function(callback, type) {
|
||||
if (typeof type === "undefined") {
|
||||
type = "arraybuffer";
|
||||
}
|
||||
// Register received callback.
|
||||
if (type === "string") {
|
||||
this.callbacks.recvString = callback;
|
||||
} else {
|
||||
this.callbacks.recvBuffer = callback;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the callback for when the socket disconnects
|
||||
*
|
||||
* @param {Function} callback The function to call when the socket disconnects
|
||||
* @param {String} type The callback argument type: "arraybuffer" or "string"
|
||||
*/
|
||||
TcpClient.prototype.addDisconnectListener = function(callback) {
|
||||
// Register disconnect callback.
|
||||
this.callbacks.disconnect = callback;
|
||||
};
|
||||
|
||||
/**
|
||||
* Disconnects from the remote side
|
||||
*
|
||||
* @see http://developer.chrome.com/trunk/apps/socket.html#method-disconnect
|
||||
*/
|
||||
TcpClient.prototype.disconnect = function() {
|
||||
if (this.isConnected) {
|
||||
this.isConnected = false;
|
||||
socket.disconnect(this.socketId);
|
||||
if (this.callbacks.disconnect) {
|
||||
this.callbacks.disconnect();
|
||||
}
|
||||
log('socket disconnected');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The callback function used for when we attempt to have Chrome
|
||||
* create a socket. If the socket is successfully created
|
||||
* we go ahead and connect to the remote side.
|
||||
*
|
||||
* @private
|
||||
* @see http://developer.chrome.com/trunk/apps/socket.html#method-connect
|
||||
* @param {Object} createInfo The socket details
|
||||
*/
|
||||
TcpClient.prototype._onCreate = function(createInfo) {
|
||||
this.socketId = createInfo.socketId;
|
||||
if (this.socketId > 0) {
|
||||
socket.connect(this.socketId, this.addr, this.port, this._onConnectComplete.bind(this));
|
||||
} else {
|
||||
error('Unable to create socket');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The callback function used for when we attempt to have Chrome
|
||||
* connect to the remote side. If a successful connection is
|
||||
* made then polling starts to check for data to read
|
||||
*
|
||||
* @private
|
||||
* @param {Number} resultCode Indicates whether the connection was successful
|
||||
*/
|
||||
TcpClient.prototype._onConnectComplete = function(resultCode) {
|
||||
// Start polling for reads.
|
||||
this.isConnected = true;
|
||||
setTimeout(this._periodicallyRead.bind(this), this.pollInterval);
|
||||
|
||||
if (this.callbacks.connect) {
|
||||
log('connect complete');
|
||||
this.callbacks.connect();
|
||||
}
|
||||
log('onConnectComplete');
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks for new data to read from the socket
|
||||
*
|
||||
* @see http://developer.chrome.com/trunk/apps/socket.html#method-read
|
||||
*/
|
||||
TcpClient.prototype._periodicallyRead = function() {
|
||||
var that = this;
|
||||
socket.getInfo(this.socketId, function (info) {
|
||||
if (info.connected) {
|
||||
setTimeout(that._periodicallyRead.bind(that), that.pollInterval);
|
||||
socket.read(that.socketId, null, that._onDataRead.bind(that));
|
||||
} else if (that.isConnected) {
|
||||
log('socket disconnect detected');
|
||||
that.disconnect();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback function for when data has been read from the socket.
|
||||
* Converts the array buffer that is read in to a string
|
||||
* and sends it on for further processing by passing it to
|
||||
* the previously assigned callback function.
|
||||
*
|
||||
* @private
|
||||
* @see TcpClient.prototype.addResponseListener
|
||||
* @param {Object} readInfo The incoming message
|
||||
*/
|
||||
TcpClient.prototype._onDataRead = function(readInfo) {
|
||||
// Call received callback if there's data in the response.
|
||||
if (readInfo.resultCode > 0) {
|
||||
log('onDataRead');
|
||||
|
||||
/*
|
||||
// Debug
|
||||
var bytes = [], u8 = new Uint8Array(readInfo.data);
|
||||
for (var i = 0; i < u8.length; i++) {
|
||||
bytes.push(u8[i]);
|
||||
}
|
||||
log("received bytes: " + (bytes.join(',')));
|
||||
*/
|
||||
|
||||
if (this.callbacks.recvBuffer) {
|
||||
// Return raw ArrayBuffer directly.
|
||||
this.callbacks.recvBuffer(readInfo.data);
|
||||
}
|
||||
if (this.callbacks.recvString) {
|
||||
// Convert ArrayBuffer to string.
|
||||
this._arrayBufferToString(readInfo.data, function(str) {
|
||||
this.callbacks.recvString(str);
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
// Trigger another read right away
|
||||
setTimeout(this._periodicallyRead.bind(this), 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback for when data has been successfully
|
||||
* written to the socket.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} writeInfo The outgoing message
|
||||
*/
|
||||
TcpClient.prototype._onWriteComplete = function(writeInfo) {
|
||||
log('onWriteComplete');
|
||||
// Call sent callback.
|
||||
if (this.callbacks.sent) {
|
||||
this.callbacks.sent(writeInfo);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts an array buffer to a string
|
||||
*
|
||||
* @private
|
||||
* @param {ArrayBuffer} buf The buffer to convert
|
||||
* @param {Function} callback The function to call when conversion is complete
|
||||
*/
|
||||
TcpClient.prototype._arrayBufferToString = function(buf, callback) {
|
||||
var bb = new Blob([new Uint8Array(buf)]);
|
||||
var f = new FileReader();
|
||||
f.onload = function(e) {
|
||||
callback(e.target.result);
|
||||
};
|
||||
f.readAsText(bb);
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a string to an array buffer
|
||||
*
|
||||
* @private
|
||||
* @param {String} str The string to convert
|
||||
* @param {Function} callback The function to call when conversion is complete
|
||||
*/
|
||||
TcpClient.prototype._stringToArrayBuffer = function(str, callback) {
|
||||
var bb = new Blob([str]);
|
||||
var f = new FileReader();
|
||||
f.onload = function(e) {
|
||||
callback(e.target.result);
|
||||
};
|
||||
f.readAsArrayBuffer(bb);
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper function for logging
|
||||
*/
|
||||
function log(msg) {
|
||||
console.log(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function for error logging
|
||||
*/
|
||||
function error(msg) {
|
||||
console.error(msg);
|
||||
}
|
||||
|
||||
exports.TcpClient = TcpClient;
|
||||
|
||||
})(window);
|
||||
@@ -1,276 +0,0 @@
|
||||
/*
|
||||
* Ported from Flashlight VNC ActionScript implementation:
|
||||
* http://www.wizhelp.com/flashlight-vnc/
|
||||
*
|
||||
* Full attribution follows:
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* This DES class has been extracted from package Acme.Crypto for use in VNC.
|
||||
* The unnecessary odd parity code has been removed.
|
||||
*
|
||||
* These changes are:
|
||||
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
|
||||
* DesCipher - the DES encryption method
|
||||
*
|
||||
* The meat of this code is by Dave Zimmerman <dzimm@widget.com>, and is:
|
||||
*
|
||||
* Copyright (c) 1996 Widget Workshop, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and
|
||||
* without fee is hereby granted, provided that this copyright notice is kept
|
||||
* intact.
|
||||
*
|
||||
* WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
|
||||
* OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
||||
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE
|
||||
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
|
||||
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
|
||||
*
|
||||
* THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
|
||||
* CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
|
||||
* PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
|
||||
* NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
|
||||
* SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
|
||||
* SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
|
||||
* PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). WIDGET WORKSHOP
|
||||
* SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
|
||||
* HIGH RISK ACTIVITIES.
|
||||
*
|
||||
*
|
||||
* The rest is:
|
||||
*
|
||||
* Copyright (C) 1996 by Jef Poskanzer <jef@acme.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* Visit the ACME Labs Java page for up-to-date versions of this and other
|
||||
* fine Java utilities: http://www.acme.com/java/
|
||||
*/
|
||||
|
||||
/* jslint white: false */
|
||||
|
||||
function DES(passwd) {
|
||||
"use strict";
|
||||
|
||||
// Tables, permutations, S-boxes, etc.
|
||||
// jshint -W013
|
||||
var PC2 = [13,16,10,23, 0, 4, 2,27,14, 5,20, 9,22,18,11, 3,
|
||||
25, 7,15, 6,26,19,12, 1,40,51,30,36,46,54,29,39,
|
||||
50,44,32,47,43,48,38,55,33,52,45,41,49,35,28,31 ],
|
||||
totrot = [ 1, 2, 4, 6, 8,10,12,14,15,17,19,21,23,25,27,28],
|
||||
z = 0x0, a,b,c,d,e,f, SP1,SP2,SP3,SP4,SP5,SP6,SP7,SP8,
|
||||
keys = [];
|
||||
|
||||
// jshint -W015
|
||||
a=1<<16; b=1<<24; c=a|b; d=1<<2; e=1<<10; f=d|e;
|
||||
SP1 = [c|e,z|z,a|z,c|f,c|d,a|f,z|d,a|z,z|e,c|e,c|f,z|e,b|f,c|d,b|z,z|d,
|
||||
z|f,b|e,b|e,a|e,a|e,c|z,c|z,b|f,a|d,b|d,b|d,a|d,z|z,z|f,a|f,b|z,
|
||||
a|z,c|f,z|d,c|z,c|e,b|z,b|z,z|e,c|d,a|z,a|e,b|d,z|e,z|d,b|f,a|f,
|
||||
c|f,a|d,c|z,b|f,b|d,z|f,a|f,c|e,z|f,b|e,b|e,z|z,a|d,a|e,z|z,c|d];
|
||||
a=1<<20; b=1<<31; c=a|b; d=1<<5; e=1<<15; f=d|e;
|
||||
SP2 = [c|f,b|e,z|e,a|f,a|z,z|d,c|d,b|f,b|d,c|f,c|e,b|z,b|e,a|z,z|d,c|d,
|
||||
a|e,a|d,b|f,z|z,b|z,z|e,a|f,c|z,a|d,b|d,z|z,a|e,z|f,c|e,c|z,z|f,
|
||||
z|z,a|f,c|d,a|z,b|f,c|z,c|e,z|e,c|z,b|e,z|d,c|f,a|f,z|d,z|e,b|z,
|
||||
z|f,c|e,a|z,b|d,a|d,b|f,b|d,a|d,a|e,z|z,b|e,z|f,b|z,c|d,c|f,a|e];
|
||||
a=1<<17; b=1<<27; c=a|b; d=1<<3; e=1<<9; f=d|e;
|
||||
SP3 = [z|f,c|e,z|z,c|d,b|e,z|z,a|f,b|e,a|d,b|d,b|d,a|z,c|f,a|d,c|z,z|f,
|
||||
b|z,z|d,c|e,z|e,a|e,c|z,c|d,a|f,b|f,a|e,a|z,b|f,z|d,c|f,z|e,b|z,
|
||||
c|e,b|z,a|d,z|f,a|z,c|e,b|e,z|z,z|e,a|d,c|f,b|e,b|d,z|e,z|z,c|d,
|
||||
b|f,a|z,b|z,c|f,z|d,a|f,a|e,b|d,c|z,b|f,z|f,c|z,a|f,z|d,c|d,a|e];
|
||||
a=1<<13; b=1<<23; c=a|b; d=1<<0; e=1<<7; f=d|e;
|
||||
SP4 = [c|d,a|f,a|f,z|e,c|e,b|f,b|d,a|d,z|z,c|z,c|z,c|f,z|f,z|z,b|e,b|d,
|
||||
z|d,a|z,b|z,c|d,z|e,b|z,a|d,a|e,b|f,z|d,a|e,b|e,a|z,c|e,c|f,z|f,
|
||||
b|e,b|d,c|z,c|f,z|f,z|z,z|z,c|z,a|e,b|e,b|f,z|d,c|d,a|f,a|f,z|e,
|
||||
c|f,z|f,z|d,a|z,b|d,a|d,c|e,b|f,a|d,a|e,b|z,c|d,z|e,b|z,a|z,c|e];
|
||||
a=1<<25; b=1<<30; c=a|b; d=1<<8; e=1<<19; f=d|e;
|
||||
SP5 = [z|d,a|f,a|e,c|d,z|e,z|d,b|z,a|e,b|f,z|e,a|d,b|f,c|d,c|e,z|f,b|z,
|
||||
a|z,b|e,b|e,z|z,b|d,c|f,c|f,a|d,c|e,b|d,z|z,c|z,a|f,a|z,c|z,z|f,
|
||||
z|e,c|d,z|d,a|z,b|z,a|e,c|d,b|f,a|d,b|z,c|e,a|f,b|f,z|d,a|z,c|e,
|
||||
c|f,z|f,c|z,c|f,a|e,z|z,b|e,c|z,z|f,a|d,b|d,z|e,z|z,b|e,a|f,b|d];
|
||||
a=1<<22; b=1<<29; c=a|b; d=1<<4; e=1<<14; f=d|e;
|
||||
SP6 = [b|d,c|z,z|e,c|f,c|z,z|d,c|f,a|z,b|e,a|f,a|z,b|d,a|d,b|e,b|z,z|f,
|
||||
z|z,a|d,b|f,z|e,a|e,b|f,z|d,c|d,c|d,z|z,a|f,c|e,z|f,a|e,c|e,b|z,
|
||||
b|e,z|d,c|d,a|e,c|f,a|z,z|f,b|d,a|z,b|e,b|z,z|f,b|d,c|f,a|e,c|z,
|
||||
a|f,c|e,z|z,c|d,z|d,z|e,c|z,a|f,z|e,a|d,b|f,z|z,c|e,b|z,a|d,b|f];
|
||||
a=1<<21; b=1<<26; c=a|b; d=1<<1; e=1<<11; f=d|e;
|
||||
SP7 = [a|z,c|d,b|f,z|z,z|e,b|f,a|f,c|e,c|f,a|z,z|z,b|d,z|d,b|z,c|d,z|f,
|
||||
b|e,a|f,a|d,b|e,b|d,c|z,c|e,a|d,c|z,z|e,z|f,c|f,a|e,z|d,b|z,a|e,
|
||||
b|z,a|e,a|z,b|f,b|f,c|d,c|d,z|d,a|d,b|z,b|e,a|z,c|e,z|f,a|f,c|e,
|
||||
z|f,b|d,c|f,c|z,a|e,z|z,z|d,c|f,z|z,a|f,c|z,z|e,b|d,b|e,z|e,a|d];
|
||||
a=1<<18; b=1<<28; c=a|b; d=1<<6; e=1<<12; f=d|e;
|
||||
SP8 = [b|f,z|e,a|z,c|f,b|z,b|f,z|d,b|z,a|d,c|z,c|f,a|e,c|e,a|f,z|e,z|d,
|
||||
c|z,b|d,b|e,z|f,a|e,a|d,c|d,c|e,z|f,z|z,z|z,c|d,b|d,b|e,a|f,a|z,
|
||||
a|f,a|z,c|e,z|e,z|d,c|d,z|e,a|f,b|e,z|d,b|d,c|z,c|d,b|z,a|z,b|f,
|
||||
z|z,c|f,a|d,b|d,c|z,b|e,b|f,z|z,c|f,a|e,a|e,z|f,z|f,a|d,b|z,c|e];
|
||||
// jshint +W013,+W015
|
||||
|
||||
// Set the key.
|
||||
function setKeys(keyBlock) {
|
||||
var i, j, l, m, n, o, pc1m = [], pcr = [], kn = [],
|
||||
raw0, raw1, rawi, KnLi;
|
||||
|
||||
for (j = 0, l = 56; j < 56; ++j, l -= 8) {
|
||||
l += l < -5 ? 65 : l < -3 ? 31 : l < -1 ? 63 : l === 27 ? 35 : 0; // PC1
|
||||
m = l & 0x7;
|
||||
pc1m[j] = ((keyBlock[l >>> 3] & (1<<m)) !== 0) ? 1: 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; ++i) {
|
||||
m = i << 1;
|
||||
n = m + 1;
|
||||
kn[m] = kn[n] = 0;
|
||||
for (o = 28; o < 59; o += 28) {
|
||||
for (j = o - 28; j < o; ++j) {
|
||||
l = j + totrot[i];
|
||||
if (l < o) {
|
||||
pcr[j] = pc1m[l];
|
||||
} else {
|
||||
pcr[j] = pc1m[l - 28];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 0; j < 24; ++j) {
|
||||
if (pcr[PC2[j]] !== 0) {
|
||||
kn[m] |= 1 << (23 - j);
|
||||
}
|
||||
if (pcr[PC2[j + 24]] !== 0) {
|
||||
kn[n] |= 1 << (23 - j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cookey
|
||||
for (i = 0, rawi = 0, KnLi = 0; i < 16; ++i) {
|
||||
raw0 = kn[rawi++];
|
||||
raw1 = kn[rawi++];
|
||||
keys[KnLi] = (raw0 & 0x00fc0000) << 6;
|
||||
keys[KnLi] |= (raw0 & 0x00000fc0) << 10;
|
||||
keys[KnLi] |= (raw1 & 0x00fc0000) >>> 10;
|
||||
keys[KnLi] |= (raw1 & 0x00000fc0) >>> 6;
|
||||
++KnLi;
|
||||
keys[KnLi] = (raw0 & 0x0003f000) << 12;
|
||||
keys[KnLi] |= (raw0 & 0x0000003f) << 16;
|
||||
keys[KnLi] |= (raw1 & 0x0003f000) >>> 4;
|
||||
keys[KnLi] |= (raw1 & 0x0000003f);
|
||||
++KnLi;
|
||||
}
|
||||
}
|
||||
|
||||
// Encrypt 8 bytes of text
|
||||
function enc8(text) {
|
||||
var i = 0, b = text.slice(), fval, keysi = 0,
|
||||
l, r, x; // left, right, accumulator
|
||||
|
||||
// Squash 8 bytes to 2 ints
|
||||
l = b[i++]<<24 | b[i++]<<16 | b[i++]<<8 | b[i++];
|
||||
r = b[i++]<<24 | b[i++]<<16 | b[i++]<<8 | b[i++];
|
||||
|
||||
x = ((l >>> 4) ^ r) & 0x0f0f0f0f;
|
||||
r ^= x;
|
||||
l ^= (x << 4);
|
||||
x = ((l >>> 16) ^ r) & 0x0000ffff;
|
||||
r ^= x;
|
||||
l ^= (x << 16);
|
||||
x = ((r >>> 2) ^ l) & 0x33333333;
|
||||
l ^= x;
|
||||
r ^= (x << 2);
|
||||
x = ((r >>> 8) ^ l) & 0x00ff00ff;
|
||||
l ^= x;
|
||||
r ^= (x << 8);
|
||||
r = (r << 1) | ((r >>> 31) & 1);
|
||||
x = (l ^ r) & 0xaaaaaaaa;
|
||||
l ^= x;
|
||||
r ^= x;
|
||||
l = (l << 1) | ((l >>> 31) & 1);
|
||||
|
||||
for (i = 0; i < 8; ++i) {
|
||||
x = (r << 28) | (r >>> 4);
|
||||
x ^= keys[keysi++];
|
||||
fval = SP7[x & 0x3f];
|
||||
fval |= SP5[(x >>> 8) & 0x3f];
|
||||
fval |= SP3[(x >>> 16) & 0x3f];
|
||||
fval |= SP1[(x >>> 24) & 0x3f];
|
||||
x = r ^ keys[keysi++];
|
||||
fval |= SP8[x & 0x3f];
|
||||
fval |= SP6[(x >>> 8) & 0x3f];
|
||||
fval |= SP4[(x >>> 16) & 0x3f];
|
||||
fval |= SP2[(x >>> 24) & 0x3f];
|
||||
l ^= fval;
|
||||
x = (l << 28) | (l >>> 4);
|
||||
x ^= keys[keysi++];
|
||||
fval = SP7[x & 0x3f];
|
||||
fval |= SP5[(x >>> 8) & 0x3f];
|
||||
fval |= SP3[(x >>> 16) & 0x3f];
|
||||
fval |= SP1[(x >>> 24) & 0x3f];
|
||||
x = l ^ keys[keysi++];
|
||||
fval |= SP8[x & 0x0000003f];
|
||||
fval |= SP6[(x >>> 8) & 0x3f];
|
||||
fval |= SP4[(x >>> 16) & 0x3f];
|
||||
fval |= SP2[(x >>> 24) & 0x3f];
|
||||
r ^= fval;
|
||||
}
|
||||
|
||||
r = (r << 31) | (r >>> 1);
|
||||
x = (l ^ r) & 0xaaaaaaaa;
|
||||
l ^= x;
|
||||
r ^= x;
|
||||
l = (l << 31) | (l >>> 1);
|
||||
x = ((l >>> 8) ^ r) & 0x00ff00ff;
|
||||
r ^= x;
|
||||
l ^= (x << 8);
|
||||
x = ((l >>> 2) ^ r) & 0x33333333;
|
||||
r ^= x;
|
||||
l ^= (x << 2);
|
||||
x = ((r >>> 16) ^ l) & 0x0000ffff;
|
||||
l ^= x;
|
||||
r ^= (x << 16);
|
||||
x = ((r >>> 4) ^ l) & 0x0f0f0f0f;
|
||||
l ^= x;
|
||||
r ^= (x << 4);
|
||||
|
||||
// Spread ints to bytes
|
||||
x = [r, l];
|
||||
for (i = 0; i < 8; i++) {
|
||||
b[i] = (x[i>>>2] >>> (8 * (3 - (i % 4)))) % 256;
|
||||
if (b[i] < 0) { b[i] += 256; } // unsigned
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
// Encrypt 16 bytes of text using passwd as key
|
||||
function encrypt(t) {
|
||||
return enc8(t.slice(0, 8)).concat(enc8(t.slice(8, 16)));
|
||||
}
|
||||
|
||||
setKeys(passwd); // Setup keys
|
||||
return {'encrypt': encrypt}; // Public interface
|
||||
|
||||
} // function DES
|
||||
@@ -1,908 +0,0 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Copyright (C) 2015 Samuel Mannehed for Cendio AB
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*
|
||||
* See README.md for usage and integration instructions.
|
||||
*/
|
||||
|
||||
/*jslint browser: true, white: false */
|
||||
/*global Util, Base64, changeCursor */
|
||||
|
||||
var Display;
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var SUPPORTS_IMAGEDATA_CONSTRUCTOR = false;
|
||||
try {
|
||||
new ImageData(new Uint8ClampedArray(1), 1, 1);
|
||||
SUPPORTS_IMAGEDATA_CONSTRUCTOR = true;
|
||||
} catch (ex) {
|
||||
// ignore failure
|
||||
}
|
||||
|
||||
Display = function (defaults) {
|
||||
this._drawCtx = null;
|
||||
this._c_forceCanvas = false;
|
||||
|
||||
this._renderQ = []; // queue drawing actions for in-oder rendering
|
||||
|
||||
// the full frame buffer (logical canvas) size
|
||||
this._fb_width = 0;
|
||||
this._fb_height = 0;
|
||||
|
||||
// the size limit of the viewport (start disabled)
|
||||
this._maxWidth = 0;
|
||||
this._maxHeight = 0;
|
||||
|
||||
// the visible "physical canvas" viewport
|
||||
this._viewportLoc = { 'x': 0, 'y': 0, 'w': 0, 'h': 0 };
|
||||
this._cleanRect = { 'x1': 0, 'y1': 0, 'x2': -1, 'y2': -1 };
|
||||
|
||||
this._prevDrawStyle = "";
|
||||
this._tile = null;
|
||||
this._tile16x16 = null;
|
||||
this._tile_x = 0;
|
||||
this._tile_y = 0;
|
||||
|
||||
Util.set_defaults(this, defaults, {
|
||||
'true_color': true,
|
||||
'colourMap': [],
|
||||
'scale': 1.0,
|
||||
'viewport': false,
|
||||
'render_mode': ''
|
||||
});
|
||||
|
||||
Util.Debug(">> Display.constructor");
|
||||
|
||||
if (!this._target) {
|
||||
throw new Error("Target must be set");
|
||||
}
|
||||
|
||||
if (typeof this._target === 'string') {
|
||||
throw new Error('target must be a DOM element');
|
||||
}
|
||||
|
||||
if (!this._target.getContext) {
|
||||
throw new Error("no getContext method");
|
||||
}
|
||||
|
||||
if (!this._drawCtx) {
|
||||
this._drawCtx = this._target.getContext('2d');
|
||||
}
|
||||
|
||||
Util.Debug("User Agent: " + navigator.userAgent);
|
||||
if (Util.Engine.gecko) { Util.Debug("Browser: gecko " + Util.Engine.gecko); }
|
||||
if (Util.Engine.webkit) { Util.Debug("Browser: webkit " + Util.Engine.webkit); }
|
||||
if (Util.Engine.trident) { Util.Debug("Browser: trident " + Util.Engine.trident); }
|
||||
if (Util.Engine.presto) { Util.Debug("Browser: presto " + Util.Engine.presto); }
|
||||
|
||||
this.clear();
|
||||
|
||||
// Check canvas features
|
||||
if ('createImageData' in this._drawCtx) {
|
||||
this._render_mode = 'canvas rendering';
|
||||
} else {
|
||||
throw new Error("Canvas does not support createImageData");
|
||||
}
|
||||
|
||||
if (this._prefer_js === null) {
|
||||
Util.Info("Prefering javascript operations");
|
||||
this._prefer_js = true;
|
||||
}
|
||||
|
||||
// Determine browser support for setting the cursor via data URI scheme
|
||||
if (this._cursor_uri || this._cursor_uri === null ||
|
||||
this._cursor_uri === undefined) {
|
||||
this._cursor_uri = Util.browserSupportsCursorURIs();
|
||||
}
|
||||
|
||||
Util.Debug("<< Display.constructor");
|
||||
};
|
||||
|
||||
Display.prototype = {
|
||||
// Public methods
|
||||
viewportChangePos: function (deltaX, deltaY) {
|
||||
var vp = this._viewportLoc;
|
||||
deltaX = Math.floor(deltaX);
|
||||
deltaY = Math.floor(deltaY);
|
||||
|
||||
if (!this._viewport) {
|
||||
deltaX = -vp.w; // clamped later of out of bounds
|
||||
deltaY = -vp.h;
|
||||
}
|
||||
|
||||
var vx2 = vp.x + vp.w - 1;
|
||||
var vy2 = vp.y + vp.h - 1;
|
||||
|
||||
// Position change
|
||||
|
||||
if (deltaX < 0 && vp.x + deltaX < 0) {
|
||||
deltaX = -vp.x;
|
||||
}
|
||||
if (vx2 + deltaX >= this._fb_width) {
|
||||
deltaX -= vx2 + deltaX - this._fb_width + 1;
|
||||
}
|
||||
|
||||
if (vp.y + deltaY < 0) {
|
||||
deltaY = -vp.y;
|
||||
}
|
||||
if (vy2 + deltaY >= this._fb_height) {
|
||||
deltaY -= (vy2 + deltaY - this._fb_height + 1);
|
||||
}
|
||||
|
||||
if (deltaX === 0 && deltaY === 0) {
|
||||
return;
|
||||
}
|
||||
Util.Debug("viewportChange deltaX: " + deltaX + ", deltaY: " + deltaY);
|
||||
|
||||
vp.x += deltaX;
|
||||
vx2 += deltaX;
|
||||
vp.y += deltaY;
|
||||
vy2 += deltaY;
|
||||
|
||||
// Update the clean rectangle
|
||||
var cr = this._cleanRect;
|
||||
if (vp.x > cr.x1) {
|
||||
cr.x1 = vp.x;
|
||||
}
|
||||
if (vx2 < cr.x2) {
|
||||
cr.x2 = vx2;
|
||||
}
|
||||
if (vp.y > cr.y1) {
|
||||
cr.y1 = vp.y;
|
||||
}
|
||||
if (vy2 < cr.y2) {
|
||||
cr.y2 = vy2;
|
||||
}
|
||||
|
||||
var x1, w;
|
||||
if (deltaX < 0) {
|
||||
// Shift viewport left, redraw left section
|
||||
x1 = 0;
|
||||
w = -deltaX;
|
||||
} else {
|
||||
// Shift viewport right, redraw right section
|
||||
x1 = vp.w - deltaX;
|
||||
w = deltaX;
|
||||
}
|
||||
|
||||
var y1, h;
|
||||
if (deltaY < 0) {
|
||||
// Shift viewport up, redraw top section
|
||||
y1 = 0;
|
||||
h = -deltaY;
|
||||
} else {
|
||||
// Shift viewport down, redraw bottom section
|
||||
y1 = vp.h - deltaY;
|
||||
h = deltaY;
|
||||
}
|
||||
|
||||
var saveStyle = this._drawCtx.fillStyle;
|
||||
var canvas = this._target;
|
||||
this._drawCtx.fillStyle = "rgb(255,255,255)";
|
||||
|
||||
// Due to this bug among others [1] we need to disable the image-smoothing to
|
||||
// avoid getting a blur effect when panning.
|
||||
//
|
||||
// 1. https://bugzilla.mozilla.org/show_bug.cgi?id=1194719
|
||||
//
|
||||
// We need to set these every time since all properties are reset
|
||||
// when the the size is changed
|
||||
if (this._drawCtx.mozImageSmoothingEnabled) {
|
||||
this._drawCtx.mozImageSmoothingEnabled = false;
|
||||
} else if (this._drawCtx.webkitImageSmoothingEnabled) {
|
||||
this._drawCtx.webkitImageSmoothingEnabled = false;
|
||||
} else if (this._drawCtx.msImageSmoothingEnabled) {
|
||||
this._drawCtx.msImageSmoothingEnabled = false;
|
||||
} else if (this._drawCtx.imageSmoothingEnabled) {
|
||||
this._drawCtx.imageSmoothingEnabled = false;
|
||||
}
|
||||
|
||||
// Copy the valid part of the viewport to the shifted location
|
||||
this._drawCtx.drawImage(canvas, 0, 0, vp.w, vp.h, -deltaX, -deltaY, vp.w, vp.h);
|
||||
|
||||
if (deltaX !== 0) {
|
||||
this._drawCtx.fillRect(x1, 0, w, vp.h);
|
||||
}
|
||||
if (deltaY !== 0) {
|
||||
this._drawCtx.fillRect(0, y1, vp.w, h);
|
||||
}
|
||||
this._drawCtx.fillStyle = saveStyle;
|
||||
},
|
||||
|
||||
viewportChangeSize: function(width, height) {
|
||||
|
||||
if (typeof(width) === "undefined" || typeof(height) === "undefined") {
|
||||
|
||||
Util.Debug("Setting viewport to full display region");
|
||||
width = this._fb_width;
|
||||
height = this._fb_height;
|
||||
}
|
||||
|
||||
var vp = this._viewportLoc;
|
||||
if (vp.w !== width || vp.h !== height) {
|
||||
|
||||
if (this._viewport) {
|
||||
if (this._maxWidth !== 0 && width > this._maxWidth) {
|
||||
width = this._maxWidth;
|
||||
}
|
||||
if (this._maxHeight !== 0 && height > this._maxHeight) {
|
||||
height = this._maxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
var cr = this._cleanRect;
|
||||
|
||||
if (width < vp.w && cr.x2 > vp.x + width - 1) {
|
||||
cr.x2 = vp.x + width - 1;
|
||||
}
|
||||
if (height < vp.h && cr.y2 > vp.y + height - 1) {
|
||||
cr.y2 = vp.y + height - 1;
|
||||
}
|
||||
|
||||
vp.w = width;
|
||||
vp.h = height;
|
||||
|
||||
var canvas = this._target;
|
||||
if (canvas.width !== width || canvas.height !== height) {
|
||||
|
||||
// We have to save the canvas data since changing the size will clear it
|
||||
var saveImg = null;
|
||||
if (vp.w > 0 && vp.h > 0 && canvas.width > 0 && canvas.height > 0) {
|
||||
var img_width = canvas.width < vp.w ? canvas.width : vp.w;
|
||||
var img_height = canvas.height < vp.h ? canvas.height : vp.h;
|
||||
saveImg = this._drawCtx.getImageData(0, 0, img_width, img_height);
|
||||
}
|
||||
|
||||
if (canvas.width !== width) {
|
||||
canvas.width = width;
|
||||
canvas.style.width = width + 'px';
|
||||
}
|
||||
if (canvas.height !== height) {
|
||||
canvas.height = height;
|
||||
canvas.style.height = height + 'px';
|
||||
}
|
||||
|
||||
if (saveImg) {
|
||||
this._drawCtx.putImageData(saveImg, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Return a map of clean and dirty areas of the viewport and reset the
|
||||
// tracking of clean and dirty areas
|
||||
//
|
||||
// Returns: { 'cleanBox': { 'x': x, 'y': y, 'w': w, 'h': h},
|
||||
// 'dirtyBoxes': [{ 'x': x, 'y': y, 'w': w, 'h': h }, ...] }
|
||||
getCleanDirtyReset: function () {
|
||||
var vp = this._viewportLoc;
|
||||
var cr = this._cleanRect;
|
||||
|
||||
var cleanBox = { 'x': cr.x1, 'y': cr.y1,
|
||||
'w': cr.x2 - cr.x1 + 1, 'h': cr.y2 - cr.y1 + 1 };
|
||||
|
||||
var dirtyBoxes = [];
|
||||
if (cr.x1 >= cr.x2 || cr.y1 >= cr.y2) {
|
||||
// Whole viewport is dirty
|
||||
dirtyBoxes.push({ 'x': vp.x, 'y': vp.y, 'w': vp.w, 'h': vp.h });
|
||||
} else {
|
||||
// Redraw dirty regions
|
||||
var vx2 = vp.x + vp.w - 1;
|
||||
var vy2 = vp.y + vp.h - 1;
|
||||
|
||||
if (vp.x < cr.x1) {
|
||||
// left side dirty region
|
||||
dirtyBoxes.push({'x': vp.x, 'y': vp.y,
|
||||
'w': cr.x1 - vp.x + 1, 'h': vp.h});
|
||||
}
|
||||
if (vx2 > cr.x2) {
|
||||
// right side dirty region
|
||||
dirtyBoxes.push({'x': cr.x2 + 1, 'y': vp.y,
|
||||
'w': vx2 - cr.x2, 'h': vp.h});
|
||||
}
|
||||
if(vp.y < cr.y1) {
|
||||
// top/middle dirty region
|
||||
dirtyBoxes.push({'x': cr.x1, 'y': vp.y,
|
||||
'w': cr.x2 - cr.x1 + 1, 'h': cr.y1 - vp.y});
|
||||
}
|
||||
if (vy2 > cr.y2) {
|
||||
// bottom/middle dirty region
|
||||
dirtyBoxes.push({'x': cr.x1, 'y': cr.y2 + 1,
|
||||
'w': cr.x2 - cr.x1 + 1, 'h': vy2 - cr.y2});
|
||||
}
|
||||
}
|
||||
|
||||
this._cleanRect = {'x1': vp.x, 'y1': vp.y,
|
||||
'x2': vp.x + vp.w - 1, 'y2': vp.y + vp.h - 1};
|
||||
|
||||
return {'cleanBox': cleanBox, 'dirtyBoxes': dirtyBoxes};
|
||||
},
|
||||
|
||||
absX: function (x) {
|
||||
return x + this._viewportLoc.x;
|
||||
},
|
||||
|
||||
absY: function (y) {
|
||||
return y + this._viewportLoc.y;
|
||||
},
|
||||
|
||||
resize: function (width, height) {
|
||||
this._prevDrawStyle = "";
|
||||
|
||||
this._fb_width = width;
|
||||
this._fb_height = height;
|
||||
|
||||
this._rescale(this._scale);
|
||||
|
||||
this.viewportChangeSize();
|
||||
},
|
||||
|
||||
clear: function () {
|
||||
if (this._logo) {
|
||||
this.resize(this._logo.width, this._logo.height);
|
||||
this.blitStringImage(this._logo.data, 0, 0);
|
||||
} else {
|
||||
if (Util.Engine.trident === 6) {
|
||||
// NB(directxman12): there's a bug in IE10 where we can fail to actually
|
||||
// clear the canvas here because of the resize.
|
||||
// Clearing the current viewport first fixes the issue
|
||||
this._drawCtx.clearRect(0, 0, this._viewportLoc.w, this._viewportLoc.h);
|
||||
}
|
||||
this.resize(240, 20);
|
||||
this._drawCtx.clearRect(0, 0, this._viewportLoc.w, this._viewportLoc.h);
|
||||
}
|
||||
|
||||
this._renderQ = [];
|
||||
},
|
||||
|
||||
fillRect: function (x, y, width, height, color, from_queue) {
|
||||
if (this._renderQ.length !== 0 && !from_queue) {
|
||||
this.renderQ_push({
|
||||
'type': 'fill',
|
||||
'x': x,
|
||||
'y': y,
|
||||
'width': width,
|
||||
'height': height,
|
||||
'color': color
|
||||
});
|
||||
} else {
|
||||
this._setFillColor(color);
|
||||
this._drawCtx.fillRect(x - this._viewportLoc.x, y - this._viewportLoc.y, width, height);
|
||||
}
|
||||
},
|
||||
|
||||
copyImage: function (old_x, old_y, new_x, new_y, w, h, from_queue) {
|
||||
if (this._renderQ.length !== 0 && !from_queue) {
|
||||
this.renderQ_push({
|
||||
'type': 'copy',
|
||||
'old_x': old_x,
|
||||
'old_y': old_y,
|
||||
'x': new_x,
|
||||
'y': new_y,
|
||||
'width': w,
|
||||
'height': h,
|
||||
});
|
||||
} else {
|
||||
var x1 = old_x - this._viewportLoc.x;
|
||||
var y1 = old_y - this._viewportLoc.y;
|
||||
var x2 = new_x - this._viewportLoc.x;
|
||||
var y2 = new_y - this._viewportLoc.y;
|
||||
|
||||
this._drawCtx.drawImage(this._target, x1, y1, w, h, x2, y2, w, h);
|
||||
}
|
||||
},
|
||||
|
||||
// start updating a tile
|
||||
startTile: function (x, y, width, height, color) {
|
||||
this._tile_x = x;
|
||||
this._tile_y = y;
|
||||
if (width === 16 && height === 16) {
|
||||
this._tile = this._tile16x16;
|
||||
} else {
|
||||
this._tile = this._drawCtx.createImageData(width, height);
|
||||
}
|
||||
|
||||
if (this._prefer_js) {
|
||||
var bgr;
|
||||
if (this._true_color) {
|
||||
bgr = color;
|
||||
} else {
|
||||
bgr = this._colourMap[color[0]];
|
||||
}
|
||||
var red = bgr[2];
|
||||
var green = bgr[1];
|
||||
var blue = bgr[0];
|
||||
|
||||
var data = this._tile.data;
|
||||
for (var i = 0; i < width * height * 4; i += 4) {
|
||||
data[i] = red;
|
||||
data[i + 1] = green;
|
||||
data[i + 2] = blue;
|
||||
data[i + 3] = 255;
|
||||
}
|
||||
} else {
|
||||
this.fillRect(x, y, width, height, color, true);
|
||||
}
|
||||
},
|
||||
|
||||
// update sub-rectangle of the current tile
|
||||
subTile: function (x, y, w, h, color) {
|
||||
if (this._prefer_js) {
|
||||
var bgr;
|
||||
if (this._true_color) {
|
||||
bgr = color;
|
||||
} else {
|
||||
bgr = this._colourMap[color[0]];
|
||||
}
|
||||
var red = bgr[2];
|
||||
var green = bgr[1];
|
||||
var blue = bgr[0];
|
||||
var xend = x + w;
|
||||
var yend = y + h;
|
||||
|
||||
var data = this._tile.data;
|
||||
var width = this._tile.width;
|
||||
for (var j = y; j < yend; j++) {
|
||||
for (var i = x; i < xend; i++) {
|
||||
var p = (i + (j * width)) * 4;
|
||||
data[p] = red;
|
||||
data[p + 1] = green;
|
||||
data[p + 2] = blue;
|
||||
data[p + 3] = 255;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.fillRect(this._tile_x + x, this._tile_y + y, w, h, color, true);
|
||||
}
|
||||
},
|
||||
|
||||
// draw the current tile to the screen
|
||||
finishTile: function () {
|
||||
if (this._prefer_js) {
|
||||
this._drawCtx.putImageData(this._tile, this._tile_x - this._viewportLoc.x,
|
||||
this._tile_y - this._viewportLoc.y);
|
||||
}
|
||||
// else: No-op -- already done by setSubTile
|
||||
},
|
||||
|
||||
blitImage: function (x, y, width, height, arr, offset, from_queue) {
|
||||
if (this._renderQ.length !== 0 && !from_queue) {
|
||||
// NB(directxman12): it's technically more performant here to use preallocated arrays,
|
||||
// but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
|
||||
// this probably isn't getting called *nearly* as much
|
||||
var new_arr = new Uint8Array(width * height * 4);
|
||||
new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length));
|
||||
this.renderQ_push({
|
||||
'type': 'blit',
|
||||
'data': new_arr,
|
||||
'x': x,
|
||||
'y': y,
|
||||
'width': width,
|
||||
'height': height,
|
||||
});
|
||||
} else if (this._true_color) {
|
||||
this._bgrxImageData(x, y, this._viewportLoc.x, this._viewportLoc.y, width, height, arr, offset);
|
||||
} else {
|
||||
this._cmapImageData(x, y, this._viewportLoc.x, this._viewportLoc.y, width, height, arr, offset);
|
||||
}
|
||||
},
|
||||
|
||||
blitRgbImage: function (x, y , width, height, arr, offset, from_queue) {
|
||||
if (this._renderQ.length !== 0 && !from_queue) {
|
||||
// NB(directxman12): it's technically more performant here to use preallocated arrays,
|
||||
// but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
|
||||
// this probably isn't getting called *nearly* as much
|
||||
var new_arr = new Uint8Array(width * height * 4);
|
||||
new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length));
|
||||
this.renderQ_push({
|
||||
'type': 'blitRgb',
|
||||
'data': new_arr,
|
||||
'x': x,
|
||||
'y': y,
|
||||
'width': width,
|
||||
'height': height,
|
||||
});
|
||||
} else if (this._true_color) {
|
||||
this._rgbImageData(x, y, this._viewportLoc.x, this._viewportLoc.y, width, height, arr, offset);
|
||||
} else {
|
||||
// probably wrong?
|
||||
this._cmapImageData(x, y, this._viewportLoc.x, this._viewportLoc.y, width, height, arr, offset);
|
||||
}
|
||||
},
|
||||
|
||||
blitRgbxImage: function (x, y, width, height, arr, offset, from_queue) {
|
||||
if (this._renderQ.length !== 0 && !from_queue) {
|
||||
// NB(directxman12): it's technically more performant here to use preallocated arrays,
|
||||
// but it's a lot of extra work for not a lot of payoff -- if we're using the render queue,
|
||||
// this probably isn't getting called *nearly* as much
|
||||
var new_arr = new Uint8Array(width * height * 4);
|
||||
new_arr.set(new Uint8Array(arr.buffer, 0, new_arr.length));
|
||||
this.renderQ_push({
|
||||
'type': 'blitRgbx',
|
||||
'data': new_arr,
|
||||
'x': x,
|
||||
'y': y,
|
||||
'width': width,
|
||||
'height': height,
|
||||
});
|
||||
} else {
|
||||
this._rgbxImageData(x, y, this._viewportLoc.x, this._viewportLoc.y, width, height, arr, offset);
|
||||
}
|
||||
},
|
||||
|
||||
blitStringImage: function (str, x, y) {
|
||||
var img = new Image();
|
||||
img.onload = function () {
|
||||
this._drawCtx.drawImage(img, x - this._viewportLoc.x, y - this._viewportLoc.y);
|
||||
}.bind(this);
|
||||
img.src = str;
|
||||
return img; // for debugging purposes
|
||||
},
|
||||
|
||||
// wrap ctx.drawImage but relative to viewport
|
||||
drawImage: function (img, x, y) {
|
||||
this._drawCtx.drawImage(img, x - this._viewportLoc.x, y - this._viewportLoc.y);
|
||||
},
|
||||
|
||||
renderQ_push: function (action) {
|
||||
this._renderQ.push(action);
|
||||
if (this._renderQ.length === 1) {
|
||||
// If this can be rendered immediately it will be, otherwise
|
||||
// the scanner will start polling the queue (every
|
||||
// requestAnimationFrame interval)
|
||||
this._scan_renderQ();
|
||||
}
|
||||
},
|
||||
|
||||
changeCursor: function (pixels, mask, hotx, hoty, w, h) {
|
||||
if (this._cursor_uri === false) {
|
||||
Util.Warn("changeCursor called but no cursor data URI support");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._true_color) {
|
||||
Display.changeCursor(this._target, pixels, mask, hotx, hoty, w, h);
|
||||
} else {
|
||||
Display.changeCursor(this._target, pixels, mask, hotx, hoty, w, h, this._colourMap);
|
||||
}
|
||||
},
|
||||
|
||||
defaultCursor: function () {
|
||||
this._target.style.cursor = "default";
|
||||
},
|
||||
|
||||
disableLocalCursor: function () {
|
||||
this._target.style.cursor = "none";
|
||||
},
|
||||
|
||||
clippingDisplay: function () {
|
||||
var vp = this._viewportLoc;
|
||||
|
||||
var fbClip = this._fb_width > vp.w || this._fb_height > vp.h;
|
||||
var limitedVp = this._maxWidth !== 0 && this._maxHeight !== 0;
|
||||
var clipping = false;
|
||||
|
||||
if (limitedVp) {
|
||||
clipping = vp.w > this._maxWidth || vp.h > this._maxHeight;
|
||||
}
|
||||
|
||||
return fbClip || (limitedVp && clipping);
|
||||
},
|
||||
|
||||
// Overridden getters/setters
|
||||
get_context: function () {
|
||||
return this._drawCtx;
|
||||
},
|
||||
|
||||
set_scale: function (scale) {
|
||||
this._rescale(scale);
|
||||
},
|
||||
|
||||
set_width: function (w) {
|
||||
this._fb_width = w;
|
||||
},
|
||||
get_width: function () {
|
||||
return this._fb_width;
|
||||
},
|
||||
|
||||
set_height: function (h) {
|
||||
this._fb_height = h;
|
||||
},
|
||||
get_height: function () {
|
||||
return this._fb_height;
|
||||
},
|
||||
|
||||
autoscale: function (containerWidth, containerHeight, downscaleOnly) {
|
||||
var targetAspectRatio = containerWidth / containerHeight;
|
||||
var fbAspectRatio = this._fb_width / this._fb_height;
|
||||
|
||||
var scaleRatio;
|
||||
if (fbAspectRatio >= targetAspectRatio) {
|
||||
scaleRatio = containerWidth / this._fb_width;
|
||||
} else {
|
||||
scaleRatio = containerHeight / this._fb_height;
|
||||
}
|
||||
|
||||
var targetW, targetH;
|
||||
if (scaleRatio > 1.0 && downscaleOnly) {
|
||||
targetW = this._fb_width;
|
||||
targetH = this._fb_height;
|
||||
scaleRatio = 1.0;
|
||||
} else if (fbAspectRatio >= targetAspectRatio) {
|
||||
targetW = containerWidth;
|
||||
targetH = Math.round(containerWidth / fbAspectRatio);
|
||||
} else {
|
||||
targetW = Math.round(containerHeight * fbAspectRatio);
|
||||
targetH = containerHeight;
|
||||
}
|
||||
|
||||
// NB(directxman12): If you set the width directly, or set the
|
||||
// style width to a number, the canvas is cleared.
|
||||
// However, if you set the style width to a string
|
||||
// ('NNNpx'), the canvas is scaled without clearing.
|
||||
this._target.style.width = targetW + 'px';
|
||||
this._target.style.height = targetH + 'px';
|
||||
|
||||
this._scale = scaleRatio;
|
||||
|
||||
return scaleRatio; // so that the mouse, etc scale can be set
|
||||
},
|
||||
|
||||
// Private Methods
|
||||
_rescale: function (factor) {
|
||||
this._scale = factor;
|
||||
|
||||
var w;
|
||||
var h;
|
||||
|
||||
if (this._viewport &&
|
||||
this._maxWidth !== 0 && this._maxHeight !== 0) {
|
||||
w = Math.min(this._fb_width, this._maxWidth);
|
||||
h = Math.min(this._fb_height, this._maxHeight);
|
||||
} else {
|
||||
w = this._fb_width;
|
||||
h = this._fb_height;
|
||||
}
|
||||
|
||||
this._target.style.width = Math.round(factor * w) + 'px';
|
||||
this._target.style.height = Math.round(factor * h) + 'px';
|
||||
},
|
||||
|
||||
_setFillColor: function (color) {
|
||||
var bgr;
|
||||
if (this._true_color) {
|
||||
bgr = color;
|
||||
} else {
|
||||
bgr = this._colourMap[color];
|
||||
}
|
||||
|
||||
var newStyle = 'rgb(' + bgr[2] + ',' + bgr[1] + ',' + bgr[0] + ')';
|
||||
if (newStyle !== this._prevDrawStyle) {
|
||||
this._drawCtx.fillStyle = newStyle;
|
||||
this._prevDrawStyle = newStyle;
|
||||
}
|
||||
},
|
||||
|
||||
_rgbImageData: function (x, y, vx, vy, width, height, arr, offset) {
|
||||
var img = this._drawCtx.createImageData(width, height);
|
||||
var data = img.data;
|
||||
for (var i = 0, j = offset; i < width * height * 4; i += 4, j += 3) {
|
||||
data[i] = arr[j];
|
||||
data[i + 1] = arr[j + 1];
|
||||
data[i + 2] = arr[j + 2];
|
||||
data[i + 3] = 255; // Alpha
|
||||
}
|
||||
this._drawCtx.putImageData(img, x - vx, y - vy);
|
||||
},
|
||||
|
||||
_bgrxImageData: function (x, y, vx, vy, width, height, arr, offset) {
|
||||
var img = this._drawCtx.createImageData(width, height);
|
||||
var data = img.data;
|
||||
for (var i = 0, j = offset; i < width * height * 4; i += 4, j += 4) {
|
||||
data[i] = arr[j + 2];
|
||||
data[i + 1] = arr[j + 1];
|
||||
data[i + 2] = arr[j];
|
||||
data[i + 3] = 255; // Alpha
|
||||
}
|
||||
this._drawCtx.putImageData(img, x - vx, y - vy);
|
||||
},
|
||||
|
||||
_rgbxImageData: function (x, y, vx, vy, width, height, arr, offset) {
|
||||
// NB(directxman12): arr must be an Type Array view
|
||||
var img;
|
||||
if (SUPPORTS_IMAGEDATA_CONSTRUCTOR) {
|
||||
img = new ImageData(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4), width, height);
|
||||
} else {
|
||||
img = this._drawCtx.createImageData(width, height);
|
||||
img.data.set(new Uint8ClampedArray(arr.buffer, arr.byteOffset, width * height * 4));
|
||||
}
|
||||
this._drawCtx.putImageData(img, x - vx, y - vy);
|
||||
},
|
||||
|
||||
_cmapImageData: function (x, y, vx, vy, width, height, arr, offset) {
|
||||
var img = this._drawCtx.createImageData(width, height);
|
||||
var data = img.data;
|
||||
var cmap = this._colourMap;
|
||||
for (var i = 0, j = offset; i < width * height * 4; i += 4, j++) {
|
||||
var bgr = cmap[arr[j]];
|
||||
data[i] = bgr[2];
|
||||
data[i + 1] = bgr[1];
|
||||
data[i + 2] = bgr[0];
|
||||
data[i + 3] = 255; // Alpha
|
||||
}
|
||||
this._drawCtx.putImageData(img, x - vx, y - vy);
|
||||
},
|
||||
|
||||
_scan_renderQ: function () {
|
||||
var ready = true;
|
||||
while (ready && this._renderQ.length > 0) {
|
||||
var a = this._renderQ[0];
|
||||
switch (a.type) {
|
||||
case 'copy':
|
||||
this.copyImage(a.old_x, a.old_y, a.x, a.y, a.width, a.height, true);
|
||||
break;
|
||||
case 'fill':
|
||||
this.fillRect(a.x, a.y, a.width, a.height, a.color, true);
|
||||
break;
|
||||
case 'blit':
|
||||
this.blitImage(a.x, a.y, a.width, a.height, a.data, 0, true);
|
||||
break;
|
||||
case 'blitRgb':
|
||||
this.blitRgbImage(a.x, a.y, a.width, a.height, a.data, 0, true);
|
||||
break;
|
||||
case 'blitRgbx':
|
||||
this.blitRgbxImage(a.x, a.y, a.width, a.height, a.data, 0, true);
|
||||
break;
|
||||
case 'img':
|
||||
if (a.img.complete) {
|
||||
this.drawImage(a.img, a.x, a.y);
|
||||
} else {
|
||||
// We need to wait for this image to 'load'
|
||||
// to keep things in-order
|
||||
ready = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
this._renderQ.shift();
|
||||
}
|
||||
}
|
||||
|
||||
if (this._renderQ.length > 0) {
|
||||
requestAnimFrame(this._scan_renderQ.bind(this));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Util.make_properties(Display, [
|
||||
['target', 'wo', 'dom'], // Canvas element for rendering
|
||||
['context', 'ro', 'raw'], // Canvas 2D context for rendering (read-only)
|
||||
['logo', 'rw', 'raw'], // Logo to display when cleared: {"width": w, "height": h, "data": data}
|
||||
['true_color', 'rw', 'bool'], // Use true-color pixel data
|
||||
['colourMap', 'rw', 'arr'], // Colour map array (when not true-color)
|
||||
['scale', 'rw', 'float'], // Display area scale factor 0.0 - 1.0
|
||||
['viewport', 'rw', 'bool'], // Use viewport clipping
|
||||
['width', 'rw', 'int'], // Display area width
|
||||
['height', 'rw', 'int'], // Display area height
|
||||
['maxWidth', 'rw', 'int'], // Viewport max width (0 if disabled)
|
||||
['maxHeight', 'rw', 'int'], // Viewport max height (0 if disabled)
|
||||
|
||||
['render_mode', 'ro', 'str'], // Canvas rendering mode (read-only)
|
||||
|
||||
['prefer_js', 'rw', 'str'], // Prefer Javascript over canvas methods
|
||||
['cursor_uri', 'rw', 'raw'] // Can we render cursor using data URI
|
||||
]);
|
||||
|
||||
// Class Methods
|
||||
Display.changeCursor = function (target, pixels, mask, hotx, hoty, w0, h0, cmap) {
|
||||
var w = w0;
|
||||
var h = h0;
|
||||
if (h < w) {
|
||||
h = w; // increase h to make it square
|
||||
} else {
|
||||
w = h; // increase w to make it square
|
||||
}
|
||||
|
||||
var cur = [];
|
||||
|
||||
// Push multi-byte little-endian values
|
||||
cur.push16le = function (num) {
|
||||
this.push(num & 0xFF, (num >> 8) & 0xFF);
|
||||
};
|
||||
cur.push32le = function (num) {
|
||||
this.push(num & 0xFF,
|
||||
(num >> 8) & 0xFF,
|
||||
(num >> 16) & 0xFF,
|
||||
(num >> 24) & 0xFF);
|
||||
};
|
||||
|
||||
var IHDRsz = 40;
|
||||
var RGBsz = w * h * 4;
|
||||
var XORsz = Math.ceil((w * h) / 8.0);
|
||||
var ANDsz = Math.ceil((w * h) / 8.0);
|
||||
|
||||
cur.push16le(0); // 0: Reserved
|
||||
cur.push16le(2); // 2: .CUR type
|
||||
cur.push16le(1); // 4: Number of images, 1 for non-animated ico
|
||||
|
||||
// Cursor #1 header (ICONDIRENTRY)
|
||||
cur.push(w); // 6: width
|
||||
cur.push(h); // 7: height
|
||||
cur.push(0); // 8: colors, 0 -> true-color
|
||||
cur.push(0); // 9: reserved
|
||||
cur.push16le(hotx); // 10: hotspot x coordinate
|
||||
cur.push16le(hoty); // 12: hotspot y coordinate
|
||||
cur.push32le(IHDRsz + RGBsz + XORsz + ANDsz);
|
||||
// 14: cursor data byte size
|
||||
cur.push32le(22); // 18: offset of cursor data in the file
|
||||
|
||||
// Cursor #1 InfoHeader (ICONIMAGE/BITMAPINFO)
|
||||
cur.push32le(IHDRsz); // 22: InfoHeader size
|
||||
cur.push32le(w); // 26: Cursor width
|
||||
cur.push32le(h * 2); // 30: XOR+AND height
|
||||
cur.push16le(1); // 34: number of planes
|
||||
cur.push16le(32); // 36: bits per pixel
|
||||
cur.push32le(0); // 38: Type of compression
|
||||
|
||||
cur.push32le(XORsz + ANDsz);
|
||||
// 42: Size of Image
|
||||
cur.push32le(0); // 46: reserved
|
||||
cur.push32le(0); // 50: reserved
|
||||
cur.push32le(0); // 54: reserved
|
||||
cur.push32le(0); // 58: reserved
|
||||
|
||||
// 62: color data (RGBQUAD icColors[])
|
||||
var y, x;
|
||||
for (y = h - 1; y >= 0; y--) {
|
||||
for (x = 0; x < w; x++) {
|
||||
if (x >= w0 || y >= h0) {
|
||||
cur.push(0); // blue
|
||||
cur.push(0); // green
|
||||
cur.push(0); // red
|
||||
cur.push(0); // alpha
|
||||
} else {
|
||||
var idx = y * Math.ceil(w0 / 8) + Math.floor(x / 8);
|
||||
var alpha = (mask[idx] << (x % 8)) & 0x80 ? 255 : 0;
|
||||
if (cmap) {
|
||||
idx = (w0 * y) + x;
|
||||
var rgb = cmap[pixels[idx]];
|
||||
cur.push(rgb[2]); // blue
|
||||
cur.push(rgb[1]); // green
|
||||
cur.push(rgb[0]); // red
|
||||
cur.push(alpha); // alpha
|
||||
} else {
|
||||
idx = ((w0 * y) + x) * 4;
|
||||
cur.push(pixels[idx + 2]); // blue
|
||||
cur.push(pixels[idx + 1]); // green
|
||||
cur.push(pixels[idx]); // red
|
||||
cur.push(alpha); // alpha
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// XOR/bitmask data (BYTE icXOR[])
|
||||
// (ignored, just needs to be the right size)
|
||||
for (y = 0; y < h; y++) {
|
||||
for (x = 0; x < Math.ceil(w / 8); x++) {
|
||||
cur.push(0);
|
||||
}
|
||||
}
|
||||
|
||||
// AND/bitmask data (BYTE icAND[])
|
||||
// (ignored, just needs to be the right size)
|
||||
for (y = 0; y < h; y++) {
|
||||
for (x = 0; x < Math.ceil(w / 8); x++) {
|
||||
cur.push(0);
|
||||
}
|
||||
}
|
||||
|
||||
var url = 'data:image/x-icon;base64,' + Base64.encode(cur);
|
||||
target.style.cursor = 'url(' + url + ')' + hotx + ' ' + hoty + ', default';
|
||||
};
|
||||
})();
|
||||
@@ -1,389 +0,0 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Copyright (C) 2013 Samuel Mannehed for Cendio AB
|
||||
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
|
||||
*/
|
||||
|
||||
/*jslint browser: true, white: false */
|
||||
/*global window, Util */
|
||||
|
||||
var Keyboard, Mouse;
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
//
|
||||
// Keyboard event handler
|
||||
//
|
||||
|
||||
Keyboard = function (defaults) {
|
||||
this._keyDownList = []; // List of depressed keys
|
||||
// (even if they are happy)
|
||||
|
||||
Util.set_defaults(this, defaults, {
|
||||
'target': document,
|
||||
'focused': true
|
||||
});
|
||||
|
||||
// create the keyboard handler
|
||||
this._handler = new KeyEventDecoder(kbdUtil.ModifierSync(),
|
||||
VerifyCharModifier( /* jshint newcap: false */
|
||||
TrackKeyState(
|
||||
EscapeModifiers(this._handleRfbEvent.bind(this))
|
||||
)
|
||||
)
|
||||
); /* jshint newcap: true */
|
||||
|
||||
// keep these here so we can refer to them later
|
||||
this._eventHandlers = {
|
||||
'keyup': this._handleKeyUp.bind(this),
|
||||
'keydown': this._handleKeyDown.bind(this),
|
||||
'keypress': this._handleKeyPress.bind(this),
|
||||
'blur': this._allKeysUp.bind(this)
|
||||
};
|
||||
};
|
||||
|
||||
Keyboard.prototype = {
|
||||
// private methods
|
||||
|
||||
_handleRfbEvent: function (e) {
|
||||
if (this._onKeyPress) {
|
||||
Util.Debug("onKeyPress " + (e.type == 'keydown' ? "down" : "up") +
|
||||
", keysym: " + e.keysym.keysym + "(" + e.keysym.keyname + ")");
|
||||
this._onKeyPress(e.keysym.keysym, e.type == 'keydown');
|
||||
}
|
||||
},
|
||||
|
||||
_handleKeyDown: function (e) {
|
||||
if (!this._focused) { return true; }
|
||||
|
||||
if (this._handler.keydown(e)) {
|
||||
// Suppress bubbling/default actions
|
||||
Util.stopEvent(e);
|
||||
return false;
|
||||
} else {
|
||||
// Allow the event to bubble and become a keyPress event which
|
||||
// will have the character code translated
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
_handleKeyPress: function (e) {
|
||||
if (!this._focused) { return true; }
|
||||
|
||||
if (this._handler.keypress(e)) {
|
||||
// Suppress bubbling/default actions
|
||||
Util.stopEvent(e);
|
||||
return false;
|
||||
} else {
|
||||
// Allow the event to bubble and become a keyPress event which
|
||||
// will have the character code translated
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
_handleKeyUp: function (e) {
|
||||
if (!this._focused) { return true; }
|
||||
|
||||
if (this._handler.keyup(e)) {
|
||||
// Suppress bubbling/default actions
|
||||
Util.stopEvent(e);
|
||||
return false;
|
||||
} else {
|
||||
// Allow the event to bubble and become a keyPress event which
|
||||
// will have the character code translated
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
_allKeysUp: function () {
|
||||
Util.Debug(">> Keyboard.allKeysUp");
|
||||
this._handler.releaseAll();
|
||||
Util.Debug("<< Keyboard.allKeysUp");
|
||||
},
|
||||
|
||||
// Public methods
|
||||
|
||||
grab: function () {
|
||||
//Util.Debug(">> Keyboard.grab");
|
||||
var c = this._target;
|
||||
|
||||
Util.addEvent(c, 'keydown', this._eventHandlers.keydown);
|
||||
Util.addEvent(c, 'keyup', this._eventHandlers.keyup);
|
||||
Util.addEvent(c, 'keypress', this._eventHandlers.keypress);
|
||||
|
||||
// Release (key up) if window loses focus
|
||||
Util.addEvent(window, 'blur', this._eventHandlers.blur);
|
||||
|
||||
//Util.Debug("<< Keyboard.grab");
|
||||
},
|
||||
|
||||
ungrab: function () {
|
||||
//Util.Debug(">> Keyboard.ungrab");
|
||||
var c = this._target;
|
||||
|
||||
Util.removeEvent(c, 'keydown', this._eventHandlers.keydown);
|
||||
Util.removeEvent(c, 'keyup', this._eventHandlers.keyup);
|
||||
Util.removeEvent(c, 'keypress', this._eventHandlers.keypress);
|
||||
Util.removeEvent(window, 'blur', this._eventHandlers.blur);
|
||||
|
||||
// Release (key up) all keys that are in a down state
|
||||
this._allKeysUp();
|
||||
|
||||
//Util.Debug(">> Keyboard.ungrab");
|
||||
},
|
||||
|
||||
sync: function (e) {
|
||||
this._handler.syncModifiers(e);
|
||||
}
|
||||
};
|
||||
|
||||
Util.make_properties(Keyboard, [
|
||||
['target', 'wo', 'dom'], // DOM element that captures keyboard input
|
||||
['focused', 'rw', 'bool'], // Capture and send key events
|
||||
|
||||
['onKeyPress', 'rw', 'func'] // Handler for key press/release
|
||||
]);
|
||||
|
||||
//
|
||||
// Mouse event handler
|
||||
//
|
||||
|
||||
Mouse = function (defaults) {
|
||||
this._mouseCaptured = false;
|
||||
|
||||
this._doubleClickTimer = null;
|
||||
this._lastTouchPos = null;
|
||||
|
||||
// Configuration attributes
|
||||
Util.set_defaults(this, defaults, {
|
||||
'target': document,
|
||||
'focused': true,
|
||||
'scale': 1.0,
|
||||
'touchButton': 1
|
||||
});
|
||||
|
||||
this._eventHandlers = {
|
||||
'mousedown': this._handleMouseDown.bind(this),
|
||||
'mouseup': this._handleMouseUp.bind(this),
|
||||
'mousemove': this._handleMouseMove.bind(this),
|
||||
'mousewheel': this._handleMouseWheel.bind(this),
|
||||
'mousedisable': this._handleMouseDisable.bind(this)
|
||||
};
|
||||
};
|
||||
|
||||
Mouse.prototype = {
|
||||
// private methods
|
||||
_captureMouse: function () {
|
||||
// capturing the mouse ensures we get the mouseup event
|
||||
if (this._target.setCapture) {
|
||||
this._target.setCapture();
|
||||
}
|
||||
|
||||
// some browsers give us mouseup events regardless,
|
||||
// so if we never captured the mouse, we can disregard the event
|
||||
this._mouseCaptured = true;
|
||||
},
|
||||
|
||||
_releaseMouse: function () {
|
||||
if (this._target.releaseCapture) {
|
||||
this._target.releaseCapture();
|
||||
}
|
||||
this._mouseCaptured = false;
|
||||
},
|
||||
|
||||
_resetDoubleClickTimer: function () {
|
||||
this._doubleClickTimer = null;
|
||||
},
|
||||
|
||||
_handleMouseButton: function (e, down) {
|
||||
if (!this._focused) { return true; }
|
||||
|
||||
if (this._notify) {
|
||||
this._notify(e);
|
||||
}
|
||||
|
||||
var evt = (e ? e : window.event);
|
||||
var pos = Util.getEventPosition(e, this._target, this._scale);
|
||||
|
||||
var bmask;
|
||||
if (e.touches || e.changedTouches) {
|
||||
// Touch device
|
||||
|
||||
// When two touches occur within 500 ms of each other and are
|
||||
// close enough together a double click is triggered.
|
||||
if (down == 1) {
|
||||
if (this._doubleClickTimer === null) {
|
||||
this._lastTouchPos = pos;
|
||||
} else {
|
||||
clearTimeout(this._doubleClickTimer);
|
||||
|
||||
// When the distance between the two touches is small enough
|
||||
// force the position of the latter touch to the position of
|
||||
// the first.
|
||||
|
||||
var xs = this._lastTouchPos.x - pos.x;
|
||||
var ys = this._lastTouchPos.y - pos.y;
|
||||
var d = Math.sqrt((xs * xs) + (ys * ys));
|
||||
|
||||
// The goal is to trigger on a certain physical width, the
|
||||
// devicePixelRatio brings us a bit closer but is not optimal.
|
||||
var threshold = 20 * (window.devicePixelRatio || 1);
|
||||
if (d < threshold) {
|
||||
pos = this._lastTouchPos;
|
||||
}
|
||||
}
|
||||
this._doubleClickTimer = setTimeout(this._resetDoubleClickTimer.bind(this), 500);
|
||||
}
|
||||
bmask = this._touchButton;
|
||||
// If bmask is set
|
||||
} else if (evt.which) {
|
||||
/* everything except IE */
|
||||
bmask = 1 << evt.button;
|
||||
} else {
|
||||
/* IE including 9 */
|
||||
bmask = (evt.button & 0x1) + // Left
|
||||
(evt.button & 0x2) * 2 + // Right
|
||||
(evt.button & 0x4) / 2; // Middle
|
||||
}
|
||||
|
||||
if (this._onMouseButton) {
|
||||
Util.Debug("onMouseButton " + (down ? "down" : "up") +
|
||||
", x: " + pos.x + ", y: " + pos.y + ", bmask: " + bmask);
|
||||
this._onMouseButton(pos.x, pos.y, down, bmask);
|
||||
}
|
||||
Util.stopEvent(e);
|
||||
return false;
|
||||
},
|
||||
|
||||
_handleMouseDown: function (e) {
|
||||
this._captureMouse();
|
||||
this._handleMouseButton(e, 1);
|
||||
},
|
||||
|
||||
_handleMouseUp: function (e) {
|
||||
if (!this._mouseCaptured) { return; }
|
||||
|
||||
this._handleMouseButton(e, 0);
|
||||
this._releaseMouse();
|
||||
},
|
||||
|
||||
_handleMouseWheel: function (e) {
|
||||
if (!this._focused) { return true; }
|
||||
|
||||
if (this._notify) {
|
||||
this._notify(e);
|
||||
}
|
||||
|
||||
var evt = (e ? e : window.event);
|
||||
var pos = Util.getEventPosition(e, this._target, this._scale);
|
||||
var wheelData = evt.detail ? evt.detail * -1 : evt.wheelDelta / 40;
|
||||
var bmask;
|
||||
if (wheelData > 0) {
|
||||
bmask = 1 << 3;
|
||||
} else {
|
||||
bmask = 1 << 4;
|
||||
}
|
||||
|
||||
if (this._onMouseButton) {
|
||||
this._onMouseButton(pos.x, pos.y, 1, bmask);
|
||||
this._onMouseButton(pos.x, pos.y, 0, bmask);
|
||||
}
|
||||
Util.stopEvent(e);
|
||||
return false;
|
||||
},
|
||||
|
||||
_handleMouseMove: function (e) {
|
||||
if (! this._focused) { return true; }
|
||||
|
||||
if (this._notify) {
|
||||
this._notify(e);
|
||||
}
|
||||
|
||||
var evt = (e ? e : window.event);
|
||||
var pos = Util.getEventPosition(e, this._target, this._scale);
|
||||
if (this._onMouseMove) {
|
||||
this._onMouseMove(pos.x, pos.y);
|
||||
}
|
||||
Util.stopEvent(e);
|
||||
return false;
|
||||
},
|
||||
|
||||
_handleMouseDisable: function (e) {
|
||||
if (!this._focused) { return true; }
|
||||
|
||||
var evt = (e ? e : window.event);
|
||||
var pos = Util.getEventPosition(e, this._target, this._scale);
|
||||
|
||||
/* Stop propagation if inside canvas area */
|
||||
if ((pos.realx >= 0) && (pos.realy >= 0) &&
|
||||
(pos.realx < this._target.offsetWidth) &&
|
||||
(pos.realy < this._target.offsetHeight)) {
|
||||
//Util.Debug("mouse event disabled");
|
||||
Util.stopEvent(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
|
||||
// Public methods
|
||||
grab: function () {
|
||||
var c = this._target;
|
||||
|
||||
if ('ontouchstart' in document.documentElement) {
|
||||
Util.addEvent(c, 'touchstart', this._eventHandlers.mousedown);
|
||||
Util.addEvent(window, 'touchend', this._eventHandlers.mouseup);
|
||||
Util.addEvent(c, 'touchend', this._eventHandlers.mouseup);
|
||||
Util.addEvent(c, 'touchmove', this._eventHandlers.mousemove);
|
||||
} else {
|
||||
Util.addEvent(c, 'mousedown', this._eventHandlers.mousedown);
|
||||
Util.addEvent(window, 'mouseup', this._eventHandlers.mouseup);
|
||||
Util.addEvent(c, 'mouseup', this._eventHandlers.mouseup);
|
||||
Util.addEvent(c, 'mousemove', this._eventHandlers.mousemove);
|
||||
Util.addEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
|
||||
this._eventHandlers.mousewheel);
|
||||
}
|
||||
|
||||
/* Work around right and middle click browser behaviors */
|
||||
Util.addEvent(document, 'click', this._eventHandlers.mousedisable);
|
||||
Util.addEvent(document.body, 'contextmenu', this._eventHandlers.mousedisable);
|
||||
},
|
||||
|
||||
ungrab: function () {
|
||||
var c = this._target;
|
||||
|
||||
if ('ontouchstart' in document.documentElement) {
|
||||
Util.removeEvent(c, 'touchstart', this._eventHandlers.mousedown);
|
||||
Util.removeEvent(window, 'touchend', this._eventHandlers.mouseup);
|
||||
Util.removeEvent(c, 'touchend', this._eventHandlers.mouseup);
|
||||
Util.removeEvent(c, 'touchmove', this._eventHandlers.mousemove);
|
||||
} else {
|
||||
Util.removeEvent(c, 'mousedown', this._eventHandlers.mousedown);
|
||||
Util.removeEvent(window, 'mouseup', this._eventHandlers.mouseup);
|
||||
Util.removeEvent(c, 'mouseup', this._eventHandlers.mouseup);
|
||||
Util.removeEvent(c, 'mousemove', this._eventHandlers.mousemove);
|
||||
Util.removeEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
|
||||
this._eventHandlers.mousewheel);
|
||||
}
|
||||
|
||||
/* Work around right and middle click browser behaviors */
|
||||
Util.removeEvent(document, 'click', this._eventHandlers.mousedisable);
|
||||
Util.removeEvent(document.body, 'contextmenu', this._eventHandlers.mousedisable);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Util.make_properties(Mouse, [
|
||||
['target', 'ro', 'dom'], // DOM element that captures mouse input
|
||||
['notify', 'ro', 'func'], // Function to call to notify whenever a mouse event is received
|
||||
['focused', 'rw', 'bool'], // Capture and send mouse clicks/movement
|
||||
['scale', 'rw', 'float'], // Viewport scale factor 0.0 - 1.0
|
||||
|
||||
['onMouseButton', 'rw', 'func'], // Handler for mouse button click/release
|
||||
['onMouseMove', 'rw', 'func'], // Handler for mouse movement
|
||||
['touchButton', 'rw', 'int'] // Button mask (1, 2, 4) for touch devices (0 means ignore clicks)
|
||||
]);
|
||||
})();
|
||||
@@ -1,543 +0,0 @@
|
||||
var kbdUtil = (function() {
|
||||
"use strict";
|
||||
|
||||
function substituteCodepoint(cp) {
|
||||
// Any Unicode code points which do not have corresponding keysym entries
|
||||
// can be swapped out for another code point by adding them to this table
|
||||
var substitutions = {
|
||||
// {S,s} with comma below -> {S,s} with cedilla
|
||||
0x218 : 0x15e,
|
||||
0x219 : 0x15f,
|
||||
// {T,t} with comma below -> {T,t} with cedilla
|
||||
0x21a : 0x162,
|
||||
0x21b : 0x163
|
||||
};
|
||||
|
||||
var sub = substitutions[cp];
|
||||
return sub ? sub : cp;
|
||||
}
|
||||
|
||||
function isMac() {
|
||||
return navigator && !!(/mac/i).exec(navigator.platform);
|
||||
}
|
||||
function isWindows() {
|
||||
return navigator && !!(/win/i).exec(navigator.platform);
|
||||
}
|
||||
function isLinux() {
|
||||
return navigator && !!(/linux/i).exec(navigator.platform);
|
||||
}
|
||||
|
||||
// Return true if a modifier which is not the specified char modifier (and is not shift) is down
|
||||
function hasShortcutModifier(charModifier, currentModifiers) {
|
||||
var mods = {};
|
||||
for (var key in currentModifiers) {
|
||||
if (parseInt(key) !== XK_Shift_L) {
|
||||
mods[key] = currentModifiers[key];
|
||||
}
|
||||
}
|
||||
|
||||
var sum = 0;
|
||||
for (var k in currentModifiers) {
|
||||
if (mods[k]) {
|
||||
++sum;
|
||||
}
|
||||
}
|
||||
if (hasCharModifier(charModifier, mods)) {
|
||||
return sum > charModifier.length;
|
||||
}
|
||||
else {
|
||||
return sum > 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Return true if the specified char modifier is currently down
|
||||
function hasCharModifier(charModifier, currentModifiers) {
|
||||
if (charModifier.length === 0) { return false; }
|
||||
|
||||
for (var i = 0; i < charModifier.length; ++i) {
|
||||
if (!currentModifiers[charModifier[i]]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Helper object tracking modifier key state
|
||||
// and generates fake key events to compensate if it gets out of sync
|
||||
function ModifierSync(charModifier) {
|
||||
if (!charModifier) {
|
||||
if (isMac()) {
|
||||
// on Mac, Option (AKA Alt) is used as a char modifier
|
||||
charModifier = [XK_Alt_L];
|
||||
}
|
||||
else if (isWindows()) {
|
||||
// on Windows, Ctrl+Alt is used as a char modifier
|
||||
charModifier = [XK_Alt_L, XK_Control_L];
|
||||
}
|
||||
else if (isLinux()) {
|
||||
// on Linux, ISO Level 3 Shift (AltGr) is used as a char modifier
|
||||
charModifier = [XK_ISO_Level3_Shift];
|
||||
}
|
||||
else {
|
||||
charModifier = [];
|
||||
}
|
||||
}
|
||||
|
||||
var state = {};
|
||||
state[XK_Control_L] = false;
|
||||
state[XK_Alt_L] = false;
|
||||
state[XK_ISO_Level3_Shift] = false;
|
||||
state[XK_Shift_L] = false;
|
||||
state[XK_Meta_L] = false;
|
||||
|
||||
function sync(evt, keysym) {
|
||||
var result = [];
|
||||
function syncKey(keysym) {
|
||||
return {keysym: keysyms.lookup(keysym), type: state[keysym] ? 'keydown' : 'keyup'};
|
||||
}
|
||||
|
||||
if (evt.ctrlKey !== undefined &&
|
||||
evt.ctrlKey !== state[XK_Control_L] && keysym !== XK_Control_L) {
|
||||
state[XK_Control_L] = evt.ctrlKey;
|
||||
result.push(syncKey(XK_Control_L));
|
||||
}
|
||||
if (evt.altKey !== undefined &&
|
||||
evt.altKey !== state[XK_Alt_L] && keysym !== XK_Alt_L) {
|
||||
state[XK_Alt_L] = evt.altKey;
|
||||
result.push(syncKey(XK_Alt_L));
|
||||
}
|
||||
if (evt.altGraphKey !== undefined &&
|
||||
evt.altGraphKey !== state[XK_ISO_Level3_Shift] && keysym !== XK_ISO_Level3_Shift) {
|
||||
state[XK_ISO_Level3_Shift] = evt.altGraphKey;
|
||||
result.push(syncKey(XK_ISO_Level3_Shift));
|
||||
}
|
||||
if (evt.shiftKey !== undefined &&
|
||||
evt.shiftKey !== state[XK_Shift_L] && keysym !== XK_Shift_L) {
|
||||
state[XK_Shift_L] = evt.shiftKey;
|
||||
result.push(syncKey(XK_Shift_L));
|
||||
}
|
||||
if (evt.metaKey !== undefined &&
|
||||
evt.metaKey !== state[XK_Meta_L] && keysym !== XK_Meta_L) {
|
||||
state[XK_Meta_L] = evt.metaKey;
|
||||
result.push(syncKey(XK_Meta_L));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function syncKeyEvent(evt, down) {
|
||||
var obj = getKeysym(evt);
|
||||
var keysym = obj ? obj.keysym : null;
|
||||
|
||||
// first, apply the event itself, if relevant
|
||||
if (keysym !== null && state[keysym] !== undefined) {
|
||||
state[keysym] = down;
|
||||
}
|
||||
return sync(evt, keysym);
|
||||
}
|
||||
|
||||
return {
|
||||
// sync on the appropriate keyboard event
|
||||
keydown: function(evt) { return syncKeyEvent(evt, true);},
|
||||
keyup: function(evt) { return syncKeyEvent(evt, false);},
|
||||
// Call this with a non-keyboard event (such as mouse events) to use its modifier state to synchronize anyway
|
||||
syncAny: function(evt) { return sync(evt);},
|
||||
|
||||
// is a shortcut modifier down?
|
||||
hasShortcutModifier: function() { return hasShortcutModifier(charModifier, state); },
|
||||
// if a char modifier is down, return the keys it consists of, otherwise return null
|
||||
activeCharModifier: function() { return hasCharModifier(charModifier, state) ? charModifier : null; }
|
||||
};
|
||||
}
|
||||
|
||||
// Get a key ID from a keyboard event
|
||||
// May be a string or an integer depending on the available properties
|
||||
function getKey(evt){
|
||||
if ('keyCode' in evt && 'key' in evt) {
|
||||
return evt.key + ':' + evt.keyCode;
|
||||
}
|
||||
else if ('keyCode' in evt) {
|
||||
return evt.keyCode;
|
||||
}
|
||||
else {
|
||||
return evt.key;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the most reliable keysym value we can get from a key event
|
||||
// if char/charCode is available, prefer those, otherwise fall back to key/keyCode/which
|
||||
function getKeysym(evt){
|
||||
var codepoint;
|
||||
if (evt.char && evt.char.length === 1) {
|
||||
codepoint = evt.char.charCodeAt();
|
||||
}
|
||||
else if (evt.charCode) {
|
||||
codepoint = evt.charCode;
|
||||
}
|
||||
else if (evt.keyCode && evt.type === 'keypress') {
|
||||
// IE10 stores the char code as keyCode, and has no other useful properties
|
||||
codepoint = evt.keyCode;
|
||||
}
|
||||
if (codepoint) {
|
||||
var res = keysyms.fromUnicode(substituteCodepoint(codepoint));
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
// we could check evt.key here.
|
||||
// Legal values are defined in http://www.w3.org/TR/DOM-Level-3-Events/#key-values-list,
|
||||
// so we "just" need to map them to keysym, but AFAIK this is only available in IE10, which also provides evt.key
|
||||
// so we don't *need* it yet
|
||||
if (evt.keyCode) {
|
||||
return keysyms.lookup(keysymFromKeyCode(evt.keyCode, evt.shiftKey));
|
||||
}
|
||||
if (evt.which) {
|
||||
return keysyms.lookup(keysymFromKeyCode(evt.which, evt.shiftKey));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Given a keycode, try to predict which keysym it might be.
|
||||
// If the keycode is unknown, null is returned.
|
||||
function keysymFromKeyCode(keycode, shiftPressed) {
|
||||
if (typeof(keycode) !== 'number') {
|
||||
return null;
|
||||
}
|
||||
// won't be accurate for azerty
|
||||
if (keycode >= 0x30 && keycode <= 0x39) {
|
||||
return keycode; // digit
|
||||
}
|
||||
if (keycode >= 0x41 && keycode <= 0x5a) {
|
||||
// remap to lowercase unless shift is down
|
||||
return shiftPressed ? keycode : keycode + 32; // A-Z
|
||||
}
|
||||
if (keycode >= 0x60 && keycode <= 0x69) {
|
||||
return XK_KP_0 + (keycode - 0x60); // numpad 0-9
|
||||
}
|
||||
|
||||
switch(keycode) {
|
||||
case 0x20: return XK_space;
|
||||
case 0x6a: return XK_KP_Multiply;
|
||||
case 0x6b: return XK_KP_Add;
|
||||
case 0x6c: return XK_KP_Separator;
|
||||
case 0x6d: return XK_KP_Subtract;
|
||||
case 0x6e: return XK_KP_Decimal;
|
||||
case 0x6f: return XK_KP_Divide;
|
||||
case 0xbb: return XK_plus;
|
||||
case 0xbc: return XK_comma;
|
||||
case 0xbd: return XK_minus;
|
||||
case 0xbe: return XK_period;
|
||||
}
|
||||
|
||||
return nonCharacterKey({keyCode: keycode});
|
||||
}
|
||||
|
||||
// if the key is a known non-character key (any key which doesn't generate character data)
|
||||
// return its keysym value. Otherwise return null
|
||||
function nonCharacterKey(evt) {
|
||||
// evt.key not implemented yet
|
||||
if (!evt.keyCode) { return null; }
|
||||
var keycode = evt.keyCode;
|
||||
|
||||
if (keycode >= 0x70 && keycode <= 0x87) {
|
||||
return XK_F1 + keycode - 0x70; // F1-F24
|
||||
}
|
||||
switch (keycode) {
|
||||
|
||||
case 8 : return XK_BackSpace;
|
||||
case 13 : return XK_Return;
|
||||
|
||||
case 9 : return XK_Tab;
|
||||
|
||||
case 27 : return XK_Escape;
|
||||
case 46 : return XK_Delete;
|
||||
|
||||
case 36 : return XK_Home;
|
||||
case 35 : return XK_End;
|
||||
case 33 : return XK_Page_Up;
|
||||
case 34 : return XK_Page_Down;
|
||||
case 45 : return XK_Insert;
|
||||
|
||||
case 37 : return XK_Left;
|
||||
case 38 : return XK_Up;
|
||||
case 39 : return XK_Right;
|
||||
case 40 : return XK_Down;
|
||||
|
||||
case 16 : return XK_Shift_L;
|
||||
case 17 : return XK_Control_L;
|
||||
case 18 : return XK_Alt_L; // also: Option-key on Mac
|
||||
|
||||
case 224 : return XK_Meta_L;
|
||||
case 225 : return XK_ISO_Level3_Shift; // AltGr
|
||||
case 91 : return XK_Super_L; // also: Windows-key
|
||||
case 92 : return XK_Super_R; // also: Windows-key
|
||||
case 93 : return XK_Menu; // also: Windows-Menu, Command on Mac
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
return {
|
||||
hasShortcutModifier : hasShortcutModifier,
|
||||
hasCharModifier : hasCharModifier,
|
||||
ModifierSync : ModifierSync,
|
||||
getKey : getKey,
|
||||
getKeysym : getKeysym,
|
||||
keysymFromKeyCode : keysymFromKeyCode,
|
||||
nonCharacterKey : nonCharacterKey,
|
||||
substituteCodepoint : substituteCodepoint
|
||||
};
|
||||
})();
|
||||
|
||||
// Takes a DOM keyboard event and:
|
||||
// - determines which keysym it represents
|
||||
// - determines a keyId identifying the key that was pressed (corresponding to the key/keyCode properties on the DOM event)
|
||||
// - synthesizes events to synchronize modifier key state between which modifiers are actually down, and which we thought were down
|
||||
// - marks each event with an 'escape' property if a modifier was down which should be "escaped"
|
||||
// - generates a "stall" event in cases where it might be necessary to wait and see if a keypress event follows a keydown
|
||||
// This information is collected into an object which is passed to the next() function. (one call per event)
|
||||
function KeyEventDecoder(modifierState, next) {
|
||||
"use strict";
|
||||
function sendAll(evts) {
|
||||
for (var i = 0; i < evts.length; ++i) {
|
||||
next(evts[i]);
|
||||
}
|
||||
}
|
||||
function process(evt, type) {
|
||||
var result = {type: type};
|
||||
var keyId = kbdUtil.getKey(evt);
|
||||
if (keyId) {
|
||||
result.keyId = keyId;
|
||||
}
|
||||
|
||||
var keysym = kbdUtil.getKeysym(evt);
|
||||
|
||||
var hasModifier = modifierState.hasShortcutModifier() || !!modifierState.activeCharModifier();
|
||||
// Is this a case where we have to decide on the keysym right away, rather than waiting for the keypress?
|
||||
// "special" keys like enter, tab or backspace don't send keypress events,
|
||||
// and some browsers don't send keypresses at all if a modifier is down
|
||||
if (keysym && (type !== 'keydown' || kbdUtil.nonCharacterKey(evt) || hasModifier)) {
|
||||
result.keysym = keysym;
|
||||
}
|
||||
|
||||
var isShift = evt.keyCode === 0x10 || evt.key === 'Shift';
|
||||
|
||||
// Should we prevent the browser from handling the event?
|
||||
// Doing so on a keydown (in most browsers) prevents keypress from being generated
|
||||
// so only do that if we have to.
|
||||
var suppress = !isShift && (type !== 'keydown' || modifierState.hasShortcutModifier() || !!kbdUtil.nonCharacterKey(evt));
|
||||
|
||||
// If a char modifier is down on a keydown, we need to insert a stall,
|
||||
// so VerifyCharModifier knows to wait and see if a keypress is comnig
|
||||
var stall = type === 'keydown' && modifierState.activeCharModifier() && !kbdUtil.nonCharacterKey(evt);
|
||||
|
||||
// if a char modifier is pressed, get the keys it consists of (on Windows, AltGr is equivalent to Ctrl+Alt)
|
||||
var active = modifierState.activeCharModifier();
|
||||
|
||||
// If we have a char modifier down, and we're able to determine a keysym reliably
|
||||
// then (a) we know to treat the modifier as a char modifier,
|
||||
// and (b) we'll have to "escape" the modifier to undo the modifier when sending the char.
|
||||
if (active && keysym) {
|
||||
var isCharModifier = false;
|
||||
for (var i = 0; i < active.length; ++i) {
|
||||
if (active[i] === keysym.keysym) {
|
||||
isCharModifier = true;
|
||||
}
|
||||
}
|
||||
if (type === 'keypress' && !isCharModifier) {
|
||||
result.escape = modifierState.activeCharModifier();
|
||||
}
|
||||
}
|
||||
|
||||
if (stall) {
|
||||
// insert a fake "stall" event
|
||||
next({type: 'stall'});
|
||||
}
|
||||
next(result);
|
||||
|
||||
return suppress;
|
||||
}
|
||||
|
||||
return {
|
||||
keydown: function(evt) {
|
||||
sendAll(modifierState.keydown(evt));
|
||||
return process(evt, 'keydown');
|
||||
},
|
||||
keypress: function(evt) {
|
||||
return process(evt, 'keypress');
|
||||
},
|
||||
keyup: function(evt) {
|
||||
sendAll(modifierState.keyup(evt));
|
||||
return process(evt, 'keyup');
|
||||
},
|
||||
syncModifiers: function(evt) {
|
||||
sendAll(modifierState.syncAny(evt));
|
||||
},
|
||||
releaseAll: function() { next({type: 'releaseall'}); }
|
||||
};
|
||||
}
|
||||
|
||||
// Combines keydown and keypress events where necessary to handle char modifiers.
|
||||
// On some OS'es, a char modifier is sometimes used as a shortcut modifier.
|
||||
// For example, on Windows, AltGr is synonymous with Ctrl-Alt. On a Danish keyboard layout, AltGr-2 yields a @, but Ctrl-Alt-D does nothing
|
||||
// so when used with the '2' key, Ctrl-Alt counts as a char modifier (and should be escaped), but when used with 'D', it does not.
|
||||
// The only way we can distinguish these cases is to wait and see if a keypress event arrives
|
||||
// When we receive a "stall" event, wait a few ms before processing the next keydown. If a keypress has also arrived, merge the two
|
||||
function VerifyCharModifier(next) {
|
||||
"use strict";
|
||||
var queue = [];
|
||||
var timer = null;
|
||||
function process() {
|
||||
if (timer) {
|
||||
return;
|
||||
}
|
||||
|
||||
var delayProcess = function () {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
process();
|
||||
};
|
||||
|
||||
while (queue.length !== 0) {
|
||||
var cur = queue[0];
|
||||
queue = queue.splice(1);
|
||||
switch (cur.type) {
|
||||
case 'stall':
|
||||
// insert a delay before processing available events.
|
||||
/* jshint loopfunc: true */
|
||||
timer = setTimeout(delayProcess, 5);
|
||||
/* jshint loopfunc: false */
|
||||
return;
|
||||
case 'keydown':
|
||||
// is the next element a keypress? Then we should merge the two
|
||||
if (queue.length !== 0 && queue[0].type === 'keypress') {
|
||||
// Firefox sends keypress even when no char is generated.
|
||||
// so, if keypress keysym is the same as we'd have guessed from keydown,
|
||||
// the modifier didn't have any effect, and should not be escaped
|
||||
if (queue[0].escape && (!cur.keysym || cur.keysym.keysym !== queue[0].keysym.keysym)) {
|
||||
cur.escape = queue[0].escape;
|
||||
}
|
||||
cur.keysym = queue[0].keysym;
|
||||
queue = queue.splice(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// swallow stall events, and pass all others to the next stage
|
||||
if (cur.type !== 'stall') {
|
||||
next(cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
return function(evt) {
|
||||
queue.push(evt);
|
||||
process();
|
||||
};
|
||||
}
|
||||
|
||||
// Keeps track of which keys we (and the server) believe are down
|
||||
// When a keyup is received, match it against this list, to determine the corresponding keysym(s)
|
||||
// in some cases, a single key may produce multiple keysyms, so the corresponding keyup event must release all of these chars
|
||||
// key repeat events should be merged into a single entry.
|
||||
// Because we can't always identify which entry a keydown or keyup event corresponds to, we sometimes have to guess
|
||||
function TrackKeyState(next) {
|
||||
"use strict";
|
||||
var state = [];
|
||||
|
||||
return function (evt) {
|
||||
var last = state.length !== 0 ? state[state.length-1] : null;
|
||||
|
||||
switch (evt.type) {
|
||||
case 'keydown':
|
||||
// insert a new entry if last seen key was different.
|
||||
if (!last || !evt.keyId || last.keyId !== evt.keyId) {
|
||||
last = {keyId: evt.keyId, keysyms: {}};
|
||||
state.push(last);
|
||||
}
|
||||
if (evt.keysym) {
|
||||
// make sure last event contains this keysym (a single "logical" keyevent
|
||||
// can cause multiple key events to be sent to the VNC server)
|
||||
last.keysyms[evt.keysym.keysym] = evt.keysym;
|
||||
last.ignoreKeyPress = true;
|
||||
next(evt);
|
||||
}
|
||||
break;
|
||||
case 'keypress':
|
||||
if (!last) {
|
||||
last = {keyId: evt.keyId, keysyms: {}};
|
||||
state.push(last);
|
||||
}
|
||||
if (!evt.keysym) {
|
||||
console.log('keypress with no keysym:', evt);
|
||||
}
|
||||
|
||||
// If we didn't expect a keypress, and already sent a keydown to the VNC server
|
||||
// based on the keydown, make sure to skip this event.
|
||||
if (evt.keysym && !last.ignoreKeyPress) {
|
||||
last.keysyms[evt.keysym.keysym] = evt.keysym;
|
||||
evt.type = 'keydown';
|
||||
next(evt);
|
||||
}
|
||||
break;
|
||||
case 'keyup':
|
||||
if (state.length === 0) {
|
||||
return;
|
||||
}
|
||||
var idx = null;
|
||||
// do we have a matching key tracked as being down?
|
||||
for (var i = 0; i !== state.length; ++i) {
|
||||
if (state[i].keyId === evt.keyId) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if we couldn't find a match (it happens), assume it was the last key pressed
|
||||
if (idx === null) {
|
||||
idx = state.length - 1;
|
||||
}
|
||||
|
||||
var item = state.splice(idx, 1)[0];
|
||||
// for each keysym tracked by this key entry, clone the current event and override the keysym
|
||||
var clone = (function(){
|
||||
function Clone(){}
|
||||
return function (obj) { Clone.prototype=obj; return new Clone(); };
|
||||
}());
|
||||
for (var key in item.keysyms) {
|
||||
var out = clone(evt);
|
||||
out.keysym = item.keysyms[key];
|
||||
next(out);
|
||||
}
|
||||
break;
|
||||
case 'releaseall':
|
||||
/* jshint shadow: true */
|
||||
for (var i = 0; i < state.length; ++i) {
|
||||
for (var key in state[i].keysyms) {
|
||||
var keysym = state[i].keysyms[key];
|
||||
next({keyId: 0, keysym: keysym, type: 'keyup'});
|
||||
}
|
||||
}
|
||||
/* jshint shadow: false */
|
||||
state = [];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Handles "escaping" of modifiers: if a char modifier is used to produce a keysym (such as AltGr-2 to generate an @),
|
||||
// then the modifier must be "undone" before sending the @, and "redone" afterwards.
|
||||
function EscapeModifiers(next) {
|
||||
"use strict";
|
||||
return function(evt) {
|
||||
if (evt.type !== 'keydown' || evt.escape === undefined) {
|
||||
next(evt);
|
||||
return;
|
||||
}
|
||||
// undo modifiers
|
||||
for (var i = 0; i < evt.escape.length; ++i) {
|
||||
next({type: 'keyup', keyId: 0, keysym: keysyms.lookup(evt.escape[i])});
|
||||
}
|
||||
// send the character event
|
||||
next(evt);
|
||||
// redo modifiers
|
||||
/* jshint shadow: true */
|
||||
for (var i = 0; i < evt.escape.length; ++i) {
|
||||
next({type: 'keydown', keyId: 0, keysym: keysyms.lookup(evt.escape[i])});
|
||||
}
|
||||
/* jshint shadow: false */
|
||||
};
|
||||
}
|
||||
@@ -1,378 +0,0 @@
|
||||
var XK_VoidSymbol = 0xffffff, /* Void symbol */
|
||||
|
||||
XK_BackSpace = 0xff08, /* Back space, back char */
|
||||
XK_Tab = 0xff09,
|
||||
XK_Linefeed = 0xff0a, /* Linefeed, LF */
|
||||
XK_Clear = 0xff0b,
|
||||
XK_Return = 0xff0d, /* Return, enter */
|
||||
XK_Pause = 0xff13, /* Pause, hold */
|
||||
XK_Scroll_Lock = 0xff14,
|
||||
XK_Sys_Req = 0xff15,
|
||||
XK_Escape = 0xff1b,
|
||||
XK_Delete = 0xffff, /* Delete, rubout */
|
||||
|
||||
/* Cursor control & motion */
|
||||
|
||||
XK_Home = 0xff50,
|
||||
XK_Left = 0xff51, /* Move left, left arrow */
|
||||
XK_Up = 0xff52, /* Move up, up arrow */
|
||||
XK_Right = 0xff53, /* Move right, right arrow */
|
||||
XK_Down = 0xff54, /* Move down, down arrow */
|
||||
XK_Prior = 0xff55, /* Prior, previous */
|
||||
XK_Page_Up = 0xff55,
|
||||
XK_Next = 0xff56, /* Next */
|
||||
XK_Page_Down = 0xff56,
|
||||
XK_End = 0xff57, /* EOL */
|
||||
XK_Begin = 0xff58, /* BOL */
|
||||
|
||||
|
||||
/* Misc functions */
|
||||
|
||||
XK_Select = 0xff60, /* Select, mark */
|
||||
XK_Print = 0xff61,
|
||||
XK_Execute = 0xff62, /* Execute, run, do */
|
||||
XK_Insert = 0xff63, /* Insert, insert here */
|
||||
XK_Undo = 0xff65,
|
||||
XK_Redo = 0xff66, /* Redo, again */
|
||||
XK_Menu = 0xff67,
|
||||
XK_Find = 0xff68, /* Find, search */
|
||||
XK_Cancel = 0xff69, /* Cancel, stop, abort, exit */
|
||||
XK_Help = 0xff6a, /* Help */
|
||||
XK_Break = 0xff6b,
|
||||
XK_Mode_switch = 0xff7e, /* Character set switch */
|
||||
XK_script_switch = 0xff7e, /* Alias for mode_switch */
|
||||
XK_Num_Lock = 0xff7f,
|
||||
|
||||
/* Keypad functions, keypad numbers cleverly chosen to map to ASCII */
|
||||
|
||||
XK_KP_Space = 0xff80, /* Space */
|
||||
XK_KP_Tab = 0xff89,
|
||||
XK_KP_Enter = 0xff8d, /* Enter */
|
||||
XK_KP_F1 = 0xff91, /* PF1, KP_A, ... */
|
||||
XK_KP_F2 = 0xff92,
|
||||
XK_KP_F3 = 0xff93,
|
||||
XK_KP_F4 = 0xff94,
|
||||
XK_KP_Home = 0xff95,
|
||||
XK_KP_Left = 0xff96,
|
||||
XK_KP_Up = 0xff97,
|
||||
XK_KP_Right = 0xff98,
|
||||
XK_KP_Down = 0xff99,
|
||||
XK_KP_Prior = 0xff9a,
|
||||
XK_KP_Page_Up = 0xff9a,
|
||||
XK_KP_Next = 0xff9b,
|
||||
XK_KP_Page_Down = 0xff9b,
|
||||
XK_KP_End = 0xff9c,
|
||||
XK_KP_Begin = 0xff9d,
|
||||
XK_KP_Insert = 0xff9e,
|
||||
XK_KP_Delete = 0xff9f,
|
||||
XK_KP_Equal = 0xffbd, /* Equals */
|
||||
XK_KP_Multiply = 0xffaa,
|
||||
XK_KP_Add = 0xffab,
|
||||
XK_KP_Separator = 0xffac, /* Separator, often comma */
|
||||
XK_KP_Subtract = 0xffad,
|
||||
XK_KP_Decimal = 0xffae,
|
||||
XK_KP_Divide = 0xffaf,
|
||||
|
||||
XK_KP_0 = 0xffb0,
|
||||
XK_KP_1 = 0xffb1,
|
||||
XK_KP_2 = 0xffb2,
|
||||
XK_KP_3 = 0xffb3,
|
||||
XK_KP_4 = 0xffb4,
|
||||
XK_KP_5 = 0xffb5,
|
||||
XK_KP_6 = 0xffb6,
|
||||
XK_KP_7 = 0xffb7,
|
||||
XK_KP_8 = 0xffb8,
|
||||
XK_KP_9 = 0xffb9,
|
||||
|
||||
/*
|
||||
* Auxiliary functions; note the duplicate definitions for left and right
|
||||
* function keys; Sun keyboards and a few other manufacturers have such
|
||||
* function key groups on the left and/or right sides of the keyboard.
|
||||
* We've not found a keyboard with more than 35 function keys total.
|
||||
*/
|
||||
|
||||
XK_F1 = 0xffbe,
|
||||
XK_F2 = 0xffbf,
|
||||
XK_F3 = 0xffc0,
|
||||
XK_F4 = 0xffc1,
|
||||
XK_F5 = 0xffc2,
|
||||
XK_F6 = 0xffc3,
|
||||
XK_F7 = 0xffc4,
|
||||
XK_F8 = 0xffc5,
|
||||
XK_F9 = 0xffc6,
|
||||
XK_F10 = 0xffc7,
|
||||
XK_F11 = 0xffc8,
|
||||
XK_L1 = 0xffc8,
|
||||
XK_F12 = 0xffc9,
|
||||
XK_L2 = 0xffc9,
|
||||
XK_F13 = 0xffca,
|
||||
XK_L3 = 0xffca,
|
||||
XK_F14 = 0xffcb,
|
||||
XK_L4 = 0xffcb,
|
||||
XK_F15 = 0xffcc,
|
||||
XK_L5 = 0xffcc,
|
||||
XK_F16 = 0xffcd,
|
||||
XK_L6 = 0xffcd,
|
||||
XK_F17 = 0xffce,
|
||||
XK_L7 = 0xffce,
|
||||
XK_F18 = 0xffcf,
|
||||
XK_L8 = 0xffcf,
|
||||
XK_F19 = 0xffd0,
|
||||
XK_L9 = 0xffd0,
|
||||
XK_F20 = 0xffd1,
|
||||
XK_L10 = 0xffd1,
|
||||
XK_F21 = 0xffd2,
|
||||
XK_R1 = 0xffd2,
|
||||
XK_F22 = 0xffd3,
|
||||
XK_R2 = 0xffd3,
|
||||
XK_F23 = 0xffd4,
|
||||
XK_R3 = 0xffd4,
|
||||
XK_F24 = 0xffd5,
|
||||
XK_R4 = 0xffd5,
|
||||
XK_F25 = 0xffd6,
|
||||
XK_R5 = 0xffd6,
|
||||
XK_F26 = 0xffd7,
|
||||
XK_R6 = 0xffd7,
|
||||
XK_F27 = 0xffd8,
|
||||
XK_R7 = 0xffd8,
|
||||
XK_F28 = 0xffd9,
|
||||
XK_R8 = 0xffd9,
|
||||
XK_F29 = 0xffda,
|
||||
XK_R9 = 0xffda,
|
||||
XK_F30 = 0xffdb,
|
||||
XK_R10 = 0xffdb,
|
||||
XK_F31 = 0xffdc,
|
||||
XK_R11 = 0xffdc,
|
||||
XK_F32 = 0xffdd,
|
||||
XK_R12 = 0xffdd,
|
||||
XK_F33 = 0xffde,
|
||||
XK_R13 = 0xffde,
|
||||
XK_F34 = 0xffdf,
|
||||
XK_R14 = 0xffdf,
|
||||
XK_F35 = 0xffe0,
|
||||
XK_R15 = 0xffe0,
|
||||
|
||||
/* Modifiers */
|
||||
|
||||
XK_Shift_L = 0xffe1, /* Left shift */
|
||||
XK_Shift_R = 0xffe2, /* Right shift */
|
||||
XK_Control_L = 0xffe3, /* Left control */
|
||||
XK_Control_R = 0xffe4, /* Right control */
|
||||
XK_Caps_Lock = 0xffe5, /* Caps lock */
|
||||
XK_Shift_Lock = 0xffe6, /* Shift lock */
|
||||
|
||||
XK_Meta_L = 0xffe7, /* Left meta */
|
||||
XK_Meta_R = 0xffe8, /* Right meta */
|
||||
XK_Alt_L = 0xffe9, /* Left alt */
|
||||
XK_Alt_R = 0xffea, /* Right alt */
|
||||
XK_Super_L = 0xffeb, /* Left super */
|
||||
XK_Super_R = 0xffec, /* Right super */
|
||||
XK_Hyper_L = 0xffed, /* Left hyper */
|
||||
XK_Hyper_R = 0xffee, /* Right hyper */
|
||||
|
||||
XK_ISO_Level3_Shift = 0xfe03, /* AltGr */
|
||||
|
||||
/*
|
||||
* Latin 1
|
||||
* (ISO/IEC 8859-1 = Unicode U+0020..U+00FF)
|
||||
* Byte 3 = 0
|
||||
*/
|
||||
|
||||
XK_space = 0x0020, /* U+0020 SPACE */
|
||||
XK_exclam = 0x0021, /* U+0021 EXCLAMATION MARK */
|
||||
XK_quotedbl = 0x0022, /* U+0022 QUOTATION MARK */
|
||||
XK_numbersign = 0x0023, /* U+0023 NUMBER SIGN */
|
||||
XK_dollar = 0x0024, /* U+0024 DOLLAR SIGN */
|
||||
XK_percent = 0x0025, /* U+0025 PERCENT SIGN */
|
||||
XK_ampersand = 0x0026, /* U+0026 AMPERSAND */
|
||||
XK_apostrophe = 0x0027, /* U+0027 APOSTROPHE */
|
||||
XK_quoteright = 0x0027, /* deprecated */
|
||||
XK_parenleft = 0x0028, /* U+0028 LEFT PARENTHESIS */
|
||||
XK_parenright = 0x0029, /* U+0029 RIGHT PARENTHESIS */
|
||||
XK_asterisk = 0x002a, /* U+002A ASTERISK */
|
||||
XK_plus = 0x002b, /* U+002B PLUS SIGN */
|
||||
XK_comma = 0x002c, /* U+002C COMMA */
|
||||
XK_minus = 0x002d, /* U+002D HYPHEN-MINUS */
|
||||
XK_period = 0x002e, /* U+002E FULL STOP */
|
||||
XK_slash = 0x002f, /* U+002F SOLIDUS */
|
||||
XK_0 = 0x0030, /* U+0030 DIGIT ZERO */
|
||||
XK_1 = 0x0031, /* U+0031 DIGIT ONE */
|
||||
XK_2 = 0x0032, /* U+0032 DIGIT TWO */
|
||||
XK_3 = 0x0033, /* U+0033 DIGIT THREE */
|
||||
XK_4 = 0x0034, /* U+0034 DIGIT FOUR */
|
||||
XK_5 = 0x0035, /* U+0035 DIGIT FIVE */
|
||||
XK_6 = 0x0036, /* U+0036 DIGIT SIX */
|
||||
XK_7 = 0x0037, /* U+0037 DIGIT SEVEN */
|
||||
XK_8 = 0x0038, /* U+0038 DIGIT EIGHT */
|
||||
XK_9 = 0x0039, /* U+0039 DIGIT NINE */
|
||||
XK_colon = 0x003a, /* U+003A COLON */
|
||||
XK_semicolon = 0x003b, /* U+003B SEMICOLON */
|
||||
XK_less = 0x003c, /* U+003C LESS-THAN SIGN */
|
||||
XK_equal = 0x003d, /* U+003D EQUALS SIGN */
|
||||
XK_greater = 0x003e, /* U+003E GREATER-THAN SIGN */
|
||||
XK_question = 0x003f, /* U+003F QUESTION MARK */
|
||||
XK_at = 0x0040, /* U+0040 COMMERCIAL AT */
|
||||
XK_A = 0x0041, /* U+0041 LATIN CAPITAL LETTER A */
|
||||
XK_B = 0x0042, /* U+0042 LATIN CAPITAL LETTER B */
|
||||
XK_C = 0x0043, /* U+0043 LATIN CAPITAL LETTER C */
|
||||
XK_D = 0x0044, /* U+0044 LATIN CAPITAL LETTER D */
|
||||
XK_E = 0x0045, /* U+0045 LATIN CAPITAL LETTER E */
|
||||
XK_F = 0x0046, /* U+0046 LATIN CAPITAL LETTER F */
|
||||
XK_G = 0x0047, /* U+0047 LATIN CAPITAL LETTER G */
|
||||
XK_H = 0x0048, /* U+0048 LATIN CAPITAL LETTER H */
|
||||
XK_I = 0x0049, /* U+0049 LATIN CAPITAL LETTER I */
|
||||
XK_J = 0x004a, /* U+004A LATIN CAPITAL LETTER J */
|
||||
XK_K = 0x004b, /* U+004B LATIN CAPITAL LETTER K */
|
||||
XK_L = 0x004c, /* U+004C LATIN CAPITAL LETTER L */
|
||||
XK_M = 0x004d, /* U+004D LATIN CAPITAL LETTER M */
|
||||
XK_N = 0x004e, /* U+004E LATIN CAPITAL LETTER N */
|
||||
XK_O = 0x004f, /* U+004F LATIN CAPITAL LETTER O */
|
||||
XK_P = 0x0050, /* U+0050 LATIN CAPITAL LETTER P */
|
||||
XK_Q = 0x0051, /* U+0051 LATIN CAPITAL LETTER Q */
|
||||
XK_R = 0x0052, /* U+0052 LATIN CAPITAL LETTER R */
|
||||
XK_S = 0x0053, /* U+0053 LATIN CAPITAL LETTER S */
|
||||
XK_T = 0x0054, /* U+0054 LATIN CAPITAL LETTER T */
|
||||
XK_U = 0x0055, /* U+0055 LATIN CAPITAL LETTER U */
|
||||
XK_V = 0x0056, /* U+0056 LATIN CAPITAL LETTER V */
|
||||
XK_W = 0x0057, /* U+0057 LATIN CAPITAL LETTER W */
|
||||
XK_X = 0x0058, /* U+0058 LATIN CAPITAL LETTER X */
|
||||
XK_Y = 0x0059, /* U+0059 LATIN CAPITAL LETTER Y */
|
||||
XK_Z = 0x005a, /* U+005A LATIN CAPITAL LETTER Z */
|
||||
XK_bracketleft = 0x005b, /* U+005B LEFT SQUARE BRACKET */
|
||||
XK_backslash = 0x005c, /* U+005C REVERSE SOLIDUS */
|
||||
XK_bracketright = 0x005d, /* U+005D RIGHT SQUARE BRACKET */
|
||||
XK_asciicircum = 0x005e, /* U+005E CIRCUMFLEX ACCENT */
|
||||
XK_underscore = 0x005f, /* U+005F LOW LINE */
|
||||
XK_grave = 0x0060, /* U+0060 GRAVE ACCENT */
|
||||
XK_quoteleft = 0x0060, /* deprecated */
|
||||
XK_a = 0x0061, /* U+0061 LATIN SMALL LETTER A */
|
||||
XK_b = 0x0062, /* U+0062 LATIN SMALL LETTER B */
|
||||
XK_c = 0x0063, /* U+0063 LATIN SMALL LETTER C */
|
||||
XK_d = 0x0064, /* U+0064 LATIN SMALL LETTER D */
|
||||
XK_e = 0x0065, /* U+0065 LATIN SMALL LETTER E */
|
||||
XK_f = 0x0066, /* U+0066 LATIN SMALL LETTER F */
|
||||
XK_g = 0x0067, /* U+0067 LATIN SMALL LETTER G */
|
||||
XK_h = 0x0068, /* U+0068 LATIN SMALL LETTER H */
|
||||
XK_i = 0x0069, /* U+0069 LATIN SMALL LETTER I */
|
||||
XK_j = 0x006a, /* U+006A LATIN SMALL LETTER J */
|
||||
XK_k = 0x006b, /* U+006B LATIN SMALL LETTER K */
|
||||
XK_l = 0x006c, /* U+006C LATIN SMALL LETTER L */
|
||||
XK_m = 0x006d, /* U+006D LATIN SMALL LETTER M */
|
||||
XK_n = 0x006e, /* U+006E LATIN SMALL LETTER N */
|
||||
XK_o = 0x006f, /* U+006F LATIN SMALL LETTER O */
|
||||
XK_p = 0x0070, /* U+0070 LATIN SMALL LETTER P */
|
||||
XK_q = 0x0071, /* U+0071 LATIN SMALL LETTER Q */
|
||||
XK_r = 0x0072, /* U+0072 LATIN SMALL LETTER R */
|
||||
XK_s = 0x0073, /* U+0073 LATIN SMALL LETTER S */
|
||||
XK_t = 0x0074, /* U+0074 LATIN SMALL LETTER T */
|
||||
XK_u = 0x0075, /* U+0075 LATIN SMALL LETTER U */
|
||||
XK_v = 0x0076, /* U+0076 LATIN SMALL LETTER V */
|
||||
XK_w = 0x0077, /* U+0077 LATIN SMALL LETTER W */
|
||||
XK_x = 0x0078, /* U+0078 LATIN SMALL LETTER X */
|
||||
XK_y = 0x0079, /* U+0079 LATIN SMALL LETTER Y */
|
||||
XK_z = 0x007a, /* U+007A LATIN SMALL LETTER Z */
|
||||
XK_braceleft = 0x007b, /* U+007B LEFT CURLY BRACKET */
|
||||
XK_bar = 0x007c, /* U+007C VERTICAL LINE */
|
||||
XK_braceright = 0x007d, /* U+007D RIGHT CURLY BRACKET */
|
||||
XK_asciitilde = 0x007e, /* U+007E TILDE */
|
||||
|
||||
XK_nobreakspace = 0x00a0, /* U+00A0 NO-BREAK SPACE */
|
||||
XK_exclamdown = 0x00a1, /* U+00A1 INVERTED EXCLAMATION MARK */
|
||||
XK_cent = 0x00a2, /* U+00A2 CENT SIGN */
|
||||
XK_sterling = 0x00a3, /* U+00A3 POUND SIGN */
|
||||
XK_currency = 0x00a4, /* U+00A4 CURRENCY SIGN */
|
||||
XK_yen = 0x00a5, /* U+00A5 YEN SIGN */
|
||||
XK_brokenbar = 0x00a6, /* U+00A6 BROKEN BAR */
|
||||
XK_section = 0x00a7, /* U+00A7 SECTION SIGN */
|
||||
XK_diaeresis = 0x00a8, /* U+00A8 DIAERESIS */
|
||||
XK_copyright = 0x00a9, /* U+00A9 COPYRIGHT SIGN */
|
||||
XK_ordfeminine = 0x00aa, /* U+00AA FEMININE ORDINAL INDICATOR */
|
||||
XK_guillemotleft = 0x00ab, /* U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */
|
||||
XK_notsign = 0x00ac, /* U+00AC NOT SIGN */
|
||||
XK_hyphen = 0x00ad, /* U+00AD SOFT HYPHEN */
|
||||
XK_registered = 0x00ae, /* U+00AE REGISTERED SIGN */
|
||||
XK_macron = 0x00af, /* U+00AF MACRON */
|
||||
XK_degree = 0x00b0, /* U+00B0 DEGREE SIGN */
|
||||
XK_plusminus = 0x00b1, /* U+00B1 PLUS-MINUS SIGN */
|
||||
XK_twosuperior = 0x00b2, /* U+00B2 SUPERSCRIPT TWO */
|
||||
XK_threesuperior = 0x00b3, /* U+00B3 SUPERSCRIPT THREE */
|
||||
XK_acute = 0x00b4, /* U+00B4 ACUTE ACCENT */
|
||||
XK_mu = 0x00b5, /* U+00B5 MICRO SIGN */
|
||||
XK_paragraph = 0x00b6, /* U+00B6 PILCROW SIGN */
|
||||
XK_periodcentered = 0x00b7, /* U+00B7 MIDDLE DOT */
|
||||
XK_cedilla = 0x00b8, /* U+00B8 CEDILLA */
|
||||
XK_onesuperior = 0x00b9, /* U+00B9 SUPERSCRIPT ONE */
|
||||
XK_masculine = 0x00ba, /* U+00BA MASCULINE ORDINAL INDICATOR */
|
||||
XK_guillemotright = 0x00bb, /* U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */
|
||||
XK_onequarter = 0x00bc, /* U+00BC VULGAR FRACTION ONE QUARTER */
|
||||
XK_onehalf = 0x00bd, /* U+00BD VULGAR FRACTION ONE HALF */
|
||||
XK_threequarters = 0x00be, /* U+00BE VULGAR FRACTION THREE QUARTERS */
|
||||
XK_questiondown = 0x00bf, /* U+00BF INVERTED QUESTION MARK */
|
||||
XK_Agrave = 0x00c0, /* U+00C0 LATIN CAPITAL LETTER A WITH GRAVE */
|
||||
XK_Aacute = 0x00c1, /* U+00C1 LATIN CAPITAL LETTER A WITH ACUTE */
|
||||
XK_Acircumflex = 0x00c2, /* U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX */
|
||||
XK_Atilde = 0x00c3, /* U+00C3 LATIN CAPITAL LETTER A WITH TILDE */
|
||||
XK_Adiaeresis = 0x00c4, /* U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS */
|
||||
XK_Aring = 0x00c5, /* U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE */
|
||||
XK_AE = 0x00c6, /* U+00C6 LATIN CAPITAL LETTER AE */
|
||||
XK_Ccedilla = 0x00c7, /* U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA */
|
||||
XK_Egrave = 0x00c8, /* U+00C8 LATIN CAPITAL LETTER E WITH GRAVE */
|
||||
XK_Eacute = 0x00c9, /* U+00C9 LATIN CAPITAL LETTER E WITH ACUTE */
|
||||
XK_Ecircumflex = 0x00ca, /* U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX */
|
||||
XK_Ediaeresis = 0x00cb, /* U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS */
|
||||
XK_Igrave = 0x00cc, /* U+00CC LATIN CAPITAL LETTER I WITH GRAVE */
|
||||
XK_Iacute = 0x00cd, /* U+00CD LATIN CAPITAL LETTER I WITH ACUTE */
|
||||
XK_Icircumflex = 0x00ce, /* U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX */
|
||||
XK_Idiaeresis = 0x00cf, /* U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS */
|
||||
XK_ETH = 0x00d0, /* U+00D0 LATIN CAPITAL LETTER ETH */
|
||||
XK_Eth = 0x00d0, /* deprecated */
|
||||
XK_Ntilde = 0x00d1, /* U+00D1 LATIN CAPITAL LETTER N WITH TILDE */
|
||||
XK_Ograve = 0x00d2, /* U+00D2 LATIN CAPITAL LETTER O WITH GRAVE */
|
||||
XK_Oacute = 0x00d3, /* U+00D3 LATIN CAPITAL LETTER O WITH ACUTE */
|
||||
XK_Ocircumflex = 0x00d4, /* U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX */
|
||||
XK_Otilde = 0x00d5, /* U+00D5 LATIN CAPITAL LETTER O WITH TILDE */
|
||||
XK_Odiaeresis = 0x00d6, /* U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS */
|
||||
XK_multiply = 0x00d7, /* U+00D7 MULTIPLICATION SIGN */
|
||||
XK_Oslash = 0x00d8, /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
|
||||
XK_Ooblique = 0x00d8, /* U+00D8 LATIN CAPITAL LETTER O WITH STROKE */
|
||||
XK_Ugrave = 0x00d9, /* U+00D9 LATIN CAPITAL LETTER U WITH GRAVE */
|
||||
XK_Uacute = 0x00da, /* U+00DA LATIN CAPITAL LETTER U WITH ACUTE */
|
||||
XK_Ucircumflex = 0x00db, /* U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX */
|
||||
XK_Udiaeresis = 0x00dc, /* U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS */
|
||||
XK_Yacute = 0x00dd, /* U+00DD LATIN CAPITAL LETTER Y WITH ACUTE */
|
||||
XK_THORN = 0x00de, /* U+00DE LATIN CAPITAL LETTER THORN */
|
||||
XK_Thorn = 0x00de, /* deprecated */
|
||||
XK_ssharp = 0x00df, /* U+00DF LATIN SMALL LETTER SHARP S */
|
||||
XK_agrave = 0x00e0, /* U+00E0 LATIN SMALL LETTER A WITH GRAVE */
|
||||
XK_aacute = 0x00e1, /* U+00E1 LATIN SMALL LETTER A WITH ACUTE */
|
||||
XK_acircumflex = 0x00e2, /* U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX */
|
||||
XK_atilde = 0x00e3, /* U+00E3 LATIN SMALL LETTER A WITH TILDE */
|
||||
XK_adiaeresis = 0x00e4, /* U+00E4 LATIN SMALL LETTER A WITH DIAERESIS */
|
||||
XK_aring = 0x00e5, /* U+00E5 LATIN SMALL LETTER A WITH RING ABOVE */
|
||||
XK_ae = 0x00e6, /* U+00E6 LATIN SMALL LETTER AE */
|
||||
XK_ccedilla = 0x00e7, /* U+00E7 LATIN SMALL LETTER C WITH CEDILLA */
|
||||
XK_egrave = 0x00e8, /* U+00E8 LATIN SMALL LETTER E WITH GRAVE */
|
||||
XK_eacute = 0x00e9, /* U+00E9 LATIN SMALL LETTER E WITH ACUTE */
|
||||
XK_ecircumflex = 0x00ea, /* U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX */
|
||||
XK_ediaeresis = 0x00eb, /* U+00EB LATIN SMALL LETTER E WITH DIAERESIS */
|
||||
XK_igrave = 0x00ec, /* U+00EC LATIN SMALL LETTER I WITH GRAVE */
|
||||
XK_iacute = 0x00ed, /* U+00ED LATIN SMALL LETTER I WITH ACUTE */
|
||||
XK_icircumflex = 0x00ee, /* U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX */
|
||||
XK_idiaeresis = 0x00ef, /* U+00EF LATIN SMALL LETTER I WITH DIAERESIS */
|
||||
XK_eth = 0x00f0, /* U+00F0 LATIN SMALL LETTER ETH */
|
||||
XK_ntilde = 0x00f1, /* U+00F1 LATIN SMALL LETTER N WITH TILDE */
|
||||
XK_ograve = 0x00f2, /* U+00F2 LATIN SMALL LETTER O WITH GRAVE */
|
||||
XK_oacute = 0x00f3, /* U+00F3 LATIN SMALL LETTER O WITH ACUTE */
|
||||
XK_ocircumflex = 0x00f4, /* U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX */
|
||||
XK_otilde = 0x00f5, /* U+00F5 LATIN SMALL LETTER O WITH TILDE */
|
||||
XK_odiaeresis = 0x00f6, /* U+00F6 LATIN SMALL LETTER O WITH DIAERESIS */
|
||||
XK_division = 0x00f7, /* U+00F7 DIVISION SIGN */
|
||||
XK_oslash = 0x00f8, /* U+00F8 LATIN SMALL LETTER O WITH STROKE */
|
||||
XK_ooblique = 0x00f8, /* U+00F8 LATIN SMALL LETTER O WITH STROKE */
|
||||
XK_ugrave = 0x00f9, /* U+00F9 LATIN SMALL LETTER U WITH GRAVE */
|
||||
XK_uacute = 0x00fa, /* U+00FA LATIN SMALL LETTER U WITH ACUTE */
|
||||
XK_ucircumflex = 0x00fb, /* U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX */
|
||||
XK_udiaeresis = 0x00fc, /* U+00FC LATIN SMALL LETTER U WITH DIAERESIS */
|
||||
XK_yacute = 0x00fd, /* U+00FD LATIN SMALL LETTER Y WITH ACUTE */
|
||||
XK_thorn = 0x00fe, /* U+00FE LATIN SMALL LETTER THORN */
|
||||
XK_ydiaeresis = 0x00ff; /* U+00FF LATIN SMALL LETTER Y WITH DIAERESIS */
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
/*jslint browser: true, white: false */
|
||||
/*global Util, VNC_frame_data, finish */
|
||||
|
||||
var rfb, mode, test_state, frame_idx, frame_length,
|
||||
iteration, iterations, istart_time,
|
||||
|
||||
// Pre-declarations for jslint
|
||||
send_array, next_iteration, queue_next_packet, do_packet, enable_test_mode;
|
||||
|
||||
// Override send_array
|
||||
send_array = function (arr) {
|
||||
// Stub out send_array
|
||||
};
|
||||
|
||||
enable_test_mode = function () {
|
||||
rfb._sock._mode = VNC_frame_encoding;
|
||||
rfb._sock.send = send_array;
|
||||
rfb._sock.close = function () {};
|
||||
rfb._sock.flush = function () {};
|
||||
rfb._checkEvents = function () {};
|
||||
rfb.connect = function (host, port, password, path) {
|
||||
this._rfb_host = host;
|
||||
this._rfb_port = port;
|
||||
this._rfb_password = (password !== undefined) ? password : "";
|
||||
this._rfb_path = (path !== undefined) ? path : "";
|
||||
this._sock.init('binary', 'ws');
|
||||
this._updateState('ProtocolVersion', "Starting VNC handshake");
|
||||
};
|
||||
};
|
||||
|
||||
next_iteration = function () {
|
||||
rfb = new RFB({'target': $D('VNC_canvas'),
|
||||
'onUpdateState': updateState});
|
||||
enable_test_mode();
|
||||
|
||||
if (iteration === 0) {
|
||||
frame_length = VNC_frame_data.length;
|
||||
test_state = 'running';
|
||||
}
|
||||
|
||||
if (test_state !== 'running') { return; }
|
||||
|
||||
iteration += 1;
|
||||
if (iteration > iterations) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
frame_idx = 0;
|
||||
istart_time = (new Date()).getTime();
|
||||
rfb.connect('test', 0, "bogus");
|
||||
|
||||
queue_next_packet();
|
||||
|
||||
};
|
||||
|
||||
queue_next_packet = function () {
|
||||
var frame, foffset, toffset, delay;
|
||||
if (test_state !== 'running') { return; }
|
||||
|
||||
frame = VNC_frame_data[frame_idx];
|
||||
while ((frame_idx < frame_length) && (frame.charAt(0) === "}")) {
|
||||
//Util.Debug("Send frame " + frame_idx);
|
||||
frame_idx += 1;
|
||||
frame = VNC_frame_data[frame_idx];
|
||||
}
|
||||
|
||||
if (frame === 'EOF') {
|
||||
Util.Debug("Finished, found EOF");
|
||||
next_iteration();
|
||||
return;
|
||||
}
|
||||
if (frame_idx >= frame_length) {
|
||||
Util.Debug("Finished, no more frames");
|
||||
next_iteration();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode === 'realtime') {
|
||||
foffset = frame.slice(1, frame.indexOf('{', 1));
|
||||
toffset = (new Date()).getTime() - istart_time;
|
||||
delay = foffset - toffset;
|
||||
if (delay < 1) {
|
||||
delay = 1;
|
||||
}
|
||||
|
||||
setTimeout(do_packet, delay);
|
||||
} else {
|
||||
setTimeout(do_packet, 1);
|
||||
}
|
||||
};
|
||||
|
||||
var bytes_processed = 0;
|
||||
|
||||
do_packet = function () {
|
||||
//Util.Debug("Processing frame: " + frame_idx);
|
||||
var frame = VNC_frame_data[frame_idx],
|
||||
start = frame.indexOf('{', 1) + 1;
|
||||
bytes_processed += frame.length - start;
|
||||
if (VNC_frame_encoding === 'binary') {
|
||||
var u8 = new Uint8Array(frame.length - start);
|
||||
for (var i = 0; i < frame.length - start; i++) {
|
||||
u8[i] = frame.charCodeAt(start + i);
|
||||
}
|
||||
rfb._sock._recv_message({'data' : u8});
|
||||
} else {
|
||||
rfb._sock._recv_message({'data' : frame.slice(start)});
|
||||
}
|
||||
frame_idx += 1;
|
||||
|
||||
queue_next_packet();
|
||||
};
|
||||
|
||||
@@ -1,622 +0,0 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*
|
||||
* See README.md for usage and integration instructions.
|
||||
*/
|
||||
|
||||
/* jshint white: false, nonstandard: true */
|
||||
/*global window, console, document, navigator, ActiveXObject, INCLUDE_URI */
|
||||
|
||||
// Globals defined here
|
||||
var Util = {};
|
||||
|
||||
|
||||
/*
|
||||
* Make arrays quack
|
||||
*/
|
||||
|
||||
var addFunc = function (cl, name, func) {
|
||||
if (!cl.prototype[name]) {
|
||||
Object.defineProperty(cl.prototype, name, { enumerable: false, value: func });
|
||||
}
|
||||
};
|
||||
|
||||
addFunc(Array, 'push8', function (num) {
|
||||
"use strict";
|
||||
this.push(num & 0xFF);
|
||||
});
|
||||
|
||||
addFunc(Array, 'push16', function (num) {
|
||||
"use strict";
|
||||
this.push((num >> 8) & 0xFF,
|
||||
num & 0xFF);
|
||||
});
|
||||
|
||||
addFunc(Array, 'push32', function (num) {
|
||||
"use strict";
|
||||
this.push((num >> 24) & 0xFF,
|
||||
(num >> 16) & 0xFF,
|
||||
(num >> 8) & 0xFF,
|
||||
num & 0xFF);
|
||||
});
|
||||
|
||||
// IE does not support map (even in IE9)
|
||||
//This prototype is provided by the Mozilla foundation and
|
||||
//is distributed under the MIT license.
|
||||
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
|
||||
addFunc(Array, 'map', function (fun /*, thisp*/) {
|
||||
"use strict";
|
||||
var len = this.length;
|
||||
if (typeof fun != "function") {
|
||||
throw new TypeError();
|
||||
}
|
||||
|
||||
var res = new Array(len);
|
||||
var thisp = arguments[1];
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (i in this) {
|
||||
res[i] = fun.call(thisp, this[i], i, this);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
});
|
||||
|
||||
// IE <9 does not support indexOf
|
||||
//This prototype is provided by the Mozilla foundation and
|
||||
//is distributed under the MIT license.
|
||||
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
|
||||
addFunc(Array, 'indexOf', function (elt /*, from*/) {
|
||||
"use strict";
|
||||
var len = this.length >>> 0;
|
||||
|
||||
var from = Number(arguments[1]) || 0;
|
||||
from = (from < 0) ? Math.ceil(from) : Math.floor(from);
|
||||
if (from < 0) {
|
||||
from += len;
|
||||
}
|
||||
|
||||
for (; from < len; from++) {
|
||||
if (from in this &&
|
||||
this[from] === elt) {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
});
|
||||
|
||||
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
|
||||
if (!Object.keys) {
|
||||
Object.keys = (function () {
|
||||
'use strict';
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
|
||||
dontEnums = [
|
||||
'toString',
|
||||
'toLocaleString',
|
||||
'valueOf',
|
||||
'hasOwnProperty',
|
||||
'isPrototypeOf',
|
||||
'propertyIsEnumerable',
|
||||
'constructor'
|
||||
],
|
||||
dontEnumsLength = dontEnums.length;
|
||||
|
||||
return function (obj) {
|
||||
if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
|
||||
throw new TypeError('Object.keys called on non-object');
|
||||
}
|
||||
|
||||
var result = [], prop, i;
|
||||
|
||||
for (prop in obj) {
|
||||
if (hasOwnProperty.call(obj, prop)) {
|
||||
result.push(prop);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (i = 0; i < dontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(obj, dontEnums[i])) {
|
||||
result.push(dontEnums[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
// PhantomJS 1.x doesn't support bind,
|
||||
// so leave this in until PhantomJS 2.0 is released
|
||||
//This prototype is provided by the Mozilla foundation and
|
||||
//is distributed under the MIT license.
|
||||
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
|
||||
addFunc(Function, 'bind', function (oThis) {
|
||||
if (typeof this !== "function") {
|
||||
// closest thing possible to the ECMAScript 5
|
||||
// internal IsCallable function
|
||||
throw new TypeError("Function.prototype.bind - " +
|
||||
"what is trying to be bound is not callable");
|
||||
}
|
||||
|
||||
var aArgs = Array.prototype.slice.call(arguments, 1),
|
||||
fToBind = this,
|
||||
fNOP = function () {},
|
||||
fBound = function () {
|
||||
return fToBind.apply(this instanceof fNOP && oThis ? this
|
||||
: oThis,
|
||||
aArgs.concat(Array.prototype.slice.call(arguments)));
|
||||
};
|
||||
|
||||
fNOP.prototype = this.prototype;
|
||||
fBound.prototype = new fNOP();
|
||||
|
||||
return fBound;
|
||||
});
|
||||
|
||||
//
|
||||
// requestAnimationFrame shim with setTimeout fallback
|
||||
//
|
||||
|
||||
window.requestAnimFrame = (function () {
|
||||
"use strict";
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function (callback) {
|
||||
window.setTimeout(callback, 1000 / 60);
|
||||
};
|
||||
})();
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Namespaced in Util
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Logging/debug routines
|
||||
*/
|
||||
|
||||
Util._log_level = 'warn';
|
||||
Util.init_logging = function (level) {
|
||||
"use strict";
|
||||
if (typeof level === 'undefined') {
|
||||
level = Util._log_level;
|
||||
} else {
|
||||
Util._log_level = level;
|
||||
}
|
||||
if (typeof window.console === "undefined") {
|
||||
if (typeof window.opera !== "undefined") {
|
||||
window.console = {
|
||||
'log' : window.opera.postError,
|
||||
'warn' : window.opera.postError,
|
||||
'error': window.opera.postError
|
||||
};
|
||||
} else {
|
||||
window.console = {
|
||||
'log' : function (m) {},
|
||||
'warn' : function (m) {},
|
||||
'error': function (m) {}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Util.Debug = Util.Info = Util.Warn = Util.Error = function (msg) {};
|
||||
/* jshint -W086 */
|
||||
switch (level) {
|
||||
case 'debug':
|
||||
Util.Debug = function (msg) { console.log(msg); };
|
||||
case 'info':
|
||||
Util.Info = function (msg) { console.log(msg); };
|
||||
case 'warn':
|
||||
Util.Warn = function (msg) { console.warn(msg); };
|
||||
case 'error':
|
||||
Util.Error = function (msg) { console.error(msg); };
|
||||
case 'none':
|
||||
break;
|
||||
default:
|
||||
throw new Error("invalid logging type '" + level + "'");
|
||||
}
|
||||
/* jshint +W086 */
|
||||
};
|
||||
Util.get_logging = function () {
|
||||
return Util._log_level;
|
||||
};
|
||||
// Initialize logging level
|
||||
Util.init_logging();
|
||||
|
||||
Util.make_property = function (proto, name, mode, type) {
|
||||
"use strict";
|
||||
|
||||
var getter;
|
||||
if (type === 'arr') {
|
||||
getter = function (idx) {
|
||||
if (typeof idx !== 'undefined') {
|
||||
return this['_' + name][idx];
|
||||
} else {
|
||||
return this['_' + name];
|
||||
}
|
||||
};
|
||||
} else {
|
||||
getter = function () {
|
||||
return this['_' + name];
|
||||
};
|
||||
}
|
||||
|
||||
var make_setter = function (process_val) {
|
||||
if (process_val) {
|
||||
return function (val, idx) {
|
||||
if (typeof idx !== 'undefined') {
|
||||
this['_' + name][idx] = process_val(val);
|
||||
} else {
|
||||
this['_' + name] = process_val(val);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return function (val, idx) {
|
||||
if (typeof idx !== 'undefined') {
|
||||
this['_' + name][idx] = val;
|
||||
} else {
|
||||
this['_' + name] = val;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var setter;
|
||||
if (type === 'bool') {
|
||||
setter = make_setter(function (val) {
|
||||
if (!val || (val in {'0': 1, 'no': 1, 'false': 1})) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else if (type === 'int') {
|
||||
setter = make_setter(function (val) { return parseInt(val, 10); });
|
||||
} else if (type === 'float') {
|
||||
setter = make_setter(parseFloat);
|
||||
} else if (type === 'str') {
|
||||
setter = make_setter(String);
|
||||
} else if (type === 'func') {
|
||||
setter = make_setter(function (val) {
|
||||
if (!val) {
|
||||
return function () {};
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
});
|
||||
} else if (type === 'arr' || type === 'dom' || type == 'raw') {
|
||||
setter = make_setter();
|
||||
} else {
|
||||
throw new Error('Unknown property type ' + type); // some sanity checking
|
||||
}
|
||||
|
||||
// set the getter
|
||||
if (typeof proto['get_' + name] === 'undefined') {
|
||||
proto['get_' + name] = getter;
|
||||
}
|
||||
|
||||
// set the setter if needed
|
||||
if (typeof proto['set_' + name] === 'undefined') {
|
||||
if (mode === 'rw') {
|
||||
proto['set_' + name] = setter;
|
||||
} else if (mode === 'wo') {
|
||||
proto['set_' + name] = function (val, idx) {
|
||||
if (typeof this['_' + name] !== 'undefined') {
|
||||
throw new Error(name + " can only be set once");
|
||||
}
|
||||
setter.call(this, val, idx);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// make a special setter that we can use in set defaults
|
||||
proto['_raw_set_' + name] = function (val, idx) {
|
||||
setter.call(this, val, idx);
|
||||
//delete this['_init_set_' + name]; // remove it after use
|
||||
};
|
||||
};
|
||||
|
||||
Util.make_properties = function (constructor, arr) {
|
||||
"use strict";
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
Util.make_property(constructor.prototype, arr[i][0], arr[i][1], arr[i][2]);
|
||||
}
|
||||
};
|
||||
|
||||
Util.set_defaults = function (obj, conf, defaults) {
|
||||
var defaults_keys = Object.keys(defaults);
|
||||
var conf_keys = Object.keys(conf);
|
||||
var keys_obj = {};
|
||||
var i;
|
||||
for (i = 0; i < defaults_keys.length; i++) { keys_obj[defaults_keys[i]] = 1; }
|
||||
for (i = 0; i < conf_keys.length; i++) { keys_obj[conf_keys[i]] = 1; }
|
||||
var keys = Object.keys(keys_obj);
|
||||
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
var setter = obj['_raw_set_' + keys[i]];
|
||||
if (!setter) {
|
||||
Util.Warn('Invalid property ' + keys[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (keys[i] in conf) {
|
||||
setter.call(obj, conf[keys[i]]);
|
||||
} else {
|
||||
setter.call(obj, defaults[keys[i]]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Decode from UTF-8
|
||||
*/
|
||||
Util.decodeUTF8 = function (utf8string) {
|
||||
"use strict";
|
||||
return decodeURIComponent(escape(utf8string));
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Cross-browser routines
|
||||
*/
|
||||
|
||||
|
||||
// Dynamically load scripts without using document.write()
|
||||
// Reference: http://unixpapa.com/js/dyna.html
|
||||
//
|
||||
// Handles the case where load_scripts is invoked from a script that
|
||||
// itself is loaded via load_scripts. Once all scripts are loaded the
|
||||
// window.onscriptsloaded handler is called (if set).
|
||||
Util.get_include_uri = function () {
|
||||
return (typeof INCLUDE_URI !== "undefined") ? INCLUDE_URI : "include/";
|
||||
};
|
||||
Util._loading_scripts = [];
|
||||
Util._pending_scripts = [];
|
||||
Util.load_scripts = function (files) {
|
||||
"use strict";
|
||||
var head = document.getElementsByTagName('head')[0], script,
|
||||
ls = Util._loading_scripts, ps = Util._pending_scripts;
|
||||
|
||||
var loadFunc = function (e) {
|
||||
while (ls.length > 0 && (ls[0].readyState === 'loaded' ||
|
||||
ls[0].readyState === 'complete')) {
|
||||
// For IE, append the script to trigger execution
|
||||
var s = ls.shift();
|
||||
//console.log("loaded script: " + s.src);
|
||||
head.appendChild(s);
|
||||
}
|
||||
if (!this.readyState ||
|
||||
(Util.Engine.presto && this.readyState === 'loaded') ||
|
||||
this.readyState === 'complete') {
|
||||
if (ps.indexOf(this) >= 0) {
|
||||
this.onload = this.onreadystatechange = null;
|
||||
//console.log("completed script: " + this.src);
|
||||
ps.splice(ps.indexOf(this), 1);
|
||||
|
||||
// Call window.onscriptsload after last script loads
|
||||
if (ps.length === 0 && window.onscriptsload) {
|
||||
window.onscriptsload();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (var f = 0; f < files.length; f++) {
|
||||
script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = Util.get_include_uri() + files[f];
|
||||
//console.log("loading script: " + script.src);
|
||||
script.onload = script.onreadystatechange = loadFunc;
|
||||
// In-order script execution tricks
|
||||
if (Util.Engine.trident) {
|
||||
// For IE wait until readyState is 'loaded' before
|
||||
// appending it which will trigger execution
|
||||
// http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order
|
||||
ls.push(script);
|
||||
} else {
|
||||
// For webkit and firefox set async=false and append now
|
||||
// https://developer.mozilla.org/en-US/docs/HTML/Element/script
|
||||
script.async = false;
|
||||
head.appendChild(script);
|
||||
}
|
||||
ps.push(script);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Util.getPosition = function(obj) {
|
||||
"use strict";
|
||||
// NB(sross): the Mozilla developer reference seems to indicate that
|
||||
// getBoundingClientRect includes border and padding, so the canvas
|
||||
// style should NOT include either.
|
||||
var objPosition = obj.getBoundingClientRect();
|
||||
return {'x': objPosition.left + window.pageXOffset, 'y': objPosition.top + window.pageYOffset,
|
||||
'width': objPosition.width, 'height': objPosition.height};
|
||||
};
|
||||
|
||||
|
||||
// Get mouse event position in DOM element
|
||||
Util.getEventPosition = function (e, obj, scale) {
|
||||
"use strict";
|
||||
var evt, docX, docY, pos;
|
||||
//if (!e) evt = window.event;
|
||||
evt = (e ? e : window.event);
|
||||
evt = (evt.changedTouches ? evt.changedTouches[0] : evt.touches ? evt.touches[0] : evt);
|
||||
if (evt.pageX || evt.pageY) {
|
||||
docX = evt.pageX;
|
||||
docY = evt.pageY;
|
||||
} else if (evt.clientX || evt.clientY) {
|
||||
docX = evt.clientX + document.body.scrollLeft +
|
||||
document.documentElement.scrollLeft;
|
||||
docY = evt.clientY + document.body.scrollTop +
|
||||
document.documentElement.scrollTop;
|
||||
}
|
||||
pos = Util.getPosition(obj);
|
||||
if (typeof scale === "undefined") {
|
||||
scale = 1;
|
||||
}
|
||||
var realx = docX - pos.x;
|
||||
var realy = docY - pos.y;
|
||||
var x = Math.max(Math.min(realx, pos.width - 1), 0);
|
||||
var y = Math.max(Math.min(realy, pos.height - 1), 0);
|
||||
return {'x': x / scale, 'y': y / scale, 'realx': realx / scale, 'realy': realy / scale};
|
||||
};
|
||||
|
||||
|
||||
// Event registration. Based on: http://www.scottandrew.com/weblog/articles/cbs-events
|
||||
Util.addEvent = function (obj, evType, fn) {
|
||||
"use strict";
|
||||
if (obj.attachEvent) {
|
||||
var r = obj.attachEvent("on" + evType, fn);
|
||||
return r;
|
||||
} else if (obj.addEventListener) {
|
||||
obj.addEventListener(evType, fn, false);
|
||||
return true;
|
||||
} else {
|
||||
throw new Error("Handler could not be attached");
|
||||
}
|
||||
};
|
||||
|
||||
Util.removeEvent = function (obj, evType, fn) {
|
||||
"use strict";
|
||||
if (obj.detachEvent) {
|
||||
var r = obj.detachEvent("on" + evType, fn);
|
||||
return r;
|
||||
} else if (obj.removeEventListener) {
|
||||
obj.removeEventListener(evType, fn, false);
|
||||
return true;
|
||||
} else {
|
||||
throw new Error("Handler could not be removed");
|
||||
}
|
||||
};
|
||||
|
||||
Util.stopEvent = function (e) {
|
||||
"use strict";
|
||||
if (e.stopPropagation) { e.stopPropagation(); }
|
||||
else { e.cancelBubble = true; }
|
||||
|
||||
if (e.preventDefault) { e.preventDefault(); }
|
||||
else { e.returnValue = false; }
|
||||
};
|
||||
|
||||
Util._cursor_uris_supported = null;
|
||||
|
||||
Util.browserSupportsCursorURIs = function () {
|
||||
if (Util._cursor_uris_supported === null) {
|
||||
try {
|
||||
var target = document.createElement('canvas');
|
||||
target.style.cursor = 'url("data:image/x-icon;base64,AAACAAEACAgAAAIAAgA4AQAAFgAAACgAAAAIAAAAEAAAAAEAIAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////AAAAAAAAAAAAAAAAAAAAAA==") 2 2, default';
|
||||
|
||||
if (target.style.cursor) {
|
||||
Util.Info("Data URI scheme cursor supported");
|
||||
Util._cursor_uris_supported = true;
|
||||
} else {
|
||||
Util.Warn("Data URI scheme cursor not supported");
|
||||
Util._cursor_uris_supported = false;
|
||||
}
|
||||
} catch (exc) {
|
||||
Util.Error("Data URI scheme cursor test exception: " + exc);
|
||||
Util._cursor_uris_supported = false;
|
||||
}
|
||||
}
|
||||
|
||||
return Util._cursor_uris_supported;
|
||||
};
|
||||
|
||||
// Set browser engine versions. Based on mootools.
|
||||
Util.Features = {xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector)};
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
// 'presto': (function () { return (!window.opera) ? false : true; }()),
|
||||
var detectPresto = function () {
|
||||
return !!window.opera;
|
||||
};
|
||||
|
||||
// 'trident': (function () { return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4);
|
||||
var detectTrident = function () {
|
||||
if (!window.ActiveXObject) {
|
||||
return false;
|
||||
} else {
|
||||
if (window.XMLHttpRequest) {
|
||||
return (document.querySelectorAll) ? 6 : 5;
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 'webkit': (function () { try { return (navigator.taintEnabled) ? false : ((Util.Features.xpath) ? ((Util.Features.query) ? 525 : 420) : 419); } catch (e) { return false; } }()),
|
||||
var detectInitialWebkit = function () {
|
||||
try {
|
||||
if (navigator.taintEnabled) {
|
||||
return false;
|
||||
} else {
|
||||
if (Util.Features.xpath) {
|
||||
return (Util.Features.query) ? 525 : 420;
|
||||
} else {
|
||||
return 419;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var detectActualWebkit = function (initial_ver) {
|
||||
var re = /WebKit\/([0-9\.]*) /;
|
||||
var str_ver = (navigator.userAgent.match(re) || ['', initial_ver])[1];
|
||||
return parseFloat(str_ver, 10);
|
||||
};
|
||||
|
||||
// 'gecko': (function () { return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19ssName) ? 19 : 18 : 18); }())
|
||||
var detectGecko = function () {
|
||||
/* jshint -W041 */
|
||||
if (!document.getBoxObjectFor && window.mozInnerScreenX == null) {
|
||||
return false;
|
||||
} else {
|
||||
return (document.getElementsByClassName) ? 19 : 18;
|
||||
}
|
||||
/* jshint +W041 */
|
||||
};
|
||||
|
||||
Util.Engine = {
|
||||
// Version detection break in Opera 11.60 (errors on arguments.callee.caller reference)
|
||||
//'presto': (function() {
|
||||
// return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925)); }()),
|
||||
'presto': detectPresto(),
|
||||
'trident': detectTrident(),
|
||||
'webkit': detectInitialWebkit(),
|
||||
'gecko': detectGecko(),
|
||||
};
|
||||
|
||||
if (Util.Engine.webkit) {
|
||||
// Extract actual webkit version if available
|
||||
Util.Engine.webkit = detectActualWebkit(Util.Engine.webkit);
|
||||
}
|
||||
})();
|
||||
|
||||
Util.Flash = (function () {
|
||||
"use strict";
|
||||
var v, version;
|
||||
try {
|
||||
v = navigator.plugins['Shockwave Flash'].description;
|
||||
} catch (err1) {
|
||||
try {
|
||||
v = new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
|
||||
} catch (err2) {
|
||||
v = '0 r0';
|
||||
}
|
||||
}
|
||||
version = v.match(/\d+/g);
|
||||
return {version: parseInt(version[0] || 0 + '.' + version[1], 10) || 0, build: parseInt(version[2], 10) || 0};
|
||||
}());
|
||||
@@ -1,440 +0,0 @@
|
||||
/*
|
||||
* Websock: high-performance binary WebSockets
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*
|
||||
* Websock is similar to the standard WebSocket object but Websock
|
||||
* enables communication with raw TCP sockets (i.e. the binary stream)
|
||||
* via websockify. This is accomplished by base64 encoding the data
|
||||
* stream between Websock and websockify.
|
||||
*
|
||||
* Websock has built-in receive queue buffering; the message event
|
||||
* does not contain actual data but is simply a notification that
|
||||
* there is new data available. Several rQ* methods are available to
|
||||
* read binary data off of the receive queue.
|
||||
*/
|
||||
|
||||
/*jslint browser: true, bitwise: true */
|
||||
/*global Util*/
|
||||
|
||||
|
||||
// Load Flash WebSocket emulator if needed
|
||||
|
||||
// To force WebSocket emulator even when native WebSocket available
|
||||
//window.WEB_SOCKET_FORCE_FLASH = true;
|
||||
// To enable WebSocket emulator debug:
|
||||
//window.WEB_SOCKET_DEBUG=1;
|
||||
|
||||
if (window.WebSocket && !window.WEB_SOCKET_FORCE_FLASH) {
|
||||
Websock_native = true;
|
||||
} else if (window.MozWebSocket && !window.WEB_SOCKET_FORCE_FLASH) {
|
||||
Websock_native = true;
|
||||
window.WebSocket = window.MozWebSocket;
|
||||
} else {
|
||||
/* no builtin WebSocket so load web_socket.js */
|
||||
|
||||
Websock_native = false;
|
||||
}
|
||||
|
||||
function Websock() {
|
||||
"use strict";
|
||||
|
||||
this._websocket = null; // WebSocket object
|
||||
|
||||
this._rQi = 0; // Receive queue index
|
||||
this._rQlen = 0; // Next write position in the receive queue
|
||||
this._rQbufferSize = 1024 * 1024 * 4; // Receive queue buffer size (4 MiB)
|
||||
this._rQmax = this._rQbufferSize / 8;
|
||||
// called in init: this._rQ = new Uint8Array(this._rQbufferSize);
|
||||
this._rQ = null; // Receive queue
|
||||
|
||||
this._sQbufferSize = 1024 * 10; // 10 KiB
|
||||
// called in init: this._sQ = new Uint8Array(this._sQbufferSize);
|
||||
this._sQlen = 0;
|
||||
this._sQ = null; // Send queue
|
||||
|
||||
this._mode = 'binary'; // Current WebSocket mode: 'binary', 'base64'
|
||||
this.maxBufferedAmount = 200;
|
||||
|
||||
this._eventHandlers = {
|
||||
'message': function () {},
|
||||
'open': function () {},
|
||||
'close': function () {},
|
||||
'error': function () {}
|
||||
};
|
||||
}
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
// this has performance issues in some versions Chromium, and
|
||||
// doesn't gain a tremendous amount of performance increase in Firefox
|
||||
// at the moment. It may be valuable to turn it on in the future.
|
||||
var ENABLE_COPYWITHIN = false;
|
||||
|
||||
var MAX_RQ_GROW_SIZE = 40 * 1024 * 1024; // 40 MiB
|
||||
|
||||
var typedArrayToString = (function () {
|
||||
// This is only for PhantomJS, which doesn't like apply-ing
|
||||
// with Typed Arrays
|
||||
try {
|
||||
var arr = new Uint8Array([1, 2, 3]);
|
||||
String.fromCharCode.apply(null, arr);
|
||||
return function (a) { return String.fromCharCode.apply(null, a); };
|
||||
} catch (ex) {
|
||||
return function (a) {
|
||||
return String.fromCharCode.apply(
|
||||
null, Array.prototype.slice.call(a));
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
Websock.prototype = {
|
||||
// Getters and Setters
|
||||
get_sQ: function () {
|
||||
return this._sQ;
|
||||
},
|
||||
|
||||
get_rQ: function () {
|
||||
return this._rQ;
|
||||
},
|
||||
|
||||
get_rQi: function () {
|
||||
return this._rQi;
|
||||
},
|
||||
|
||||
set_rQi: function (val) {
|
||||
this._rQi = val;
|
||||
},
|
||||
|
||||
// Receive Queue
|
||||
rQlen: function () {
|
||||
return this._rQlen - this._rQi;
|
||||
},
|
||||
|
||||
rQpeek8: function () {
|
||||
return this._rQ[this._rQi];
|
||||
},
|
||||
|
||||
rQshift8: function () {
|
||||
return this._rQ[this._rQi++];
|
||||
},
|
||||
|
||||
rQskip8: function () {
|
||||
this._rQi++;
|
||||
},
|
||||
|
||||
rQskipBytes: function (num) {
|
||||
this._rQi += num;
|
||||
},
|
||||
|
||||
// TODO(directxman12): test performance with these vs a DataView
|
||||
rQshift16: function () {
|
||||
return (this._rQ[this._rQi++] << 8) +
|
||||
this._rQ[this._rQi++];
|
||||
},
|
||||
|
||||
rQshift32: function () {
|
||||
return (this._rQ[this._rQi++] << 24) +
|
||||
(this._rQ[this._rQi++] << 16) +
|
||||
(this._rQ[this._rQi++] << 8) +
|
||||
this._rQ[this._rQi++];
|
||||
},
|
||||
|
||||
rQshiftStr: function (len) {
|
||||
if (typeof(len) === 'undefined') { len = this.rQlen(); }
|
||||
var arr = new Uint8Array(this._rQ.buffer, this._rQi, len);
|
||||
this._rQi += len;
|
||||
return typedArrayToString(arr);
|
||||
},
|
||||
|
||||
rQshiftBytes: function (len) {
|
||||
if (typeof(len) === 'undefined') { len = this.rQlen(); }
|
||||
this._rQi += len;
|
||||
return new Uint8Array(this._rQ.buffer, this._rQi - len, len);
|
||||
},
|
||||
|
||||
rQshiftTo: function (target, len) {
|
||||
if (len === undefined) { len = this.rQlen(); }
|
||||
// TODO: make this just use set with views when using a ArrayBuffer to store the rQ
|
||||
target.set(new Uint8Array(this._rQ.buffer, this._rQi, len));
|
||||
this._rQi += len;
|
||||
},
|
||||
|
||||
rQwhole: function () {
|
||||
return new Uint8Array(this._rQ.buffer, 0, this._rQlen);
|
||||
},
|
||||
|
||||
rQslice: function (start, end) {
|
||||
if (end) {
|
||||
return new Uint8Array(this._rQ.buffer, this._rQi + start, end - start);
|
||||
} else {
|
||||
return new Uint8Array(this._rQ.buffer, this._rQi + start, this._rQlen - this._rQi - start);
|
||||
}
|
||||
},
|
||||
|
||||
// Check to see if we must wait for 'num' bytes (default to FBU.bytes)
|
||||
// to be available in the receive queue. Return true if we need to
|
||||
// wait (and possibly print a debug message), otherwise false.
|
||||
rQwait: function (msg, num, goback) {
|
||||
var rQlen = this._rQlen - this._rQi; // Skip rQlen() function call
|
||||
if (rQlen < num) {
|
||||
if (goback) {
|
||||
if (this._rQi < goback) {
|
||||
throw new Error("rQwait cannot backup " + goback + " bytes");
|
||||
}
|
||||
this._rQi -= goback;
|
||||
}
|
||||
return true; // true means need more data
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// Send Queue
|
||||
|
||||
flush: function () {
|
||||
if (this._websocket.bufferedAmount !== 0) {
|
||||
Util.Debug("bufferedAmount: " + this._websocket.bufferedAmount);
|
||||
}
|
||||
|
||||
if (this._websocket.bufferedAmount < this.maxBufferedAmount) {
|
||||
if (this._sQlen > 0 && this._websocket.readyState === WebSocket.OPEN) {
|
||||
this._websocket.send(this._encode_message());
|
||||
this._sQlen = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
Util.Info("Delaying send, bufferedAmount: " +
|
||||
this._websocket.bufferedAmount);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
send: function (arr) {
|
||||
this._sQ.set(arr, this._sQlen);
|
||||
this._sQlen += arr.length;
|
||||
return this.flush();
|
||||
},
|
||||
|
||||
send_string: function (str) {
|
||||
this.send(str.split('').map(function (chr) {
|
||||
return chr.charCodeAt(0);
|
||||
}));
|
||||
},
|
||||
|
||||
// Event Handlers
|
||||
off: function (evt) {
|
||||
this._eventHandlers[evt] = function () {};
|
||||
},
|
||||
|
||||
on: function (evt, handler) {
|
||||
this._eventHandlers[evt] = handler;
|
||||
},
|
||||
|
||||
_allocate_buffers: function () {
|
||||
this._rQ = new Uint8Array(this._rQbufferSize);
|
||||
this._sQ = new Uint8Array(this._sQbufferSize);
|
||||
},
|
||||
|
||||
init: function (protocols, ws_schema) {
|
||||
this._allocate_buffers();
|
||||
this._rQi = 0;
|
||||
this._websocket = null;
|
||||
|
||||
// Check for full typed array support
|
||||
var bt = false;
|
||||
if (('Uint8Array' in window) &&
|
||||
('set' in Uint8Array.prototype)) {
|
||||
bt = true;
|
||||
}
|
||||
|
||||
// Check for full binary type support in WebSockets
|
||||
// Inspired by:
|
||||
// https://github.com/Modernizr/Modernizr/issues/370
|
||||
// https://github.com/Modernizr/Modernizr/blob/master/feature-detects/websockets/binary.js
|
||||
var wsbt = false;
|
||||
try {
|
||||
if (bt && ('binaryType' in WebSocket.prototype ||
|
||||
!!(new WebSocket(ws_schema + '://.').binaryType))) {
|
||||
Util.Info("Detected binaryType support in WebSockets");
|
||||
wsbt = true;
|
||||
}
|
||||
} catch (exc) {
|
||||
// Just ignore failed test localhost connection
|
||||
}
|
||||
|
||||
// Default protocols if not specified
|
||||
if (typeof(protocols) === "undefined") {
|
||||
protocols = 'binary';
|
||||
}
|
||||
|
||||
if (Array.isArray(protocols) && protocols.indexOf('binary') > -1) {
|
||||
protocols = 'binary';
|
||||
}
|
||||
|
||||
if (!wsbt) {
|
||||
throw new Error("noVNC no longer supports base64 WebSockets. " +
|
||||
"Please use a browser which supports binary WebSockets.");
|
||||
}
|
||||
|
||||
if (protocols != 'binary') {
|
||||
throw new Error("noVNC no longer supports base64 WebSockets. Please " +
|
||||
"use the binary subprotocol instead.");
|
||||
}
|
||||
|
||||
return protocols;
|
||||
},
|
||||
|
||||
open: function (uri, protocols) {
|
||||
var ws_schema = uri.match(/^([a-z]+):\/\//)[1];
|
||||
protocols = this.init(protocols, ws_schema);
|
||||
|
||||
this._websocket = new WebSocket(uri, protocols);
|
||||
|
||||
if (protocols.indexOf('binary') >= 0) {
|
||||
this._websocket.binaryType = 'arraybuffer';
|
||||
}
|
||||
|
||||
this._websocket.onmessage = this._recv_message.bind(this);
|
||||
this._websocket.onopen = (function () {
|
||||
Util.Debug('>> WebSock.onopen');
|
||||
if (this._websocket.protocol) {
|
||||
this._mode = this._websocket.protocol;
|
||||
Util.Info("Server choose sub-protocol: " + this._websocket.protocol);
|
||||
} else {
|
||||
this._mode = 'binary';
|
||||
Util.Error('Server select no sub-protocol!: ' + this._websocket.protocol);
|
||||
}
|
||||
|
||||
if (this._mode != 'binary') {
|
||||
throw new Error("noVNC no longer supports base64 WebSockets. Please " +
|
||||
"use the binary subprotocol instead.");
|
||||
|
||||
}
|
||||
|
||||
this._eventHandlers.open();
|
||||
Util.Debug("<< WebSock.onopen");
|
||||
}).bind(this);
|
||||
this._websocket.onclose = (function (e) {
|
||||
Util.Debug(">> WebSock.onclose");
|
||||
this._eventHandlers.close(e);
|
||||
Util.Debug("<< WebSock.onclose");
|
||||
}).bind(this);
|
||||
this._websocket.onerror = (function (e) {
|
||||
Util.Debug(">> WebSock.onerror: " + e);
|
||||
this._eventHandlers.error(e);
|
||||
Util.Debug("<< WebSock.onerror: " + e);
|
||||
}).bind(this);
|
||||
},
|
||||
|
||||
close: function () {
|
||||
if (this._websocket) {
|
||||
if ((this._websocket.readyState === WebSocket.OPEN) ||
|
||||
(this._websocket.readyState === WebSocket.CONNECTING)) {
|
||||
Util.Info("Closing WebSocket connection");
|
||||
this._websocket.close();
|
||||
}
|
||||
|
||||
this._websocket.onmessage = function (e) { return; };
|
||||
}
|
||||
},
|
||||
|
||||
// private methods
|
||||
_encode_message: function () {
|
||||
// Put in a binary arraybuffer
|
||||
// according to the spec, you can send ArrayBufferViews with the send method
|
||||
return new Uint8Array(this._sQ.buffer, 0, this._sQlen);
|
||||
},
|
||||
|
||||
_expand_compact_rQ: function (min_fit) {
|
||||
var resizeNeeded = min_fit || this._rQlen - this._rQi > this._rQbufferSize / 2;
|
||||
if (resizeNeeded) {
|
||||
if (!min_fit) {
|
||||
// just double the size if we need to do compaction
|
||||
this._rQbufferSize *= 2;
|
||||
} else {
|
||||
// otherwise, make sure we satisy rQlen - rQi + min_fit < rQbufferSize / 8
|
||||
this._rQbufferSize = (this._rQlen - this._rQi + min_fit) * 8;
|
||||
}
|
||||
}
|
||||
|
||||
// we don't want to grow unboundedly
|
||||
if (this._rQbufferSize > MAX_RQ_GROW_SIZE) {
|
||||
this._rQbufferSize = MAX_RQ_GROW_SIZE;
|
||||
if (this._rQbufferSize - this._rQlen - this._rQi < min_fit) {
|
||||
throw new Exception("Receive Queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit");
|
||||
}
|
||||
}
|
||||
|
||||
if (resizeNeeded) {
|
||||
var old_rQbuffer = this._rQ.buffer;
|
||||
this._rQmax = this._rQbufferSize / 8;
|
||||
this._rQ = new Uint8Array(this._rQbufferSize);
|
||||
this._rQ.set(new Uint8Array(old_rQbuffer, this._rQi));
|
||||
} else {
|
||||
if (ENABLE_COPYWITHIN) {
|
||||
this._rQ.copyWithin(0, this._rQi);
|
||||
} else {
|
||||
this._rQ.set(new Uint8Array(this._rQ.buffer, this._rQi));
|
||||
}
|
||||
}
|
||||
|
||||
this._rQlen = this._rQlen - this._rQi;
|
||||
this._rQi = 0;
|
||||
},
|
||||
|
||||
_decode_message: function (data) {
|
||||
// push arraybuffer values onto the end
|
||||
var u8 = new Uint8Array(data);
|
||||
if (u8.length > this._rQbufferSize - this._rQlen) {
|
||||
this._expand_compact_rQ(u8.length);
|
||||
}
|
||||
this._rQ.set(u8, this._rQlen);
|
||||
this._rQlen += u8.length;
|
||||
},
|
||||
|
||||
_recv_message: function (e) {
|
||||
try {
|
||||
this._decode_message(e.data);
|
||||
if (this.rQlen() > 0) {
|
||||
this._eventHandlers.message();
|
||||
// Compact the receive queue
|
||||
if (this._rQlen == this._rQi) {
|
||||
this._rQlen = 0;
|
||||
this._rQi = 0;
|
||||
} else if (this._rQlen > this._rQmax) {
|
||||
this._expand_compact_rQ();
|
||||
}
|
||||
} else {
|
||||
Util.Debug("Ignoring empty message");
|
||||
}
|
||||
} catch (exc) {
|
||||
var exception_str = "";
|
||||
if (exc.name) {
|
||||
exception_str += "\n name: " + exc.name + "\n";
|
||||
exception_str += " message: " + exc.message + "\n";
|
||||
}
|
||||
|
||||
if (typeof exc.description !== 'undefined') {
|
||||
exception_str += " description: " + exc.description + "\n";
|
||||
}
|
||||
|
||||
if (typeof exc.stack !== 'undefined') {
|
||||
exception_str += exc.stack;
|
||||
}
|
||||
|
||||
if (exception_str.length > 0) {
|
||||
Util.Error("recv_message, caught exception: " + exception_str);
|
||||
} else {
|
||||
Util.Error("recv_message, caught exception: " + exc);
|
||||
}
|
||||
|
||||
if (typeof exc.name !== 'undefined') {
|
||||
this._eventHandlers.error(exc.name + ": " + exc.message);
|
||||
} else {
|
||||
this._eventHandlers.error(exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -1,292 +0,0 @@
|
||||
/*
|
||||
* noVNC: HTML5 VNC client
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Copyright (C) 2013 NTT corp.
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*
|
||||
* See README.md for usage and integration instructions.
|
||||
*/
|
||||
|
||||
/*jslint bitwise: false, white: false, browser: true, devel: true */
|
||||
/*global Util, window, document */
|
||||
|
||||
// Globals defined here
|
||||
var WebUtil = {}, $D;
|
||||
|
||||
/*
|
||||
* Simple DOM selector by ID
|
||||
*/
|
||||
if (!window.$D) {
|
||||
window.$D = function (id) {
|
||||
if (document.getElementById) {
|
||||
return document.getElementById(id);
|
||||
} else if (document.all) {
|
||||
return document.all[id];
|
||||
} else if (document.layers) {
|
||||
return document.layers[id];
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Namespaced in WebUtil
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
// init log level reading the logging HTTP param
|
||||
WebUtil.init_logging = function (level) {
|
||||
"use strict";
|
||||
if (typeof level !== "undefined") {
|
||||
Util._log_level = level;
|
||||
} else {
|
||||
var param = document.location.href.match(/logging=([A-Za-z0-9\._\-]*)/);
|
||||
Util._log_level = (param || ['', Util._log_level])[1];
|
||||
}
|
||||
Util.init_logging();
|
||||
};
|
||||
|
||||
|
||||
WebUtil.dirObj = function (obj, depth, parent) {
|
||||
"use strict";
|
||||
if (! depth) { depth = 2; }
|
||||
if (! parent) { parent = ""; }
|
||||
|
||||
// Print the properties of the passed-in object
|
||||
var msg = "";
|
||||
for (var i in obj) {
|
||||
if ((depth > 1) && (typeof obj[i] === "object")) {
|
||||
// Recurse attributes that are objects
|
||||
msg += WebUtil.dirObj(obj[i], depth - 1, parent + "." + i);
|
||||
} else {
|
||||
//val = new String(obj[i]).replace("\n", " ");
|
||||
var val = "";
|
||||
if (typeof(obj[i]) === "undefined") {
|
||||
val = "undefined";
|
||||
} else {
|
||||
val = obj[i].toString().replace("\n", " ");
|
||||
}
|
||||
if (val.length > 30) {
|
||||
val = val.substr(0, 30) + "...";
|
||||
}
|
||||
msg += parent + "." + i + ": " + val + "\n";
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
// Read a query string variable
|
||||
WebUtil.getQueryVar = function (name, defVal) {
|
||||
"use strict";
|
||||
var re = new RegExp('.*[?&]' + name + '=([^&#]*)'),
|
||||
match = document.location.href.match(re);
|
||||
if (typeof defVal === 'undefined') { defVal = null; }
|
||||
if (match) {
|
||||
return decodeURIComponent(match[1]);
|
||||
} else {
|
||||
return defVal;
|
||||
}
|
||||
};
|
||||
|
||||
// Read a hash fragment variable
|
||||
WebUtil.getHashVar = function (name, defVal) {
|
||||
"use strict";
|
||||
var re = new RegExp('.*[&#]' + name + '=([^&]*)'),
|
||||
match = document.location.hash.match(re);
|
||||
if (typeof defVal === 'undefined') { defVal = null; }
|
||||
if (match) {
|
||||
return decodeURIComponent(match[1]);
|
||||
} else {
|
||||
return defVal;
|
||||
}
|
||||
};
|
||||
|
||||
// Read a variable from the fragment or the query string
|
||||
// Fragment takes precedence
|
||||
WebUtil.getConfigVar = function (name, defVal) {
|
||||
"use strict";
|
||||
var val = WebUtil.getHashVar(name);
|
||||
if (val === null) {
|
||||
val = WebUtil.getQueryVar(name, defVal);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
/*
|
||||
* Cookie handling. Dervied from: http://www.quirksmode.org/js/cookies.html
|
||||
*/
|
||||
|
||||
// No days means only for this browser session
|
||||
WebUtil.createCookie = function (name, value, days) {
|
||||
"use strict";
|
||||
var date, expires;
|
||||
if (days) {
|
||||
date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
} else {
|
||||
expires = "";
|
||||
}
|
||||
|
||||
var secure;
|
||||
if (document.location.protocol === "https:") {
|
||||
secure = "; secure";
|
||||
} else {
|
||||
secure = "";
|
||||
}
|
||||
document.cookie = name + "=" + value + expires + "; path=/" + secure;
|
||||
};
|
||||
|
||||
WebUtil.readCookie = function (name, defaultValue) {
|
||||
"use strict";
|
||||
var nameEQ = name + "=",
|
||||
ca = document.cookie.split(';');
|
||||
|
||||
for (var i = 0; i < ca.length; i += 1) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ') { c = c.substring(1, c.length); }
|
||||
if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length, c.length); }
|
||||
}
|
||||
return (typeof defaultValue !== 'undefined') ? defaultValue : null;
|
||||
};
|
||||
|
||||
WebUtil.eraseCookie = function (name) {
|
||||
"use strict";
|
||||
WebUtil.createCookie(name, "", -1);
|
||||
};
|
||||
|
||||
/*
|
||||
* Setting handling.
|
||||
*/
|
||||
|
||||
WebUtil.initSettings = function (callback /*, ...callbackArgs */) {
|
||||
"use strict";
|
||||
var callbackArgs = Array.prototype.slice.call(arguments, 1);
|
||||
if (window.chrome && window.chrome.storage) {
|
||||
window.chrome.storage.sync.get(function (cfg) {
|
||||
WebUtil.settings = cfg;
|
||||
console.log(WebUtil.settings);
|
||||
if (callback) {
|
||||
callback.apply(this, callbackArgs);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// No-op
|
||||
if (callback) {
|
||||
callback.apply(this, callbackArgs);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// No days means only for this browser session
|
||||
WebUtil.writeSetting = function (name, value) {
|
||||
"use strict";
|
||||
if (window.chrome && window.chrome.storage) {
|
||||
//console.log("writeSetting:", name, value);
|
||||
if (WebUtil.settings[name] !== value) {
|
||||
WebUtil.settings[name] = value;
|
||||
window.chrome.storage.sync.set(WebUtil.settings);
|
||||
}
|
||||
} else {
|
||||
localStorage.setItem(name, value);
|
||||
}
|
||||
};
|
||||
|
||||
WebUtil.readSetting = function (name, defaultValue) {
|
||||
"use strict";
|
||||
var value;
|
||||
if (window.chrome && window.chrome.storage) {
|
||||
value = WebUtil.settings[name];
|
||||
} else {
|
||||
value = localStorage.getItem(name);
|
||||
}
|
||||
if (typeof value === "undefined") {
|
||||
value = null;
|
||||
}
|
||||
if (value === null && typeof defaultValue !== undefined) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
WebUtil.eraseSetting = function (name) {
|
||||
"use strict";
|
||||
if (window.chrome && window.chrome.storage) {
|
||||
window.chrome.storage.sync.remove(name);
|
||||
delete WebUtil.settings[name];
|
||||
} else {
|
||||
localStorage.removeItem(name);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Alternate stylesheet selection
|
||||
*/
|
||||
WebUtil.getStylesheets = function () {
|
||||
"use strict";
|
||||
var links = document.getElementsByTagName("link");
|
||||
var sheets = [];
|
||||
|
||||
for (var i = 0; i < links.length; i += 1) {
|
||||
if (links[i].title &&
|
||||
links[i].rel.toUpperCase().indexOf("STYLESHEET") > -1) {
|
||||
sheets.push(links[i]);
|
||||
}
|
||||
}
|
||||
return sheets;
|
||||
};
|
||||
|
||||
// No sheet means try and use value from cookie, null sheet used to
|
||||
// clear all alternates.
|
||||
WebUtil.selectStylesheet = function (sheet) {
|
||||
"use strict";
|
||||
if (typeof sheet === 'undefined') {
|
||||
sheet = 'default';
|
||||
}
|
||||
|
||||
var sheets = WebUtil.getStylesheets();
|
||||
for (var i = 0; i < sheets.length; i += 1) {
|
||||
var link = sheets[i];
|
||||
if (link.title === sheet) {
|
||||
Util.Debug("Using stylesheet " + sheet);
|
||||
link.disabled = false;
|
||||
} else {
|
||||
//Util.Debug("Skipping stylesheet " + link.title);
|
||||
link.disabled = true;
|
||||
}
|
||||
}
|
||||
return sheet;
|
||||
};
|
||||
|
||||
WebUtil.injectParamIfMissing = function (path, param, value) {
|
||||
// force pretend that we're dealing with a relative path
|
||||
// (assume that we wanted an extra if we pass one in)
|
||||
path = "/" + path;
|
||||
|
||||
var elem = document.createElement('a');
|
||||
elem.href = path;
|
||||
|
||||
var param_eq = encodeURIComponent(param) + "=";
|
||||
var query;
|
||||
if (elem.search) {
|
||||
query = elem.search.slice(1).split('&');
|
||||
} else {
|
||||
query = [];
|
||||
}
|
||||
|
||||
if (!query.some(function (v) { return v.startsWith(param_eq); })) {
|
||||
query.push(param_eq + encodeURIComponent(value));
|
||||
elem.search = "?" + query.join("&");
|
||||
}
|
||||
|
||||
// some browsers (e.g. IE11) may occasionally omit the leading slash
|
||||
// in the elem.pathname string. Handle that case gracefully.
|
||||
if (elem.pathname.charAt(0) == "/") {
|
||||
return elem.pathname.slice(1) + elem.search + elem.hash;
|
||||
} else {
|
||||
return elem.pathname + elem.search + elem.hash;
|
||||
}
|
||||
};
|
||||
@@ -21,7 +21,7 @@
|
||||
"scripts": {
|
||||
"lint": "eslint app core po/po2js po/xgettext-html tests utils",
|
||||
"test": "karma start karma.conf.js",
|
||||
"prepublish": "node ./utils/use_require.js --clean"
|
||||
"prepublish": "node ./utils/convert.js --clean"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -66,9 +66,6 @@
|
||||
"mocha": "*",
|
||||
"node-getopt": "*",
|
||||
"po2json": "*",
|
||||
"requirejs": "*",
|
||||
"rollup": "*",
|
||||
"rollup-plugin-node-resolve": "*",
|
||||
"sinon": "*",
|
||||
"sinon-chai": "*"
|
||||
},
|
||||
|
||||
5
public/novnc/po/.eslintrc
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"env": {
|
||||
"node": true,
|
||||
},
|
||||
}
|
||||
@@ -3,14 +3,15 @@
|
||||
# Copyright (C) 2021 The noVNC Authors
|
||||
# This file is distributed under the same license as the noVNC package.
|
||||
# Jose <jose.matsuda@canada.ca>, 2021.
|
||||
# Lowxorx <lowxorx@lahan.fr>, 2022.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: noVNC 1.2.0\n"
|
||||
"Report-Msgid-Bugs-To: novnc@googlegroups.com\n"
|
||||
"POT-Creation-Date: 2020-07-03 16:11+0200\n"
|
||||
"PO-Revision-Date: 2021-05-05 20:19-0400\n"
|
||||
"Last-Translator: Jose <jose.matsuda@canada.ca>\n"
|
||||
"PO-Revision-Date: 2022-04-25 23:40+0200\n"
|
||||
"Last-Translator: Lowxorx <lowxorx@lahan.fr>\n"
|
||||
"Language-Team: French\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@@ -40,15 +41,15 @@ msgstr "Doit définir l'hôte"
|
||||
|
||||
#: ../app/ui.js:1090
|
||||
msgid "Connected (encrypted) to "
|
||||
msgstr "Connecté (crypté) à "
|
||||
msgstr "Connecté (chiffré) à "
|
||||
|
||||
#: ../app/ui.js:1092
|
||||
msgid "Connected (unencrypted) to "
|
||||
msgstr "Connecté (non crypté) à "
|
||||
msgstr "Connecté (non chiffré) à "
|
||||
|
||||
#: ../app/ui.js:1115
|
||||
msgid "Something went wrong, connection is closed"
|
||||
msgstr "Quelque chose est arrivé, la connexion est fermée"
|
||||
msgstr "Quelque chose s'est mal passé, la connexion a été fermée"
|
||||
|
||||
#: ../app/ui.js:1118
|
||||
msgid "Failed to connect to server"
|
||||
@@ -60,7 +61,7 @@ msgstr "Déconnecté"
|
||||
|
||||
#: ../app/ui.js:1143
|
||||
msgid "New connection has been rejected with reason: "
|
||||
msgstr "Une nouvelle connexion a été rejetée avec raison: "
|
||||
msgstr "Une nouvelle connexion a été rejetée avec motif : "
|
||||
|
||||
#: ../app/ui.js:1146
|
||||
msgid "New connection has been rejected"
|
||||
@@ -72,7 +73,7 @@ msgstr "Les identifiants sont requis"
|
||||
|
||||
#: ../vnc.html:74
|
||||
msgid "noVNC encountered an error:"
|
||||
msgstr "noVNC a rencontré une erreur:"
|
||||
msgstr "noVNC a rencontré une erreur :"
|
||||
|
||||
#: ../vnc.html:84
|
||||
msgid "Hide/Show the control bar"
|
||||
@@ -84,7 +85,7 @@ msgstr "Faire glisser"
|
||||
|
||||
#: ../vnc.html:91
|
||||
msgid "Move/Drag Viewport"
|
||||
msgstr "Déplacer/faire glisser Viewport"
|
||||
msgstr "Déplacer/faire glisser le Viewport"
|
||||
|
||||
#: ../vnc.html:97
|
||||
msgid "Keyboard"
|
||||
@@ -204,7 +205,7 @@ msgstr "Clip à fenêtre"
|
||||
|
||||
#: ../vnc.html:185
|
||||
msgid "Scaling Mode:"
|
||||
msgstr "Mode mise à l'échelle:"
|
||||
msgstr "Mode mise à l'échelle :"
|
||||
|
||||
#: ../vnc.html:187
|
||||
msgid "None"
|
||||
@@ -224,15 +225,15 @@ msgstr "Avancé"
|
||||
|
||||
#: ../vnc.html:197
|
||||
msgid "Quality:"
|
||||
msgstr "Qualité:"
|
||||
msgstr "Qualité :"
|
||||
|
||||
#: ../vnc.html:201
|
||||
msgid "Compression level:"
|
||||
msgstr "Niveau de compression:"
|
||||
msgstr "Niveau de compression :"
|
||||
|
||||
#: ../vnc.html:206
|
||||
msgid "Repeater ID:"
|
||||
msgstr "ID Répéteur:"
|
||||
msgstr "ID Répéteur :"
|
||||
|
||||
#: ../vnc.html:210
|
||||
msgid "WebSocket"
|
||||
@@ -240,19 +241,19 @@ msgstr "WebSocket"
|
||||
|
||||
#: ../vnc.html:213
|
||||
msgid "Encrypt"
|
||||
msgstr "Crypter"
|
||||
msgstr "Chiffrer"
|
||||
|
||||
#: ../vnc.html:216
|
||||
msgid "Host:"
|
||||
msgstr "Hôte:"
|
||||
msgstr "Hôte :"
|
||||
|
||||
#: ../vnc.html:220
|
||||
msgid "Port:"
|
||||
msgstr "Port:"
|
||||
msgstr "Port :"
|
||||
|
||||
#: ../vnc.html:224
|
||||
msgid "Path:"
|
||||
msgstr "Chemin:"
|
||||
msgstr "Chemin :"
|
||||
|
||||
#: ../vnc.html:231
|
||||
msgid "Automatic Reconnect"
|
||||
@@ -260,7 +261,7 @@ msgstr "Reconnecter automatiquemen"
|
||||
|
||||
#: ../vnc.html:234
|
||||
msgid "Reconnect Delay (ms):"
|
||||
msgstr "Délai de reconnexion (ms):"
|
||||
msgstr "Délai de reconnexion (ms) :"
|
||||
|
||||
#: ../vnc.html:239
|
||||
msgid "Show Dot when No Cursor"
|
||||
@@ -268,11 +269,11 @@ msgstr "Afficher le point lorsqu'il n'y a pas de curseur"
|
||||
|
||||
#: ../vnc.html:244
|
||||
msgid "Logging:"
|
||||
msgstr "Se connecter:"
|
||||
msgstr "Se connecter :"
|
||||
|
||||
#: ../vnc.html:253
|
||||
msgid "Version:"
|
||||
msgstr "Version:"
|
||||
msgstr "Version :"
|
||||
|
||||
#: ../vnc.html:261
|
||||
msgid "Disconnect"
|
||||
@@ -284,11 +285,11 @@ msgstr "Connecter"
|
||||
|
||||
#: ../vnc.html:290
|
||||
msgid "Username:"
|
||||
msgstr "Nom d'utilisateur:"
|
||||
msgstr "Nom d'utilisateur :"
|
||||
|
||||
#: ../vnc.html:294
|
||||
msgid "Password:"
|
||||
msgstr "Mot de passe:"
|
||||
msgstr "Mot de passe :"
|
||||
|
||||
#: ../vnc.html:298
|
||||
msgid "Send Credentials"
|
||||
|
||||
0
public/novnc/po/po2js
Normal file → Executable file
0
public/novnc/po/xgettext-html
Normal file → Executable file
0
public/novnc/snap/local/svc_wrapper.sh
Normal file → Executable file
@@ -23,6 +23,9 @@ parts:
|
||||
- core/**/*.js
|
||||
- vendor/**/*.js
|
||||
- novnc_proxy
|
||||
|
||||
novnc-deps:
|
||||
plugin: nil
|
||||
stage-packages:
|
||||
- bash
|
||||
|
||||
@@ -31,6 +34,9 @@ parts:
|
||||
plugin: dump
|
||||
stage:
|
||||
- svc_wrapper.sh
|
||||
|
||||
svc-script-deps:
|
||||
plugin: nil
|
||||
stage-packages:
|
||||
- bash
|
||||
- jq
|
||||
|
||||
15
public/novnc/tests/.eslintrc
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"env": {
|
||||
"node": true,
|
||||
"mocha": true
|
||||
},
|
||||
"globals": {
|
||||
"chai": false,
|
||||
"sinon": false
|
||||
},
|
||||
"rules": {
|
||||
"prefer-arrow-callback": 0,
|
||||
// Too many anonymous callbacks
|
||||
"func-names": "off",
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Javascript Arrays Performance Test</title>
|
||||
<!--
|
||||
<script type='text/javascript'
|
||||
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
|
||||
-->
|
||||
<script src="../include/util.js"></script>
|
||||
<script src="../include/webutil.js"></script>
|
||||
<script src="browser.js"></script>
|
||||
<script src="stats.js"></script>
|
||||
<script src="arrays.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h3>Javascript Arrays Performance Test</h3>
|
||||
Iterations: <input id='iterations' style='width:50'>
|
||||
Array Size: <input id='arraySize' style='width:40'>*1024
|
||||
|
||||
<input id='startButton' type='button' value='Run Tests'
|
||||
onclick="begin();">
|
||||
|
||||
<br><br>
|
||||
Results:<br>
|
||||
<textarea id="messages" style="font-size: 9;" cols=80 rows=50></textarea>
|
||||
</br>
|
||||
<canvas id="canvas" style="display: none;"></canvas>
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
var verbose = true;
|
||||
window.onload = function() {
|
||||
vmessage("in onload");
|
||||
init();
|
||||
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,375 +0,0 @@
|
||||
/*
|
||||
* Javascript binary array performance tests
|
||||
* Copyright (C) 2012 Joel Martin
|
||||
* Licensed under MPL 2.0 (see LICENSE.txt)
|
||||
*/
|
||||
|
||||
var ctx, i, j, randlist,
|
||||
new_normal, new_imageData, new_arrayBuffer,
|
||||
browser = Browser.browser + " " +
|
||||
Browser.version + " on " +
|
||||
Browser.OS,
|
||||
do_imageData = false,
|
||||
do_arrayBuffer = false,
|
||||
conf = {
|
||||
'create_cnt' : 2000,
|
||||
'read_cnt' : 5000000,
|
||||
'write_cnt' : 5000000,
|
||||
'iterations' : 0,
|
||||
'order_l1' : [browser],
|
||||
'order_l2' : ['normal',
|
||||
'imageData',
|
||||
'arrayBuffer'],
|
||||
'order_l3' : ['create',
|
||||
'sequentialRead',
|
||||
'randomRead',
|
||||
'sequentialWrite']
|
||||
},
|
||||
stats = {},
|
||||
testFunc = {},
|
||||
iteration, arraySize;
|
||||
|
||||
var newline = "\n";
|
||||
if (Util.Engine.trident) {
|
||||
var newline = "<br>\n";
|
||||
}
|
||||
function message(str) {
|
||||
//console.log(str);
|
||||
cell = $D('messages');
|
||||
cell.textContent += str + newline;
|
||||
cell.scrollTop = cell.scrollHeight;
|
||||
}
|
||||
|
||||
function vmessage(str) {
|
||||
if (verbose) {
|
||||
message(str);
|
||||
} else {
|
||||
console.log(str);
|
||||
}
|
||||
}
|
||||
|
||||
new_normal = function() {
|
||||
var arr = [], i;
|
||||
for (i = 0; i < arraySize; i++) {
|
||||
arr[i] = 0;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/* Will be overridden with real function */
|
||||
new_imageData = function() {
|
||||
throw("imageData not supported");
|
||||
};
|
||||
|
||||
new_imageData_createImageData = function() {
|
||||
var imageData = ctx.createImageData(1024/4, arraySize / 1024);
|
||||
return imageData.data;
|
||||
};
|
||||
|
||||
new_imageData_getImageData = function() {
|
||||
var imageData = ctx.getImageData(0, 0, 1024/4, arraySize / 1024),
|
||||
arr = imageData.data;
|
||||
for (i = 0; i < arraySize; i++) {
|
||||
arr[i] = 0;
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
new_arrayBuffer = function() {
|
||||
var arr = new ArrayBuffer(arraySize);
|
||||
return new Uint8Array(arr);
|
||||
}
|
||||
|
||||
function init_randlist() {
|
||||
randlist = [];
|
||||
for (var i=0; i < arraySize; i++) {
|
||||
randlist[i] = parseInt(Math.random() * 256, 10);
|
||||
}
|
||||
}
|
||||
function copy_randlist(arr) {
|
||||
for (var i=0; i < arraySize; i++) {
|
||||
arr[i] = randlist[i];
|
||||
}
|
||||
}
|
||||
|
||||
function begin() {
|
||||
var i, j;
|
||||
conf.iterations = parseInt($D('iterations').value, 10);
|
||||
arraySize = parseInt($D('arraySize').value, 10) * 1024;
|
||||
|
||||
init_randlist();
|
||||
|
||||
// TODO: randomize test_list
|
||||
|
||||
stats = {};
|
||||
for (i = 0; i < conf.order_l2.length; i++) {
|
||||
stats[conf.order_l2[i]] = {};
|
||||
for (j = 0; j < conf.order_l3.length; j++) {
|
||||
stats[conf.order_l2[i]][conf.order_l3[j]] = [];
|
||||
}
|
||||
}
|
||||
|
||||
$D('startButton').value = "Running";
|
||||
$D('startButton').disabled = true;
|
||||
|
||||
message("running " + conf.iterations + " test iterations");
|
||||
iteration = 1;
|
||||
setTimeout(run_next_iteration, 250);
|
||||
}
|
||||
|
||||
function finish() {
|
||||
var totalTime, arrayType, testType, times;
|
||||
message("tests finished");
|
||||
|
||||
for (j = 0; j < conf.order_l3.length; j++) {
|
||||
testType = conf.order_l3[j];
|
||||
message("Test '" + testType + "'");
|
||||
for (i = 0; i < conf.order_l2.length; i++) {
|
||||
arrayType = conf.order_l2[i];
|
||||
message(" Array Type '" + arrayType);
|
||||
times = stats[arrayType][testType];
|
||||
message(" Average : " + times.mean() + "ms" +
|
||||
" (Total: " + times.sum() + "ms)");
|
||||
message(" Min/Max : " + times.min() + "ms/" +
|
||||
times.max() + "ms");
|
||||
message(" StdDev : " + times.stdDev() + "ms");
|
||||
}
|
||||
}
|
||||
|
||||
vmessage("array_chart.py JSON data:");
|
||||
chart_data = {'conf' : conf, 'stats' : { } };
|
||||
chart_data.stats[browser] = stats;
|
||||
chart_data.stats['next_browser'] = {};
|
||||
vmessage(JSON.stringify(chart_data, null, 2));
|
||||
|
||||
$D('startButton').disabled = false;
|
||||
$D('startButton').value = "Run Tests";
|
||||
}
|
||||
|
||||
function run_next_iteration() {
|
||||
var arrayType, testType, deltaTime;
|
||||
|
||||
for (i = 0; i < conf.order_l2.length; i++) {
|
||||
arrayType = conf.order_l2[i];
|
||||
if (arrayType === 'imageData' && (!do_imageData)) {
|
||||
continue;
|
||||
}
|
||||
if (arrayType === 'arrayBuffer' && (!do_arrayBuffer)) {
|
||||
continue;
|
||||
}
|
||||
for (j = 0; j < conf.order_l3.length; j++) {
|
||||
testType = conf.order_l3[j];
|
||||
|
||||
deltaTime = testFunc[arrayType + "_" + testType]();
|
||||
|
||||
stats[arrayType][testType].push(deltaTime);
|
||||
vmessage("test " + (arrayType + "_" + testType) +
|
||||
" time: " + (deltaTime) + "ms");
|
||||
}
|
||||
}
|
||||
|
||||
message("finished test iteration " + iteration);
|
||||
if (iteration >= conf.iterations) {
|
||||
setTimeout(finish, 1);
|
||||
return;
|
||||
}
|
||||
iteration++;
|
||||
setTimeout(run_next_iteration, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test functions
|
||||
*/
|
||||
|
||||
testFunc["normal_create"] = function() {
|
||||
var cnt, arrNormal, startTime, endTime;
|
||||
vmessage("create normal array " + conf.create_cnt + "x, initialized to 0");
|
||||
|
||||
startTime = (new Date()).getTime();
|
||||
for (cnt = 0; cnt < conf.create_cnt; cnt++) {
|
||||
arrNormal = new_normal();
|
||||
}
|
||||
endTime = (new Date()).getTime();
|
||||
|
||||
return endTime - startTime;
|
||||
};
|
||||
|
||||
testFunc["imageData_create"] = function() {
|
||||
var cnt, arrImage, startTime, endTime;
|
||||
vmessage("create imageData array " + conf.create_cnt + "x, initialized to 0");
|
||||
|
||||
startTime = (new Date()).getTime();
|
||||
for (cnt = 0; cnt < conf.create_cnt; cnt++) {
|
||||
arrImage = new_imageData();
|
||||
}
|
||||
endTime = (new Date()).getTime();
|
||||
|
||||
if (arrImage[103] !== 0) {
|
||||
message("Initialization failed, arrImage[103] is: " + arrImage[103]);
|
||||
throw("Initialization failed, arrImage[103] is: " + arrImage[103]);
|
||||
}
|
||||
return endTime - startTime;
|
||||
};
|
||||
|
||||
testFunc["arrayBuffer_create"] = function() {
|
||||
var cnt, arrBuffer, startTime, endTime;
|
||||
vmessage("create arrayBuffer array " + conf.create_cnt + "x, initialized to 0");
|
||||
|
||||
startTime = (new Date()).getTime();
|
||||
for (cnt = 0; cnt < conf.create_cnt; cnt++) {
|
||||
arrBuffer = new_arrayBuffer();
|
||||
}
|
||||
endTime = (new Date()).getTime();
|
||||
|
||||
if (arrBuffer[103] !== 0) {
|
||||
message("Initialization failed, arrBuffer[103] is: " + arrBuffer[103]);
|
||||
throw("Initialization failed, arrBuffer[103] is: " + arrBuffer[103]);
|
||||
}
|
||||
return endTime - startTime;
|
||||
};
|
||||
|
||||
function test_sequentialRead(arr) {
|
||||
var i, j, cnt, startTime, endTime;
|
||||
/* Initialize the array */
|
||||
copy_randlist(arr);
|
||||
|
||||
startTime = (new Date()).getTime();
|
||||
i = 0;
|
||||
j = 0;
|
||||
for (cnt = 0; cnt < conf.read_cnt; cnt++) {
|
||||
j = arr[i];
|
||||
i++;
|
||||
if (i >= arraySize) {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
endTime = (new Date()).getTime();
|
||||
|
||||
return endTime - startTime;
|
||||
}
|
||||
|
||||
function test_randomRead(arr) {
|
||||
var i, cnt, startTime, endTime;
|
||||
/* Initialize the array */
|
||||
copy_randlist(arr); // used as jumplist
|
||||
|
||||
startTime = (new Date()).getTime();
|
||||
i = 0;
|
||||
for (cnt = 0; cnt < conf.read_cnt; cnt++) {
|
||||
i = (arr[i] + cnt) % arraySize;
|
||||
}
|
||||
endTime = (new Date()).getTime();
|
||||
|
||||
return endTime - startTime;
|
||||
}
|
||||
|
||||
function test_sequentialWrite(arr) {
|
||||
var i, cnt, startTime, endTime;
|
||||
/* Initialize the array */
|
||||
copy_randlist(arr);
|
||||
|
||||
startTime = (new Date()).getTime();
|
||||
i = 0;
|
||||
for (cnt = 0; cnt < conf.write_cnt; cnt++) {
|
||||
arr[i] = (cnt % 256);
|
||||
i++;
|
||||
if (i >= arraySize) {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
endTime = (new Date()).getTime();
|
||||
|
||||
return endTime - startTime;
|
||||
}
|
||||
|
||||
/* Sequential Read Tests */
|
||||
testFunc["normal_sequentialRead"] = function() {
|
||||
vmessage("read normal array " + conf.read_cnt + "x");
|
||||
return test_sequentialRead(new_normal());
|
||||
};
|
||||
|
||||
testFunc["imageData_sequentialRead"] = function() {
|
||||
vmessage("read imageData array " + conf.read_cnt + "x");
|
||||
return test_sequentialRead(new_imageData());
|
||||
};
|
||||
|
||||
testFunc["arrayBuffer_sequentialRead"] = function() {
|
||||
vmessage("read arrayBuffer array " + conf.read_cnt + "x");
|
||||
return test_sequentialRead(new_arrayBuffer());
|
||||
};
|
||||
|
||||
|
||||
/* Random Read Tests */
|
||||
testFunc["normal_randomRead"] = function() {
|
||||
vmessage("read normal array " + conf.read_cnt + "x");
|
||||
return test_randomRead(new_normal());
|
||||
};
|
||||
|
||||
testFunc["imageData_randomRead"] = function() {
|
||||
vmessage("read imageData array " + conf.read_cnt + "x");
|
||||
return test_randomRead(new_imageData());
|
||||
};
|
||||
|
||||
testFunc["arrayBuffer_randomRead"] = function() {
|
||||
vmessage("read arrayBuffer array " + conf.read_cnt + "x");
|
||||
return test_randomRead(new_arrayBuffer());
|
||||
};
|
||||
|
||||
|
||||
/* Sequential Write Tests */
|
||||
testFunc["normal_sequentialWrite"] = function() {
|
||||
vmessage("write normal array " + conf.write_cnt + "x");
|
||||
return test_sequentialWrite(new_normal());
|
||||
};
|
||||
|
||||
testFunc["imageData_sequentialWrite"] = function() {
|
||||
vmessage("write imageData array " + conf.write_cnt + "x");
|
||||
return test_sequentialWrite(new_imageData());
|
||||
};
|
||||
|
||||
testFunc["arrayBuffer_sequentialWrite"] = function() {
|
||||
vmessage("write arrayBuffer array " + conf.write_cnt + "x");
|
||||
return test_sequentialWrite(new_arrayBuffer());
|
||||
};
|
||||
|
||||
init = function() {
|
||||
vmessage(">> init");
|
||||
|
||||
$D('iterations').value = 10;
|
||||
$D('arraySize').value = 10;
|
||||
arraySize = parseInt($D('arraySize').value, 10) * 1024;
|
||||
|
||||
message("Browser: " + browser);
|
||||
|
||||
/* Determine browser binary array support */
|
||||
try {
|
||||
ctx = $D('canvas').getContext('2d');
|
||||
new_imageData = new_imageData_createImageData;
|
||||
new_imageData();
|
||||
do_imageData = true;
|
||||
} catch (exc) {
|
||||
vmessage("createImageData not supported: " + exc);
|
||||
try {
|
||||
ctx = $D('canvas').getContext('2d');
|
||||
new_imageData = new_imageData_getImageData;
|
||||
blah = new_imageData();
|
||||
do_imageData = true;
|
||||
} catch (exc) {
|
||||
vmessage("getImageData not supported: " + exc);
|
||||
}
|
||||
}
|
||||
if (! do_imageData) {
|
||||
message("imageData arrays not supported");
|
||||
}
|
||||
|
||||
try {
|
||||
new_arrayBuffer();
|
||||
do_arrayBuffer = true;
|
||||
} catch (exc) {
|
||||
vmessage("Typed Arrays not supported: " + exc);
|
||||
}
|
||||
if (! do_arrayBuffer) {
|
||||
message("Typed Arrays (ArrayBuffers) not suppoted");
|
||||
}
|
||||
vmessage("<< init");
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Native Base64 Tests</title>
|
||||
<script src="../include/util.js"></script>
|
||||
<script src="../include/webutil.js"></script>
|
||||
<script src="../include/base64.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Native Base64 Tests</h1>
|
||||
|
||||
<br>
|
||||
Messages:<br>
|
||||
<textarea id="debug" style="font-size: 9px;" cols=80 rows=25></textarea>
|
||||
|
||||
<br>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
function debug(str) {
|
||||
console.log(str);
|
||||
cell = $D('debug');
|
||||
cell.textContent += str + "\n";
|
||||
cell.scrollTop = cell.scrollHeight;
|
||||
}
|
||||
|
||||
function assertRun(code, result) {
|
||||
try {
|
||||
var actual = eval(code);
|
||||
} catch (exc) {
|
||||
debug("FAIL: '" + code + "' threw an exception");
|
||||
fail += 1;
|
||||
return false;
|
||||
}
|
||||
if (actual !== result) {
|
||||
debug("FAIL: '" + code + "' returned '" + actual + "', expected '" + result + "'");
|
||||
fail += 1;
|
||||
return false;
|
||||
}
|
||||
debug("PASS: '" + code + "' returned expected '" + result +"'");
|
||||
pass += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
function Base64_decode(data) {
|
||||
var arr = Base64.decode (data);
|
||||
return arr.map(function (num) {
|
||||
return String.fromCharCode(num); } ).join('');
|
||||
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
var str;
|
||||
debug('onload');
|
||||
fail = 0;
|
||||
pass = 0;
|
||||
assertRun('window.btoa("hello world")', 'aGVsbG8gd29ybGQ=');
|
||||
assertRun('window.btoa("a")', 'YQ==');
|
||||
assertRun('window.btoa("ab")', 'YWI=');
|
||||
assertRun('window.btoa("abc")', 'YWJj');
|
||||
assertRun('window.btoa("abcd")', 'YWJjZA==');
|
||||
assertRun('window.btoa("abcde")', 'YWJjZGU=');
|
||||
assertRun('window.btoa("abcdef")', 'YWJjZGVm');
|
||||
assertRun('window.btoa("abcdefg")', 'YWJjZGVmZw==');
|
||||
assertRun('window.btoa("abcdefgh")', 'YWJjZGVmZ2g=');
|
||||
|
||||
assertRun('window.atob("aGVsbG8gd29ybGQ=")', 'hello world');
|
||||
assertRun('Base64_decode("aGVsbG8gd29ybGQ=")', 'hello world');
|
||||
assertRun('window.atob("YQ==")', 'a');
|
||||
assertRun('Base64_decode("YQ==")', 'a');
|
||||
assertRun('window.atob("YWI=")', 'ab');
|
||||
assertRun('Base64_decode("YWI=")', 'ab');
|
||||
assertRun('window.atob("YWJj")', 'abc');
|
||||
assertRun('Base64_decode("YWJj")', 'abc');
|
||||
assertRun('window.atob("YWJjZA==")', 'abcd');
|
||||
assertRun('Base64_decode("YWJjZA==")', 'abcd');
|
||||
assertRun('window.atob("YWJjZGU=")', 'abcde');
|
||||
assertRun('Base64_decode("YWJjZGU=")', 'abcde');
|
||||
assertRun('window.atob("YWJjZGVm")', 'abcdef');
|
||||
assertRun('Base64_decode("YWJjZGVm")', 'abcdef');
|
||||
|
||||
assertRun('typeof window.btoa', 'function');
|
||||
assertRun('window.btoa("")', '');
|
||||
assertRun('window.btoa(null)', '');
|
||||
assertRun('window.atob(window.btoa(window))', window.toString()); // "[object DOMWindow]"
|
||||
assertRun('window.btoa("\\u0080\\u0081")', 'gIE=');
|
||||
|
||||
debug("Tests failed: " + fail);
|
||||
debug("Tests passed: " + pass);
|
||||
}
|
||||
</script>
|
||||
@@ -1,12 +0,0 @@
|
||||
// The following results in 'hello [MANGLED]'
|
||||
//
|
||||
// Filed as https://github.com/ry/node/issues/issue/402
|
||||
|
||||
var sys = require("sys"),
|
||||
buf = new Buffer(1024), len,
|
||||
str1 = "aGVsbG8g", // 'hello '
|
||||
str2 = "d29ybGQ=", // 'world'
|
||||
|
||||
len = buf.write(str1, 0, 'base64');
|
||||
len += buf.write(str2, len, 'base64');
|
||||
sys.log("decoded result: " + buf.toString('binary', 0, len));
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* From:
|
||||
* http://www.quirksmode.org/js/detect.html
|
||||
*/
|
||||
|
||||
var Browser = {
|
||||
init: function () {
|
||||
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
|
||||
this.version = this.searchVersion(navigator.userAgent)
|
||||
|| this.searchVersion(navigator.appVersion)
|
||||
|| "an unknown version";
|
||||
this.majorVersion = this.searchMajorVersion(navigator.userAgent)
|
||||
|| this.searchMajorVersion(navigator.appVersion)
|
||||
|| "an unknown version";
|
||||
this.fullVersion = this.searchFullVersion(navigator.userAgent)
|
||||
|| this.searchFullVersion(navigator.appVersion)
|
||||
|| "an unknown version";
|
||||
this.OS = this.searchString(this.dataOS) || "an unknown OS";
|
||||
},
|
||||
searchString: function (data) {
|
||||
for (var i=0;i<data.length;i++) {
|
||||
var dataString = data[i].string;
|
||||
var dataProp = data[i].prop;
|
||||
this.versionSearchString = data[i].versionSearch || data[i].identity;
|
||||
if (dataString) {
|
||||
if (dataString.indexOf(data[i].subString) != -1)
|
||||
return data[i].identity;
|
||||
}
|
||||
else if (dataProp)
|
||||
return data[i].identity;
|
||||
}
|
||||
},
|
||||
searchFullVersion: function (dataString) {
|
||||
var index = dataString.indexOf(this.versionSearchString);
|
||||
if (index == -1) return;
|
||||
return dataString.substring(index+this.versionSearchString.length+1);
|
||||
},
|
||||
searchVersion: function (dataString) {
|
||||
return this.searchFullVersion(dataString).split(" ")[0];
|
||||
},
|
||||
searchMajorVersion: function (dataString) {
|
||||
return parseFloat(this.searchFullVersion(dataString).split(".")[0]);
|
||||
},
|
||||
dataBrowser: [
|
||||
{
|
||||
string: navigator.userAgent,
|
||||
subString: "Chrome",
|
||||
identity: "Chrome"
|
||||
},
|
||||
{ string: navigator.userAgent,
|
||||
subString: "OmniWeb",
|
||||
versionSearch: "OmniWeb/",
|
||||
identity: "OmniWeb"
|
||||
},
|
||||
{
|
||||
string: navigator.vendor,
|
||||
subString: "Apple",
|
||||
identity: "Safari",
|
||||
versionSearch: "Version"
|
||||
},
|
||||
{
|
||||
prop: window.opera,
|
||||
identity: "Opera",
|
||||
versionSearch: "Version"
|
||||
},
|
||||
{
|
||||
string: navigator.vendor,
|
||||
subString: "iCab",
|
||||
identity: "iCab"
|
||||
},
|
||||
{
|
||||
string: navigator.vendor,
|
||||
subString: "KDE",
|
||||
identity: "Konqueror"
|
||||
},
|
||||
{
|
||||
string: navigator.userAgent,
|
||||
subString: "Firefox",
|
||||
identity: "Firefox"
|
||||
},
|
||||
{
|
||||
string: navigator.vendor,
|
||||
subString: "Camino",
|
||||
identity: "Camino"
|
||||
},
|
||||
{ // for newer Netscapes (6+)
|
||||
string: navigator.userAgent,
|
||||
subString: "Netscape",
|
||||
identity: "Netscape"
|
||||
},
|
||||
{
|
||||
string: navigator.userAgent,
|
||||
subString: "MSIE",
|
||||
identity: "Explorer",
|
||||
versionSearch: "MSIE"
|
||||
},
|
||||
{
|
||||
string: navigator.userAgent,
|
||||
subString: "Gecko",
|
||||
identity: "Mozilla",
|
||||
versionSearch: "rv"
|
||||
},
|
||||
{ // for older Netscapes (4-)
|
||||
string: navigator.userAgent,
|
||||
subString: "Mozilla",
|
||||
identity: "Netscape",
|
||||
versionSearch: "Mozilla"
|
||||
}
|
||||
],
|
||||
dataOS : [
|
||||
{
|
||||
string: navigator.platform,
|
||||
subString: "Win",
|
||||
identity: "Windows"
|
||||
},
|
||||
{
|
||||
string: navigator.platform,
|
||||
subString: "Mac",
|
||||
identity: "Mac"
|
||||
},
|
||||
{
|
||||
string: navigator.userAgent,
|
||||
subString: "iPhone",
|
||||
identity: "iPhone/iPod"
|
||||
},
|
||||
{
|
||||
string: navigator.platform,
|
||||
subString: "Linux",
|
||||
identity: "Linux"
|
||||
}
|
||||
]
|
||||
|
||||
};
|
||||
Browser.init();
|
||||
@@ -1,148 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Canvas Performance Test</title>
|
||||
<!--
|
||||
<script type='text/javascript'
|
||||
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
|
||||
-->
|
||||
<script src="../include/util.js"></script>
|
||||
<script src="../include/webutil.js"></script>
|
||||
<script src="../include/base64.js"></script>
|
||||
<script src="../include/display.js"></script>
|
||||
<script src="face.png.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
Iterations: <input id='iterations' style='width:50' value="100">
|
||||
|
||||
Width: <input id='width' style='width:50' value="640">
|
||||
Height: <input id='height' style='width:50' value="480">
|
||||
|
||||
<input id='startButton' type='button' value='Do Performance Test'
|
||||
style='width:150px' onclick="begin();">
|
||||
|
||||
<br><br>
|
||||
|
||||
<b>Canvas</b> (should see three squares and two happy faces):<br>
|
||||
<canvas id="canvas" width="200" height="100"
|
||||
style="border-style: dotted; border-width: 1px;">
|
||||
Canvas not supported.
|
||||
</canvas>
|
||||
|
||||
<br>
|
||||
Results:<br>
|
||||
<textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
var msg_cnt = 0;
|
||||
var display, start_width = 300, start_height = 100;
|
||||
var iterations;
|
||||
|
||||
function message(str) {
|
||||
console.log(str);
|
||||
cell = $D('messages');
|
||||
cell.textContent += msg_cnt + ": " + str + "\n";
|
||||
cell.scrollTop = cell.scrollHeight;
|
||||
msg_cnt += 1;
|
||||
}
|
||||
|
||||
function test_functions () {
|
||||
var img, x, y, w, h, ctx = display.get_context();
|
||||
w = display.get_width();
|
||||
h = display.get_height();
|
||||
display.fillRect(0, 0, w, h, [240,240,240]);
|
||||
|
||||
display.blitStringImage("data:image/png;base64," + face64, 150, 10);
|
||||
|
||||
var himg = new Image();
|
||||
himg.onload = function () {
|
||||
ctx.drawImage(himg, 200, 40); };
|
||||
himg.src = "face.png";
|
||||
|
||||
/* Test array image data */
|
||||
data = [];
|
||||
for (y=0; y< 50; y++) {
|
||||
for (x=0; x< 50; x++) {
|
||||
data[(y*50 + x)*4 + 0] = 255 - parseInt((255 / 50) * y, 10);
|
||||
data[(y*50 + x)*4 + 1] = parseInt((255 / 50) * y, 10);
|
||||
data[(y*50 + x)*4 + 2] = parseInt((255 / 50) * x, 10);
|
||||
data[(y*50 + x)*4 + 3] = 255;
|
||||
}
|
||||
}
|
||||
display.blitImage(30, 10, 50, 50, data, 0);
|
||||
|
||||
img = display.getTile(5,5,16,16,[0,128,128]);
|
||||
display.putTile(img);
|
||||
|
||||
img = display.getTile(90,15,16,16,[0,0,0]);
|
||||
display.setSubTile(img, 0,0,16,16,[128,128,0]);
|
||||
display.putTile(img);
|
||||
}
|
||||
|
||||
function begin () {
|
||||
$D('startButton').value = "Running";
|
||||
$D('startButton').disabled = true;
|
||||
setTimeout(start_delayed, 250);
|
||||
iterations = $D('iterations').value;
|
||||
}
|
||||
|
||||
function start_delayed () {
|
||||
var ret;
|
||||
|
||||
ret = display.set_prefer_js(true);
|
||||
if (ret) {
|
||||
message("Running test: prefer Javascript ops");
|
||||
var time1 = run_test();
|
||||
message("prefer Javascript ops: " + time1 + "ms total, " +
|
||||
(time1 / iterations) + "ms per frame");
|
||||
} else {
|
||||
message("Could not run: prefer Javascript ops");
|
||||
}
|
||||
|
||||
display.set_prefer_js(false);
|
||||
message("Running test: prefer Canvas ops");
|
||||
var time2 = run_test();
|
||||
message("prefer Canvas ops: " + time2 + "ms total, " +
|
||||
(time2 / iterations) + "ms per frame");
|
||||
|
||||
if (Util.get_logging() !== 'debug') {
|
||||
display.resize(start_width, start_height, true);
|
||||
test_functions();
|
||||
}
|
||||
$D('startButton').disabled = false;
|
||||
$D('startButton').value = "Do Performance Test";
|
||||
}
|
||||
|
||||
function run_test () {
|
||||
var width, height;
|
||||
width = $D('width').value;
|
||||
height = $D('height').value;
|
||||
display.resize(width, height);
|
||||
var color, start_time = (new Date()).getTime(), w, h;
|
||||
for (var i=0; i < iterations; i++) {
|
||||
color = [128, 128, (255 / iterations) * i, 0];
|
||||
for (var x=0; x < width; x = x + 16) {
|
||||
for (var y=0; y < height; y = y + 16) {
|
||||
w = Math.min(16, width - x);
|
||||
h = Math.min(16, height - y);
|
||||
var tile = display.getTile(x, y, w, h, color);
|
||||
display.setSubTile(tile, 0, 0, w, h, color);
|
||||
display.putTile(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
var end_time = (new Date()).getTime();
|
||||
return (end_time - start_time);
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
message("in onload");
|
||||
$D('iterations').value = 10;
|
||||
display = new Display({'target' : $D('canvas')});
|
||||
display.resize(start_width, start_height, true);
|
||||
message("Canvas initialized");
|
||||
test_functions();
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,135 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Cursor Change test</title>
|
||||
<meta charset="UTF-8">
|
||||
<!--
|
||||
<script type='text/javascript'
|
||||
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
|
||||
-->
|
||||
<script src="../include/util.js"></script>
|
||||
<script src="../include/webutil.js"></script>
|
||||
<script src="../include/base64.js"></script>
|
||||
<script src="../include/canvas.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Roll over the buttons to test cursors</h1>
|
||||
<br>
|
||||
<input id=button1 type="button" value="Cursor from file (smiley face)">
|
||||
<input id=button2 type="button" value="Data URI cursor (crosshair)">
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
Debug:<br>
|
||||
<textarea id="debug" style="font-size: 9px;" cols=80 rows=25></textarea>
|
||||
<br>
|
||||
<br>
|
||||
<canvas id="testcanvas" width="100px" height="20px">
|
||||
Canvas not supported.
|
||||
</canvas>
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
function debug(str) {
|
||||
console.log(str);
|
||||
cell = $D('debug');
|
||||
cell.textContent += str + "\n";
|
||||
cell.scrollTop = cell.scrollHeight;
|
||||
}
|
||||
|
||||
function makeCursor() {
|
||||
var arr = [], x, y, w = 32, h = 32, hx = 16, hy = 16;
|
||||
|
||||
var IHDRsz = 40;
|
||||
var ANDsz = w * h * 4;
|
||||
var XORsz = Math.ceil( (w * h) / 8.0 );
|
||||
|
||||
// Push multi-byte little-endian values
|
||||
arr.push16le = function (num) {
|
||||
this.push((num ) & 0xFF,
|
||||
(num >> 8) & 0xFF );
|
||||
};
|
||||
arr.push32le = function (num) {
|
||||
this.push((num ) & 0xFF,
|
||||
(num >> 8) & 0xFF,
|
||||
(num >> 16) & 0xFF,
|
||||
(num >> 24) & 0xFF );
|
||||
};
|
||||
|
||||
// Main header
|
||||
arr.push16le(0); // Reserved
|
||||
arr.push16le(2); // .CUR type
|
||||
arr.push16le(1); // Number of images, 1 for non-animated arr
|
||||
|
||||
// Cursor #1
|
||||
arr.push(w); // width
|
||||
arr.push(h); // height
|
||||
arr.push(0); // colors, 0 -> true-color
|
||||
arr.push(0); // reserved
|
||||
arr.push16le(hx); // hotspot x coordinate
|
||||
arr.push16le(hy); // hotspot y coordinate
|
||||
arr.push32le(IHDRsz + XORsz + ANDsz); // cursor data byte size
|
||||
arr.push32le(22); // offset of cursor data in the file
|
||||
|
||||
// Infoheader for Cursor #1
|
||||
arr.push32le(IHDRsz); // Infoheader size
|
||||
arr.push32le(w); // Cursor width
|
||||
arr.push32le(h*2); // XOR+AND height
|
||||
arr.push16le(1); // number of planes
|
||||
arr.push16le(32); // bits per pixel
|
||||
arr.push32le(0); // type of compression
|
||||
arr.push32le(XORsz + ANDsz); // Size of Image
|
||||
arr.push32le(0);
|
||||
arr.push32le(0);
|
||||
arr.push32le(0);
|
||||
arr.push32le(0);
|
||||
|
||||
// XOR/color data
|
||||
for (y = h-1; y >= 0; y--) {
|
||||
for (x = 0; x < w; x++) {
|
||||
//if ((x === hx) || (y === (h-hy-1))) {
|
||||
if ((x === hx) || (y === hy)) {
|
||||
arr.push(0xe0); // blue
|
||||
arr.push(0x00); // green
|
||||
arr.push(0x00); // red
|
||||
arr.push(0xff); // alpha
|
||||
} else {
|
||||
arr.push(0x05); // blue
|
||||
arr.push(0xe6); // green
|
||||
arr.push(0x00); // red
|
||||
arr.push(0x80); // alpha
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AND/bitmask data (seems to be ignored)
|
||||
for (y = 0; y < h; y++) {
|
||||
for (x = 0; x < Math.ceil(w / 8); x++) {
|
||||
arr.push(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
debug("cursor generated");
|
||||
return arr;
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
debug("onload");
|
||||
var canvas, cross, cursor, cursor64;
|
||||
|
||||
canvas = new Canvas({'target' : $D("testcanvas")});
|
||||
debug("canvas indicates Data URI cursor support is: " + canvas.get_cursor_uri());
|
||||
|
||||
$D('button1').style.cursor="url(face.png), default";
|
||||
|
||||
cursor = makeCursor();
|
||||
cursor64 = Base64.encode(cursor);
|
||||
//debug("cursor: " + cursor.slice(0,100) + " (" + cursor.length + ")");
|
||||
//debug("cursor64: " + cursor64.slice(0,100) + " (" + cursor64.length + ")");
|
||||
$D('button2').style.cursor="url(data:image/x-icon;base64," + cursor64 + "), default";
|
||||
|
||||
debug("onload complete");
|
||||
}
|
||||
</script>
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1 +0,0 @@
|
||||
var face64 = 'iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAIAAACRuyQOAAAAA3NCSVQICAjb4U/gAAAAGXRFWHRTb2Z0d2FyZQBnbm9tZS1zY3JlZW5zaG907wO/PgAACJJJREFUSIm1lltsXMUdxr8558zZq9d3OxebJDYhJLhNIAmUWyFKIBUtVaGqSgtUlIJKeahoEahgIZU+VC0oQiVVC60obckDgVIp3KRCQkmhhIhA4oY4wjg2ufmS9drec/bc5vbvw9prJwq85dP/YWfP7Pfb/8w3s8v6339l2fkrbMvGuZQ2mkUTA0bpc4qpyjrX3dTkAATQ5z0WUrqcAwjL/eXirmBqj0yKSTTBwNxMM0+15JuurG/dlClcOH/yWcVEaVBKUR3Eidizr2946Nhr/9q5b//BsudZzDLG5DK4sDt3443XrFm34bkX9x4ZPimkWNBa/+MfrB84+O7rbxz4+JPQD8liljY6n8t9uWfld2/++vp1F3ct6cikU2eSnvr7P7e99OqC9vaTJ0ccMtl8loyJ4igKwzAIK0GglersWv7sM08VCrk4joY/O/rLXz3mTYzmcnnXdZXWcRzHURwEQRCEHUuXdS/vnp4qP/CT2zdvuAKAQwCB4kRse+m1LY//Wojkscd/57opKUQUJ8wyzFaOq7OGGGPcdZ/f/sKbu3YT0YZrr3JT7pq1l3qeH4SBqgRETBljDKXSqXyh/i9PP/W/Q31btz59zVXrUpxb1dYsixUK+c7Fi59/YUdz2yInnbXcLHfTtpu23ZRlu4ZZiRBTp8Z37HjlhW1/evnFZ9/a+VZdLsecFOMpx83ydJanc24q67iuFOr48NC1G6+fKBY7zutIElFNBAC4nN99602XXLzutjvvETqAlcqktVQin0QiLsRxEAUBaRVUfBh1QfcigmzIuw0NTe2LOjNlL07iOArDwA88z0unGWNTk5P1dfkf3XH3BT2r9b23zZKIAHxr81f/uGpF/8G+Fau+VPbKp8ZHpqdKSRiEYWiMMVopJSuVyl+f3UpIQKL34btvvf2BxuZWN5Umo7TWFiNDDHCampob6utLpRKz7Hvv+E5jfR5ELCkNShFXOytOTH7vjrsOfXJ0wcLFF63sXr1mfXtbS6FQB4BZyGYzX7l0TWtrvWVpUGxUMFEa2bv3Q9+bNCaECX2/NFEc3bd/4r19/tR0uLC98c+/3/LVy9fWzhNq56m1pfEPvabnut2OI8EvBMAYAxhgAWz3u3tuvuWeRx/56aYNa0Hy3fc/euiRZx596IZvbF5Dpgw9CdMI0waqaMrEScPgvtdWXH5JzdzC7NElIPQH3GyTk+4ABCgCEpAkMgRGcLb/49WGxqYtTzwNaJDa/tJ7DU1tW558GaYCEwESYGAWwEidTOcWM8tElcGauTP/ivDGd7V3fxv6JGCBIpBDjIMxgIM5B/YfjMJwfGwEMIA40DcQhcn46DGAzX7p6gIwBhj5WUvH8vLYG+nu8+d6qimY2lPXup70GFEEE9baAhRIj5w8cfz4MSESkJw3FLOfnrvSCETqs3xTd2Vyd+1Na/4MmRRt3gBTgfGJKkQhTAQTwgQgv2tpR8X3Vq5YCiiC7lrSXPG9lRe0AmZ2hQxo5jXpspNqEElxPmlOIi5ZThYUgBKYKRgPxgMFMAGM/+D9P2xuLPQ+dBcoAYkHf/bN5sZM74M3gHS1acBUi0gZ4zk8J5NyzdzBGSIJkoANCqsrwgBAg+zN1605Mfw6IIkiUHL9xouODzwBE4ACkKrGBNBkBEgSKSIz39gxRkuRVAduulHLCZtZoARkzybTAFU2m7GjBBSDkmoRJYCc3U5lSBgjAFeJae4Wauan9WSnWlU0aqdtUAXElAicVDNIgfHZaJkZU0pAESgmCJAACUCApJIBKCITg+VVMuWm2+btEwFE1coVLvOKe2HVE8UwUd/OXi0nQZXZ8kH+7HIFoIgoqvKqzWkV9L2zy5jQ6Ig5nX5pOFd/Vc3cmv9zW9eyYfzITmY1giKiMJNtCiYPw1RgPBh/psiHqcAEZAJQBFMlxaDEnyqmc3mjY2NCiy+bHB3Kt2w8I+UzxTPLlAzjygCz6kFBx6qNg/ue84p9M7AZRoWoQhSAqumfacsrnRg6uH9Rd4/RFWafl1RGjLJ5ZknNnIXjh+PQB0BEQkqv9L4sb1t59cMU74GVKxcnhg5sdzN1jQtX5grtqVyj46ZtywIJrUOZeCKYCLxTU+PHkzhZ2vO1XH5MRIfcwvcHP9qRafp5XfN6l3PGGIA5ktJaJEJINXnkvmWrNza0rSBxEFYbnE6veGRq9IPQO54Ep5QItRYAs22Hu1k315QtdDYsuCzf1KHDt0XlbTu3ySuVRo6MNnc/6XLHTbmObc+QotAHIJUSQiSJTKLR4Nh9Pdc+kM44JA+D5RhfBud8ZjeD5WHVMVYHqwAYmGkyUyRPqPDfMnhTxcNW+jKpGj/94NX8eVtTmYWpFHddlzsOABaOzZGkkImQUsrI/1iVfrPq6vszuSyJD0EasGEVmN0KlgXLgYGMT6qkkwEthrQuG53Y2U0icT79YIfb2pup6+Gcp1zOXV4j9VdJxhghpJBSSCmEjL0+XXqsa+0tTYvWQ/aTHJrZW9JEkowwJjYmMjo0OmR8uZ1eNz12+Nih/zgtv0gXVrsur1Jcl1uWNUsK/GoQldZSSCGllEpIGYcndOm36Vyqa/VNmboFRh4ldZR02ZhpMhJwCGnmLGZ8SewXj/bvTkLDW3pT2UUu55w7Lufc5dVNAsCCsf4o8Gqpr8KkUlIqpZRUKim/Y/y/pVLZ1s5V+Zbl3C3Ybp5Iq2RKxhP+xFBxZFAmwi7cmaq/kjuO4zicO9xx5mPOQqrGvYZRWmulldYqGlLBf3X8EfQkSR8A43WMN1nuWid3hZPpcmzbdmzHtmuwarjnkw5FldNIczyljDZKa62NNpoM1QSA1WQx27Jt23Js27It7pzJmLthz/7/nzHOOThcImPoNBIIAMNpJMtiNcBZDZ3PfVIjgtkWsy3riyZ9AaFGMlozhuqCnDsxxv4PC7uS+QV5eeoAAAAASUVORK5CYII=';
|
||||
@@ -1,132 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head><title>Input Test</title></head>
|
||||
<body>
|
||||
<br><br>
|
||||
|
||||
Canvas:
|
||||
<span id="button-selection" style="display: none;">
|
||||
<input id="button1" type="button" value="L"><input id="button2" type="button" value="M"><input id="button4" type="button" value="R">
|
||||
</span>
|
||||
<br>
|
||||
<canvas id="canvas" width="640" height="20"
|
||||
style="border-style: dotted; border-width: 1px;">
|
||||
Canvas not supported.
|
||||
</canvas>
|
||||
|
||||
<br>
|
||||
Results:<br>
|
||||
<textarea id="messages" style="font-size: 9;" cols=80 rows=25></textarea>
|
||||
</body>
|
||||
|
||||
<!--
|
||||
<script type='text/javascript'
|
||||
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
|
||||
-->
|
||||
<script src="../include/util.js"></script>
|
||||
<script src="../include/webutil.js"></script>
|
||||
<script src="../include/base64.js"></script>
|
||||
<script src="../include/keysym.js"></script>
|
||||
<script src="../include/keysymdef.js"></script>
|
||||
<script src="../include/keyboard.js"></script>
|
||||
<script src="../include/input.js"></script>
|
||||
<script src="../include/display.js"></script>
|
||||
<script>
|
||||
var msg_cnt = 0, iterations,
|
||||
width = 400, height = 200,
|
||||
canvas, keyboard, mouse;
|
||||
|
||||
var newline = "\n";
|
||||
if (Util.Engine.trident) {
|
||||
var newline = "<br>\n";
|
||||
}
|
||||
|
||||
function message(str) {
|
||||
console.log(str);
|
||||
cell = $D('messages');
|
||||
cell.textContent += msg_cnt + ": " + str + newline;
|
||||
cell.scrollTop = cell.scrollHeight;
|
||||
msg_cnt++;
|
||||
}
|
||||
|
||||
function mouseButton(x, y, down, bmask) {
|
||||
msg = 'mouse x,y: ' + x + ',' + y + ' down: ' + down;
|
||||
msg += ' bmask: ' + bmask;
|
||||
message(msg);
|
||||
}
|
||||
|
||||
function mouseMove(x, y) {
|
||||
msg = 'mouse x,y: ' + x + ',' + y;
|
||||
//console.log(msg);
|
||||
}
|
||||
|
||||
function rfbKeyPress(keysym, down) {
|
||||
var d = down ? "down" : " up ";
|
||||
var key = keysyms.lookup(keysym);
|
||||
var msg = "RFB keypress " + d + " keysym: " + keysym;
|
||||
if (key && key.keyname) {
|
||||
msg += " key name: " + key.keyname;
|
||||
}
|
||||
message(msg);
|
||||
}
|
||||
function rawKey(e) {
|
||||
msg = "raw key event " + e.type +
|
||||
" (key: " + e.keyCode + ", char: " + e.charCode +
|
||||
", which: " + e.which +")";
|
||||
message(msg);
|
||||
}
|
||||
|
||||
function selectButton(num) {
|
||||
var b, blist = [1,2,4];
|
||||
|
||||
if (typeof num === 'undefined') {
|
||||
// Show the default
|
||||
num = mouse.get_touchButton();
|
||||
} else if (num === mouse.get_touchButton()) {
|
||||
// Set all buttons off (no clicks)
|
||||
mouse.set_touchButton(0);
|
||||
num = 0;
|
||||
} else {
|
||||
// Turn on one button
|
||||
mouse.set_touchButton(num);
|
||||
}
|
||||
|
||||
for (b = 0; b < blist.length; b++) {
|
||||
if (blist[b] === num) {
|
||||
$D('button' + blist[b]).style.backgroundColor = "black";
|
||||
$D('button' + blist[b]).style.color = "lightgray";
|
||||
} else {
|
||||
$D('button' + blist[b]).style.backgroundColor = "";
|
||||
$D('button' + blist[b]).style.color = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
canvas = new Display({'target' : $D('canvas')});
|
||||
keyboard = new Keyboard({'target': document,
|
||||
'onKeyPress': rfbKeyPress});
|
||||
Util.addEvent(document, 'keypress', rawKey);
|
||||
Util.addEvent(document, 'keydown', rawKey);
|
||||
Util.addEvent(document, 'keyup', rawKey);
|
||||
mouse = new Mouse({'target': $D('canvas'),
|
||||
'onMouseButton': mouseButton,
|
||||
'onMouseMove': mouseMove});
|
||||
|
||||
canvas.resize(width, height, true);
|
||||
keyboard.grab();
|
||||
mouse.grab();
|
||||
message("Display initialized");
|
||||
|
||||
if ('ontouchstart' in document.documentElement) {
|
||||
message("Touch device detected");
|
||||
$D('button-selection').style.display = "inline";
|
||||
$D('button1').onclick = function(){ selectButton(1) };
|
||||
$D('button2').onclick = function(){ selectButton(2) };
|
||||
$D('button4').onclick = function(){ selectButton(4) };
|
||||
selectButton();
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
</html>
|
||||
@@ -1,29 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mocha Tests</title>
|
||||
<link rel="stylesheet" href="node_modules/mocha/mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<!--
|
||||
To run tests
|
||||
cd .../noVNC/tests
|
||||
npm install chai mocha
|
||||
open keyboard-tests.html in a browser
|
||||
-->
|
||||
<div id="mocha"></div>
|
||||
<script src="node_modules/chai/chai.js"></script>
|
||||
<script src="node_modules/mocha/mocha.js"></script>
|
||||
<script>mocha.setup('bdd')</script>
|
||||
<script src="../include/keysymdef.js"></script>
|
||||
<script src="../include/keyboard.js"></script>
|
||||
<script src="test.keyboard.js"></script>
|
||||
<script src="test.helper.js"></script>
|
||||
<script>
|
||||
mocha.checkLeaks();
|
||||
mocha.globals(['navigator']);
|
||||
mocha.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,114 +0,0 @@
|
||||
var Spooky = require('spooky');
|
||||
var path = require('path');
|
||||
|
||||
var phantom_path = require('phantomjs').path;
|
||||
var casper_path = path.resolve(__dirname, '../node_modules/casperjs/bin/casperjs');
|
||||
process.env.PHANTOMJS_EXECUTABLE = phantom_path;
|
||||
var casper_opts = {
|
||||
child: {
|
||||
transport: 'http',
|
||||
command: casper_path
|
||||
},
|
||||
casper: {
|
||||
logLevel: 'debug',
|
||||
verbose: true
|
||||
}
|
||||
};
|
||||
|
||||
var provide_emitter = function(file_paths, debug_port) {
|
||||
if (debug_port) {
|
||||
casper_opts.child['remote-debugger-port'] = debug_port;
|
||||
var debug_url = ('https://localhost:' + debug_port +
|
||||
'/webkit/inspector/inspector.html?page=');
|
||||
console.info('[remote-debugger] Navigate to ' + debug_url + '1 and ' +
|
||||
'run `__run();` in the console to continue loading.' +
|
||||
'\n[remote-debugger] Navigate to ' + debug_url + '2 to ' +
|
||||
'view the actual page source.\n' +
|
||||
'[remote-debugger] Use the `debugger;` statement to ' +
|
||||
'trigger an initial breakpoint.');
|
||||
}
|
||||
|
||||
var spooky = new Spooky(casper_opts, function(err) {
|
||||
if (err) {
|
||||
if (err.stack) console.warn(err.stack);
|
||||
else console.warn(err);
|
||||
return;
|
||||
}
|
||||
spooky.start('about:blank');
|
||||
|
||||
file_paths.forEach(function(file_path, path_ind) {
|
||||
spooky.thenOpen('file://'+file_path);
|
||||
spooky.waitFor(function() {
|
||||
return this.getGlobal('__mocha_done') === true;
|
||||
},
|
||||
[{ path_ind: path_ind }, function() {
|
||||
var res_json = {
|
||||
file_ind: path_ind
|
||||
};
|
||||
|
||||
res_json.num_tests = this.evaluate(function() { return document.querySelectorAll('li.test').length; });
|
||||
res_json.num_passes = this.evaluate(function() { return document.querySelectorAll('li.test.pass').length; });
|
||||
res_json.num_fails = this.evaluate(function() { return document.querySelectorAll('li.test.fail').length; });
|
||||
res_json.num_slow = this.evaluate(function() { return document.querySelectorAll('li.test.pass:not(.fast):not(.pending)').length; });
|
||||
res_json.num_skipped = this.evaluate(function () { return document.querySelectorAll('li.test.pending').length; });
|
||||
res_json.duration = this.evaluate(function() { return document.querySelector('li.duration em').textContent; });
|
||||
|
||||
res_json.suites = this.evaluate(function() {
|
||||
var traverse_node = function(elem) {
|
||||
var res;
|
||||
if (elem.classList.contains('suite')) {
|
||||
res = {
|
||||
type: 'suite',
|
||||
name: elem.querySelector('h1').textContent,
|
||||
has_subfailures: elem.querySelectorAll('li.test.fail').length > 0,
|
||||
};
|
||||
|
||||
var child_elems = elem.querySelector('ul').children;
|
||||
res.children = Array.prototype.map.call(child_elems, traverse_node);
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
var h2_content = elem.querySelector('h2').childNodes;
|
||||
res = {
|
||||
type: 'test',
|
||||
text: h2_content[0].textContent,
|
||||
};
|
||||
|
||||
if (elem.classList.contains('pass')) {
|
||||
res.pass = true;
|
||||
if (elem.classList.contains('pending')) {
|
||||
res.slow = false;
|
||||
res.skipped = true;
|
||||
}
|
||||
else {
|
||||
res.slow = !elem.classList.contains('fast');
|
||||
res.skipped = false;
|
||||
res.duration = h2_content[1].textContent;
|
||||
}
|
||||
}
|
||||
else {
|
||||
res.error = elem.querySelector('pre.error').textContent;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
var top_suites = document.querySelectorAll('#mocha-report > li.suite');
|
||||
return Array.prototype.map.call(top_suites, traverse_node);
|
||||
});
|
||||
|
||||
res_json.replay = this.evaluate(function() { return document.querySelector('a.replay').textContent; });
|
||||
|
||||
this.emit('test_ready', res_json);
|
||||
}]);
|
||||
});
|
||||
spooky.run();
|
||||
});
|
||||
|
||||
return spooky;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
provide_emitter: provide_emitter,
|
||||
name: 'SpookyJS (CapserJS on PhantomJS)'
|
||||
};
|
||||
@@ -1,361 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
var ansi = require('ansi');
|
||||
var program = require('commander');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
var make_list = function(val) {
|
||||
return val.split(',');
|
||||
};
|
||||
|
||||
program
|
||||
.option('-t, --tests <testlist>', 'Run the specified html-file-based test(s). \'testlist\' should be a comma-separated list', make_list, [])
|
||||
.option('-a, --print-all', 'Print all tests, not just the failures')
|
||||
.option('--disable-color', 'Explicitly disable color')
|
||||
.option('-c, --color', 'Explicitly enable color (default is to use color when not outputting to a pipe)')
|
||||
.option('-i, --auto-inject <includefiles>', 'Treat the test list as a set of mocha JS files, and automatically generate HTML files with which to test test. \'includefiles\' should be a comma-separated list of paths to javascript files to include in each of the generated HTML files', make_list, null)
|
||||
.option('-p, --provider <name>', 'Use the given provider (defaults to "casper"). Currently, may be "casper" or "zombie"', 'casper')
|
||||
.option('-g, --generate-html', 'Instead of running the tests, just return the path to the generated HTML file, then wait for user interaction to exit (should be used with .js tests).')
|
||||
.option('-o, --open-in-browser', 'Open the generated HTML files in a web browser using the "open" module (must be used with the "-g"/"--generate-html" option).')
|
||||
.option('--output-html', 'Instead of running the tests, just output the generated HTML source to STDOUT (should be used with .js tests)')
|
||||
.option('-d, --debug', 'Show debug output (the "console" event) from the provider')
|
||||
.option('-r, --relative', 'Use relative paths in the generated HTML file')
|
||||
.option('--debugger <port>', 'Enable the remote debugger for CasperJS')
|
||||
.parse(process.argv);
|
||||
|
||||
if (program.tests.length === 0) {
|
||||
program.tests = fs.readdirSync(__dirname).filter(function(f) { return (/^test\.(\w|\.|-)+\.js$/).test(f); });
|
||||
program.tests = program.tests.map(function (f) { return path.resolve(__dirname, f); }); // add full paths in
|
||||
console.log('using files %s', program.tests);
|
||||
}
|
||||
|
||||
var file_paths = [];
|
||||
|
||||
var all_js = program.tests.reduce(function(a,e) { return a && e.slice(-3) == '.js'; }, true);
|
||||
|
||||
var get_path = function (/* arguments */) {
|
||||
if (program.relative) {
|
||||
return path.join.apply(null, arguments);
|
||||
} else {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift(__dirname, '..');
|
||||
return path.resolve.apply(null, args);
|
||||
}
|
||||
};
|
||||
|
||||
var get_path_cwd = function (/* arguments */) {
|
||||
if (program.relative) {
|
||||
var part_path = path.join.apply(null, arguments);
|
||||
return path.relative(path.join(__dirname, '..'), path.resolve(process.cwd(), part_path));
|
||||
} else {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args.unshift(process.cwd());
|
||||
return path.resolve.apply(null, args);
|
||||
}
|
||||
};
|
||||
|
||||
if (all_js && !program.autoInject) {
|
||||
var all_modules = {};
|
||||
|
||||
// uses the first instance of the string 'requires local modules: '
|
||||
program.tests.forEach(function (testname) {
|
||||
var full_path = path.resolve(process.cwd(), testname);
|
||||
var content = fs.readFileSync(full_path).toString();
|
||||
var ind = content.indexOf('requires local modules: ');
|
||||
if (ind > -1) {
|
||||
ind += 'requires local modules: '.length;
|
||||
var eol = content.indexOf('\n', ind);
|
||||
var modules = content.slice(ind, eol).split(/,\s*/);
|
||||
modules.forEach(function (mod) {
|
||||
all_modules[get_path('include/', mod) + '.js'] = 1;
|
||||
});
|
||||
}
|
||||
|
||||
var fakes_ind = content.indexOf('requires test modules: ');
|
||||
if (fakes_ind > -1) {
|
||||
fakes_ind += 'requires test modules: '.length;
|
||||
var fakes_eol = content.indexOf('\n', fakes_ind);
|
||||
var fakes_modules = content.slice(fakes_ind, fakes_eol).split(/,\s*/);
|
||||
fakes_modules.forEach(function (mod) {
|
||||
all_modules[get_path('tests/', mod) + '.js'] = 1;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
program.autoInject = Object.keys(all_modules);
|
||||
}
|
||||
|
||||
if (program.autoInject) {
|
||||
var temp = require('temp');
|
||||
temp.track();
|
||||
|
||||
var template = {
|
||||
header: "<html>\n<head>\n<meta charset='utf-8' />\n<link rel='stylesheet' href='" + get_path('node_modules/mocha/mocha.css') + "'/>\n</head>\n<body><div id='mocha'></div>",
|
||||
script_tag: function(p) { return "<script src='" + p + "'></script>"; },
|
||||
footer: "<script>\nmocha.checkLeaks();\nmocha.globals(['navigator', 'create', 'ClientUtils', '__utils__']);\nmocha.run(function () { window.__mocha_done = true; });\n</script>\n</body>\n</html>"
|
||||
};
|
||||
|
||||
template.header += "\n" + template.script_tag(get_path('node_modules/chai/chai.js'));
|
||||
template.header += "\n" + template.script_tag(get_path('node_modules/mocha/mocha.js'));
|
||||
template.header += "\n" + template.script_tag(get_path('node_modules/sinon/pkg/sinon.js'));
|
||||
template.header += "\n" + template.script_tag(get_path('node_modules/sinon-chai/lib/sinon-chai.js'));
|
||||
template.header += "\n" + template.script_tag(get_path('node_modules/sinon-chai/lib/sinon-chai.js'));
|
||||
template.header += "\n<script>mocha.setup('bdd');</script>";
|
||||
|
||||
|
||||
template.header = program.autoInject.reduce(function(acc, sn) {
|
||||
return acc + "\n" + template.script_tag(get_path_cwd(sn));
|
||||
}, template.header);
|
||||
|
||||
file_paths = program.tests.map(function(jsn, ind) {
|
||||
var templ = template.header;
|
||||
templ += "\n";
|
||||
templ += template.script_tag(get_path_cwd(jsn));
|
||||
templ += template.footer;
|
||||
|
||||
var tempfile = temp.openSync({ prefix: 'novnc-zombie-inject-', suffix: '-file_num-'+ind+'.html' });
|
||||
fs.writeSync(tempfile.fd, templ);
|
||||
fs.closeSync(tempfile.fd);
|
||||
return tempfile.path;
|
||||
});
|
||||
|
||||
}
|
||||
else {
|
||||
file_paths = program.tests.map(function(fn) {
|
||||
return path.resolve(process.cwd(), fn);
|
||||
});
|
||||
}
|
||||
|
||||
var use_ansi = false;
|
||||
if (program.color) use_ansi = true;
|
||||
else if (program.disableColor) use_ansi = false;
|
||||
else if (process.stdout.isTTY) use_ansi = true;
|
||||
|
||||
var cursor = ansi(process.stdout, { enabled: use_ansi });
|
||||
|
||||
if (program.outputHtml) {
|
||||
file_paths.forEach(function(path, path_ind) {
|
||||
fs.readFile(path, function(err, data) {
|
||||
if (err) {
|
||||
console.warn(error.stack);
|
||||
return;
|
||||
}
|
||||
|
||||
if (use_ansi) {
|
||||
cursor
|
||||
.bold()
|
||||
.write(program.tests[path_ind])
|
||||
.reset()
|
||||
.write("\n")
|
||||
.write(Array(program.tests[path_ind].length+1).join('='))
|
||||
.write("\n\n");
|
||||
}
|
||||
|
||||
cursor
|
||||
.write(data)
|
||||
.write("\n\n");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (program.generateHtml) {
|
||||
var open_browser;
|
||||
if (program.openInBrowser) {
|
||||
open_browser = require('open');
|
||||
}
|
||||
|
||||
file_paths.forEach(function(path, path_ind) {
|
||||
cursor
|
||||
.bold()
|
||||
.write(program.tests[path_ind])
|
||||
.write(": ")
|
||||
.reset()
|
||||
.write(path)
|
||||
.write("\n");
|
||||
|
||||
if (program.openInBrowser) {
|
||||
open_browser(path);
|
||||
}
|
||||
});
|
||||
console.log('');
|
||||
}
|
||||
|
||||
if (program.generateHtml) {
|
||||
process.stdin.resume(); // pause until C-c
|
||||
process.on('SIGINT', function() {
|
||||
process.stdin.pause(); // exit
|
||||
});
|
||||
}
|
||||
|
||||
if (!program.outputHtml && !program.generateHtml) {
|
||||
var failure_count = 0;
|
||||
|
||||
var prov = require(path.resolve(__dirname, 'run_from_console.'+program.provider+'.js'));
|
||||
|
||||
cursor
|
||||
.write("Running tests ")
|
||||
.bold()
|
||||
.write(program.tests.join(', '))
|
||||
.reset()
|
||||
.grey()
|
||||
.write(' using provider '+prov.name)
|
||||
.reset()
|
||||
.write("\n");
|
||||
//console.log("Running tests %s using provider %s", program.tests.join(', '), prov.name);
|
||||
|
||||
var provider = prov.provide_emitter(file_paths, program.debugger);
|
||||
provider.on('test_ready', function(test_json) {
|
||||
console.log('');
|
||||
|
||||
filename = program.tests[test_json.file_ind];
|
||||
|
||||
cursor.bold();
|
||||
console.log('Results for %s:', filename);
|
||||
console.log(Array('Results for :'.length+filename.length+1).join('='));
|
||||
cursor.reset();
|
||||
|
||||
console.log('');
|
||||
|
||||
cursor
|
||||
.write(''+test_json.num_tests+' tests run, ')
|
||||
.green()
|
||||
.write(''+test_json.num_passes+' passed');
|
||||
if (test_json.num_slow > 0) {
|
||||
cursor
|
||||
.reset()
|
||||
.write(' (');
|
||||
cursor
|
||||
.yellow()
|
||||
.write(''+test_json.num_slow+' slow')
|
||||
.reset()
|
||||
.write(')');
|
||||
}
|
||||
cursor
|
||||
.reset()
|
||||
.write(', ');
|
||||
cursor
|
||||
.red()
|
||||
.write(''+test_json.num_fails+' failed');
|
||||
if (test_json.num_skipped > 0) {
|
||||
cursor
|
||||
.reset()
|
||||
.write(', ')
|
||||
.grey()
|
||||
.write(''+test_json.num_skipped+' skipped');
|
||||
}
|
||||
cursor
|
||||
.reset()
|
||||
.write(' -- duration: '+test_json.duration+"s\n");
|
||||
|
||||
console.log('');
|
||||
|
||||
if (test_json.num_fails > 0 || program.printAll) {
|
||||
var extract_error_lines = function (err) {
|
||||
// the split is to avoid a weird thing where in PhantomJS where we get a stack trace too
|
||||
var err_lines = err.split('\n');
|
||||
if (err_lines.length == 1) {
|
||||
return err_lines[0];
|
||||
} else {
|
||||
var ind;
|
||||
for (ind = 0; ind < err_lines.length; ind++) {
|
||||
var at_ind = err_lines[ind].trim().indexOf('at ');
|
||||
if (at_ind === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return err_lines.slice(0, ind).join('\n');
|
||||
}
|
||||
};
|
||||
|
||||
var traverse_tree = function(indentation, node) {
|
||||
if (node.type == 'suite') {
|
||||
if (!node.has_subfailures && !program.printAll) return;
|
||||
|
||||
if (indentation === 0) {
|
||||
cursor.bold();
|
||||
console.log(node.name);
|
||||
console.log(Array(node.name.length+1).join('-'));
|
||||
cursor.reset();
|
||||
}
|
||||
else {
|
||||
cursor
|
||||
.write(Array(indentation+3).join('#'))
|
||||
.bold()
|
||||
.write(' '+node.name+' ')
|
||||
.reset()
|
||||
.write(Array(indentation+3).join('#'))
|
||||
.write("\n");
|
||||
}
|
||||
|
||||
console.log('');
|
||||
|
||||
for (var i = 0; i < node.children.length; i++) {
|
||||
traverse_tree(indentation+1, node.children[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!node.pass) {
|
||||
cursor.magenta();
|
||||
console.log('- failed: '+node.text+test_json.replay);
|
||||
cursor.red();
|
||||
console.log(' '+extract_error_lines(node.error));
|
||||
cursor.reset();
|
||||
console.log('');
|
||||
}
|
||||
else if (program.printAll) {
|
||||
if (node.skipped) {
|
||||
cursor
|
||||
.grey()
|
||||
.write('- skipped: '+node.text);
|
||||
}
|
||||
else {
|
||||
if (node.slow) cursor.yellow();
|
||||
else cursor.green();
|
||||
|
||||
cursor
|
||||
.write('- pass: '+node.text)
|
||||
.grey()
|
||||
.write(' ('+node.duration+') ');
|
||||
}
|
||||
/*if (node.slow) cursor.yellow();
|
||||
else cursor.green();*/
|
||||
cursor
|
||||
//.write(test_json.replay)
|
||||
.reset()
|
||||
.write("\n");
|
||||
console.log('');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (var i = 0; i < test_json.suites.length; i++) {
|
||||
traverse_tree(0, test_json.suites[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (test_json.num_fails === 0) {
|
||||
cursor.fg.green();
|
||||
console.log('all tests passed :-)');
|
||||
cursor.reset();
|
||||
}
|
||||
});
|
||||
|
||||
if (program.debug) {
|
||||
provider.on('console', function(line) {
|
||||
// log to stderr
|
||||
console.error(line);
|
||||
});
|
||||
}
|
||||
|
||||
provider.on('error', function(line) {
|
||||
// log to stderr
|
||||
console.error('ERROR: ' + line);
|
||||
});
|
||||
|
||||
/*gprom.finally(function(ph) {
|
||||
ph.exit();
|
||||
// exit with a status code that actually gives information
|
||||
if (program.exitWithFailureCount) process.exit(failure_count);
|
||||
});*/
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
var Browser = require('zombie');
|
||||
var path = require('path');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var Q = require('q');
|
||||
|
||||
var provide_emitter = function(file_paths) {
|
||||
var emitter = new EventEmitter();
|
||||
|
||||
file_paths.reduce(function(prom, file_path, path_ind) {
|
||||
return prom.then(function(browser) {
|
||||
browser.visit('file://'+file_path, function() {
|
||||
if (browser.error) throw new Error(browser.errors);
|
||||
|
||||
var res_json = {};
|
||||
res_json.file_ind = path_ind;
|
||||
|
||||
res_json.num_tests = browser.querySelectorAll('li.test').length;
|
||||
res_json.num_fails = browser.querySelectorAll('li.test.fail').length;
|
||||
res_json.num_passes = browser.querySelectorAll('li.test.pass').length;
|
||||
res_json.num_slow = browser.querySelectorAll('li.test.pass:not(.fast)').length;
|
||||
res_json.num_skipped = browser.querySelectorAll('li.test.pending').length;
|
||||
res_json.duration = browser.text('li.duration em');
|
||||
|
||||
var traverse_node = function(elem) {
|
||||
var classList = elem.className.split(' ');
|
||||
var res;
|
||||
if (classList.indexOf('suite') > -1) {
|
||||
res = {
|
||||
type: 'suite',
|
||||
name: elem.querySelector('h1').textContent,
|
||||
has_subfailures: elem.querySelectorAll('li.test.fail').length > 0
|
||||
};
|
||||
|
||||
var child_elems = elem.querySelector('ul').children;
|
||||
res.children = Array.prototype.map.call(child_elems, traverse_node);
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
var h2_content = elem.querySelector('h2').childNodes;
|
||||
res = {
|
||||
type: 'test',
|
||||
text: h2_content[0].textContent
|
||||
};
|
||||
|
||||
if (classList.indexOf('pass') > -1) {
|
||||
res.pass = true;
|
||||
if (classList.indexOf('pending') > -1) {
|
||||
res.slow = false;
|
||||
res.skipped = true;
|
||||
}
|
||||
else {
|
||||
res.slow = classList.indexOf('fast') < 0;
|
||||
res.skipped = false;
|
||||
res.duration = h2_content[1].textContent;
|
||||
}
|
||||
}
|
||||
else {
|
||||
res.error = elem.querySelector('pre.error').textContent;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
var top_suites = browser.querySelectorAll('#mocha-report > li.suite');
|
||||
res_json.suites = Array.prototype.map.call(top_suites, traverse_node);
|
||||
res_json.replay = browser.querySelector('a.replay').textContent;
|
||||
|
||||
emitter.emit('test_ready', res_json);
|
||||
});
|
||||
|
||||
return new Browser();
|
||||
});
|
||||
}, Q(new Browser()));
|
||||
|
||||
return emitter;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
provide_emitter: provide_emitter,
|
||||
name: 'ZombieJS'
|
||||
};
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Define some useful statistical functions on arrays of numbers
|
||||
*/
|
||||
|
||||
Array.prototype.sum = function() {
|
||||
var i, sum = 0;
|
||||
for (i = 0; i < this.length; i++) {
|
||||
sum += this[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
Array.prototype.max = function() {
|
||||
return Math.max.apply(null, this);
|
||||
}
|
||||
|
||||
Array.prototype.min = function() {
|
||||
return Math.min.apply(null, this);
|
||||
}
|
||||
|
||||
Array.prototype.mean = function() {
|
||||
return this.sum() / this.length;
|
||||
}
|
||||
Array.prototype.average = Array.prototype.mean;
|
||||
|
||||
Array.prototype.median = function() {
|
||||
var sorted = this.sort( function(a,b) { return a-b; }),
|
||||
len = sorted.length;
|
||||
if (len % 2) {
|
||||
return sorted[Math.floor(len / 2)]; // Odd
|
||||
} else {
|
||||
return (sorted[len/2 - 1] + sorted[len/2]) / 2; // Even
|
||||
}
|
||||
}
|
||||
|
||||
Array.prototype.stdDev = function(sample) {
|
||||
var i, sumSqr = 0, mean = this.mean(), N;
|
||||
|
||||
if (sample) {
|
||||
// Population correction if this is a sample
|
||||
N = this.length - 1;
|
||||
} else {
|
||||
// Standard deviation of just the array
|
||||
N = this.length;
|
||||
}
|
||||
|
||||
for (i = 0; i < this.length; i++) {
|
||||
sumSqr += Math.pow(this[i] - mean, 2);
|
||||
}
|
||||
|
||||
return Math.sqrt(sumSqr / N);
|
||||
}
|
||||
|
||||
113
public/novnc/tests/test.inflator.js
Normal file
@@ -0,0 +1,113 @@
|
||||
/* eslint-disable no-console */
|
||||
const expect = chai.expect;
|
||||
|
||||
import { deflateInit, deflate, Z_FULL_FLUSH } from "../vendor/pako/lib/zlib/deflate.js";
|
||||
import ZStream from "../vendor/pako/lib/zlib/zstream.js";
|
||||
import Inflator from "../core/inflator.js";
|
||||
|
||||
function _deflator(data) {
|
||||
let strm = new ZStream();
|
||||
|
||||
deflateInit(strm, 5);
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
strm.input = data;
|
||||
strm.avail_in = strm.input.length;
|
||||
strm.next_in = 0;
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
let chunks = [];
|
||||
let totalLen = 0;
|
||||
while (strm.avail_in > 0) {
|
||||
/* eslint-disable camelcase */
|
||||
strm.output = new Uint8Array(1024 * 10 * 10);
|
||||
strm.avail_out = strm.output.length;
|
||||
strm.next_out = 0;
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
let ret = deflate(strm, Z_FULL_FLUSH);
|
||||
|
||||
// Check that return code is not an error
|
||||
expect(ret).to.be.greaterThan(-1);
|
||||
|
||||
let chunk = new Uint8Array(strm.output.buffer, 0, strm.next_out);
|
||||
totalLen += chunk.length;
|
||||
chunks.push(chunk);
|
||||
}
|
||||
|
||||
// Combine chunks into a single data
|
||||
|
||||
let outData = new Uint8Array(totalLen);
|
||||
let offset = 0;
|
||||
|
||||
for (let i = 0; i < chunks.length; i++) {
|
||||
outData.set(chunks[i], offset);
|
||||
offset += chunks[i].length;
|
||||
}
|
||||
|
||||
return outData;
|
||||
}
|
||||
|
||||
describe('Inflate data', function () {
|
||||
|
||||
it('should be able to inflate messages', function () {
|
||||
let inflator = new Inflator();
|
||||
|
||||
let text = "123asdf";
|
||||
let preText = new Uint8Array(text.length);
|
||||
for (let i = 0; i < preText.length; i++) {
|
||||
preText[i] = text.charCodeAt(i);
|
||||
}
|
||||
|
||||
let compText = _deflator(preText);
|
||||
|
||||
inflator.setInput(compText);
|
||||
let inflatedText = inflator.inflate(preText.length);
|
||||
|
||||
expect(inflatedText).to.array.equal(preText);
|
||||
|
||||
});
|
||||
|
||||
it('should be able to inflate large messages', function () {
|
||||
let inflator = new Inflator();
|
||||
|
||||
/* Generate a big string with random characters. Used because
|
||||
repetition of letters might be deflated more effectively than
|
||||
random ones. */
|
||||
let text = "";
|
||||
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
for (let i = 0; i < 300000; i++) {
|
||||
text += characters.charAt(Math.floor(Math.random() * characters.length));
|
||||
}
|
||||
|
||||
let preText = new Uint8Array(text.length);
|
||||
for (let i = 0; i < preText.length; i++) {
|
||||
preText[i] = text.charCodeAt(i);
|
||||
}
|
||||
|
||||
let compText = _deflator(preText);
|
||||
|
||||
//Check that the compressed size is expected size
|
||||
expect(compText.length).to.be.greaterThan((1024 * 10 * 10) * 2);
|
||||
|
||||
inflator.setInput(compText);
|
||||
let inflatedText = inflator.inflate(preText.length);
|
||||
|
||||
expect(inflatedText).to.array.equal(preText);
|
||||
});
|
||||
|
||||
it('should throw an error on insufficient data', function () {
|
||||
let inflator = new Inflator();
|
||||
|
||||
let text = "123asdf";
|
||||
let preText = new Uint8Array(text.length);
|
||||
for (let i = 0; i < preText.length; i++) {
|
||||
preText[i] = text.charCodeAt(i);
|
||||
}
|
||||
|
||||
let compText = _deflator(preText);
|
||||
|
||||
inflator.setInput(compText);
|
||||
expect(() => inflator.inflate(preText.length * 2)).to.throw();
|
||||
});
|
||||
});
|
||||
288
public/novnc/tests/test.jpeg.js
Normal file
@@ -0,0 +1,288 @@
|
||||
const expect = chai.expect;
|
||||
|
||||
import Websock from '../core/websock.js';
|
||||
import Display from '../core/display.js';
|
||||
|
||||
import JPEGDecoder from '../core/decoders/jpeg.js';
|
||||
|
||||
import FakeWebSocket from './fake.websocket.js';
|
||||
|
||||
function testDecodeRect(decoder, x, y, width, height, data, display, depth) {
|
||||
let sock;
|
||||
|
||||
sock = new Websock;
|
||||
sock.open("ws://example.com");
|
||||
|
||||
sock.on('message', () => {
|
||||
decoder.decodeRect(x, y, width, height, sock, display, depth);
|
||||
});
|
||||
|
||||
// Empty messages are filtered at multiple layers, so we need to
|
||||
// do a direct call
|
||||
if (data.length === 0) {
|
||||
decoder.decodeRect(x, y, width, height, sock, display, depth);
|
||||
} else {
|
||||
sock._websocket._receiveData(new Uint8Array(data));
|
||||
}
|
||||
|
||||
display.flip();
|
||||
}
|
||||
|
||||
describe('JPEG Decoder', function () {
|
||||
let decoder;
|
||||
let display;
|
||||
|
||||
before(FakeWebSocket.replace);
|
||||
after(FakeWebSocket.restore);
|
||||
|
||||
beforeEach(function () {
|
||||
decoder = new JPEGDecoder();
|
||||
display = new Display(document.createElement('canvas'));
|
||||
display.resize(4, 4);
|
||||
});
|
||||
|
||||
it('should handle JPEG rects', function (done) {
|
||||
let data = [
|
||||
// JPEG data
|
||||
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46,
|
||||
0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x01, 0x2c,
|
||||
0x01, 0x2c, 0x00, 0x42, 0xff, 0xdb, 0x00, 0x43,
|
||||
0x00, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03,
|
||||
0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x05,
|
||||
0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x0a, 0x07,
|
||||
0x07, 0x06, 0x08, 0x0c, 0x0a, 0x0c, 0x0c, 0x0b,
|
||||
0x0a, 0x0b, 0x0b, 0x0d, 0x0e, 0x12, 0x10, 0x0d,
|
||||
0x0e, 0x11, 0x0e, 0x0b, 0x0b, 0x10, 0x16, 0x10,
|
||||
0x11, 0x13, 0x14, 0x15, 0x15, 0x15, 0x0c, 0x0f,
|
||||
0x17, 0x18, 0x16, 0x14, 0x18, 0x12, 0x14, 0x15,
|
||||
0x14, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x03, 0x04,
|
||||
0x04, 0x05, 0x04, 0x05, 0x09, 0x05, 0x05, 0x09,
|
||||
0x14, 0x0d, 0x0b, 0x0d, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xff, 0xc0,
|
||||
0x00, 0x11, 0x08, 0x00, 0x04, 0x00, 0x04, 0x03,
|
||||
0x01, 0x11, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11,
|
||||
0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01,
|
||||
0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
||||
0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00,
|
||||
0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05,
|
||||
0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01,
|
||||
0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21,
|
||||
0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22,
|
||||
0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23,
|
||||
0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24,
|
||||
0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29,
|
||||
0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a,
|
||||
0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a,
|
||||
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
|
||||
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
|
||||
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
||||
0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a,
|
||||
0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
|
||||
0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
|
||||
0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6,
|
||||
0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5,
|
||||
0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3,
|
||||
0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1,
|
||||
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
|
||||
0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
||||
0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07,
|
||||
0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00,
|
||||
0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31,
|
||||
0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13,
|
||||
0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1,
|
||||
0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15,
|
||||
0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1,
|
||||
0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
||||
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
||||
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
||||
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
|
||||
0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
|
||||
0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
|
||||
0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5,
|
||||
0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4,
|
||||
0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3,
|
||||
0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
|
||||
0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00,
|
||||
0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf9,
|
||||
0xf7, 0xfb, 0x67, 0x56, 0xff, 0x00, 0x9f, 0xf8,
|
||||
0x3f, 0xf0, 0x51, 0xa7, 0xff, 0x00, 0xf2, 0x3d,
|
||||
0x7e, 0x6f, 0xfd, 0xab, 0x94, 0x7f, 0xd0, 0x9a,
|
||||
0x8f, 0xfe, 0x0d, 0xc7, 0x7f, 0xf3, 0x61, 0xfd,
|
||||
0xa7, 0xff, 0x00, 0x10, 0x77, 0x0d, 0xff, 0x00,
|
||||
0x43, 0xec, 0xcf, 0xff, 0x00, 0x0b, 0xab, 0x1f,
|
||||
0xff, 0xd9,
|
||||
];
|
||||
|
||||
testDecodeRect(decoder, 0, 0, 4, 4, data, display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255
|
||||
]);
|
||||
|
||||
// Browsers have rounding errors, so we need an approximate
|
||||
// comparing function
|
||||
function almost(a, b) {
|
||||
let diff = Math.abs(a - b);
|
||||
return diff < 5;
|
||||
}
|
||||
|
||||
display.onflush = () => {
|
||||
expect(display).to.have.displayed(targetData, almost);
|
||||
done();
|
||||
};
|
||||
display.flush();
|
||||
});
|
||||
|
||||
it('should handle JPEG rects without Huffman and quantification tables', function (done) {
|
||||
let data1 = [
|
||||
// JPEG data
|
||||
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46,
|
||||
0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x01, 0x2c,
|
||||
0x01, 0x2c, 0x00, 0x42, 0xff, 0xdb, 0x00, 0x43,
|
||||
0x00, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03,
|
||||
0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x05,
|
||||
0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x0a, 0x07,
|
||||
0x07, 0x06, 0x08, 0x0c, 0x0a, 0x0c, 0x0c, 0x0b,
|
||||
0x0a, 0x0b, 0x0b, 0x0d, 0x0e, 0x12, 0x10, 0x0d,
|
||||
0x0e, 0x11, 0x0e, 0x0b, 0x0b, 0x10, 0x16, 0x10,
|
||||
0x11, 0x13, 0x14, 0x15, 0x15, 0x15, 0x0c, 0x0f,
|
||||
0x17, 0x18, 0x16, 0x14, 0x18, 0x12, 0x14, 0x15,
|
||||
0x14, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x03, 0x04,
|
||||
0x04, 0x05, 0x04, 0x05, 0x09, 0x05, 0x05, 0x09,
|
||||
0x14, 0x0d, 0x0b, 0x0d, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
|
||||
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xff, 0xc0,
|
||||
0x00, 0x11, 0x08, 0x00, 0x04, 0x00, 0x04, 0x03,
|
||||
0x01, 0x11, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11,
|
||||
0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01,
|
||||
0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
||||
0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00,
|
||||
0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05,
|
||||
0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01,
|
||||
0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21,
|
||||
0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22,
|
||||
0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23,
|
||||
0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24,
|
||||
0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29,
|
||||
0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a,
|
||||
0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a,
|
||||
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
|
||||
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
|
||||
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
||||
0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a,
|
||||
0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
|
||||
0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8,
|
||||
0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
|
||||
0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6,
|
||||
0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5,
|
||||
0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3,
|
||||
0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1,
|
||||
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
|
||||
0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
||||
0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00,
|
||||
0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07,
|
||||
0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00,
|
||||
0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31,
|
||||
0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13,
|
||||
0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1,
|
||||
0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15,
|
||||
0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1,
|
||||
0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
||||
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
||||
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
||||
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
|
||||
0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
|
||||
0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||||
0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
|
||||
0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5,
|
||||
0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4,
|
||||
0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3,
|
||||
0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2,
|
||||
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||||
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
|
||||
0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00,
|
||||
0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf9,
|
||||
0xf7, 0xfb, 0x67, 0x56, 0xff, 0x00, 0x9f, 0xf8,
|
||||
0x3f, 0xf0, 0x51, 0xa7, 0xff, 0x00, 0xf2, 0x3d,
|
||||
0x7e, 0x6f, 0xfd, 0xab, 0x94, 0x7f, 0xd0, 0x9a,
|
||||
0x8f, 0xfe, 0x0d, 0xc7, 0x7f, 0xf3, 0x61, 0xfd,
|
||||
0xa7, 0xff, 0x00, 0x10, 0x77, 0x0d, 0xff, 0x00,
|
||||
0x43, 0xec, 0xcf, 0xff, 0x00, 0x0b, 0xab, 0x1f,
|
||||
0xff, 0xd9,
|
||||
];
|
||||
|
||||
testDecodeRect(decoder, 0, 0, 4, 4, data1, display, 24);
|
||||
|
||||
let data2 = [
|
||||
// JPEG data
|
||||
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46,
|
||||
0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x01, 0x2c,
|
||||
0x01, 0x2c, 0x00, 0x73, 0xff, 0xc0, 0x00, 0x11,
|
||||
0x08, 0x00, 0x04, 0x00, 0x04, 0x03, 0x01, 0x11,
|
||||
0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff,
|
||||
0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11,
|
||||
0x03, 0x11, 0x00, 0x3f, 0x00, 0xf9, 0xf7, 0xfb,
|
||||
0x67, 0x56, 0xff, 0x00, 0x9f, 0xf8, 0x3f, 0xf0,
|
||||
0x51, 0xa7, 0xff, 0x00, 0xf2, 0x3d, 0x7e, 0x6f,
|
||||
0xfd, 0xab, 0x94, 0x7f, 0xd0, 0x9a, 0x8f, 0xfe,
|
||||
0x0d, 0xc7, 0x7f, 0xf3, 0x61, 0xfd, 0xa7, 0xff,
|
||||
0x00, 0x10, 0x77, 0x0d, 0xff, 0x00, 0x43, 0xec,
|
||||
0xcf, 0xff, 0x00, 0x0b, 0xab, 0x1f, 0xff, 0xd9,
|
||||
];
|
||||
|
||||
testDecodeRect(decoder, 0, 0, 4, 4, data2, display, 24);
|
||||
|
||||
let targetData = new Uint8Array([
|
||||
0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255,
|
||||
0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255, 0x00, 0xff, 0x00, 255,
|
||||
0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255, 0x00, 0x00, 0xff, 255,
|
||||
0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255, 0xff, 0x00, 0x00, 255
|
||||
]);
|
||||
|
||||
// Browsers have rounding errors, so we need an approximate
|
||||
// comparing function
|
||||
function almost(a, b) {
|
||||
let diff = Math.abs(a - b);
|
||||
return diff < 5;
|
||||
}
|
||||
|
||||
display.onflush = () => {
|
||||
expect(display).to.have.displayed(targetData, almost);
|
||||
done();
|
||||
};
|
||||
display.flush();
|
||||
});
|
||||
});
|
||||
357
public/novnc/tests/test.ra2.js
Normal file
@@ -0,0 +1,357 @@
|
||||
const expect = chai.expect;
|
||||
|
||||
import RFB from '../core/rfb.js';
|
||||
|
||||
import FakeWebSocket from './fake.websocket.js';
|
||||
|
||||
function fakeGetRandomValues(arr) {
|
||||
if (arr.length === 16) {
|
||||
arr.set(new Uint8Array([
|
||||
0x1c, 0x08, 0xfe, 0x21, 0x78, 0xef, 0x4e, 0xf9,
|
||||
0x3f, 0x05, 0xec, 0xea, 0xd4, 0x6b, 0xa5, 0xd5,
|
||||
]));
|
||||
} else {
|
||||
arr.set(new Uint8Array([
|
||||
0xee, 0xe2, 0xf1, 0x5a, 0x3c, 0xa7, 0xbe, 0x95,
|
||||
0x6f, 0x2a, 0x75, 0xfd, 0x62, 0x01, 0xcb, 0xbf,
|
||||
0x43, 0x74, 0xca, 0x47, 0x4d, 0xfb, 0x0f, 0xcf,
|
||||
0x3a, 0x6d, 0x55, 0x6b, 0x59, 0x3a, 0xf6, 0x87,
|
||||
0xcb, 0x03, 0xb7, 0x28, 0x35, 0x7b, 0x15, 0x8e,
|
||||
0xb6, 0xc8, 0x8f, 0x2d, 0x5e, 0x7b, 0x1c, 0x9a,
|
||||
0x32, 0x55, 0xe7, 0x64, 0x36, 0x25, 0x7b, 0xa3,
|
||||
0xe9, 0x4f, 0x6f, 0x97, 0xdc, 0xa4, 0xd4, 0x62,
|
||||
0x6d, 0x7f, 0xab, 0x02, 0x6b, 0x13, 0x56, 0x69,
|
||||
0xfb, 0xd0, 0xd4, 0x13, 0x76, 0xcd, 0x0d, 0xd0,
|
||||
0x1f, 0xd1, 0x0c, 0x63, 0x3a, 0x34, 0x20, 0x6c,
|
||||
0xbb, 0x60, 0x45, 0x82, 0x23, 0xfd, 0x7c, 0x77,
|
||||
0x6d, 0xcc, 0x5e, 0xaa, 0xc3, 0x0c, 0x43, 0xb7,
|
||||
0x8d, 0xc0, 0x27, 0x6e, 0xeb, 0x1d, 0x6c, 0x5f,
|
||||
0xd8, 0x1c, 0x3c, 0x1c, 0x60, 0x2e, 0x82, 0x15,
|
||||
0xfd, 0x2e, 0x5f, 0x3a, 0x15, 0x53, 0x14, 0x70,
|
||||
0x4f, 0xe1, 0x65, 0x68, 0x35, 0x6d, 0xc7, 0x64,
|
||||
0xdb, 0xdd, 0x09, 0x31, 0x4f, 0x7b, 0x6d, 0x6c,
|
||||
0x77, 0x59, 0x5e, 0x1e, 0xfa, 0x4b, 0x06, 0x14,
|
||||
0xbe, 0xdc, 0x9c, 0x3d, 0x7b, 0xed, 0xf3, 0x2b,
|
||||
0x19, 0x26, 0x11, 0x8e, 0x3f, 0xab, 0x73, 0x9a,
|
||||
0x0a, 0x3a, 0xaa, 0x85, 0x06, 0xd5, 0xca, 0x3f,
|
||||
0xc3, 0xe2, 0x33, 0x7f, 0x97, 0x74, 0x98, 0x8f,
|
||||
0x2f, 0xa5, 0xfc, 0x7e, 0xb1, 0x77, 0x71, 0x58,
|
||||
0xf0, 0xbc, 0x04, 0x59, 0xbb, 0xb4, 0xc6, 0xcc,
|
||||
0x0f, 0x06, 0xcd, 0xa2, 0xd5, 0x01, 0x2f, 0xb2,
|
||||
0x22, 0x0b, 0xfc, 0x1e, 0x59, 0x9f, 0xd3, 0x4f,
|
||||
0x30, 0x95, 0xc6, 0x80, 0x0f, 0x69, 0xf3, 0x4a,
|
||||
0xd4, 0x36, 0xb6, 0x5a, 0x0b, 0x16, 0x0d, 0x81,
|
||||
0x31, 0xb0, 0x69, 0xd4, 0x4e,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
async function fakeGeneratekey() {
|
||||
let key = JSON.parse('{"alg":"RSA-OAEP-256","d":"B7QR2yI8sXjo8vQhJpX9odqqR\
|
||||
6wIuPrTM1B1JJEKVeSrr7OYcc1FRJ52Vap9LIAU-ezigs9QDvWMxknB8motLnG69Wck37nt9_z4s8l\
|
||||
FQp0nROA-oaR92HW34KNL1b2fEVWGI0N86h730MvTJC5O2cmKeMezIG-oNqbbfFyP8AW-WLdDlgZm1\
|
||||
1-FjzhbVpb0Bc7nRSgBPSV-EY6Sl-LuglxDx4LaTdQW7QE_WXoRUt-GYGfTseuFQQK5WeoyX3yBtQy\
|
||||
dpauW6rrgyWdtP4hDFIoZsX6w1i-UMWMMwlIB5FdnUSi26igVGADGpV_vGMP36bv-EHp0bY-Qp0gpI\
|
||||
fLfgQ","dp":"Z1v5UceFfV2bhmbG19eGYb30jFxqoRBq36PKNY7IunMs1keYy0FpLbyGhtgMZ1Ymm\
|
||||
c8wEzGYsCPEP-ykcun_rlyu7YxmcnyC9YQqTqLyqvO-7rUqDvk9TMfdqWFP6heADRhKZmEbmcau6_m\
|
||||
2MwwK9kOkMKWvpqp8_TpJMnAH7zE","dq":"OBacRE15aY3NtCR4cvP5os3sT70JbDdDLHT3IHZM6r\
|
||||
E35CYNpLDia2chm_wnMcYvKFW9zC2ajRZ15i9c_VXQzS7ZlTaQYBFyMt7kVhxMEMFsPv1crD6t3uEI\
|
||||
j0LNuNYyy0jkon_LPZKQFK654CiL-L2YaNXOH4HbHP02dWeVQIE","e":"AQAB","ext":true,"ke\
|
||||
y_ops":["decrypt"],"kty":"RSA","n":"m1c92ZFk9ZI6l_O4YFiNxbv0Ng94SB3yThy1P_mcqr\
|
||||
GDQkRiGVdcTxAk38T9PgLztmspF-6U5TAHO-gSmmW88AC9m6f1Mspps6r7zl-M_OG-TwvGzf3BDz8z\
|
||||
Eg1FPbZV7whO1M4TCAZ0PqwG7qCc6nK1WiAhaKrSpzuPdL1igfNBsX7qu5wgw4ZTTGSLbVC_LfULQ5\
|
||||
FADgFTRXUSaxm1F8C_Lwy6a2e4nTcXilmtN2IHUjHegzm-Tq2HizmR3ARdWJpESYIW5-AXoiqj29tD\
|
||||
rqCmu2WPkB2psVp83IzZfaQNQzjNfvA8GpimkcDCkP5VMRrtKCcG4ZAFnO-A3NBX_Q","p":"2Q_lN\
|
||||
L7vCOBzAppYzCZo3WSh0hX-MOZyPUznks5U2TjmfdNZoL6_FJRiGyyLvwSiZFdEAAvpAyESFfFigng\
|
||||
AqMLSf448nPg15VUGj533CotsEM0WpoEr1JCgqdUbgDAfJQIBcwOmegBqd7lWm7uzEnRCvouB70ybk\
|
||||
JfpdprhkVE","q":"tzTt-F3g2u_3Ctj26Ho9iN_wC_W0lXGzslLt5nLmss8JqdLoDDrijjU-gjeRh\
|
||||
7lgiuHdUc3dorfFKbaMNOjoW3QKqt9oZ1JM0HKeRw0X2PnWW_0WK6DK5ASWDTXbMq2sUZqJvYEyL74\
|
||||
H2Zrt0RPAux7XQLEVgND6ROdXnMJ70O0","qi":"qfl4cXQkz4BNqa2De0-PfdU-8d1w3onnaGqx1D\
|
||||
s2fHzD_SJ4cNghn2TksoT9Qo64b3pUjH9igi2pyEjomk6D12N6FG0e10u7vFKv3W5YqUOgTpYdbcWH\
|
||||
dZ2qZWJU0XQZIrF8jLGTOO4GYP6_9sJ5R7Wk_0MdqQy8qvixWD4zLcY"}');
|
||||
key = await window.crypto.subtle.importKey("jwk", key, {
|
||||
name: "RSA-OAEP",
|
||||
hash: {name: "SHA-256"}
|
||||
}, true, ["decrypt"]);
|
||||
return {privateKey: key};
|
||||
}
|
||||
|
||||
const receiveData = new Uint8Array([
|
||||
// server public key
|
||||
0x00, 0x00, 0x08, 0x00, 0xac, 0x1a, 0xbc, 0x42,
|
||||
0x8a, 0x2a, 0x69, 0x65, 0x54, 0xf8, 0x9a, 0xe6,
|
||||
0x43, 0xaa, 0xf7, 0x27, 0xf6, 0x2a, 0xf8, 0x8f,
|
||||
0x36, 0xd4, 0xae, 0x54, 0x0f, 0x16, 0x28, 0x08,
|
||||
0xc2, 0x5b, 0xca, 0x23, 0xdc, 0x27, 0x88, 0x1a,
|
||||
0x12, 0x82, 0xa8, 0x54, 0xea, 0x00, 0x99, 0x8d,
|
||||
0x02, 0x1d, 0x77, 0x4a, 0xeb, 0xd0, 0x93, 0x40,
|
||||
0x79, 0x86, 0xcb, 0x37, 0xd4, 0xb2, 0xc7, 0xcd,
|
||||
0x93, 0xe1, 0x00, 0x4d, 0x86, 0xff, 0x97, 0x33,
|
||||
0x0c, 0xad, 0x51, 0x47, 0x45, 0x85, 0x56, 0x07,
|
||||
0x65, 0x21, 0x7c, 0x57, 0x6d, 0x68, 0x7d, 0xd7,
|
||||
0x00, 0x43, 0x0c, 0x9d, 0x3b, 0xa1, 0x5a, 0x11,
|
||||
0xed, 0x51, 0x77, 0xf9, 0xd1, 0x5b, 0x33, 0xd7,
|
||||
0x1a, 0xeb, 0x65, 0x57, 0xc0, 0x01, 0x51, 0xff,
|
||||
0x9b, 0x82, 0xb3, 0xeb, 0x82, 0xc2, 0x1f, 0xca,
|
||||
0x47, 0xc0, 0x6a, 0x09, 0xe0, 0xf7, 0xda, 0x39,
|
||||
0x85, 0x12, 0xe7, 0x45, 0x8d, 0xb4, 0x1a, 0xda,
|
||||
0xcb, 0x86, 0x58, 0x52, 0x37, 0x66, 0x9d, 0x8a,
|
||||
0xce, 0xf2, 0x18, 0x78, 0x7d, 0x7f, 0xf0, 0x07,
|
||||
0x94, 0x8e, 0x6b, 0x17, 0xd9, 0x00, 0x2a, 0x3a,
|
||||
0xb9, 0xd4, 0x77, 0xde, 0x70, 0x85, 0xc4, 0x3a,
|
||||
0x62, 0x10, 0x02, 0xee, 0xba, 0xd8, 0xc0, 0x62,
|
||||
0xd0, 0x8e, 0xc1, 0x98, 0x19, 0x8e, 0x39, 0x0f,
|
||||
0x3e, 0x1d, 0x61, 0xb1, 0x93, 0x13, 0x59, 0x39,
|
||||
0xcb, 0x96, 0xf2, 0x17, 0xc9, 0xe1, 0x41, 0xd3,
|
||||
0x20, 0xdd, 0x62, 0x5e, 0x7d, 0x53, 0xd6, 0xb7,
|
||||
0x1d, 0xfe, 0x02, 0x18, 0x1f, 0xe0, 0xef, 0x3d,
|
||||
0x94, 0xe3, 0x0a, 0x9c, 0x59, 0x54, 0xd8, 0x98,
|
||||
0x16, 0x9c, 0x31, 0xda, 0x41, 0x0f, 0x2e, 0x71,
|
||||
0x68, 0xe0, 0xa2, 0x62, 0x3e, 0xe5, 0x25, 0x31,
|
||||
0xcf, 0xfc, 0x67, 0x63, 0xc3, 0xb0, 0xda, 0x3f,
|
||||
0x7b, 0x59, 0xbe, 0x7e, 0x9e, 0xa8, 0xd0, 0x01,
|
||||
0x4f, 0x43, 0x7f, 0x8d, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x01,
|
||||
// server random
|
||||
0x01, 0x00, 0x5b, 0x58, 0x2a, 0x96, 0x2d, 0xbb,
|
||||
0x88, 0xec, 0xc3, 0x54, 0x00, 0xf3, 0xbb, 0xbe,
|
||||
0x17, 0xa3, 0x84, 0xd3, 0xef, 0xd8, 0x4a, 0x31,
|
||||
0x09, 0x20, 0xdd, 0xbc, 0x16, 0x9d, 0xc9, 0x5b,
|
||||
0x99, 0x62, 0x86, 0xfe, 0x0b, 0x28, 0x4b, 0xfe,
|
||||
0x5b, 0x56, 0x2d, 0xcb, 0x6e, 0x6f, 0xec, 0xf0,
|
||||
0x53, 0x0c, 0x33, 0x84, 0x93, 0xc9, 0xbf, 0x79,
|
||||
0xde, 0xb3, 0xb9, 0x29, 0x60, 0x78, 0xde, 0xe6,
|
||||
0x1d, 0xa7, 0x89, 0x48, 0x3f, 0xd1, 0x58, 0x66,
|
||||
0x27, 0x9c, 0xd4, 0x6e, 0x72, 0x9c, 0x6e, 0x4a,
|
||||
0xc0, 0x69, 0x79, 0x6f, 0x79, 0x0f, 0x13, 0xc4,
|
||||
0x20, 0xcf, 0xa6, 0xbb, 0xce, 0x18, 0x6d, 0xd5,
|
||||
0x9e, 0xd9, 0x67, 0xbe, 0x61, 0x43, 0x67, 0x11,
|
||||
0x76, 0x2f, 0xfd, 0x78, 0x75, 0x2b, 0x89, 0x35,
|
||||
0xdd, 0x0f, 0x13, 0x7f, 0xee, 0x78, 0xad, 0x32,
|
||||
0x56, 0x21, 0x81, 0x08, 0x1f, 0xcf, 0x4c, 0x29,
|
||||
0xa3, 0xeb, 0x89, 0x2d, 0xbe, 0xba, 0x8d, 0xe4,
|
||||
0x69, 0x28, 0xba, 0x53, 0x82, 0xce, 0x5c, 0xf6,
|
||||
0x5e, 0x5e, 0xa5, 0xb3, 0x88, 0xd8, 0x3d, 0xab,
|
||||
0xf4, 0x24, 0x9e, 0x3f, 0x04, 0xaf, 0xdc, 0x48,
|
||||
0x90, 0x53, 0x37, 0xe6, 0x82, 0x1d, 0xe0, 0x15,
|
||||
0x91, 0xa1, 0xc6, 0xa9, 0x54, 0xe5, 0x2a, 0xb5,
|
||||
0x64, 0x2d, 0x93, 0xc0, 0xc0, 0xe1, 0x0f, 0x6a,
|
||||
0x4b, 0xdb, 0x77, 0xf8, 0x4a, 0x0f, 0x83, 0x36,
|
||||
0xdd, 0x5e, 0x1e, 0xdd, 0x39, 0x65, 0xa2, 0x11,
|
||||
0xc2, 0xcf, 0x56, 0x1e, 0xa1, 0x29, 0xae, 0x11,
|
||||
0x9f, 0x3a, 0x82, 0xc7, 0xbd, 0x89, 0x6e, 0x59,
|
||||
0xb8, 0x59, 0x17, 0xcb, 0x65, 0xa0, 0x4b, 0x4d,
|
||||
0xbe, 0x33, 0x32, 0x85, 0x9c, 0xca, 0x5e, 0x95,
|
||||
0xc2, 0x5a, 0xd0, 0xc9, 0x8b, 0xf1, 0xf5, 0x14,
|
||||
0xcf, 0x76, 0x80, 0xc2, 0x24, 0x0a, 0x39, 0x7e,
|
||||
0x60, 0x64, 0xce, 0xd9, 0xb8, 0xad, 0x24, 0xa8,
|
||||
0xdf, 0xcb,
|
||||
// server hash
|
||||
0x00, 0x14, 0x39, 0x30, 0x66, 0xb5, 0x66, 0x8a,
|
||||
0xcd, 0xb9, 0xda, 0xe0, 0xde, 0xcb, 0xf6, 0x47,
|
||||
0x5f, 0x54, 0x66, 0xe0, 0xbc, 0x49, 0x37, 0x01,
|
||||
0xf2, 0x9e, 0xef, 0xcc, 0xcd, 0x4d, 0x6c, 0x0e,
|
||||
0xc6, 0xab, 0x28, 0xd4, 0x7b, 0x13,
|
||||
// subtype
|
||||
0x00, 0x01, 0x30, 0x2a, 0xc3, 0x0b, 0xc2, 0x1c,
|
||||
0xeb, 0x02, 0x44, 0x92, 0x5d, 0xfd, 0xf9, 0xa7,
|
||||
0x94, 0xd0, 0x19,
|
||||
]);
|
||||
|
||||
const sendData = new Uint8Array([
|
||||
// client public key
|
||||
0x00, 0x00, 0x08, 0x00, 0x9b, 0x57, 0x3d, 0xd9,
|
||||
0x91, 0x64, 0xf5, 0x92, 0x3a, 0x97, 0xf3, 0xb8,
|
||||
0x60, 0x58, 0x8d, 0xc5, 0xbb, 0xf4, 0x36, 0x0f,
|
||||
0x78, 0x48, 0x1d, 0xf2, 0x4e, 0x1c, 0xb5, 0x3f,
|
||||
0xf9, 0x9c, 0xaa, 0xb1, 0x83, 0x42, 0x44, 0x62,
|
||||
0x19, 0x57, 0x5c, 0x4f, 0x10, 0x24, 0xdf, 0xc4,
|
||||
0xfd, 0x3e, 0x02, 0xf3, 0xb6, 0x6b, 0x29, 0x17,
|
||||
0xee, 0x94, 0xe5, 0x30, 0x07, 0x3b, 0xe8, 0x12,
|
||||
0x9a, 0x65, 0xbc, 0xf0, 0x00, 0xbd, 0x9b, 0xa7,
|
||||
0xf5, 0x32, 0xca, 0x69, 0xb3, 0xaa, 0xfb, 0xce,
|
||||
0x5f, 0x8c, 0xfc, 0xe1, 0xbe, 0x4f, 0x0b, 0xc6,
|
||||
0xcd, 0xfd, 0xc1, 0x0f, 0x3f, 0x33, 0x12, 0x0d,
|
||||
0x45, 0x3d, 0xb6, 0x55, 0xef, 0x08, 0x4e, 0xd4,
|
||||
0xce, 0x13, 0x08, 0x06, 0x74, 0x3e, 0xac, 0x06,
|
||||
0xee, 0xa0, 0x9c, 0xea, 0x72, 0xb5, 0x5a, 0x20,
|
||||
0x21, 0x68, 0xaa, 0xd2, 0xa7, 0x3b, 0x8f, 0x74,
|
||||
0xbd, 0x62, 0x81, 0xf3, 0x41, 0xb1, 0x7e, 0xea,
|
||||
0xbb, 0x9c, 0x20, 0xc3, 0x86, 0x53, 0x4c, 0x64,
|
||||
0x8b, 0x6d, 0x50, 0xbf, 0x2d, 0xf5, 0x0b, 0x43,
|
||||
0x91, 0x40, 0x0e, 0x01, 0x53, 0x45, 0x75, 0x12,
|
||||
0x6b, 0x19, 0xb5, 0x17, 0xc0, 0xbf, 0x2f, 0x0c,
|
||||
0xba, 0x6b, 0x67, 0xb8, 0x9d, 0x37, 0x17, 0x8a,
|
||||
0x59, 0xad, 0x37, 0x62, 0x07, 0x52, 0x31, 0xde,
|
||||
0x83, 0x39, 0xbe, 0x4e, 0xad, 0x87, 0x8b, 0x39,
|
||||
0x91, 0xdc, 0x04, 0x5d, 0x58, 0x9a, 0x44, 0x49,
|
||||
0x82, 0x16, 0xe7, 0xe0, 0x17, 0xa2, 0x2a, 0xa3,
|
||||
0xdb, 0xdb, 0x43, 0xae, 0xa0, 0xa6, 0xbb, 0x65,
|
||||
0x8f, 0x90, 0x1d, 0xa9, 0xb1, 0x5a, 0x7c, 0xdc,
|
||||
0x8c, 0xd9, 0x7d, 0xa4, 0x0d, 0x43, 0x38, 0xcd,
|
||||
0x7e, 0xf0, 0x3c, 0x1a, 0x98, 0xa6, 0x91, 0xc0,
|
||||
0xc2, 0x90, 0xfe, 0x55, 0x31, 0x1a, 0xed, 0x28,
|
||||
0x27, 0x06, 0xe1, 0x90, 0x05, 0x9c, 0xef, 0x80,
|
||||
0xdc, 0xd0, 0x57, 0xfd, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x01,
|
||||
// client random
|
||||
0x01, 0x00, 0x84, 0x7f, 0x26, 0x54, 0x74, 0xf6,
|
||||
0x47, 0xaf, 0x33, 0x64, 0x0d, 0xa6, 0xe5, 0x30,
|
||||
0xba, 0xe6, 0xe4, 0x8e, 0x50, 0x40, 0x71, 0x1c,
|
||||
0x0e, 0x06, 0x63, 0xf5, 0x07, 0x2a, 0x26, 0x68,
|
||||
0xd6, 0xcf, 0xa6, 0x80, 0x84, 0x5e, 0x64, 0xd4,
|
||||
0x5e, 0x62, 0x31, 0xfe, 0x44, 0x51, 0x0b, 0x7c,
|
||||
0x4d, 0x55, 0xc5, 0x4a, 0x7e, 0x0d, 0x4d, 0x9b,
|
||||
0x84, 0xb4, 0x32, 0x2b, 0x4d, 0x8a, 0x34, 0x8d,
|
||||
0xc8, 0xcf, 0x19, 0x3b, 0x64, 0x82, 0x27, 0x9e,
|
||||
0xa7, 0x70, 0x2a, 0xc1, 0xb8, 0xf3, 0x6a, 0x3a,
|
||||
0xf2, 0x75, 0x6e, 0x1d, 0xeb, 0xb6, 0x70, 0x7a,
|
||||
0x15, 0x18, 0x38, 0x00, 0xb4, 0x4f, 0x55, 0xb5,
|
||||
0xd8, 0x03, 0x4e, 0xb8, 0x53, 0xff, 0x80, 0x62,
|
||||
0xf1, 0x9d, 0x27, 0xe8, 0x2a, 0x3d, 0x98, 0x19,
|
||||
0x32, 0x09, 0x7e, 0x9a, 0xb0, 0xc7, 0x46, 0x23,
|
||||
0x10, 0x85, 0x35, 0x00, 0x96, 0xce, 0xb3, 0x2c,
|
||||
0x84, 0x8d, 0xf4, 0x9e, 0xa8, 0x42, 0x67, 0xed,
|
||||
0x09, 0xa6, 0x09, 0x97, 0xb3, 0x64, 0x26, 0xfb,
|
||||
0x71, 0x11, 0x9b, 0x3f, 0xbb, 0x57, 0xb8, 0x5b,
|
||||
0x2e, 0xc5, 0x2d, 0x8c, 0x5c, 0xf7, 0xef, 0x27,
|
||||
0x25, 0x88, 0x42, 0x45, 0x43, 0xa4, 0xe7, 0xde,
|
||||
0xea, 0xf9, 0x15, 0x7b, 0x5d, 0x66, 0x24, 0xce,
|
||||
0xf7, 0xc8, 0x2f, 0xc5, 0xc0, 0x3d, 0xcd, 0xf2,
|
||||
0x62, 0xfc, 0x1a, 0x5e, 0xec, 0xff, 0xf1, 0x1b,
|
||||
0xc8, 0xdb, 0xc1, 0x0f, 0x54, 0x66, 0x9e, 0xfd,
|
||||
0x99, 0x9b, 0x23, 0x70, 0x62, 0x37, 0x80, 0xad,
|
||||
0x91, 0x6b, 0x84, 0x85, 0x6a, 0x4c, 0x80, 0x9e,
|
||||
0x60, 0x8a, 0x93, 0xa3, 0xc8, 0x8e, 0xc4, 0x4b,
|
||||
0x4d, 0xb4, 0x8e, 0x3e, 0xaf, 0xce, 0xcd, 0x83,
|
||||
0xe5, 0x21, 0x90, 0x95, 0x20, 0x3c, 0x82, 0xb4,
|
||||
0x7c, 0xab, 0x63, 0x9c, 0xae, 0xc3, 0xc9, 0x71,
|
||||
0x1a, 0xec, 0x34, 0x18, 0x47, 0xec, 0x5c, 0x4d,
|
||||
0xed, 0x84,
|
||||
// client hash
|
||||
0x00, 0x14, 0x9c, 0x91, 0x9e, 0x76, 0xcf, 0x1e,
|
||||
0x66, 0x87, 0x5e, 0x29, 0xf1, 0x13, 0x80, 0xea,
|
||||
0x7d, 0xec, 0xae, 0xf9, 0x60, 0x01, 0xd3, 0x6f,
|
||||
0xb7, 0x9e, 0xb2, 0xcd, 0x2d, 0xc8, 0xf8, 0x84,
|
||||
0xb2, 0x9f, 0xc3, 0x7e, 0xb4, 0xbe,
|
||||
// credentials
|
||||
0x00, 0x08, 0x9d, 0xc8, 0x3a, 0xb8, 0x80, 0x4f,
|
||||
0xe3, 0x52, 0xdb, 0x62, 0x9e, 0x97, 0x64, 0x82,
|
||||
0xa8, 0xa1, 0x6b, 0x7e, 0x4d, 0x68, 0x8c, 0x29,
|
||||
0x91, 0x38,
|
||||
]);
|
||||
|
||||
describe('RA2 handshake', function () {
|
||||
let sock;
|
||||
let rfb;
|
||||
let sentData;
|
||||
|
||||
before(() => {
|
||||
FakeWebSocket.replace();
|
||||
sinon.stub(window.crypto, "getRandomValues").callsFake(fakeGetRandomValues);
|
||||
sinon.stub(window.crypto.subtle, "generateKey").callsFake(fakeGeneratekey);
|
||||
});
|
||||
after(() => {
|
||||
FakeWebSocket.restore();
|
||||
window.crypto.getRandomValues.restore();
|
||||
window.crypto.subtle.generateKey.restore();
|
||||
});
|
||||
|
||||
it('should fire the serververification event', function (done) {
|
||||
sentData = new Uint8Array();
|
||||
rfb = new RFB(document.createElement('div'), "ws://example.com");
|
||||
sock = rfb._sock;
|
||||
sock.send = (data) => {
|
||||
let res = new Uint8Array(sentData.length + data.length);
|
||||
res.set(sentData);
|
||||
res.set(data, sentData.length);
|
||||
sentData = res;
|
||||
};
|
||||
rfb._rfbInitState = "Security";
|
||||
rfb._rfbVersion = 3.8;
|
||||
sock._websocket._receiveData(new Uint8Array([1, 6]));
|
||||
rfb.addEventListener("serververification", (e) => {
|
||||
expect(e.detail.publickey).to.eql(receiveData.slice(0, 516));
|
||||
done();
|
||||
});
|
||||
sock._websocket._receiveData(receiveData);
|
||||
});
|
||||
|
||||
it('should handle approveServer and fire the credentialsrequired event', function (done) {
|
||||
rfb.addEventListener("credentialsrequired", (e) => {
|
||||
expect(e.detail.types).to.eql(["password"]);
|
||||
done();
|
||||
});
|
||||
rfb.approveServer();
|
||||
});
|
||||
|
||||
it('should match sendData after sending credentials', function (done) {
|
||||
rfb.addEventListener("securityresult", (event) => {
|
||||
expect(sentData.slice(1)).to.eql(sendData);
|
||||
done();
|
||||
});
|
||||
rfb.sendCredentials({ "password": "123456" });
|
||||
});
|
||||
});
|
||||