Exemplo n.º 1
0
def new_ws_proxy():
    try:
        os.makedirs(WS_TOKENS_DIR, mode=0755)
    except OSError as e:
        if e.errno == errno.EEXIST:
            pass

    cert = config.get('server', 'ssl_cert')
    key = config.get('server', 'ssl_key')
    if not (cert and key):
        cert = '%s/wok-cert.pem' % paths.conf_dir
        key = '%s/wok-key.pem' % paths.conf_dir

    params = {
        'listen_host': '127.0.0.1',
        'listen_port': config.get('server', 'websockets_port'),
        'ssl_only': False
    }

    # old websockify: do not use TokenFile
    if not tokenFile:
        params['target_cfg'] = WS_TOKENS_DIR

    # websockify 0.7 and higher: use TokenFile
    else:
        params['token_plugin'] = TokenFile(src=WS_TOKENS_DIR)

    def start_proxy():
        server = WebSocketProxy(**params)
        server.start_server()

    proc = Process(target=start_proxy)
    proc.start()
    return proc
Exemplo n.º 2
0
def new_ws_proxy():
    try:
        os.makedirs(WS_TOKENS_DIR, mode=0755)
    except OSError as e:
        if e.errno == errno.EEXIST:
            pass

    params = {
        'listen_host': '127.0.0.1',
        'listen_port': config.get('server', 'websockets_port'),
        'ssl_only': False
    }

    # old websockify: do not use TokenFile
    if not tokenFile:
        params['target_cfg'] = WS_TOKENS_DIR

    # websockify 0.7 and higher: use TokenFile
    else:
        params['token_plugin'] = TokenFile(src=WS_TOKENS_DIR)

    def start_proxy():
        try:
            server = WebSocketProxy(RequestHandlerClass=CustomHandler,
                                    **params)
        except TypeError:
            server = CustomHandler(**params)

        server.start_server()

    proc = Process(target=start_proxy)
    proc.start()
    return proc
Exemplo n.º 3
0
def start_websockify():
    #t = threading.Thread(target=worker)
    #t.start()
    websockify.logger_init()
    data = {
        #'target_cfg': VNC_TOKENS_FILE,
        'listen_port': 6080,
    }
    target_cfg = VNC_TOKENS_FILE
    target_cfg = os.path.abspath(target_cfg)
    token_plugin = TokenFile(target_cfg)
    data['token_plugin'] = token_plugin

    ws_proxy = websockify.WebSocketProxy(
        **data, RequestHandlerClass=MyProxyRequestHandler)
    ws_proxy.start_server()