本文整理汇总了Python中txtorcon.TorConfig.hiddenservices方法的典型用法代码示例。如果您正苦于以下问题:Python TorConfig.hiddenservices方法的具体用法?Python TorConfig.hiddenservices怎么用?Python TorConfig.hiddenservices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.TorConfig
的用法示例。
在下文中一共展示了TorConfig.hiddenservices方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multiple_append
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import hiddenservices [as 别名]
def test_multiple_append(self):
conf = TorConfig()
h0 = HiddenService(conf, '/fake/path', ['80 127.0.0.1:1234'], '', 3)
h1 = HiddenService(conf, '/fake/path', ['90 127.0.0.1:4321'], '', 3)
h2 = HiddenService(conf, '/fake/path', ['90 127.0.0.1:5432'], '', 3, True)
conf.hiddenservices = [h0]
conf.hiddenservices.append(h1)
conf.hiddenservices.append(h2)
self.assertEqual(len(conf.hiddenservices), 3)
self.assertEqual(h0, conf.hiddenservices[0])
self.assertEqual(h1, conf.hiddenservices[1])
self.assertEqual(h2, conf.hiddenservices[2])
self.assertTrue(conf.needs_save())
示例2: test_create_torrc
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import hiddenservices [as 别名]
def test_create_torrc(self):
config = TorConfig()
config.SocksPort = 1234
config.hiddenservices = [HiddenService(config, '/some/dir', '80 127.0.0.1:1234',
'auth', 2)]
config.Log = ['80 127.0.0.1:80', '90 127.0.0.1:90']
torrc = config.create_torrc()
self.assertTrue(torrc == '''HiddenServiceDir /some/dir
HiddenServicePort 80 127.0.0.1:1234
HiddenServiceVersion 2
HiddenServiceAuthorizeClient auth
Log 80 127.0.0.1:80
Log 90 127.0.0.1:90
SocksPort 1234
''')
示例3: test_create_torrc
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import hiddenservices [as 别名]
def test_create_torrc(self):
config = TorConfig()
config.SocksPort = 1234
config.hiddenservices = [HiddenService(config, '/some/dir', '80 127.0.0.1:1234',
'auth', 2)]
config.Log = ['80 127.0.0.1:80', '90 127.0.0.1:90']
config.save()
torrc = config.create_torrc()
lines = torrc.split('\n')
lines.sort()
torrc = '\n'.join(lines).strip()
self.assertEqual(torrc, '''HiddenServiceAuthorizeClient auth
HiddenServiceDir /some/dir
HiddenServicePort 80 127.0.0.1:1234
HiddenServiceVersion 2
Log 80 127.0.0.1:80
Log 90 127.0.0.1:90
SocksPort 1234''')
示例4: test_set_save_modify
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import hiddenservices [as 别名]
def test_set_save_modify(self):
self.protocol.answers.append('')
conf = TorConfig(self.protocol)
conf.hiddenservices = [HiddenService(conf, '/fake/path', ['80 127.0.0.1:1234'], '', 3)]
self.assertTrue(conf.needs_save())
conf.save()
self.assertEqual(len(conf.hiddenservices), 1)
self.assertEqual(conf.hiddenservices[0].dir, '/fake/path')
self.assertEqual(conf.hiddenservices[0].version, 3)
self.assertEqual(conf.hiddenservices[0].authorize_client, '')
conf.hiddenservices[0].ports = ['123 127.0.0.1:4321']
conf.save()
self.assertTrue(not conf.needs_save())
conf.hiddenservices[0].ports.append('90 127.0.0.1:2345')
self.assertTrue(conf.needs_save())