Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
noVNC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
noVNC
Commits
d595e656
Commit
d595e656
authored
Sep 08, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JSLint.
parent
2f6a1c2b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
77 deletions
+104
-77
base64.js
include/base64.js
+30
-24
des.js
include/des.js
+37
-28
rfb.js
include/rfb.js
+1
-1
vnc.js
include/vnc.js
+2
-1
playback.js
tests/playback.js
+25
-14
vnc.html
vnc.html
+3
-3
vnc_auto.html
vnc_auto.html
+6
-6
No files found.
include/base64.js
View file @
d595e656
...
@@ -41,18 +41,22 @@
...
@@ -41,18 +41,22 @@
*
*
* ***** END LICENSE BLOCK ***** */
* ***** END LICENSE BLOCK ***** */
Base64
=
{
"use strict"
;
/*jslint white: false, bitwise: false, plusplus: false */
/*global console */
var
Base64
=
{
/* Convert data (an array of integers) to a Base64 string. */
/* Convert data (an array of integers) to a Base64 string. */
toBase64Table
:
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
,
toBase64Table
:
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
,
base64Pad
:
'='
,
base64Pad
:
'='
,
encode
:
function
(
data
)
{
encode
:
function
(
data
)
{
var
result
=
''
;
var
result
=
''
,
var
chrTable
=
Base64
.
toBase64Table
.
split
(
''
);
chrTable
=
Base64
.
toBase64Table
.
split
(
''
),
var
pad
=
Base64
.
base64Pad
;
pad
=
Base64
.
base64Pad
,
var
length
=
data
.
length
;
length
=
data
.
length
,
var
i
;
i
;
// Convert every three bytes to 4 ascii characters.
// Convert every three bytes to 4 ascii characters.
for
(
i
=
0
;
i
<
(
length
-
2
);
i
+=
3
)
{
for
(
i
=
0
;
i
<
(
length
-
2
);
i
+=
3
)
{
result
+=
chrTable
[
data
[
i
]
>>
2
];
result
+=
chrTable
[
data
[
i
]
>>
2
];
...
@@ -65,7 +69,7 @@ encode: function (data) {
...
@@ -65,7 +69,7 @@ encode: function (data) {
if
(
length
%
3
)
{
if
(
length
%
3
)
{
i
=
length
-
(
length
%
3
);
i
=
length
-
(
length
%
3
);
result
+=
chrTable
[
data
[
i
]
>>
2
];
result
+=
chrTable
[
data
[
i
]
>>
2
];
if
((
length
%
3
)
==
2
)
{
if
((
length
%
3
)
==
=
2
)
{
result
+=
chrTable
[((
data
[
i
]
&
0x03
)
<<
4
)
+
(
data
[
i
+
1
]
>>
4
)];
result
+=
chrTable
[((
data
[
i
]
&
0x03
)
<<
4
)
+
(
data
[
i
+
1
]
>>
4
)];
result
+=
chrTable
[(
data
[
i
+
1
]
&
0x0f
)
<<
2
];
result
+=
chrTable
[(
data
[
i
+
1
]
&
0x0f
)
<<
2
];
result
+=
pad
;
result
+=
pad
;
...
@@ -91,26 +95,26 @@ toBinaryTable : [
...
@@ -91,26 +95,26 @@ toBinaryTable : [
],
],
decode
:
function
(
data
,
offset
)
{
decode
:
function
(
data
,
offset
)
{
offset
=
typeof
(
offset
)
!=
'undefined'
?
offset
:
0
;
offset
=
typeof
(
offset
)
!==
'undefined'
?
offset
:
0
;
var
binTable
=
Base64
.
toBinaryTable
;
var
binTable
=
Base64
.
toBinaryTable
,
var
pad
=
Base64
.
base64Pad
;
pad
=
Base64
.
base64Pad
,
var
leftbits
=
0
;
// number of bits decoded, but yet to be appended
result
,
result_length
,
idx
,
i
,
c
,
padding
,
var
leftdata
=
0
;
// bits decoded, but yet to be appended
leftbits
=
0
,
// number of bits decoded, but yet to be appended
leftdata
=
0
,
// bits decoded, but yet to be appended
data_length
=
data
.
indexOf
(
'='
)
-
offset
;
/* Every four characters is 3 resulting numbers */
if
(
data_length
<
0
)
{
data_length
=
data
.
length
-
offset
;
}
var
data_length
=
data
.
indexOf
(
'='
)
-
offset
;
if
(
data_length
<
0
)
data_length
=
data
.
length
-
offset
;
var
result_length
=
(
data_length
>>
2
)
*
3
+
Math
.
floor
((
data_length
%
4
)
/
1.5
);
/* Every four characters is 3 resulting numbers */
var
result
=
new
Array
(
result_length
);
result_length
=
(
data_length
>>
2
)
*
3
+
Math
.
floor
((
data_length
%
4
)
/
1.5
);
result
=
new
Array
(
result_length
);
// Convert one by one.
// Convert one by one.
var
idx
=
0
;
for
(
idx
=
0
,
i
=
offset
;
i
<
data
.
length
;
i
++
)
{
for
(
var
i
=
offset
;
i
<
data
.
length
;
i
++
)
{
c
=
binTable
[
data
.
charCodeAt
(
i
)
&
0x7f
];
var
c
=
binTable
[
data
.
charCodeAt
(
i
)
&
0x7f
];
padding
=
(
data
.
charAt
(
i
)
===
pad
);
var
padding
=
(
data
.
charAt
(
i
)
==
pad
);
// Skip illegal characters and whitespace
// Skip illegal characters and whitespace
if
(
c
==
-
1
)
{
if
(
c
==
=
-
1
)
{
console
.
error
(
"Illegal character '"
+
data
.
charCodeAt
(
i
)
+
"'"
);
console
.
error
(
"Illegal character '"
+
data
.
charCodeAt
(
i
)
+
"'"
);
continue
;
continue
;
}
}
...
@@ -123,16 +127,18 @@ decode: function (data, offset) {
...
@@ -123,16 +127,18 @@ decode: function (data, offset) {
if
(
leftbits
>=
8
)
{
if
(
leftbits
>=
8
)
{
leftbits
-=
8
;
leftbits
-=
8
;
// Append if not padding.
// Append if not padding.
if
(
!
padding
)
if
(
!
padding
)
{
result
[
idx
++
]
=
(
leftdata
>>
leftbits
)
&
0xff
;
result
[
idx
++
]
=
(
leftdata
>>
leftbits
)
&
0xff
;
}
leftdata
&=
(
1
<<
leftbits
)
-
1
;
leftdata
&=
(
1
<<
leftbits
)
-
1
;
}
}
}
}
// If there are any bits left, the base64 string was corrupted
// If there are any bits left, the base64 string was corrupted
if
(
leftbits
)
if
(
leftbits
)
{
throw
{
name
:
'Base64-Error'
,
throw
{
name
:
'Base64-Error'
,
message
:
'Corrupted base64 string'
};
message
:
'Corrupted base64 string'
};
}
return
result
;
return
result
;
}
}
...
...
include/des.js
View file @
d595e656
...
@@ -77,7 +77,10 @@
...
@@ -77,7 +77,10 @@
* fine Java utilities: http://www.acme.com/java/
* fine Java utilities: http://www.acme.com/java/
*/
*/
DES
=
{
"use strict"
;
/*jslint white: false, bitwise: false, plusplus: false */
var
DES
=
{
// Tables, permutations, S-boxes, etc.
// Tables, permutations, S-boxes, etc.
...
@@ -107,7 +110,7 @@ DES = {
...
@@ -107,7 +110,7 @@ DES = {
46
,
54
,
29
,
39
,
50
,
44
,
46
,
54
,
29
,
39
,
50
,
44
,
32
,
47
,
43
,
48
,
38
,
55
,
32
,
47
,
43
,
48
,
38
,
55
,
33
,
52
,
45
,
41
,
49
,
35
,
33
,
52
,
45
,
41
,
49
,
35
,
28
,
31
,
],
28
,
31
],
SP1
:
[
0x01010400
,
0x00000000
,
0x00010000
,
SP1
:
[
0x01010400
,
0x00000000
,
0x00010000
,
0x01010404
,
0x01010004
,
0x00010404
,
0x00000004
,
0x00010000
,
0x01010404
,
0x01010004
,
0x00010404
,
0x00000004
,
0x00010000
,
0x00000400
,
0x01010400
,
0x01010404
,
0x00000400
,
0x01000404
,
0x00000400
,
0x01010400
,
0x01010404
,
0x00000400
,
0x01000404
,
...
@@ -237,52 +240,57 @@ DES = {
...
@@ -237,52 +240,57 @@ DES = {
// Turn an 8-byte key into internal keys.
// Turn an 8-byte key into internal keys.
deskey
:
function
(
keyBlock
,
encrypting
,
KnL
)
{
deskey
:
function
(
keyBlock
,
encrypting
,
KnL
)
{
var
i
,
j
,
l
,
m
,
n
;
var
i
,
j
,
l
,
m
,
n
,
var
pc1m
=
new
Array
(
56
);
pc1m
=
new
Array
(
56
),
var
pcr
=
new
Array
(
56
);
pcr
=
new
Array
(
56
),
var
kn
=
new
Array
(
32
);
kn
=
new
Array
(
32
);
for
(
j
=
0
;
j
<
56
;
++
j
)
{
for
(
j
=
0
;
j
<
56
;
++
j
)
{
l
=
DES
.
pc1
[
j
];
l
=
DES
.
pc1
[
j
];
m
=
l
&
07
;
m
=
l
&
0
x
7
;
pc1m
[
j
]
=
((
keyBlock
[
l
>>>
3
]
&
DES
.
bytebit
[
m
])
!=
0
)
?
1
:
0
;
pc1m
[
j
]
=
((
keyBlock
[
l
>>>
3
]
&
DES
.
bytebit
[
m
])
!=
=
0
)
?
1
:
0
;
}
}
for
(
i
=
0
;
i
<
16
;
++
i
)
{
for
(
i
=
0
;
i
<
16
;
++
i
)
{
if
(
encrypting
)
if
(
encrypting
)
{
m
=
i
<<
1
;
m
=
i
<<
1
;
else
}
else
{
m
=
(
15
-
i
)
<<
1
;
m
=
(
15
-
i
)
<<
1
;
}
n
=
m
+
1
;
n
=
m
+
1
;
kn
[
m
]
=
kn
[
n
]
=
0
;
kn
[
m
]
=
kn
[
n
]
=
0
;
for
(
j
=
0
;
j
<
28
;
++
j
)
{
for
(
j
=
0
;
j
<
28
;
++
j
)
{
l
=
j
+
DES
.
totrot
[
i
];
l
=
j
+
DES
.
totrot
[
i
];
if
(
l
<
28
)
if
(
l
<
28
)
{
pcr
[
j
]
=
pc1m
[
l
];
pcr
[
j
]
=
pc1m
[
l
];
else
}
else
{
pcr
[
j
]
=
pc1m
[
l
-
28
];
pcr
[
j
]
=
pc1m
[
l
-
28
];
}
}
}
for
(
j
=
28
;
j
<
56
;
++
j
)
{
for
(
j
=
28
;
j
<
56
;
++
j
)
{
l
=
j
+
DES
.
totrot
[
i
];
l
=
j
+
DES
.
totrot
[
i
];
if
(
l
<
56
)
if
(
l
<
56
)
{
pcr
[
j
]
=
pc1m
[
l
];
pcr
[
j
]
=
pc1m
[
l
];
else
}
else
{
pcr
[
j
]
=
pc1m
[
l
-
28
];
pcr
[
j
]
=
pc1m
[
l
-
28
];
}
}
}
for
(
j
=
0
;
j
<
24
;
++
j
)
{
for
(
j
=
0
;
j
<
24
;
++
j
)
{
if
(
pcr
[
DES
.
pc2
[
j
]]
!=
0
)
if
(
pcr
[
DES
.
pc2
[
j
]]
!=
=
0
)
{
kn
[
m
]
|=
DES
.
bigbyte
[
j
];
kn
[
m
]
|=
DES
.
bigbyte
[
j
];
if
(
pcr
[
DES
.
pc2
[
j
+
24
]]
!=
0
)
}
if
(
pcr
[
DES
.
pc2
[
j
+
24
]]
!==
0
)
{
kn
[
n
]
|=
DES
.
bigbyte
[
j
];
kn
[
n
]
|=
DES
.
bigbyte
[
j
];
}
}
}
}
}
DES
.
cookey
(
kn
,
KnL
);
DES
.
cookey
(
kn
,
KnL
);
},
},
cookey
:
function
(
raw
,
KnL
)
{
cookey
:
function
(
raw
,
KnL
)
{
var
raw0
,
raw1
;
var
raw0
,
raw1
,
var
rawi
,
KnLi
;
rawi
,
KnLi
,
var
i
;
i
;
for
(
i
=
0
,
rawi
=
0
,
KnLi
=
0
;
i
<
16
;
++
i
)
{
for
(
i
=
0
,
rawi
=
0
,
KnLi
=
0
;
i
<
16
;
++
i
)
{
raw0
=
raw
[
rawi
++
];
raw0
=
raw
[
rawi
++
];
...
@@ -320,9 +328,9 @@ DES = {
...
@@ -320,9 +328,9 @@ DES = {
// The DES function.
// The DES function.
des
:
function
(
inInts
,
outInts
,
keys
)
{
des
:
function
(
inInts
,
outInts
,
keys
)
{
var
fval
,
work
,
right
,
leftt
;
var
fval
,
work
,
right
,
leftt
,
var
round
;
round
,
var
keysi
=
0
;
keysi
=
0
;
leftt
=
inInts
[
0
];
leftt
=
inInts
[
0
];
right
=
inInts
[
1
];
right
=
inInts
[
1
];
...
@@ -401,25 +409,26 @@ DES = {
...
@@ -401,25 +409,26 @@ DES = {
// / Squash bytes down to ints.
// / Squash bytes down to ints.
squashBytesToInts
:
function
(
inBytes
,
inOff
,
outInts
,
outOff
,
intLen
)
{
squashBytesToInts
:
function
(
inBytes
,
inOff
,
outInts
,
outOff
,
intLen
)
{
for
(
var
i
=
0
;
i
<
intLen
;
++
i
)
for
(
var
i
=
0
;
i
<
intLen
;
++
i
)
{
outInts
[
outOff
+
i
]
=
((
inBytes
[
inOff
+
i
*
4
]
&
0xff
)
<<
24
)
outInts
[
outOff
+
i
]
=
((
inBytes
[
inOff
+
i
*
4
]
&
0xff
)
<<
24
)
|
((
inBytes
[
inOff
+
i
*
4
+
1
]
&
0xff
)
<<
16
)
|
((
inBytes
[
inOff
+
i
*
4
+
1
]
&
0xff
)
<<
16
)
|
((
inBytes
[
inOff
+
i
*
4
+
2
]
&
0xff
)
<<
8
)
|
((
inBytes
[
inOff
+
i
*
4
+
2
]
&
0xff
)
<<
8
)
|
(
inBytes
[
inOff
+
i
*
4
+
3
]
&
0xff
);
|
(
inBytes
[
inOff
+
i
*
4
+
3
]
&
0xff
);
}
},
},
// / Spread ints into unsigned bytes.
// / Spread ints into unsigned bytes.
spreadIntsToBytes
:
function
(
inInts
,
inOff
,
outBytes
,
outOff
,
intLen
)
{
spreadIntsToBytes
:
function
(
inInts
,
inOff
,
outBytes
,
outOff
,
intLen
)
{
for
(
var
i
=
0
;
i
<
intLen
;
++
i
)
{
var
i
,
j
,
idx
;
for
(
i
=
0
;
i
<
intLen
;
++
i
)
{
outBytes
[
outOff
+
i
*
4
]
=
(
inInts
[
inOff
+
i
]
>>>
24
)
%
256
;
outBytes
[
outOff
+
i
*
4
]
=
(
inInts
[
inOff
+
i
]
>>>
24
)
%
256
;
outBytes
[
outOff
+
i
*
4
+
1
]
=
(
inInts
[
inOff
+
i
]
>>>
16
)
%
256
;
outBytes
[
outOff
+
i
*
4
+
1
]
=
(
inInts
[
inOff
+
i
]
>>>
16
)
%
256
;
outBytes
[
outOff
+
i
*
4
+
2
]
=
(
inInts
[
inOff
+
i
]
>>>
8
)
%
256
;
outBytes
[
outOff
+
i
*
4
+
2
]
=
(
inInts
[
inOff
+
i
]
>>>
8
)
%
256
;
outBytes
[
outOff
+
i
*
4
+
3
]
=
(
inInts
[
inOff
+
i
])
%
256
;
outBytes
[
outOff
+
i
*
4
+
3
]
=
(
inInts
[
inOff
+
i
])
%
256
;
}
}
/* Make unsigned */
/* Make unsigned */
var
idx
;
for
(
i
=
0
;
i
<
intLen
;
++
i
)
{
for
(
var
i
=
0
;
i
<
intLen
;
++
i
)
{
for
(
j
=
0
;
j
<
4
;
j
++
)
{
for
(
var
j
=
0
;
j
<
4
;
j
++
)
{
idx
=
outOff
+
i
*
4
+
j
;
idx
=
outOff
+
i
*
4
+
j
;
if
(
outBytes
[
idx
]
<
0
)
{
if
(
outBytes
[
idx
]
<
0
)
{
outBytes
[
idx
]
+=
256
;
outBytes
[
idx
]
+=
256
;
...
@@ -428,4 +437,4 @@ DES = {
...
@@ -428,4 +437,4 @@ DES = {
}
}
}
}
}
}
;
include/rfb.js
View file @
d595e656
...
@@ -112,7 +112,7 @@ var that = {}, // Public API interface
...
@@ -112,7 +112,7 @@ var that = {}, // Public API interface
fbu_rt_start
:
0
,
fbu_rt_start
:
0
,
fbu_rt_total
:
0
,
fbu_rt_total
:
0
,
fbu_rt_cnt
:
0
,
fbu_rt_cnt
:
0
},
},
test_mode
=
false
,
test_mode
=
false
,
...
...
include/vnc.js
View file @
d595e656
...
@@ -7,7 +7,8 @@
...
@@ -7,7 +7,8 @@
*/
*/
"use strict"
;
"use strict"
;
/*global window, VNC_uri_prefix */
/*jslint evil: true */
/*global window, document, VNC_uri_prefix */
// Globals defined here
// Globals defined here
var
VNC_native_ws
,
WebSocket__swfLocation
;
var
VNC_native_ws
,
WebSocket__swfLocation
;
...
...
tests/playback.js
View file @
d595e656
/*
* noVNC: HTML5 VNC client
* Copyright (C) 2010 Joel Martin
* Licensed under LGPL-3 (see LICENSE.LGPL-3)
*/
"use strict"
;
/*jslint browser: true, white: false */
/*global Util, VNC_frame_data, finish */
var
rfb
,
mode
,
test_state
,
frame_idx
,
frame_length
,
var
rfb
,
mode
,
test_state
,
frame_idx
,
frame_length
,
iteration
,
iterations
,
istart_time
;
iteration
,
iterations
,
istart_time
,
// Pre-declarations for jslint
send_array
,
next_iteration
,
queue_next_packet
,
do_packet
;
// Override send_array
// Override send_array
send_array
=
function
(
arr
)
{
send_array
=
function
(
arr
)
{
// Stub out send_array
// Stub out send_array
}
};
function
next_iteration
()
{
var
time
,
iter_time
,
end_time
;
next_iteration
=
function
()
{
if
(
iteration
===
0
)
{
if
(
iteration
===
0
)
{
frame_length
=
VNC_frame_data
.
length
;
frame_length
=
VNC_frame_data
.
length
;
test_state
=
'running'
;
test_state
=
'running'
;
...
@@ -18,7 +29,7 @@ function next_iteration () {
...
@@ -18,7 +29,7 @@ function next_iteration () {
if
(
test_state
!==
'running'
)
{
return
;
}
if
(
test_state
!==
'running'
)
{
return
;
}
iteration
++
;
iteration
+=
1
;
if
(
iteration
>
iterations
)
{
if
(
iteration
>
iterations
)
{
finish
();
finish
();
return
;
return
;
...
@@ -30,10 +41,10 @@ function next_iteration () {
...
@@ -30,10 +41,10 @@ function next_iteration () {
queue_next_packet
();
queue_next_packet
();
}
}
;
function
queue_next_packet
()
{
queue_next_packet
=
function
()
{
var
frame
,
now
,
foffset
,
toffset
,
delay
;
var
frame
,
foffset
,
toffset
,
delay
;
if
(
test_state
!==
'running'
)
{
return
;
}
if
(
test_state
!==
'running'
)
{
return
;
}
frame
=
VNC_frame_data
[
frame_idx
];
frame
=
VNC_frame_data
[
frame_idx
];
...
@@ -66,14 +77,14 @@ function queue_next_packet () {
...
@@ -66,14 +77,14 @@ function queue_next_packet () {
}
else
{
}
else
{
setTimeout
(
do_packet
,
1
);
setTimeout
(
do_packet
,
1
);
}
}
}
}
;
function
do_packet
()
{
do_packet
=
function
()
{
//Util.Debug("Processing frame: " + frame_idx);
//Util.Debug("Processing frame: " + frame_idx);
frame
=
VNC_frame_data
[
frame_idx
];
var
frame
=
VNC_frame_data
[
frame_idx
];
rfb
.
recv_message
({
'data'
:
frame
.
slice
(
frame
.
indexOf
(
'{'
,
1
)
+
1
)});
rfb
.
recv_message
({
'data'
:
frame
.
slice
(
frame
.
indexOf
(
'{'
,
1
)
+
1
)});
frame_idx
+=
1
;
frame_idx
+=
1
;
queue_next_packet
();
queue_next_packet
();
}
}
;
vnc.html
View file @
d595e656
<!--
noVNC example: simple example using default controls
-->
<html>
<html>
<!--
noVNC example: simple example using default controls
-->
<head>
<head>
<title>
VNC Client
</title>
<title>
VNC Client
</title>
<link
rel=
"stylesheet"
href=
"include/plain.css"
>
<link
rel=
"stylesheet"
href=
"include/plain.css"
>
...
...
vnc_auto.html
View file @
d595e656
<!--
<html>
noVNC Example: Automatically connect on page load.
<!--
noVNC Example: Automatically connect on page load.
Connect parameters are provided in query string:
Connect parameters are provided in query string:
http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
http://example.com/?host=HOST&port=PORT&encrypt=1&true_color=1
-->
-->
<html>
<head>
<head>
<title>
VNC Client
</title>
<title>
VNC Client
</title>
<link
rel=
"stylesheet"
href=
"include/plain.css"
title=
"plain"
>
<link
rel=
"stylesheet"
href=
"include/plain.css"
title=
"plain"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment