parent
de4acf0752
commit
4aa05c7499
67
setup.py
67
setup.py
|
|
@ -5,41 +5,42 @@ name = 'websockify'
|
|||
long_description = open("README.md").read() + "\n" + \
|
||||
open("CHANGES.txt").read() + "\n"
|
||||
|
||||
setup(name=name,
|
||||
version=version,
|
||||
description="Websockify.",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
classifiers=[
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
],
|
||||
python_requires='>=3.6',
|
||||
keywords='noVNC websockify',
|
||||
license='LGPLv3',
|
||||
url="https://github.com/novnc/websockify",
|
||||
author="Joel Martin",
|
||||
author_email="github@martintribe.org",
|
||||
|
||||
packages=['websockify'],
|
||||
include_package_data=True,
|
||||
install_requires=[
|
||||
'numpy', 'requests',
|
||||
setup(
|
||||
name=name,
|
||||
version=version,
|
||||
description="Websockify.",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
classifiers=[
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
],
|
||||
python_requires='>=3.6',
|
||||
keywords='noVNC websockify',
|
||||
license='LGPLv3',
|
||||
url="https://github.com/novnc/websockify",
|
||||
author="Joel Martin",
|
||||
author_email="github@martintribe.org",
|
||||
packages=['websockify'],
|
||||
include_package_data=True,
|
||||
install_requires=[
|
||||
'numpy',
|
||||
'requests',
|
||||
'jwcrypto',
|
||||
'redis',
|
||||
],
|
||||
zip_safe=False,
|
||||
entry_points={
|
||||
],
|
||||
zip_safe=False,
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'websockify = websockify.websocketproxy:websockify_init',
|
||||
]
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -57,13 +57,13 @@ class WebSocketEcho(WebSockifyRequestHandler):
|
|||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser(usage="%prog [options] listen_port")
|
||||
parser.add_option("--verbose", "-v", action="store_true",
|
||||
help="verbose messages and per frame traffic")
|
||||
help="verbose messages and per frame traffic")
|
||||
parser.add_option("--cert", default="self.pem",
|
||||
help="SSL certificate file")
|
||||
help="SSL certificate file")
|
||||
parser.add_option("--key", default=None,
|
||||
help="SSL key file (if separate from cert)")
|
||||
help="SSL key file (if separate from cert)")
|
||||
parser.add_option("--ssl-only", action="store_true",
|
||||
help="disallow non-encrypted connections")
|
||||
help="disallow non-encrypted connections")
|
||||
(opts, args) = parser.parse_args()
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -133,13 +133,13 @@ class WebSocketLoad(WebSockifyRequestHandler):
|
|||
if __name__ == '__main__':
|
||||
parser = optparse.OptionParser(usage="%prog [options] listen_port")
|
||||
parser.add_option("--verbose", "-v", action="store_true",
|
||||
help="verbose messages and per frame traffic")
|
||||
help="verbose messages and per frame traffic")
|
||||
parser.add_option("--cert", default="self.pem",
|
||||
help="SSL certificate file")
|
||||
help="SSL certificate file")
|
||||
parser.add_option("--key", default=None,
|
||||
help="SSL key file (if separate from cert)")
|
||||
help="SSL key file (if separate from cert)")
|
||||
parser.add_option("--ssl-only", action="store_true",
|
||||
help="disallow non-encrypted connections")
|
||||
help="disallow non-encrypted connections")
|
||||
(opts, args) = parser.parse_args()
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ class JWSTokenTestCase(unittest.TestCase):
|
|||
jwt_token = jwt.JWT({"alg": "RS256"}, {'host': "remote_host", 'port': "remote_port"})
|
||||
jwt_token.make_signed_token(private_key)
|
||||
jwe_token = jwt.JWT(header={"alg": "RSA-OAEP", "enc": "A256CBC-HS512"},
|
||||
claims=jwt_token.serialize())
|
||||
claims=jwt_token.serialize())
|
||||
jwe_token.make_encrypted_token(public_key)
|
||||
|
||||
result = plugin.lookup(jwt_token.serialize())
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ class TokenRedis(BasePlugin):
|
|||
self._namespace += ":"
|
||||
|
||||
logger.info("TokenRedis backend initialized (%s:%s)" %
|
||||
(self._server, self._port))
|
||||
(self._server, self._port))
|
||||
except ValueError:
|
||||
logger.error("The provided --token-source='%s' is not in the "
|
||||
"expected format <host>[:<port>[:<db>[:<password>[:<namespace>]]]]" %
|
||||
|
|
@ -375,5 +375,5 @@ class UnixDomainSocketDirectory(BasePlugin):
|
|||
|
||||
return ['unix_socket', uds_path]
|
||||
except Exception as e:
|
||||
logger.error("Error finding unix domain socket: %s" % str(e))
|
||||
return None
|
||||
logger.error("Error finding unix domain socket: %s" % str(e))
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -772,7 +772,7 @@ class WebSocket:
|
|||
dtype = dtype.newbyteorder('>')
|
||||
mask = numpy.frombuffer(mask, dtype, count=(plen % 4))
|
||||
data = numpy.frombuffer(buf, dtype,
|
||||
offset=plen - (plen % 4), count=(plen % 4))
|
||||
offset=plen - (plen % 4), count=(plen % 4))
|
||||
c = numpy.bitwise_xor(data, mask).tobytes()
|
||||
return b + c
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ Traffic Legend:
|
|||
msg = "connecting to unix socket: %s" % self.server.unix_target
|
||||
else:
|
||||
msg = "connecting to: %s:%s" % (
|
||||
self.server.target_host, self.server.target_port)
|
||||
self.server.target_host, self.server.target_port)
|
||||
|
||||
if self.server.ssl_target:
|
||||
msg += " (using SSL)"
|
||||
|
|
@ -110,10 +110,10 @@ Traffic Legend:
|
|||
|
||||
try:
|
||||
tsock = websockifyserver.WebSockifyServer.socket(self.server.target_host,
|
||||
self.server.target_port,
|
||||
connect=True,
|
||||
use_ssl=self.server.ssl_target,
|
||||
unix_socket=self.server.unix_target)
|
||||
self.server.target_port,
|
||||
connect=True,
|
||||
use_ssl=self.server.ssl_target,
|
||||
unix_socket=self.server.unix_target)
|
||||
except Exception as e:
|
||||
self.log_message("Failed to connect to %s:%s: %s",
|
||||
self.server.target_host, self.server.target_port, e)
|
||||
|
|
@ -136,7 +136,7 @@ Traffic Legend:
|
|||
tsock.close()
|
||||
if self.verbose:
|
||||
self.log_message("%s:%s: Closed target",
|
||||
self.server.target_host, self.server.target_port)
|
||||
self.server.target_host, self.server.target_port)
|
||||
|
||||
def get_target(self, target_plugin):
|
||||
"""
|
||||
|
|
@ -249,7 +249,7 @@ Traffic Legend:
|
|||
# TODO: What about blocking on client socket?
|
||||
if self.verbose:
|
||||
self.log_message("%s:%s: Client closed connection",
|
||||
self.server.target_host, self.server.target_port)
|
||||
self.server.target_host, self.server.target_port)
|
||||
raise self.CClose(closed['code'], closed['reason'])
|
||||
|
||||
if target in outs:
|
||||
|
|
@ -279,7 +279,7 @@ Traffic Legend:
|
|||
|
||||
if self.verbose:
|
||||
self.log_message("%s:%s: Target closed connection",
|
||||
self.server.target_host, self.server.target_port)
|
||||
self.server.target_host, self.server.target_port)
|
||||
raise self.CClose(1000, "Target closed")
|
||||
|
||||
cqueue.append(buf)
|
||||
|
|
@ -351,7 +351,7 @@ class WebSocketProxy(websockifyserver.WebSockifyServer):
|
|||
self.wrap_times.append(time.time())
|
||||
self.wrap_times.pop(0)
|
||||
self.cmd = subprocess.Popen(
|
||||
self.wrap_cmd, env=os.environ, preexec_fn=_subprocess_setup)
|
||||
self.wrap_cmd, env=os.environ, preexec_fn=_subprocess_setup)
|
||||
self.spawn_message = True
|
||||
|
||||
def started(self):
|
||||
|
|
@ -470,72 +470,72 @@ def websockify_init():
|
|||
usage += " [source_addr:]source_port -- WRAP_COMMAND_LINE"
|
||||
parser = optparse.OptionParser(usage=usage)
|
||||
parser.add_option("--verbose", "-v", action="store_true",
|
||||
help="verbose messages")
|
||||
help="verbose messages")
|
||||
parser.add_option("--traffic", action="store_true",
|
||||
help="per frame traffic")
|
||||
help="per frame traffic")
|
||||
parser.add_option("--record",
|
||||
help="record sessions to FILE.[session_number]", metavar="FILE")
|
||||
help="record sessions to FILE.[session_number]", metavar="FILE")
|
||||
parser.add_option("--daemon", "-D",
|
||||
dest="daemon", action="store_true",
|
||||
help="become a daemon (background process)")
|
||||
dest="daemon", action="store_true",
|
||||
help="become a daemon (background process)")
|
||||
parser.add_option("--run-once", action="store_true",
|
||||
help="handle a single WebSocket connection and exit")
|
||||
help="handle a single WebSocket connection and exit")
|
||||
parser.add_option("--timeout", type=int, default=0,
|
||||
help="after TIMEOUT seconds exit when not connected")
|
||||
help="after TIMEOUT seconds exit when not connected")
|
||||
parser.add_option("--idle-timeout", type=int, default=0,
|
||||
help="server exits after TIMEOUT seconds if there are no "
|
||||
"active connections")
|
||||
help="server exits after TIMEOUT seconds if there are no "
|
||||
"active connections")
|
||||
parser.add_option("--cert", default="self.pem",
|
||||
help="SSL certificate file")
|
||||
help="SSL certificate file")
|
||||
parser.add_option("--key", default=None,
|
||||
help="SSL key file (if separate from cert)")
|
||||
help="SSL key file (if separate from cert)")
|
||||
parser.add_option("--key-password", default=None,
|
||||
help="SSL key password")
|
||||
help="SSL key password")
|
||||
parser.add_option("--ssl-only", action="store_true",
|
||||
help="disallow non-encrypted client connections")
|
||||
help="disallow non-encrypted client connections")
|
||||
parser.add_option("--ssl-target", action="store_true",
|
||||
help="connect to SSL target as SSL client")
|
||||
help="connect to SSL target as SSL client")
|
||||
parser.add_option("--verify-client", action="store_true",
|
||||
help="require encrypted client to present a valid certificate "
|
||||
"(needs Python 2.7.9 or newer or Python 3.4 or newer)")
|
||||
help="require encrypted client to present a valid certificate "
|
||||
"(needs Python 2.7.9 or newer or Python 3.4 or newer)")
|
||||
parser.add_option("--cafile", metavar="FILE",
|
||||
help="file of concatenated certificates of authorities trusted "
|
||||
"for validating clients (only effective with --verify-client). "
|
||||
"If omitted, system default list of CAs is used.")
|
||||
help="file of concatenated certificates of authorities trusted "
|
||||
"for validating clients (only effective with --verify-client). "
|
||||
"If omitted, system default list of CAs is used.")
|
||||
parser.add_option("--ssl-version", type="choice", default="default",
|
||||
choices=["default", "tlsv1_1", "tlsv1_2", "tlsv1_3"], action="store",
|
||||
help="minimum TLS version to use (default, tlsv1_1, tlsv1_2, tlsv1_3)")
|
||||
choices=["default", "tlsv1_1", "tlsv1_2", "tlsv1_3"], action="store",
|
||||
help="minimum TLS version to use (default, tlsv1_1, tlsv1_2, tlsv1_3)")
|
||||
parser.add_option("--ssl-ciphers", action="store",
|
||||
help="list of ciphers allowed for connection. For a list of "
|
||||
"supported ciphers run `openssl ciphers`")
|
||||
help="list of ciphers allowed for connection. For a list of "
|
||||
"supported ciphers run `openssl ciphers`")
|
||||
parser.add_option("--unix-listen",
|
||||
help="listen to unix socket", metavar="FILE", default=None)
|
||||
help="listen to unix socket", metavar="FILE", default=None)
|
||||
parser.add_option("--unix-listen-mode", default=None,
|
||||
help="specify mode for unix socket (defaults to 0600)")
|
||||
help="specify mode for unix socket (defaults to 0600)")
|
||||
parser.add_option("--unix-target",
|
||||
help="connect to unix socket target", metavar="FILE")
|
||||
help="connect to unix socket target", metavar="FILE")
|
||||
parser.add_option("--inetd",
|
||||
help="inetd mode, receive listening socket from stdin", action="store_true")
|
||||
help="inetd mode, receive listening socket from stdin", action="store_true")
|
||||
parser.add_option("--web", default=None, metavar="DIR",
|
||||
help="run webserver on same port. Serve files from DIR.")
|
||||
help="run webserver on same port. Serve files from DIR.")
|
||||
parser.add_option("--web-auth", action="store_true",
|
||||
help="require authentication to access webserver.")
|
||||
help="require authentication to access webserver.")
|
||||
parser.add_option("--wrap-mode", default="exit", metavar="MODE",
|
||||
choices=["exit", "ignore", "respawn"],
|
||||
help="action to take when the wrapped program exits "
|
||||
"or daemonizes: exit (default), ignore, respawn")
|
||||
choices=["exit", "ignore", "respawn"],
|
||||
help="action to take when the wrapped program exits "
|
||||
"or daemonizes: exit (default), ignore, respawn")
|
||||
parser.add_option("--prefer-ipv6", "-6",
|
||||
action="store_true", dest="source_is_ipv6",
|
||||
help="prefer IPv6 when resolving source_addr")
|
||||
action="store_true", dest="source_is_ipv6",
|
||||
help="prefer IPv6 when resolving source_addr")
|
||||
parser.add_option("--libserver", action="store_true",
|
||||
help="use Python library SocketServer engine")
|
||||
help="use Python library SocketServer engine")
|
||||
parser.add_option("--target-config", metavar="FILE",
|
||||
dest="target_cfg",
|
||||
help="Configuration file containing valid targets "
|
||||
"in the form 'token: host:port' or, alternatively, a "
|
||||
"directory containing configuration files of this form "
|
||||
"(DEPRECATED: use `--token-plugin TokenFile --token-source "
|
||||
" path/to/token/file` instead)")
|
||||
dest="target_cfg",
|
||||
help="Configuration file containing valid targets "
|
||||
"in the form 'token: host:port' or, alternatively, a "
|
||||
"directory containing configuration files of this form "
|
||||
"(DEPRECATED: use `--token-plugin TokenFile --token-source "
|
||||
" path/to/token/file` instead)")
|
||||
parser.add_option("--token-plugin", default=None, metavar="CLASS",
|
||||
help="use a Python class, usually one from websockify.token_plugins, "
|
||||
"such as TokenFile, to process tokens into host:port pairs")
|
||||
|
|
@ -552,13 +552,13 @@ def websockify_init():
|
|||
help="an argument to be passed to the auth plugin "
|
||||
"on instantiation")
|
||||
parser.add_option("--heartbeat", type=int, default=0, metavar="INTERVAL",
|
||||
help="send a ping to the client every INTERVAL seconds")
|
||||
help="send a ping to the client every INTERVAL seconds")
|
||||
parser.add_option("--log-file", metavar="FILE",
|
||||
dest="log_file",
|
||||
help="File where logs will be saved")
|
||||
dest="log_file",
|
||||
help="File where logs will be saved")
|
||||
parser.add_option("--syslog", default=None, metavar="SERVER",
|
||||
help="Log to syslog server. SERVER can be local socket, "
|
||||
"such as /dev/log, or a UDP host:port pair.")
|
||||
help="Log to syslog server. SERVER can be local socket, "
|
||||
"such as /dev/log, or a UDP host:port pair.")
|
||||
parser.add_option("--legacy-syslog", action="store_true",
|
||||
help="Use the old syslog protocol instead of RFC 5424. "
|
||||
"Use this if the messages produced by websockify seem abnormal.")
|
||||
|
|
|
|||
|
|
@ -335,15 +335,15 @@ class WebSockifyServer():
|
|||
pass
|
||||
|
||||
def __init__(self, RequestHandlerClass, listen_fd=None,
|
||||
listen_host='', listen_port=None, source_is_ipv6=False,
|
||||
verbose=False, cert='', key='', key_password=None, ssl_only=None,
|
||||
verify_client=False, cafile=None,
|
||||
daemon=False, record='', web='', web_auth=False,
|
||||
file_only=False,
|
||||
run_once=False, timeout=0, idle_timeout=0, traffic=False,
|
||||
tcp_keepalive=True, tcp_keepcnt=None, tcp_keepidle=None,
|
||||
tcp_keepintvl=None, ssl_ciphers=None, ssl_options=0,
|
||||
unix_listen=None, unix_listen_mode=None):
|
||||
listen_host='', listen_port=None, source_is_ipv6=False,
|
||||
verbose=False, cert='', key='', key_password=None, ssl_only=None,
|
||||
verify_client=False, cafile=None,
|
||||
daemon=False, record='', web='', web_auth=False,
|
||||
file_only=False,
|
||||
run_once=False, timeout=0, idle_timeout=0, traffic=False,
|
||||
tcp_keepalive=True, tcp_keepcnt=None, tcp_keepidle=None,
|
||||
tcp_keepintvl=None, ssl_ciphers=None, ssl_options=0,
|
||||
unix_listen=None, unix_listen_mode=None):
|
||||
|
||||
# settings
|
||||
self.RequestHandlerClass = RequestHandlerClass
|
||||
|
|
@ -411,7 +411,7 @@ class WebSockifyServer():
|
|||
self.msg(" - Listen on unix socket %s", self.unix_listen)
|
||||
else:
|
||||
self.msg(" - Listen on %s:%s",
|
||||
self.listen_host, self.listen_port)
|
||||
self.listen_host, self.listen_port)
|
||||
if self.web:
|
||||
if self.file_only:
|
||||
self.msg(" - Web server (no directory listings). Web root: %s", self.web)
|
||||
|
|
@ -464,7 +464,7 @@ class WebSockifyServer():
|
|||
|
||||
if not unix_socket:
|
||||
addrs = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM,
|
||||
socket.IPPROTO_TCP, flags)
|
||||
socket.IPPROTO_TCP, flags)
|
||||
if not addrs:
|
||||
raise Exception("Could not resolve host '%s'" % host)
|
||||
addrs.sort(key=lambda x: x[0])
|
||||
|
|
@ -604,8 +604,8 @@ class WebSockifyServer():
|
|||
else:
|
||||
context.set_default_verify_paths()
|
||||
retsock = context.wrap_socket(
|
||||
sock,
|
||||
server_side=True)
|
||||
sock,
|
||||
server_side=True)
|
||||
except ssl.SSLError:
|
||||
_, x, _ = sys.exc_info()
|
||||
if x.args[0] == ssl.SSL_ERROR_EOF:
|
||||
|
|
@ -794,7 +794,7 @@ class WebSockifyServer():
|
|||
time_elapsed = time.time() - self.launch_time
|
||||
if self.timeout and time_elapsed > self.timeout:
|
||||
self.msg('listener exit due to --timeout %s'
|
||||
% self.timeout)
|
||||
% self.timeout)
|
||||
break
|
||||
|
||||
if self.idle_timeout:
|
||||
|
|
@ -807,7 +807,7 @@ class WebSockifyServer():
|
|||
|
||||
if idle_time > self.idle_timeout and child_count == 0:
|
||||
self.msg('listener exit due to --idle-timeout %s'
|
||||
% self.idle_timeout)
|
||||
% self.idle_timeout)
|
||||
break
|
||||
|
||||
try:
|
||||
|
|
@ -842,13 +842,13 @@ class WebSockifyServer():
|
|||
self.top_new_client(startsock, address)
|
||||
if self.ws_connection:
|
||||
self.msg('%s: exiting due to --run-once'
|
||||
% address[0])
|
||||
% address[0])
|
||||
break
|
||||
else:
|
||||
self.vmsg('%s: new handler Process' % address[0])
|
||||
p = multiprocessing.Process(
|
||||
target=self.top_new_client,
|
||||
args=(startsock, address))
|
||||
target=self.top_new_client,
|
||||
args=(startsock, address))
|
||||
p.start()
|
||||
# child will not return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue