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


Python TorConfig.post_bootstrap方法代码示例

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


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

示例1: test_parse_user_path

# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import post_bootstrap [as 别名]
    def test_parse_user_path(self):
        # this makes sure we expand users and symlinks in
        # hiddenServiceDir args. see Issue #77

        # make sure we have a valid thing from get_global_tor without
        # actually launching tor
        config = TorConfig()
        config.post_bootstrap = defer.succeed(config)
        from txtorcon import torconfig
        torconfig._global_tor_config = None
        get_global_tor(
            self.reactor,
            _tor_launcher=lambda react, config, prog: defer.succeed(config)
        )
        ep = serverFromString(
            self.reactor,
            'onion:88:localPort=1234:hiddenServiceDir=~/blam/blarg'
        )
        # would be nice to have a fixed path here, but then would have
        # to run as a known user :/
        # maybe using the docker stuff to run integration tests better here?
        self.assertEqual(
            os.path.expanduser('~/blam/blarg'),
            ep.hidden_service_dir
        )
开发者ID:coffeemakr,项目名称:txtorcon,代码行数:27,代码来源:test_endpoints.py

示例2: test_parse_relative_path

# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import post_bootstrap [as 别名]
    def test_parse_relative_path(self):
        # this makes sure we convert a relative path to absolute
        # hiddenServiceDir args. see Issue #77

        # make sure we have a valid thing from get_global_tor without
        # actually launching tor
        config = TorConfig()
        config.post_bootstrap = defer.succeed(config)
        from txtorcon import torconfig
        torconfig._global_tor_config = None
        get_global_tor(
            self.reactor,
            _tor_launcher=lambda react, config, prog: defer.succeed(config)
        )

        orig = os.path.realpath('.')
        try:
            with util.TempDir() as t:
                t = str(t)
                os.chdir(t)
                os.mkdir(os.path.join(t, 'foo'))
                hsdir = os.path.join(t, 'foo', 'blam')
                os.mkdir(hsdir)

                ep = serverFromString(
                    self.reactor,
                    'onion:88:localPort=1234:hiddenServiceDir=foo/blam'
                )
                self.assertEqual(
                    os.path.realpath(hsdir),
                    ep.hidden_service_dir
                )

        finally:
            os.chdir(orig)
开发者ID:coffeemakr,项目名称:txtorcon,代码行数:37,代码来源:test_endpoints.py

示例3: test_parse_via_plugin

# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import post_bootstrap [as 别名]
 def test_parse_via_plugin(self):
     # make sure we have a valid thing from get_global_tor without actually launching tor
     config = TorConfig()
     config.post_bootstrap = defer.succeed(config)
     from txtorcon import torconfig
     torconfig._global_tor_config = None
     get_global_tor(self.reactor,
                    _tor_launcher=lambda react, config, prog: defer.succeed(config))
     ep = serverFromString(self.reactor, 'onion:88:localPort=1234:hiddenServiceDir=/foo/bar')
     self.assertEqual(ep.public_port, 88)
     self.assertEqual(ep.local_port, 1234)
     self.assertEqual(ep.hidden_service_dir, '/foo/bar')
开发者ID:arlolra,项目名称:txtorcon,代码行数:14,代码来源:test_endpoints.py


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