当前位置: 首页>>代码示例>>Python>>正文


Python TorConfig.Tor2webMode方法代码示例

本文整理汇总了Python中txtorcon.TorConfig.Tor2webMode方法的典型用法代码示例。如果您正苦于以下问题:Python TorConfig.Tor2webMode方法的具体用法?Python TorConfig.Tor2webMode怎么用?Python TorConfig.Tor2webMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在txtorcon.TorConfig的用法示例。


在下文中一共展示了TorConfig.Tor2webMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: startTor

# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import Tor2webMode [as 别名]
def startTor():
    def updates(prog, tag, summary):
        print("%d%%: %s" % (prog, summary))

    tempfile.tempdir = os.path.join(_repo_dir, 'tmp')
    if not os.path.isdir(tempfile.gettempdir()):
        os.makedirs(tempfile.gettempdir())
    _temp_dir = tempfile.mkdtemp()

    torconfig = TorConfig()
    torconfig.SocksPort = config.main.socks_port
    if config.main.tor2webmode:
        torconfig.Tor2webMode = 1
        torconfig.CircuitBuildTimeout = 60
    if config.main.tor_datadir is None:
        log.warn("Option 'tor_datadir' in oonib.conf is unspecified!")
        log.msg("Creating tmp directory in current directory for datadir.")
        log.debug("Using %s" % _temp_dir)
        datadir = _temp_dir
    else:
        datadir = config.main.tor_datadir
    torconfig.DataDirectory = datadir
    torconfig.save()
    if config.main.tor_binary is not None:
        d = launch_tor(torconfig, reactor,
                       tor_binary=config.main.tor_binary,
                       progress_updates=updates)
    else:
        d = launch_tor(torconfig, reactor, progress_updates=updates)
    d.addCallback(setupCollector, datadir)
    if ooniBouncer:
        d.addCallback(setupBouncer, datadir)
    d.addErrback(txSetupFailed)
开发者ID:waaaaargh,项目名称:ooni-backend,代码行数:35,代码来源:runner.py

示例2: startTor

# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import Tor2webMode [as 别名]
def startTor():
    def updates(prog, tag, summary):
        print("%d%%: %s" % (prog, summary))

    torconfig = TorConfig()
    torconfig.SocksPort = config.main.socks_port
    if config.main.tor2webmode:
        torconfig.Tor2webMode = 1
        torconfig.CircuitBuildTimeout = 60
    torconfig.save()
    if config.main.tor_binary is not None:
        d = launch_tor(torconfig, reactor,
                       tor_binary=config.main.tor_binary,
                       progress_updates=updates)
    else:
        d = launch_tor(torconfig, reactor, progress_updates=updates)
    d.addCallback(setupCollector)
    d.addErrback(txSetupFailed)
开发者ID:stephen-soltesz,项目名称:ooni-backend,代码行数:20,代码来源:runner.py

示例3: _configTor

# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import Tor2webMode [as 别名]
def _configTor():
    torconfig = TorConfig()

    if config.main.socks_port is None:
        config.main.socks_port = int(randomFreePort())
    torconfig.SocksPort = config.main.socks_port

    if config.main.control_port is None:
        config.main.control_port = int(randomFreePort())
    torconfig.ControlPort = config.main.control_port

    if config.main.tor2webmode is True:
        torconfig.Tor2webMode = 1
        torconfig.CircuitBuildTimeout = 60
    if config.main.tor_datadir is None:
        temporary_data_dir = tempfile.mkdtemp()
        log.warn("Option 'tor_datadir' in oonib.conf is unspecified!")
        log.warn("Using %s" % temporary_data_dir)
        torconfig.DataDirectory = temporary_data_dir
        uid = -1
        gid = -1
        if config.main.uid is not None:
            uid = config.main.uid
        if config.main.gid is not None:
            gid = config.main.gid
        os.chown(temporary_data_dir, uid, gid)
    else:
        if os.path.exists(config.main.tor_datadir):
            torconfig.DataDirectory = os.path.abspath(config.main.tor_datadir)
        else:
            raise Exception("Could not find tor datadir")

    if config.main.uid is not None:
        try:
            user = pwd.getpwuid(config.main.uid)[0]
        except KeyError:
            raise Exception("Invalid user ID")
        torconfig.User = user

    tor_log_file = os.path.join(torconfig.DataDirectory, "tor.log")
    torconfig.Log = ["notice stdout", "notice file %s" % tor_log_file]
    torconfig.save()
    return torconfig
开发者ID:TheTorProject,项目名称:ooni-backend,代码行数:45,代码来源:onion.py


注:本文中的txtorcon.TorConfig.Tor2webMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。