Esempio n. 1
0
    def run(self):
        ''' Periodically run rendezvous '''

        if not privacy.allowed_to_run():
            _open_browser_on_windows('privacy.html')
            # Except from opening the browser, privacy actions are
            # now performed by RUNNER_CORE

        RUNNER_CORE.run('rendezvous', self._after_rendezvous)
Esempio n. 2
0
 def _api_index(self, stream, request, query):
     '''
      Redirect either to /index.html or /privacy.html depending on
      whether the user has already set privacy permissions or not
     '''
     response = Message()
     if not privacy.allowed_to_run():
         response.compose_redirect(stream, '/privacy.html')
     else:
         response.compose_redirect(stream, '/index.html')
     stream.send_response(request, response)
Esempio n. 3
0
def main(args):
    """ Main function """
    try:
        options, arguments = getopt.getopt(args[1:], "6A:np:vy")
    except getopt.error:
        sys.exit("usage: neubot skype [-6nvy] [-A address] [-p port]")
    if arguments:
        sys.exit("usage: neubot skype [-6nvy] [-A address] [-p port]")

    prefer_ipv6 = 0
    # address = 'master.neubot.org'
    address = "localhost"
    runner = 1
    port = 8080
    noisy = 0
    fakeprivacy = 0
    for name, value in options:
        if name == "-6":
            prefer_ipv6 = 1
        elif name == "-A":
            address = value
        elif name == "-n":
            runner = 0
        elif name == "-p":
            port = int(value)
        elif name == "-v":
            noisy = 1
        elif name == "-y":
            fakeprivacy = 1

    if os.path.isfile(DATABASE.path):
        DATABASE.connect()
        CONFIG.merge_database(DATABASE.connection())
    else:
        logging.warning("skype: database file is missing: %s", DATABASE.path)
        BACKEND.use_backend("null")
    if noisy:
        log.set_verbose()
    if runner:
        result = runner_clnt.runner_client(
            CONFIG["agent.api.address"], CONFIG["agent.api.port"], CONFIG["verbose"], "skype"
        )
        if result:
            sys.exit(0)

    logging.info("skype: running the test in the local process context...")
    if not fakeprivacy and not privacy.allowed_to_run():
        privacy.complain()
        logging.info("skype: otherwise use -y option to temporarily provide " "privacy permissions")
        sys.exit(1)

    handler = SkypeNegotiate()
    handler.connect((address, port), prefer_ipv6, 0, {})
    POLLER.loop()
    def run(self):
        ''' Periodically run rendezvous '''

        #
        # Except from opening the browser, privacy actions are
        # now performed by RUNNER_CORE
        #
        if not privacy.allowed_to_run():
            self._open_browser_on_windows('privacy.html')

        logging.info('background_rendezvous: automatic rendezvous...')
        RUNNER_CORE.run('rendezvous', self._after_rendezvous)
 def run(self):
     ''' Periodically run rendezvous '''
     #
     # Except from opening the browser, privacy actions are
     # now performed by RUNNER_CORE
     #
     if not privacy.allowed_to_run():
         self._open_browser_on_windows('privacy.html')
     logging.info('background_rendezvous: automatic rendezvous...')
     deferred = Deferred()
     deferred.add_callback(self._after_rendezvous)
     deferred.add_errback(self._schedule)
     RUNNER_CORE.run('rendezvous', deferred, False, None)
Esempio n. 6
0
    def connect_uri(self, uri=None, count=None):
        self._task = None

        if not privacy.allowed_to_run():
            _open_browser_on_windows("privacy.html")
            privacy.complain()
            self._schedule()
            return

        if not uri:
            uri = "http://%s:9773/rendezvous" % CONFIG["agent.master"]

        LOG.start("* Rendezvous with %s" % uri)
        STATE.update("rendezvous")

        # We need to make just one connection
        ClientHTTP.connect_uri(self, uri, 1)
Esempio n. 7
0
def main(args):

    CONFIG.register_descriptions({
        "speedtest.client.uri": "Base URI to connect to",
        "speedtest.client.nconn": "Number of concurrent connections to use",
        "speedtest.client.latency_tries": "Number of latency measurements",
    })

    common.main("speedtest.client", "Speedtest client", args)
    conf = CONFIG.copy()

    #
    # If possible use the runner, which will execute the
    # test in the context of the neubot daemon.  Then exit
    # to bypass the POLLER.loop() invokation that is below
    # here.
    # If the runner fails, fallback to the usual code path,
    # which executes the test in the context of the local
    # process.
    # Set 'runned.enabled' to 0 to bypass the runner and
    # run the test locally.
    #
    if (utils.intify(conf['runner.enabled']) and
        runner_clnt.runner_client(conf["agent.api.address"],
                                  conf["agent.api.port"],
                                  LOG.noisy, "speedtest")):
        sys.exit(0)

    logging.info('Will run the test in the local context...')

    if not privacy.allowed_to_run():
        privacy.complain()
        sys.exit(1)

    client = ClientSpeedtest(POLLER)
    client.configure(conf)
    client.connect_uri()
    POLLER.loop()
Esempio n. 8
0
 def test_failure(self):
     ''' Make sure collect_allowed() returns False on bad input '''
     CONFIG.merge_kv(('privacy.informed', 1))
     CONFIG.merge_kv(('privacy.can_collect', 1))
     CONFIG.merge_kv(('privacy.can_publish', 0))
     self.assertFalse(privacy.allowed_to_run())
Esempio n. 9
0
 def test_success(self):
     ''' Make sure allowed_to_run() returns True on valid CONFIG '''
     CONFIG.merge_kv(('privacy.informed', 1))
     CONFIG.merge_kv(('privacy.can_collect', 1))
     CONFIG.merge_kv(('privacy.can_publish', 1))
     self.assertTrue(privacy.allowed_to_run())
Esempio n. 10
0
 def test_failure(self):
     ''' Make sure collect_allowed() returns False on bad input '''
     CONFIG.merge_kv(('privacy.informed', 1))
     CONFIG.merge_kv(('privacy.can_collect', 1))
     CONFIG.merge_kv(('privacy.can_publish', 0))
     self.assertFalse(privacy.allowed_to_run())
Esempio n. 11
0
 def test_success(self):
     ''' Make sure allowed_to_run() returns True on valid CONFIG '''
     CONFIG.merge_kv(('privacy.informed', 1))
     CONFIG.merge_kv(('privacy.can_collect', 1))
     CONFIG.merge_kv(('privacy.can_publish', 1))
     self.assertTrue(privacy.allowed_to_run())
Esempio n. 12
0
def main(args):

    config.register_descriptions()
    common.main("bittorrent", "Neubot BitTorrent module", args)
    conf = CONFIG.copy()
    config.finalize_conf(conf)

    if conf["bittorrent.listen"]:

        #
        # If we need to negotiate and we're runing
        # standalone we also need to bring up the
        # global HTTP server.
        #
        if conf["bittorrent.negotiate"]:
            HTTP_SERVER.configure(conf)
            HTTP_SERVER.listen((conf["bittorrent.address"],
                               conf["bittorrent.negotiate.port"]))
            conf["negotiate.listen"] = True
            negotiate.run(POLLER, conf)

        #
        # Drop privileges after listen() so we can
        # bind() to privileged ports
        #
        if conf["bittorrent.daemonize"]:
            system.change_dir()
            system.go_background()
            LOG.redirect()

        system.drop_privileges(LOG.error)

    else:

        #
        # If possible use the runner, which will execute the
        # test in the context of the neubot daemon.  Then exit
        # to bypass the run() invokation that is below here.
        # If the runner fails, fallback to the usual code path,
        # which executes the test in the context of the local
        # process.
        # Set 'runned.enabled' to 0 to bypass the runner and
        # run the test locally.
        #
        if (utils.intify(conf['runner.enabled']) and
            runner_clnt.runner_client(conf["agent.api.address"],
                                      conf["agent.api.port"],
                                      LOG.noisy, "bittorrent")):
            sys.exit(0)

        LOG.info('Will run the test in the local context...')

        if not privacy.allowed_to_run():
            privacy.complain()
            sys.exit(1)

        #
        # When we're connecting to a remote host to perform a test
        # we want Neubot to quit at the end of the test.  When this
        # happens the test code publishes the "testdone" event, so
        # here we prepare to intercept the event and break our main
        # loop.
        #
        NOTIFIER.subscribe("testdone", lambda event, ctx: POLLER.break_loop())

    run(POLLER, conf)

    POLLER.loop()