Merge branch 'master' of github.com:kanaka/websockify
This commit is contained in:
commit
471b504799
|
|
@ -11,7 +11,7 @@ as taken from http://docs.python.org/dev/library/ssl.html#certificates
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import socket, optparse, time, os, sys, subprocess
|
import signal, socket, optparse, time, os, sys, subprocess
|
||||||
from select import select
|
from select import select
|
||||||
import websocket
|
import websocket
|
||||||
try: from urllib.parse import parse_qs, urlparse
|
try: from urllib.parse import parse_qs, urlparse
|
||||||
|
|
@ -87,7 +87,7 @@ Traffic Legend:
|
||||||
self.wrap_times.append(time.time())
|
self.wrap_times.append(time.time())
|
||||||
self.wrap_times.pop(0)
|
self.wrap_times.pop(0)
|
||||||
self.cmd = subprocess.Popen(
|
self.cmd = subprocess.Popen(
|
||||||
self.wrap_cmd, env=os.environ)
|
self.wrap_cmd, env=os.environ, preexec_fn=_subprocess_setup)
|
||||||
self.spawn_message = True
|
self.spawn_message = True
|
||||||
|
|
||||||
def started(self):
|
def started(self):
|
||||||
|
|
@ -144,7 +144,7 @@ Traffic Legend:
|
||||||
else:
|
else:
|
||||||
self.run_wrap_cmd()
|
self.run_wrap_cmd()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Routines above this point are run in the master listener
|
# Routines above this point are run in the master listener
|
||||||
# process.
|
# process.
|
||||||
#
|
#
|
||||||
|
|
@ -171,7 +171,7 @@ Traffic Legend:
|
||||||
else:
|
else:
|
||||||
msg = "connecting to: %s:%s" % (
|
msg = "connecting to: %s:%s" % (
|
||||||
self.target_host, self.target_port)
|
self.target_host, self.target_port)
|
||||||
|
|
||||||
if self.ssl_target:
|
if self.ssl_target:
|
||||||
msg += " (using SSL)"
|
msg += " (using SSL)"
|
||||||
self.msg(msg)
|
self.msg(msg)
|
||||||
|
|
@ -291,6 +291,13 @@ Traffic Legend:
|
||||||
self.target_host, self.target_port))
|
self.target_host, self.target_port))
|
||||||
raise self.CClose(closed['code'], closed['reason'])
|
raise self.CClose(closed['code'], closed['reason'])
|
||||||
|
|
||||||
|
|
||||||
|
def _subprocess_setup():
|
||||||
|
# Python installs a SIGPIPE handler by default. This is usually not what
|
||||||
|
# non-Python successfulbprocesses expect.
|
||||||
|
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
||||||
|
|
||||||
|
|
||||||
def websockify_init():
|
def websockify_init():
|
||||||
usage = "\n %prog [options]"
|
usage = "\n %prog [options]"
|
||||||
usage += " [source_addr:]source_port [target_addr:target_port]"
|
usage += " [source_addr:]source_port [target_addr:target_port]"
|
||||||
|
|
@ -338,7 +345,7 @@ def websockify_init():
|
||||||
(opts, args) = parser.parse_args()
|
(opts, args) = parser.parse_args()
|
||||||
|
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if len(args) < 2 and not opts.target_cfg:
|
if len(args) < 2 and not (opts.target_cfg or opts.unix_target):
|
||||||
parser.error("Too few arguments")
|
parser.error("Too few arguments")
|
||||||
if sys.argv.count('--'):
|
if sys.argv.count('--'):
|
||||||
opts.wrap_cmd = args[1:]
|
opts.wrap_cmd = args[1:]
|
||||||
|
|
@ -349,7 +356,7 @@ def websockify_init():
|
||||||
|
|
||||||
if not websocket.ssl and opts.ssl_target:
|
if not websocket.ssl and opts.ssl_target:
|
||||||
parser.error("SSL target requested and Python SSL module not loaded.");
|
parser.error("SSL target requested and Python SSL module not loaded.");
|
||||||
|
|
||||||
if opts.ssl_only and not os.path.exists(opts.cert):
|
if opts.ssl_only and not os.path.exists(opts.cert):
|
||||||
parser.error("SSL only and %s not found" % opts.cert)
|
parser.error("SSL only and %s not found" % opts.cert)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue