Example #1
0
File: base.py Project: djon3s/APAF
def main(progress_updates=updates, data_directory=None):
    """
    Start logging, apaf services, and tor.

    :param progress_updates: a callback fired during tor's bootstrap.
    :ret: a twisted Deferred object for setting up callbacks in case of
          sucess/errors.
    """
    ## start the logger. ##
    log.startLogging(sys.stdout)
    torconfig = txtorcon.TorConfig()

    ## start apaf. ##
    panel.start_panel(torconfig)
    core.start_services(torconfig)

    torconfig.HiddenServices = [x.hs for x in apaf.hiddenservices]
    torconfig.save()

    ## start tor. ##
    try:
        return txtorcon.launch_tor(
            torconfig,
            reactor,
            progress_updates=progress_updates,
            data_directory=data_directory,
            tor_binary=config.tor_binary,
        )
    except OSError as exc:
        print >> sys.stderr, "Failing to launch tor executable (%s)" % ecx
        sys.exit(1)  # return error status.
Example #2
0
File: base.py Project: djon3s/APAF
def main(progress_updates=updates, data_directory=None):
    """
    Start logging, apaf services, and tor.

    :param progress_updates: a callback fired during tor's bootstrap.
    :ret: a twisted Deferred object for setting up callbacks in case of
          sucess/errors.
    """
    ## start the logger. ##
    log.startLogging(sys.stdout)
    torconfig = txtorcon.TorConfig()

    ## start apaf. ##
    panel.start_panel(torconfig)
    core.start_services(torconfig)

    torconfig.HiddenServices = [x.hs for x in apaf.hiddenservices]
    torconfig.save()

    ## start tor. ##
    try:
        return txtorcon.launch_tor(torconfig, reactor,
                                   progress_updates=progress_updates,
                                   data_directory=data_directory,
                                   tor_binary=config.tor_binary,
        )
    except OSError as exc:
        print  >> sys.stderr, "Failing to launch tor executable (%s)" % ecx
        sys.exit(1)  # return error status.
Example #3
0
File: run.py Project: mogui/APAF
def main():
    """
    Start the apaf.
    """
    ## start the logger. ##
    log.startLogging(sys.stdout)
    torconfig = txtorcon.TorConfig()

    ## start apaf. ##
    panel.start_panel(torconfig)
    core.start_services(torconfig)

    torconfig.HiddenServices = [x.hs for x in apaf.hiddenservices]
    torconfig.save()

    start_tor(torconfig)

    ##  Start the reactor. ##
    #if config.platform == 'darwin':
    #    reactor.interleave(AppHelper.callAfter)
    #else:
    reactor.run()
Example #4
0
def main(progress_updates=updates,
         data_directory=None,
         connection_creator=None):
    """
    Start logging, apaf services, and tor.

    :param progress_updates: a callback fired during tor's bootstrap.
    :ret: a twisted Deferred object for setting up callbacks in case of
          sucess/errors.


    XXX: for versions of txtorcon greater that 0.6 it is possible to set the
    data_directory argument directly in the toconfig, and removing from
    launch_tor. See issue #15 of txtorcon and #40 of APAF.
    """
    ## start the logger. ##
    log.startLogging(sys.stdout)
    torconfig = txtorcon.TorConfig()
    if data_directory is not None:
        config.DataDirectory = data_directory

    ## start apaf. ##
    panel.start_panel(torconfig)
    core.start_services(torconfig)

    # torconfig.DataDirectory = data_directory
    torconfig.HiddenServices = [x.hs for x in apaf.hiddenservices]
    torconfig.save()

    ## start tor. ##
    try:
        return txtorcon.launch_tor(torconfig,
                                   reactor,
                                   progress_updates=progress_updates,
                                   tor_binary=config.tor_binary,
                                   connection_creator=connection_creator)
    except OSError as exc:
        print >> sys.stderr, "Failing to launch tor executable (%s)" % ecx
        sys.exit(1)  # return error status.
Example #5
0
def main():
    """
    Start the apaf.
    """
    ## start the logger. ##
    log.startLogging(sys.stdout)
    torconfig = txtorcon.TorConfig()

    ## start apaf. ##
    panel.start_panel(torconfig)
    core.start_services(torconfig)

    torconfig.HiddenServices = [x.hs for x in apaf.hiddenservices]
    torconfig.save()

    start_tor(torconfig)

    ##  Start the reactor. ##
    #if config.platform == 'darwin':
    #    reactor.interleave(AppHelper.callAfter)
    #else:
    reactor.run()
Example #6
0
def main(progress_updates=updates, data_directory=None, connection_creator=None):
    """
    Start logging, apaf services, and tor.

    :param progress_updates: a callback fired during tor's bootstrap.
    :ret: a twisted Deferred object for setting up callbacks in case of
          sucess/errors.


    XXX: for versions of txtorcon greater that 0.6 it is possible to set the
    data_directory argument directly in the toconfig, and removing from
    launch_tor. See issue #15 of txtorcon and #40 of APAF.
    """
    ## start the logger. ##
    log.startLogging(sys.stdout)
    torconfig = txtorcon.TorConfig()
    if data_directory is not None:
        config.DataDirectory = data_directory

    ## start apaf. ##
    panel.start_panel(torconfig)
    core.start_services(torconfig)

    # torconfig.DataDirectory = data_directory
    torconfig.HiddenServices = [x.hs for x in apaf.hiddenservices]
    torconfig.save()

    ## start tor. ##
    try:
        return txtorcon.launch_tor(
            torconfig,
            reactor,
            progress_updates=progress_updates,
            tor_binary=config.tor_binary,
            connection_creator=connection_creator,
        )
    except OSError as exc:
        print >>sys.stderr, "Failing to launch tor executable (%s)" % ecx
        sys.exit(1)  # return error status.
Example #7
0
def start_mock_apaf(tor, *services):
    """
    Start the apaf for testing purposes.
    XXX. how to handle cleanup? Currently the reactor is left unclean
    :ret: None.
    """
    torconfig = txtorcon.TorConfig()

    ## start apaf. ##
    panel.start_panel(torconfig)

    for service in services:
            service = imp.load_module(
                      service, *imp.find_module(service, [config.services_dir])
                      ).ServiceDescriptor
    torconfig.HiddenServices = [x.hs for x in apaf.hiddenservices]
    torconfig.save()


    if tor:
        txtorcon.launch_tor(torconfig, reactor,
                            progress_updates=progress_updates,
                            tor_binary=config.tor_binary)