Ejemplo n.º 1
0
def main():
    # Setup flags
    config.parse_args(sys.argv)

    if CONF.ssl_only and not os.path.exists(CONF.cert):
        print("SSL only and %s not found." % CONF.cert)
        return (-1)

    # Check to see if spice html/js/css files are present
    if not os.path.exists(CONF.web):
        print("Can not find spice html/js/css files at %s." % CONF.web)
        return (-1)

    gmr.TextGuruMeditation.setup_autorun(version)

    # Create and start the NovaWebSockets proxy
    server = websocketproxy.NovaWebSocketProxy(
        listen_host=CONF.spice.html5proxy_host,
        listen_port=CONF.spice.html5proxy_port,
        source_is_ipv6=CONF.source_is_ipv6,
        verbose=CONF.verbose,
        cert=CONF.cert,
        key=CONF.key,
        ssl_only=CONF.ssl_only,
        daemon=CONF.daemon,
        record=CONF.record,
        web=CONF.web,
        target_host='ignore',
        target_port='ignore',
        wrap_mode='exit',
        wrap_cmd=None)
    server.start_server()
Ejemplo n.º 2
0
    def setUp(self):
        super(NovaWebsocketSecurityProxyTestCase, self).setUp()

        self.flags(allowed_origins=[
            'allowed-origin-example-1.net', 'allowed-origin-example-2.net'
        ],
                   group='console')

        self.server = websocketproxy.NovaWebSocketProxy(
            security_proxy=mock.MagicMock(spec=base.SecurityProxy))

        with mock.patch('websockify.ProxyRequestHandler'):
            self.wh = websocketproxy.NovaProxyRequestHandler()
        self.wh.server = self.server
        self.wh.path = "http://127.0.0.1/?token=123-456-789"
        self.wh.socket = mock.MagicMock()
        self.wh.msg = mock.MagicMock()
        self.wh.do_proxy = mock.MagicMock()
        self.wh.headers = mock.MagicMock()

        def get_header(header):
            if header == 'cookie':
                return 'token="123-456-789"'
            elif header == 'Origin':
                return 'https://example.net:6080'
            elif header == 'Host':
                return 'example.net:6080'
            else:
                return

        self.wh.headers.get = get_header
Ejemplo n.º 3
0
def main():
    # Setup flags
    config.parse_args(sys.argv)

    if CONF.ssl_only and not os.path.exists(CONF.cert):
        print("SSL only and %s not found" % CONF.cert)
        return (-1)

    # Check to see if tty html/js/css files are present
    if not os.path.exists(CONF.web):
        print("Can not find serial terminal html/js/css files at %s." \
            % CONF.web)
        sys.exit(-1)

    # Create and start the NovaWebSockets proxy
    server = websocketproxy.NovaWebSocketProxy(
        listen_host=CONF.serialproxy_host,
        listen_port=CONF.serialproxy_port,
        source_is_ipv6=CONF.source_is_ipv6,
        verbose=CONF.verbose,
        cert=CONF.cert,
        key=CONF.key,
        ssl_only=CONF.ssl_only,
        daemon=CONF.daemon,
        record=CONF.record,
        web=CONF.web,
        target_host='ignore',
        target_port='ignore',
        wrap_mode='exit',
        wrap_cmd=None,
        connect_info_validator=validate_connection)
    server.start_server()
Ejemplo n.º 4
0
def proxy(host, port, target_host=None):

    if CONF.ssl_only and not os.path.exists(CONF.cert):
        exit_with_error("SSL only and %s not found" % CONF.cert)

    # Check to see if tty html/js/css files are present
    if CONF.web and not os.path.exists(CONF.web):
        exit_with_error("Can not find html/js files at %s." % CONF.web)

    logging.setup(CONF, "nova")

    gmr.TextGuruMeditation.setup_autorun(version)

    # Create and start the NovaWebSockets proxy
    websocketproxy.NovaWebSocketProxy(
        listen_host=host,
        listen_port=port,
        source_is_ipv6=CONF.source_is_ipv6,
        verbose=CONF.verbose,
        cert=CONF.cert,
        key=CONF.key,
        ssl_only=CONF.ssl_only,
        daemon=CONF.daemon,
        record=CONF.record,
        traffic=CONF.verbose and not CONF.daemon,
        web=CONF.web,
        target_host=target_host,
        file_only=True,
        RequestHandlerClass=websocketproxy.NovaProxyRequestHandler
    ).start_server()
