Exemple #1
0
def initializeOoniprobe(global_options):
    print("It looks like this is the first time you are running ooniprobe")
    if not sys.stdin.isatty():
        print("ERROR: STDIN is not attached to a tty. Quiting.")
        sys.exit(8)

    print("Please take a minute to read through the informed consent documentation and "
          "understand what are the risks associated with running ooniprobe.")
    print("Press enter to continue...")
    raw_input()
    with open(os.path.join(OONIPROBE_ROOT, 'ui', 'consent-form.md')) as f:
        consent_form_text = ''.join(f.readlines())
    from pydoc import pager
    pager(consent_form_text)

    answer = ""
    while answer.lower() != "yes":
        print('Type "yes" if you are fully aware of the risks associated with using ooniprobe and you wish to proceed')
        answer = raw_input("> ")

    print("")
    print("Now help us configure some things!")
    answer = raw_input('Should we upload measurements to a collector? (Y/n) ')
    should_upload = True
    if answer.lower().startswith("n"):
        should_upload = False

    answer = raw_input('Should we include your IP in measurements? (y/N) ')
    include_ip = False
    if answer.lower().startswith("y"):
        include_ip = True

    answer = raw_input('Should we include your ASN (your network) in '
                       'measurements? (Y/n) ')
    include_asn = True
    if answer.lower().startswith("n"):
        include_asn = False

    answer = raw_input('Should we include your Country in '
                       'measurements? (Y/n) ')
    include_country = True
    if answer.lower().startswith("n"):
        include_country = False

    answer = raw_input('How would you like reports to be uploaded? (onion, '
                       'https, cloudfront) ')

    preferred_backend = 'onion'
    if answer.lower().startswith("https"):
        preferred_backend = 'https'
    elif answer.lower().startswith("cloudfront"):
        preferred_backend = 'cloudfront'

    config.create_config_file(include_ip=include_ip,
                              include_asn=include_asn,
                              include_country=include_country,
                              should_upload=should_upload,
                              preferred_backend=preferred_backend)
    config.set_initialized()
    print("ooniprobe is now initialized. You can begin using it!")
def initializeOoniprobe(global_options):
    print("It looks like this is the first time you are running ooniprobe")
    if not sys.stdin.isatty():
        print("ERROR: STDIN is not attached to a tty. Quiting.")
        sys.exit(8)

    print("Please take a minute to read through the informed consent documentation and "
          "understand what are the risks associated with running ooniprobe.")
    print("Press enter to continue...")
    raw_input()
    with open(os.path.join(OONIPROBE_ROOT, 'ui', 'consent-form.md')) as f:
        consent_form_text = ''.join(f.readlines())
    from pydoc import pager
    pager(consent_form_text)

    answer = ""
    while answer.lower() != "yes":
        print('Type "yes" if you are fully aware of the risks associated with using ooniprobe and you wish to proceed')
        answer = raw_input("> ")

    print("")
    print("Now help us configure some things!")
    answer = raw_input('Should we upload measurements to a collector? (Y/n) ')
    should_upload = True
    if answer.lower().startswith("n"):
        should_upload = False

    answer = raw_input('Should we include your IP in measurements? (y/N) ')
    include_ip = False
    if answer.lower().startswith("y"):
        include_ip = True

    answer = raw_input('Should we include your ASN (your network) in '
                       'measurements? (Y/n) ')
    include_asn = True
    if answer.lower().startswith("n"):
        include_asn = False

    answer = raw_input('Should we include your Country in '
                       'measurements? (Y/n) ')
    include_country = True
    if answer.lower().startswith("n"):
        include_country = False

    answer = raw_input('How would you like reports to be uploaded? (onion, '
                       'https, cloudfront) ')

    preferred_backend = 'onion'
    if answer.lower().startswith("https"):
        preferred_backend = 'https'
    elif answer.lower().startswith("cloudfront"):
        preferred_backend = 'cloudfront'

    config.create_config_file(include_ip=include_ip,
                              include_asn=include_asn,
                              include_country=include_country,
                              should_upload=should_upload,
                              preferred_backend=preferred_backend)
    config.set_initialized()
    print("ooniprobe is now initialized. You can begin using it!")
Exemple #3
0
    def api_initialize(self, request):
        try:
            initial_configuration = json.load(request.content)
        except ValueError:
            raise WebUIError(400, 'Invalid JSON message recevied')

        required_keys = [
            'include_ip', 'include_asn', 'include_country', 'should_upload',
            'preferred_backend'
        ]
        options = {}
        for required_key in required_keys:
            try:
                options[required_key] = initial_configuration[required_key]
            except KeyError:
                raise WebUIError(
                    400, 'Missing required key {0}'.format(required_key))
        config.create_config_file(**options)
        try:
            deck_config = initial_configuration['deck_config']
        except KeyError:
            raise WebUIError(400, 'Missing enabled decks')

        for deck_id, enabled in deck_config.items():
            try:
                if enabled is True:
                    self.director.deck_store.enable(deck_id)
                elif enabled is False:
                    try:
                        self.director.deck_store.disable(deck_id)
                    except DeckNotFound:
                        # We ignore these errors, because it could be that a deck
                        # that is marked as disabled is already disabled
                        pass
            except DeckNotFound:
                raise WebUIError(404, 'Deck not found')

        config.set_initialized()
        self.scheduler.refresh_deck_list()

        self._is_initialized = True

        self.status_poller.notify()
        self.start_director()
        return self.render_json({"result": "ok"}, request)
Exemple #4
0
    def api_initialize(self, request):
        try:
            initial_configuration = json.load(request.content)
        except ValueError:
            raise WebUIError(400, 'Invalid JSON message recevied')

        required_keys = ['include_ip', 'include_asn', 'include_country',
                         'should_upload', 'preferred_backend']
        options = {}
        for required_key in required_keys:
            try:
                options[required_key] = initial_configuration[required_key]
            except KeyError:
                raise WebUIError(400, 'Missing required key {0}'.format(
                    required_key))
        config.create_config_file(**options)
        try:
            deck_config = initial_configuration['deck_config']
        except KeyError:
            raise WebUIError(400, 'Missing enabled decks')

        for deck_id, enabled in deck_config.items():
            try:
                if enabled is True:
                    self.director.deck_store.enable(deck_id)
                elif enabled is False:
                    try:
                        self.director.deck_store.disable(deck_id)
                    except DeckNotFound:
                        # We ignore these errors, because it could be that a deck
                        # that is marked as disabled is already disabled
                        pass
            except DeckNotFound:
                raise WebUIError(404, 'Deck not found')

        config.set_initialized()
        self.scheduler.refresh_deck_list()

        self._is_initialized = True

        self.status_poller.notify()
        self.start_director()
        return self.render_json({"result": "ok"}, request)