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
a9469926
Commit
a9469926
authored
14 years ago
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove sequence code in client and proxies.
parent
2b71a4db
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
88 deletions
+7
-88
vnc.js
include/vnc.js
+2
-60
websocket.c
utils/websocket.c
+1
-12
websocket.h
utils/websocket.h
+0
-2
websocket.py
utils/websocket.py
+4
-14
No files found.
include/vnc.js
View file @
a9469926
...
...
@@ -135,7 +135,6 @@ load: function () {
WebSocket
.
__swfLocation
=
get_VNC_uri_prefix
()
+
"web-socket-js/WebSocketMain.swf"
;
WebSocket
.
__initialize
();
RFB
.
use_seq
=
true
;
RFB
.
updateState
(
'disconnected'
,
'Disconnected'
);
}
}
...
...
@@ -224,12 +223,9 @@ clipboardPasteFrom: function (text) {
ws
:
null
,
// Web Socket object
sendID
:
null
,
scanID
:
null
,
// TIGHT_PNG render image scanner
use_seq
:
false
,
// Receive and send queues
RQ
:
[],
// Receive Queue
RQ_reorder
:
[],
// Receive Queue re-order list
RQ_seq_num
:
0
,
// Expected sequence number
SQ
:
""
,
// Send Queue
encHandlers
:
{},
...
...
@@ -1161,13 +1157,8 @@ recv_message: function(e) {
//console.log(">> recv_message");
try
{
if
(
RFB
.
use_seq
)
{
RFB
.
recv_message_reorder
(
e
);
}
else
{
RFB
.
decode_message
(
e
.
data
,
0
);
RFB
.
handle_message
();
}
RFB
.
decode_message
(
e
.
data
,
0
);
RFB
.
handle_message
();
}
catch
(
exc
)
{
if
(
typeof
exc
.
stack
!==
'undefined'
)
{
console
.
log
(
"recv_message, caught exception: "
+
exc
.
stack
);
...
...
@@ -1185,50 +1176,6 @@ recv_message: function(e) {
//console.log("<< recv_message");
},
recv_message_reorder
:
function
(
e
)
{
//console.log(">> recv_message_reorder");
var
offset
,
seq_num
,
i
;
offset
=
e
.
data
.
indexOf
(
":"
)
+
1
;
seq_num
=
parseInt
(
e
.
data
.
substr
(
0
,
offset
-
1
),
10
);
if
(
RFB
.
RQ_seq_num
===
seq_num
)
{
RFB
.
decode_message
(
e
.
data
,
offset
);
RFB
.
RQ_seq_num
+=
1
;
}
else
{
console
.
warn
(
"sequence number mismatch: expected "
+
RFB
.
RQ_seq_num
+
", got "
+
seq_num
);
if
(
RFB
.
RQ_reorder
.
length
>
40
)
{
RFB
.
updateState
(
'failed'
,
"Re-order queue too long"
);
}
else
{
RFB
.
RQ_reorder
=
RFB
.
RQ_reorder
.
concat
(
e
.
data
.
substr
(
0
));
i
=
0
;
while
(
i
<
RFB
.
RQ_reorder
.
length
)
{
offset
=
RFB
.
RQ_reorder
[
i
].
indexOf
(
":"
)
+
1
;
seq_num
=
parseInt
(
RFB
.
RQ_reorder
[
i
].
substr
(
0
,
offset
-
1
),
10
);
//console.log("Searching reorder list item " +
// i + ", seq_num " + seq_num);
if
(
seq_num
===
RFB
.
RQ_seq_num
)
{
/* Remove it from reorder queue, decode it and
* add it to the receive queue */
console
.
log
(
"Found re-ordered packet seq_num "
+
seq_num
);
RFB
.
decode_message
(
RFB
.
RQ_reorder
.
splice
(
i
,
1
)[
0
],
offset
);
RFB
.
RQ_seq_num
+=
1
;
i
=
0
;
// Start search again for next one
}
else
{
i
+=
1
;
}
}
}
}
if
(
RFB
.
RQ
.
length
>
0
)
{
RFB
.
handle_message
();
}
//console.log("<< recv_message_reorder");
},
handle_message
:
function
()
{
//console.log("RQ.slice(0,20): " + RFB.RQ.slice(0,20) + " (" + RFB.RQ.length + ")");
switch
(
RFB
.
state
)
{
...
...
@@ -1443,9 +1390,6 @@ init_ws: function () {
if
(
RFB
.
b64encode
)
{
vars
.
push
(
"b64encode"
);
}
if
(
RFB
.
use_seq
)
{
vars
.
push
(
"seq_num"
);
}
if
(
vars
.
length
>
0
)
{
uri
+=
"?"
+
vars
.
join
(
"&"
);
}
...
...
@@ -1499,8 +1443,6 @@ init_vars: function () {
RFB
.
cuttext
=
'none'
;
RFB
.
ct_length
=
0
;
RFB
.
RQ
=
[];
RFB
.
RQ_reorder
=
[];
RFB
.
RQ_seq_num
=
0
;
RFB
.
SQ
=
""
;
RFB
.
FBU
.
rects
=
0
;
RFB
.
FBU
.
subrects
=
0
;
// RRE and HEXTILE
...
...
This diff is collapsed.
Click to expand it.
utils/websocket.c
View file @
a9469926
...
...
@@ -187,10 +187,6 @@ int encode(u_char const *src, size_t srclength, char *target, size_t targsize) {
int
i
,
sz
=
0
,
len
=
0
;
unsigned
char
chr
;
target
[
sz
++
]
=
'\x00'
;
if
(
client_settings
.
do_seq_num
)
{
sz
+=
sprintf
(
target
+
sz
,
"%d:"
,
client_settings
.
seq_num
);
client_settings
.
seq_num
++
;
}
if
(
client_settings
.
do_b64encode
)
{
len
=
__b64_ntop
(
src
,
srclength
,
target
+
sz
,
targsize
-
sz
);
if
(
len
<
0
)
{
...
...
@@ -383,8 +379,6 @@ ws_ctx_t *do_handshake(int sock) {
// Reset settings
client_settings
.
do_b64encode
=
0
;
client_settings
.
do_seq_num
=
0
;
client_settings
.
seq_num
=
0
;
// Peek, but don't read the data
len
=
recv
(
sock
,
handshake
,
1024
,
MSG_PEEK
);
...
...
@@ -449,11 +443,6 @@ ws_ctx_t *do_handshake(int sock) {
printf
(
" b64encode=1
\n
"
);
client_settings
.
do_b64encode
=
1
;
}
arg_idx
=
strstr
(
args_start
,
"seq_num"
);
if
(
arg_idx
&&
arg_idx
<
args_end
)
{
printf
(
" seq_num=1
\n
"
);
client_settings
.
do_seq_num
=
1
;
}
}
sprintf
(
response
,
server_handshake
,
pre
,
headers
.
origin
,
pre
,
scheme
,
...
...
@@ -569,7 +558,7 @@ void start_server() {
/* Calculate dbufsize based on client_settings */
if
(
client_settings
.
do_b64encode
)
{
/* base64 is 4 bytes for every 3
* 20 for WS '\x00' / '\xff'
, seq_num
and good measure */
* 20 for WS '\x00' / '\xff' and good measure */
dbufsize
=
(
bufsize
*
3
)
/
4
-
20
;
}
else
{
/* UTF-8 encoding is up to 2X larger */
...
...
This diff is collapsed.
Click to expand it.
utils/websocket.h
View file @
a9469926
...
...
@@ -18,8 +18,6 @@ typedef struct {
typedef
struct
{
int
do_b64encode
;
int
do_seq_num
;
int
seq_num
;
}
client_settings_t
;
typedef
struct
{
...
...
This diff is collapsed.
Click to expand it.
utils/websocket.py
View file @
a9469926
...
...
@@ -23,10 +23,7 @@ settings = {
'daemon'
:
True
,
'record'
:
None
,
}
client_settings
=
{
'b64encode'
:
False
,
'seq_num'
:
False
,
}
send_seq
=
0
'b64encode'
:
False
,
}
server_handshake
=
"""HTTP/1.1 101 Web Socket Protocol Handshake
\r
Upgrade: WebSocket
\r
...
...
@@ -44,18 +41,13 @@ def traffic(token="."):
sys
.
stdout
.
flush
()
def
encode
(
buf
):
global
send_seq
if
client_settings
[
'b64encode'
]:
buf
=
b64encode
(
buf
)
else
:
# Modified UTF-8 encode
buf
=
buf
.
decode
(
'latin-1'
)
.
encode
(
'utf-8'
)
.
replace
(
"
\x00
"
,
"
\xc4\x80
"
)
if
client_settings
[
'seq_num'
]:
send_seq
+=
1
return
"
\x00
%
d:
%
s
\xff
"
%
(
send_seq
-
1
,
buf
)
else
:
return
"
\x00
%
s
\xff
"
%
buf
return
"
\x00
%
s
\xff
"
%
buf
def
decode
(
buf
):
""" Parse out WebSocket packets. """
...
...
@@ -100,11 +92,9 @@ def gen_md5(keys):
def
do_handshake
(
sock
):
global
client_settings
,
send_seq
global
client_settings
client_settings
[
'b64encode'
]
=
False
client_settings
[
'seq_num'
]
=
False
send_seq
=
0
# Peek, but don't read the data
handshake
=
sock
.
recv
(
1024
,
socket
.
MSG_PEEK
)
...
...
@@ -143,7 +133,7 @@ def do_handshake(sock):
cvars
=
h
[
'path'
]
.
partition
(
'?'
)[
2
]
.
partition
(
'#'
)[
0
]
.
split
(
'&'
)
for
cvar
in
[
c
for
c
in
cvars
if
c
]:
name
,
_
,
val
=
cvar
.
partition
(
'='
)
if
name
not
in
[
'b64encode'
,
'seq_num'
]:
continue
if
name
not
in
[
'b64encode'
]:
continue
value
=
val
and
val
or
True
client_settings
[
name
]
=
value
print
"
%
s=
%
s"
%
(
name
,
value
)
...
...
This diff is collapsed.
Click to expand it.
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