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
9ec97d86
Commit
9ec97d86
authored
Apr 03, 2010
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Base64 encode/decode for client Javascript.
parent
65e27ddd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
wsproxy.py
wsproxy.py
+11
-11
No files found.
wsproxy.py
View file @
9ec97d86
#!/usr/bin/python
import
sys
,
os
,
socket
,
time
,
traceback
from
base64
import
b64encode
,
b64decode
from
select
import
select
server_handshake
=
"""HTTP/1.1 101 Web Socket Protocol Handshake
\r
...
...
@@ -36,29 +37,28 @@ def proxy(client, target):
if
client
in
ins
:
buf
=
client
.
recv
(
1024
)
if
len
(
buf
)
==
0
:
raise
Exception
(
"Client closed"
)
tqueue
.
append
(
b
uf
[
1
:
-
1
]
)
#print "Client recv: %s (%d)" % (buf[1:-1]
, len(buf))
traffic
(
"}"
)
tqueue
.
append
(
b
64decode
(
buf
[
1
:
-
1
])
)
print
"Client recv:
%
s (
%
d)"
%
(
repr
(
buf
[
1
:
-
1
])
,
len
(
buf
))
#
traffic("}")
if
target
in
ins
:
buf
=
target
.
recv
(
1024
)
if
len
(
buf
)
==
0
:
raise
Exception
(
"Target closed"
)
cqueue
.
append
(
"
\x00
"
+
b
uf
+
"
\xff
"
)
#print "Target recv: %s (%d)" % (buf
, len(buf))
traffic
(
"{"
)
cqueue
.
append
(
"
\x00
"
+
b
64encode
(
buf
)
+
"
\xff
"
)
print
"Target recv:
%
s (
%
d)"
%
(
repr
(
buf
)
,
len
(
buf
))
#
traffic("{")
if
cqueue
and
client
in
outs
:
while
cqueue
:
#print "Client send: %s" % cqueue[0]
print
"Client send:
%
s"
%
repr
(
cqueue
[
0
])
client
.
send
(
cqueue
.
pop
(
0
))
traffic
(
"<"
)
#
traffic("<")
if
tqueue
and
target
in
outs
:
while
tqueue
:
#print "Target send: %s" % tqueue[0]
sys
.
stdout
.
flush
()
print
"Target send:
%
s"
%
repr
(
tqueue
[
0
])
target
.
send
(
tqueue
.
pop
(
0
))
traffic
(
">"
)
#
traffic(">")
def
start_server
(
listen_port
,
target_host
,
target_port
):
lsock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
...
...
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