Ejemplo n.º 1
0
def do_external_mode(args):
    """This function starts obfsproxy's external-mode functionality."""

    assert (args)
    assert (args.name)
    assert (args.name in transports.transports)

    from twisted.internet import reactor

    pt_config = transport_config.TransportConfig()
    pt_config.setStateLocation(args.data_dir)
    pt_config.setListenerMode(args.mode)
    pt_config.setObfsproxyMode("external")
    if args.proxy:  # Set outgoing proxy settings if we have them
        proxy = parseProxyURI(args.proxy)
        pt_config.setProxy(proxy)

    # Run setup() method.
    run_transport_setup(pt_config, args.name)

    launch_transport.launch_transport_listener(args.name, args.listen_addr,
                                               args.mode, args.dest, pt_config,
                                               args.ext_cookie_file)
    log.info("Launched '%s' listener at '%s:%s' for transport '%s'." % \
                 (args.mode, log.safe_addr_str(args.listen_addr[0]), args.listen_addr[1], args.name))
    reactor.run()
Ejemplo n.º 2
0
def consider_cli_args(args):
    """Check out parsed CLI arguments and take the appropriate actions."""

    if args.log_file:
        log.set_log_file(args.log_file)
    if args.log_min_severity:
        log.set_log_severity(args.log_min_severity)
    if args.no_log:
        log.disable_logs()
    if args.no_safe_logging:
        log.set_no_safe_logging()

    # validate:
    if (args.name
            == 'managed') and (not args.log_file) and (args.log_min_severity):
        log.error("obfsproxy in managed-proxy mode can only log to a file!")
        sys.exit(1)
    elif (args.name == 'managed') and (not args.log_file):
        # managed proxies without a logfile must not log at all.
        log.disable_logs()

    if args.proxy:
        # CLI proxy is only supported in external mode.
        if args.name == 'managed':
            log.error("Don't set the proxy using the CLI in managed mode. " \
                      "Use the managed-proxy configuration protocol instead!")
            sys.exit(1)

        # Check if we have the necessary dependencies
        # (the function will raise an exception if not)
        network.ensure_outgoing_proxy_dependencies()

        # Make sure that the proxy URI parses smoothly.
        try:
            proxy = parseProxyURI(args.proxy)
        except Exception as e:
            log.error("Failed to parse proxy specifier: %s", e)
            sys.exit(1)
Ejemplo n.º 3
0
def consider_cli_args(args):
    """Check out parsed CLI arguments and take the appropriate actions."""

    if args.log_file:
        log.set_log_file(args.log_file)
    if args.log_min_severity:
        log.set_log_severity(args.log_min_severity)
    if args.no_log:
        log.disable_logs()
    if args.no_safe_logging:
        log.set_no_safe_logging()

    # validate:
    if (args.name == 'managed') and (not args.log_file) and (args.log_min_severity):
        log.error("obfsproxy in managed-proxy mode can only log to a file!")
        sys.exit(1)
    elif (args.name == 'managed') and (not args.log_file):
        # managed proxies without a logfile must not log at all.
        log.disable_logs()

    if args.proxy:
        # CLI proxy is only supported in external mode.
        if args.name == 'managed':
            log.error("Don't set the proxy using the CLI in managed mode. " \
                      "Use the managed-proxy configuration protocol instead!")
            sys.exit(1)

        # Check if we have the necessary dependencies
        # (the function will raise an exception if not)
        network.ensure_outgoing_proxy_dependencies()

        # Make sure that the proxy URI parses smoothly.
        try:
            proxy = parseProxyURI(args.proxy)
        except Exception as e:
            log.error("Failed to parse proxy specifier: %s", e)
            sys.exit(1)
Ejemplo n.º 4
0
def do_external_mode(args):
    """This function starts obfsproxy's external-mode functionality."""

    assert(args)
    assert(args.name)
    assert(args.name in transports.transports)

    from twisted.internet import reactor

    pt_config = transport_config.TransportConfig()
    pt_config.setStateLocation(args.data_dir)
    pt_config.setListenerMode(args.mode)
    pt_config.setObfsproxyMode("external")
    if args.proxy: # Set outgoing proxy settings if we have them
        proxy = parseProxyURI(args.proxy)
        pt_config.setProxy(proxy)

    # Run setup() method.
    run_transport_setup(pt_config, args.name)

    launch_transport.launch_transport_listener(args.name, args.listen_addr, args.mode, args.dest, pt_config, args.ext_cookie_file)
    log.info("Launched '%s' listener at '%s:%s' for transport '%s'." % \
                 (args.mode, log.safe_addr_str(args.listen_addr[0]), args.listen_addr[1], args.name))
    reactor.run()