Ejemplo n.º 5
0
def main():
    # Setup flags
    config.parse_args(sys.argv)

    if CONF.ssl_only and not os.path.exists(CONF.cert):
        exit_with_error("SSL only and %s not found" % CONF.cert)

    logging.setup("nova")
    gmr.TextGuruMeditation.setup_autorun(version)

    # Create and start the NovaWebSockets proxy
    server = websocketproxy.NovaWebSocketProxy(
        listen_host=CONF.serial_console.serialproxy_host,
        listen_port=CONF.serial_console.serialproxy_port,
        source_is_ipv6=CONF.source_is_ipv6,
        verbose=CONF.verbose,
        cert=CONF.cert,
        key=CONF.key,
        ssl_only=CONF.ssl_only,
        daemon=CONF.daemon,
        record=CONF.record,
        traffic=CONF.verbose and not CONF.daemon,
        file_only=True,
        RequestHandlerClass=websocketproxy.NovaProxyRequestHandler)
    server.start_server()
Ejemplo n.º 6
0
def main():
    # Setup flags
    CONF.set_default('web', '/usr/share/novnc')
    config.parse_args(sys.argv)
    logging.setup("nova")

    if CONF.ssl_only and not os.path.exists(CONF.cert):
        print("SSL only and %s not found" % CONF.cert)
        return (-1)

    # Check to see if novnc html/js/css files are present
    if not os.path.exists(CONF.web):
        print("Can not find novnc html/js/css files at %s." % CONF.web)
        return (-1)

    logging.setup("nova")

    gmr.TextGuruMeditation.setup_autorun(version)

    # Create and start the NovaWebSockets proxy
    server = websocketproxy.NovaWebSocketProxy(
        listen_host=CONF.novncproxy_host,
        listen_port=CONF.novncproxy_port,
        source_is_ipv6=CONF.source_is_ipv6,
        verbose=CONF.verbose,
        cert=CONF.cert,
        key=CONF.key,
        ssl_only=CONF.ssl_only,
        daemon=CONF.daemon,
        record=CONF.record,
        traffic=CONF.verbose and not CONF.daemon,
        web=CONF.web,
        file_only=True,
        RequestHandlerClass=websocketproxy.NovaProxyRequestHandler)
    server.start_server()
Ejemplo n.º 7
0
def main():
    # Setup flags
    CONF.set_default('web', '/usr/share/novnc')
    config.parse_args(sys.argv)

    if CONF.ssl_only and not os.path.exists(CONF.cert):
        print("SSL only and %s not found" % CONF.cert)
        return (-1)

    # Check to see if novnc html/js/css files are present
    if not os.path.exists(CONF.web):
        print("Can not find novnc html/js/css files at %s." % CONF.web)
        return (-1)

    # Create and start the NovaWebSockets proxy
    server = websocketproxy.NovaWebSocketProxy(
        listen_host=CONF.novncproxy_host,
        listen_port=CONF.novncproxy_port,
        source_is_ipv6=CONF.source_is_ipv6,
        verbose=CONF.verbose,
        cert=CONF.cert,
        key=CONF.key,
        ssl_only=CONF.ssl_only,
        daemon=CONF.daemon,
        record=CONF.record,
        web=CONF.web,
        file_only=True,
        no_parent=True,
        target_host='ignore',
        target_port='ignore',
        wrap_mode='exit',
        wrap_cmd=None)
    server.start_server()
Ejemplo n.º 8
0
def main():
    # Setup flags

    CONF = cfg.CONF
    CONF.register_cli_opts(opts)
    CONF.import_opt('debug', 'nova.openstack.common.log')
    config.parse_args(sys.argv)

    if CONF.ssl_only and not os.path.exists(CONF.cert):
        print "SSL only and %s not found." % CONF.cert
        return (-1)

    # Check to see if spice html/js/css files are present
    if not os.path.exists(CONF.web):
        print "Can not find spice html/js/css files at %s." % CONF.web
        return (-1)

    # Create and start the NovaWebSockets proxy
    server = websocketproxy.NovaWebSocketProxy(
        listen_host=CONF.spicehtml5proxy_host,
        listen_port=CONF.spicehtml5proxy_port,
        source_is_ipv6=CONF.source_is_ipv6,
        verbose=CONF.verbose,
        cert=CONF.cert,
        key=CONF.key,
        ssl_only=CONF.ssl_only,
        daemon=CONF.daemon,
        record=CONF.record,
        web=CONF.web,
        target_host='ignore',
        target_port='ignore',
        wrap_mode='exit',
        wrap_cmd=None)
    server.start_server()
