Add listen address to proxy (C and python).

This allows forwarding from an external port to the same port on
localhost (loopback). I.e.

./utils/wsproxy `hostname -f`:5901 localhost:5901
This commit is contained in:
Joel Martin
2010-06-16 12:37:03 -05:00
parent f755ca9631
commit f2898eabd3
5 changed files with 83 additions and 27 deletions

View File

@@ -101,10 +101,10 @@ def do_handshake(sock):
retsock.send(server_handshake % (origin, scheme, host, path))
return retsock
def start_server(listen_port, handler):
def start_server(listen_port, handler, listen_host=''):
lsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
lsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
lsock.bind(('', listen_port))
lsock.bind((listen_host, listen_port))
lsock.listen(100)
while True:
try: