summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2011-07-07 15:14:41 -0500
committerJoel Martin <github@martintribe.org>2011-07-07 15:14:41 -0500
commit3a39bf60f3815650ec630593c1e259a61d0aad87 (patch)
tree4403a7226a65abdd840a74919088420295a7ec72
parent123e5e74452842ec216612bfbfd27aedc0e04e41 (diff)
downloadnovnc-3a39bf60f3815650ec630593c1e259a61d0aad87.tar.gz
Pull IPv6 and HyBi fixes from websockify.
Pull 7ae8711 from websockify.
-rwxr-xr-xutils/websocket.py12
-rwxr-xr-xutils/websockify4
2 files changed, 9 insertions, 7 deletions
diff --git a/utils/websocket.py b/utils/websocket.py
index 90346a5..b931aa8 100755
--- a/utils/websocket.py
+++ b/utils/websocket.py
@@ -142,15 +142,17 @@ Sec-WebSocket-Accept: %s\r
#
# 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
"""
+ if not host:
+ host = 'localhost'
addrs = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM, socket.IPPROTO_TCP)
if not addrs:
- raise Exception("Could resolve host '%s'" % self.target_host)
+ raise Exception("Could resolve host '%s'" % host)
return addrs[0]
@staticmethod
@@ -492,7 +494,7 @@ Sec-WebSocket-Accept: %s\r
if code != None:
msg = struct.pack(">H%ds" % (len(reason)), code)
- buf = self.encode_hybi(msg, opcode=0x08, base64=False)
+ buf, h, t = self.encode_hybi(msg, opcode=0x08, base64=False)
self.client.send(buf)
elif self.version == "hixie-76":
@@ -596,8 +598,8 @@ Sec-WebSocket-Accept: %s\r
if sys.hexversion < 0x2060000 or not numpy:
raise self.EClose("Python >= 2.6 and numpy module is required for HyBi-07 or greater")
- if ver == '7':
- self.version = "hybi-07"
+ if ver in ['7', '8', '9']:
+ self.version = "hybi-0" + ver
else:
raise self.EClose('Unsupported protocol version %s' % ver)
diff --git a/utils/websockify b/utils/websockify
index 8ee48cb..e05ecab 100755
--- a/utils/websockify
+++ b/utils/websockify
@@ -259,10 +259,10 @@ if __name__ == '__main__':
opts.listen_host, sep, opts.listen_port = args[0].rpartition(':')
else:
opts.listen_host, opts.listen_port = '', args[0]
-
+
try: opts.listen_port = int(opts.listen_port)
except: parser.error("Error parsing listen port")
-
+
if opts.wrap_cmd:
opts.target_host = None
opts.target_port = None