Ejemplo n.º 9
0
    def setUp(self):
        super(NovaProxyRequestHandlerDBTestCase, self).setUp()

        self.flags(console_allowed_origins=['allowed-origin-example-1.net',
                                            'allowed-origin-example-2.net'])
        with mock.patch('websockify.ProxyRequestHandler'):
            self.wh = websocketproxy.NovaProxyRequestHandler()
        self.wh.server = websocketproxy.NovaWebSocketProxy()
        self.wh.socket = mock.MagicMock()
        self.wh.msg = mock.MagicMock()
        self.wh.do_proxy = mock.MagicMock()
        self.wh.headers = mock.MagicMock()
Ejemplo n.º 10
0
    def setUp(self):
        super(NovaProxyRequestHandlerBaseTestCase, self).setUp()

        self.flags(allowed_origins=['allowed-origin-example-1.net',
                                    'allowed-origin-example-2.net'],
                   group='console')
        self.server = websocketproxy.NovaWebSocketProxy()
        self.wh = websocketproxy.NovaProxyRequestHandlerBase()
        self.wh.server = self.server
        self.wh.socket = mock.MagicMock()
        self.wh.msg = mock.MagicMock()
        self.wh.do_proxy = mock.MagicMock()
        self.wh.headers = mock.MagicMock()
Ejemplo n.º 11
0
    def setUp(self):
        super(NovaProxyRequestHandlerBaseTestCase, self).setUp()

        self.flags(allowed_origins=[
            'allowed-origin-example-1.net', 'allowed-origin-example-2.net'
        ],
                   group='console')
        self.server = websocketproxy.NovaWebSocketProxy()
        with mock.patch('websockify.ProxyRequestHandler'):
            self.wh = websocketproxy.NovaProxyRequestHandler()
        self.wh.server = self.server
        self.wh.socket = mock.MagicMock()
        self.wh.msg = mock.MagicMock()
        self.wh.do_proxy = mock.MagicMock()
        self.wh.headers = mock.MagicMock()
        self.path = urlparse.urlencode({'path': '?token=123-456-789'})
        self.path_invalid = urlparse.urlencode({'path': '?token=XXX'})
Ejemplo n.º 12
0
def proxy(host, port, security_proxy=None):
    """:param host: local address to listen on
    :param port: local port to listen on
    :param security_proxy: instance of
        nova.console.securityproxy.base.SecurityProxy

    Setup a proxy listening on @host:@port. If the
    @security_proxy parameter is not None, this instance
    is used to negotiate security layer with the proxy target
    """

    if CONF.ssl_only and not os.path.exists(CONF.cert):
        exit_with_error("SSL only and %s not found" % CONF.cert)

    # Check to see if tty html/js/css files are present
    if CONF.web and not os.path.exists(CONF.web):
        exit_with_error("Can not find html/js files at %s." % CONF.web)

    logging.setup(CONF, "nova")

    gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)

    # Create and start the NovaWebSockets proxy
    websocketproxy.NovaWebSocketProxy(
        listen_host=host,
        listen_port=port,
        source_is_ipv6=CONF.source_is_ipv6,
        cert=CONF.cert,
        key=CONF.key,
        ssl_only=CONF.ssl_only,
        ssl_ciphers=CONF.console.ssl_ciphers,
        ssl_minimum_version=CONF.console.ssl_minimum_version,
        daemon=CONF.daemon,
        record=CONF.record,
        traffic=not CONF.daemon,
        web=CONF.web,
        file_only=True,
        RequestHandlerClass=websocketproxy.NovaProxyRequestHandler,
        security_proxy=security_proxy,
    ).start_server()
Ejemplo n.º 13
0
 def test_non_default_ssl_min_version_is_set(self, mock_select_ssl):
     minver = 'tlsv1_3'
     websocketproxy.NovaWebSocketProxy(ssl_minimum_version=minver)
     mock_select_ssl.assert_called_once_with(minver)
Ejemplo n.º 14
0
 def test_ssl_min_version_not_set_by_default(self, mock_select_ssl):
     websocketproxy.NovaWebSocketProxy(ssl_minimum_version='default')
     self.assertFalse(mock_select_ssl.called)
Ejemplo n.º 15
0
 def test_ssl_min_version_is_not_set(self, mock_select_ssl):
     websocketproxy.NovaWebSocketProxy()
     self.assertFalse(mock_select_ssl.called)