Esempio n. 1
0
    ]

    app = tornado.web.Application(
        handlers,
        **settings)

    # Create a secure http listener
    ssl_http_server = tornado.httpserver.HTTPServer(app, ssl_options=ssl_ctx)
    upstream_http_server = tornado.httpserver.HTTPServer(app)
    upstream_http_server.listen(8888)
    ssl_http_server.listen(8443, "127.0.0.1")

    log.debug("Enabling port forwarding")
    # Setup network for exposing the ports to the outside world
    port_forwarder = PortForwarder()
    port_forwarder.enable_port_forwarding()
    port_forwarder.setup_external_ip(hostname=hostname)
    # Information used by the TurnServer
    internal_ip, external_ip = port_forwarder.get_network_adresses()
    # Used for starting the turn server process with security
    turn_server = TurnServerManager(cert=os.path.join(ssl_stuff_dir, "startssl.crt"),
                                    key=os.path.join(ssl_stuff_dir, "startssl.key"),
                                    internal_ip=internal_ip,
                                    external_ip=external_ip,
                                    realm=hostname,
                                    secret=base64.b64encode(os.urandom(50)).decode('ascii'),
                                    other_options="--lt-cred-mech --fingerprint --pidfile /tmp/turnserver.pid")
    turn_server.start_turn_server()
    log.info("Starting Tornado server")
    # Periodically check if the display must be woken up
    tornado.ioloop.PeriodicCallback(wake_up_display, 1000 * 60 * 5).start()