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
123e5e74
Commit
123e5e74
authored
Jul 07, 2011
by
Joel Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pull IPv6 support from websockify.
Pull from websockify 247b74950d.
parent
a4ff1f57
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
18 deletions
+32
-18
websocket.py
utils/websocket.py
+22
-10
websockify
utils/websockify
+10
-8
No files found.
utils/websocket.py
View file @
123e5e74
...
@@ -87,17 +87,17 @@ Sec-WebSocket-Accept: %s\r
...
@@ -87,17 +87,17 @@ Sec-WebSocket-Accept: %s\r
class
EClose
(
Exception
):
class
EClose
(
Exception
):
pass
pass
def
__init__
(
self
,
listen_host
=
''
,
listen_port
=
None
,
def
__init__
(
self
,
listen_host
=
''
,
listen_port
=
None
,
source_is_ipv6
=
False
,
verbose
=
False
,
cert
=
''
,
key
=
''
,
ssl_only
=
None
,
verbose
=
False
,
cert
=
''
,
key
=
''
,
ssl_only
=
None
,
daemon
=
False
,
record
=
''
,
web
=
''
):
daemon
=
False
,
record
=
''
,
web
=
''
):
# settings
# settings
self
.
verbose
=
verbose
self
.
verbose
=
verbose
self
.
listen_host
=
listen_host
self
.
listen_host
=
listen_host
self
.
listen_port
=
listen_port
self
.
listen_port
=
listen_port
self
.
ssl_only
=
ssl_only
self
.
ssl_only
=
ssl_only
self
.
daemon
=
daemon
self
.
daemon
=
daemon
self
.
handler_id
=
1
self
.
handler_id
=
1
# Make paths settings absolute
# Make paths settings absolute
self
.
cert
=
os
.
path
.
abspath
(
cert
)
self
.
cert
=
os
.
path
.
abspath
(
cert
)
...
@@ -113,7 +113,7 @@ Sec-WebSocket-Accept: %s\r
...
@@ -113,7 +113,7 @@ Sec-WebSocket-Accept: %s\r
os
.
chdir
(
self
.
web
)
os
.
chdir
(
self
.
web
)
# Sanity checks
# Sanity checks
if
ssl
and
self
.
ssl_only
:
if
not
ssl
and
self
.
ssl_only
:
raise
Exception
(
"No 'ssl' module and SSL-only specified"
)
raise
Exception
(
"No 'ssl' module and SSL-only specified"
)
if
self
.
daemon
and
not
resource
:
if
self
.
daemon
and
not
resource
:
raise
Exception
(
"Module 'resource' required to daemonize"
)
raise
Exception
(
"Module 'resource' required to daemonize"
)
...
@@ -142,6 +142,17 @@ Sec-WebSocket-Accept: %s\r
...
@@ -142,6 +142,17 @@ Sec-WebSocket-Accept: %s\r
#
#
# WebSocketServer static methods
# WebSocketServer static methods
#
#
@
staticmethod
def
addrinfo
(
host
,
port
=
None
):
""" Resolve a host (and optional port) to an IPv4 or IPv6 address.
Returns: family, socktype, proto, canonname, sockaddr
"""
addrs
=
socket
.
getaddrinfo
(
host
,
port
,
0
,
socket
.
SOCK_STREAM
,
socket
.
IPPROTO_TCP
)
if
not
addrs
:
raise
Exception
(
"Could resolve host '
%
s'"
%
self
.
target_host
)
return
addrs
[
0
]
@
staticmethod
@
staticmethod
def
daemonize
(
keepfd
=
None
,
chdir
=
'/'
):
def
daemonize
(
keepfd
=
None
,
chdir
=
'/'
):
os
.
umask
(
0
)
os
.
umask
(
0
)
...
@@ -534,6 +545,7 @@ Sec-WebSocket-Accept: %s\r
...
@@ -534,6 +545,7 @@ Sec-WebSocket-Accept: %s\r
if
not
os
.
path
.
exists
(
self
.
cert
):
if
not
os
.
path
.
exists
(
self
.
cert
):
raise
self
.
EClose
(
"SSL connection but '
%
s' not found"
raise
self
.
EClose
(
"SSL connection but '
%
s' not found"
%
self
.
cert
)
%
self
.
cert
)
retsock
=
None
try
:
try
:
retsock
=
ssl
.
wrap_socket
(
retsock
=
ssl
.
wrap_socket
(
sock
,
sock
,
...
@@ -724,8 +736,8 @@ Sec-WebSocket-Accept: %s\r
...
@@ -724,8 +736,8 @@ Sec-WebSocket-Accept: %s\r
is a WebSockets client then call new_client() method (which must
is a WebSockets client then call new_client() method (which must
be overridden) for each new client connection.
be overridden) for each new client connection.
"""
"""
addr
=
self
.
addrinfo
(
self
.
listen_host
,
self
.
listen_port
)
lsock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
lsock
=
socket
.
socket
(
addr
[
0
],
addr
[
1
]
)
lsock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
lsock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
lsock
.
bind
((
self
.
listen_host
,
self
.
listen_port
))
lsock
.
bind
((
self
.
listen_host
,
self
.
listen_port
))
lsock
.
listen
(
100
)
lsock
.
listen
(
100
)
...
...
utils/websockify
View file @
123e5e74
...
@@ -39,10 +39,10 @@ Traffic Legend:
...
@@ -39,10 +39,10 @@ Traffic Legend:
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
# Save off proxy specific options
# Save off proxy specific options
self
.
target_host
=
kwargs
.
pop
(
'target_host'
)
self
.
target_host
=
kwargs
.
pop
(
'target_host'
)
self
.
target_port
=
kwargs
.
pop
(
'target_port'
)
self
.
target_port
=
kwargs
.
pop
(
'target_port'
)
self
.
wrap_cmd
=
kwargs
.
pop
(
'wrap_cmd'
)
self
.
wrap_cmd
=
kwargs
.
pop
(
'wrap_cmd'
)
self
.
wrap_mode
=
kwargs
.
pop
(
'wrap_mode'
)
self
.
wrap_mode
=
kwargs
.
pop
(
'wrap_mode'
)
# Last 3 timestamps command was run
# Last 3 timestamps command was run
self
.
wrap_times
=
[
0
,
0
,
0
]
self
.
wrap_times
=
[
0
,
0
,
0
]
...
@@ -141,7 +141,8 @@ Traffic Legend:
...
@@ -141,7 +141,8 @@ Traffic Legend:
# Connect to the target
# Connect to the target
self
.
msg
(
"connecting to:
%
s:
%
s"
%
(
self
.
msg
(
"connecting to:
%
s:
%
s"
%
(
self
.
target_host
,
self
.
target_port
))
self
.
target_host
,
self
.
target_port
))
tsock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
addr
=
self
.
addrinfo
(
self
.
target_host
,
self
.
target_port
)
tsock
=
socket
.
socket
(
addr
[
0
],
addr
[
1
])
tsock
.
connect
((
self
.
target_host
,
self
.
target_port
))
tsock
.
connect
((
self
.
target_host
,
self
.
target_port
))
if
self
.
verbose
and
not
self
.
daemon
:
if
self
.
verbose
and
not
self
.
daemon
:
...
@@ -255,18 +256,19 @@ if __name__ == '__main__':
...
@@ -255,18 +256,19 @@ if __name__ == '__main__':
# Parse host:port and convert ports to numbers
# Parse host:port and convert ports to numbers
if
args
[
0
]
.
count
(
':'
)
>
0
:
if
args
[
0
]
.
count
(
':'
)
>
0
:
opts
.
listen_host
,
opts
.
listen_port
=
args
[
0
]
.
split
(
':'
)
opts
.
listen_host
,
sep
,
opts
.
listen_port
=
args
[
0
]
.
rpartition
(
':'
)
else
:
else
:
opts
.
listen_host
,
opts
.
listen_port
=
''
,
args
[
0
]
opts
.
listen_host
,
opts
.
listen_port
=
''
,
args
[
0
]
try
:
opts
.
listen_port
=
int
(
opts
.
listen_port
)
try
:
opts
.
listen_port
=
int
(
opts
.
listen_port
)
except
:
parser
.
error
(
"Error parsing listen port"
)
except
:
parser
.
error
(
"Error parsing listen port"
)
if
opts
.
wrap_cmd
:
if
opts
.
wrap_cmd
:
opts
.
target_host
=
None
opts
.
target_host
=
None
opts
.
target_port
=
None
opts
.
target_port
=
None
else
:
else
:
if
args
[
1
]
.
count
(
':'
)
>
0
:
if
args
[
1
]
.
count
(
':'
)
>
0
:
opts
.
target_host
,
opts
.
target_port
=
args
[
1
]
.
split
(
':'
)
opts
.
target_host
,
sep
,
opts
.
target_port
=
args
[
1
]
.
rpartition
(
':'
)
else
:
else
:
parser
.
error
(
"Error parsing target"
)
parser
.
error
(
"Error parsing target"
)
try
:
opts
.
target_port
=
int
(
opts
.
target_port
)
try
:
opts
.
target_port
=
int
(
opts
.
target_port
)
...
...
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