本文整理汇总了Python中txtorcon.TorConfig.needs_save方法的典型用法代码示例。如果您正苦于以下问题:Python TorConfig.needs_save方法的具体用法?Python TorConfig.needs_save怎么用?Python TorConfig.needs_save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txtorcon.TorConfig
的用法示例。
在下文中一共展示了TorConfig.needs_save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_options_hidden
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_options_hidden(self):
self.protocol.answers.append(
'HiddenServiceDir=/fake/path\nHiddenServicePort=80 '
'127.0.0.1:1234\nHiddenServiceDirGroupReadable=1\n'
)
conf = TorConfig(self.protocol)
yield conf.post_bootstrap
self.assertTrue(conf.post_bootstrap.called)
self.assertTrue('HiddenServiceOptions' not in conf.config)
self.assertTrue('HiddenServices' in conf.config)
self.assertEqual(len(conf.HiddenServices), 1)
self.assertTrue(not conf.needs_save())
conf.hiddenservices.append(
HiddenService(conf, '/some/dir', '80 127.0.0.1:2345', 'auth', 2, True)
)
conf.hiddenservices[0].ports.append('443 127.0.0.1:443')
self.assertTrue(conf.needs_save())
conf.save()
self.assertEqual(len(self.protocol.sets), 9)
self.assertEqual(self.protocol.sets[0], ('HiddenServiceDir', '/fake/path'))
self.assertEqual(self.protocol.sets[1], ('HiddenServiceDirGroupReadable', '1'))
self.assertEqual(self.protocol.sets[2], ('HiddenServicePort', '80 127.0.0.1:1234'))
self.assertEqual(self.protocol.sets[3], ('HiddenServicePort', '443 127.0.0.1:443'))
self.assertEqual(self.protocol.sets[4], ('HiddenServiceDir', '/some/dir'))
self.assertEqual(self.protocol.sets[5], ('HiddenServiceDirGroupReadable', '1'))
self.assertEqual(self.protocol.sets[6], ('HiddenServicePort', '80 127.0.0.1:2345'))
self.assertEqual(self.protocol.sets[7], ('HiddenServiceVersion', '2'))
self.assertEqual(self.protocol.sets[8], ('HiddenServiceAuthorizeClient', 'auth'))
示例2: test_set_save_modify
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_set_save_modify(self):
self.protocol.answers.append('config/names=\nLog LineList')
self.protocol.answers.append({'Log': 'notice file /var/log/tor/notices.log'})
conf = TorConfig(self.protocol)
conf.log = []
self.assertTrue(conf.needs_save())
conf.save()
conf.log.append('notice file /tmp/foo.log')
self.assertTrue(conf.needs_save())
示例3: test_log_double_save
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_log_double_save(self):
self.protocol.answers.append('config/names=\nLog LineList\nFoo String''')
self.protocol.answers.append({'Log': 'notice file /var/log/tor/notices.log'})
self.protocol.answers.append({'Foo': 'foo'})
conf = TorConfig(self.protocol)
conf.log.append('info file /tmp/foo.log')
conf.foo = 'bar'
self.assertTrue(conf.needs_save())
conf.save()
conf.save() # just for the code coverage...
self.assertTrue(not conf.needs_save())
self.protocol.sets = []
conf.save()
self.assertEqual(self.protocol.sets, [])
示例4: test_add_hidden_service_to_empty_config
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_add_hidden_service_to_empty_config(self):
conf = TorConfig()
h = HiddenService(conf, '/fake/path', ['80 127.0.0.1:1234'], '', 3)
conf.hiddenservices.append(h)
self.assertEqual(len(conf.hiddenservices), 1)
self.assertEqual(h, conf.hiddenservices[0])
self.assertTrue(conf.needs_save())
示例5: test_log_set_index
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_log_set_index(self):
conf = TorConfig(self.protocol)
conf.log[0] = 'info file /tmp/foo.log'
self.assertTrue(conf.needs_save())
conf.save()
self.assertTrue(self.protocol.sets[0] == ('Log', 'info file /tmp/foo.log'))
示例6: test_log_set_slice
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_log_set_slice(self):
conf = TorConfig(self.protocol)
conf.log[0:1] = ['info file /tmp/foo.log']
self.assertTrue(conf.needs_save())
conf.save()
self.assertEqual(self.protocol.sets[0], ('Log', 'info file /tmp/foo.log'))
示例7: test_log_set_capital
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_log_set_capital(self):
conf = TorConfig(self.protocol)
conf.Log.append('info file /tmp/foo.log')
self.assertTrue(conf.needs_save())
conf.save()
self.assertEqual(self.protocol.sets[0], ('Log', 'notice file /var/log/tor/notices.log'))
self.assertEqual(self.protocol.sets[1], ('Log', 'info file /tmp/foo.log'))
示例8: test_multiple_append
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [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)
conf.hiddenservices.append(h0)
conf.hiddenservices.append(h1)
self.assertEqual(len(conf.hiddenservices), 2)
self.assertEqual(h0, conf.hiddenservices[0])
self.assertEqual(h1, conf.hiddenservices[1])
self.assertTrue(conf.needs_save())
示例9: test_set_save_modify
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [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())
示例10: test_log_set_remove
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_log_set_remove(self):
conf = TorConfig(self.protocol)
self.assertEqual(len(conf.log), 1)
conf.log.remove('notice file /var/log/tor/notices.log')
self.assertTrue(conf.needs_save())
conf.save()
self.assertEqual(len(conf.log), 0)
self.assertEqual(len(self.protocol.sets), 0)
示例11: test_log_set_pop
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_log_set_pop(self):
conf = TorConfig(self.protocol)
self.assertEqual(len(conf.log), 1)
conf.log.pop()
self.assertTrue(conf.needs_save())
conf.save()
self.assertEqual(len(conf.log), 0)
self.assertEqual(len(self.protocol.sets), 0)
示例12: test_hidden_service_same_directory
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_hidden_service_same_directory(self):
conf = TorConfig(FakeControlProtocol(['config/names=']))
servicelines = '''HiddenServiceDir=/fake/path
HiddenServiceDir=/fake/path'''
self.assertRaises(RuntimeError, conf._setup_hidden_services, servicelines)
conf = TorConfig()
conf.HiddenServices = [HiddenService(conf, '/fake/path', ['80 127.0.0.1:1234'])]
conf.HiddenServices.append(HiddenService(conf, '/fake/path', ['80 127.0.0.1:1234']))
self.assertTrue(conf.needs_save())
self.assertRaises(RuntimeError, conf.save)
conf = TorConfig()
conf.HiddenServices = [HiddenService(conf, '/fake/path', ['80 127.0.0.1:1234'])]
conf.HiddenServices.append(HiddenService(conf, '/fake/path/two', ['80 127.0.0.1:1234']))
self.assertTrue(conf.needs_save())
conf.save()
conf.hiddenservices[1].dir = '/fake/path'
self.assertTrue(conf.needs_save())
self.assertRaises(RuntimeError, conf.save)
示例13: test_log_set_extend
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_log_set_extend(self):
conf = TorConfig(self.protocol)
self.assertTrue(len(conf.log) == 1)
conf.log.extend(['info file /tmp/foo'])
self.assertTrue(conf.needs_save())
conf.save()
self.assertTrue(len(conf.log) == 2)
self.assertTrue(len(self.protocol.sets) == 2)
self.assertTrue(self.protocol.sets[0] == ('Log', 'notice file /var/log/tor/notices.log'))
self.assertTrue(self.protocol.sets[1] == ('Log', 'info file /tmp/foo'))
示例14: test_options_hidden
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_options_hidden(self):
self.protocol.answers.append('HiddenServiceDir=/fake/path\nHiddenServicePort=80 127.0.0.1:1234\n')
conf = TorConfig(self.protocol)
self.assertTrue(not conf.config.has_key('HiddenServiceOptions'))
self.assertEqual(len(conf.HiddenServices), 1)
self.assertTrue(not conf.needs_save())
conf.hiddenservices.append(HiddenService(conf, '/some/dir', '80 127.0.0.1:2345', 'auth', 2))
conf.hiddenservices[0].ports.append('443 127.0.0.1:443')
self.assertTrue(conf.needs_save())
conf.save()
self.assertEqual(len(self.protocol.sets), 7)
self.assertEqual(self.protocol.sets[0], ('HiddenServiceDir', '/fake/path'))
self.assertEqual(self.protocol.sets[1], ('HiddenServicePort', '80 127.0.0.1:1234'))
self.assertEqual(self.protocol.sets[2], ('HiddenServicePort', '443 127.0.0.1:443'))
self.assertEqual(self.protocol.sets[3], ('HiddenServiceDir', '/some/dir'))
self.assertEqual(self.protocol.sets[4], ('HiddenServicePort', '80 127.0.0.1:2345'))
self.assertEqual(self.protocol.sets[5], ('HiddenServiceVersion', '2'))
self.assertEqual(self.protocol.sets[6], ('HiddenServiceAuthorizeClient', 'auth'))
示例15: test_log_set_multiple
# 需要导入模块: from txtorcon import TorConfig [as 别名]
# 或者: from txtorcon.TorConfig import needs_save [as 别名]
def test_log_set_multiple(self):
conf = TorConfig(self.protocol)
self.assertEqual(len(conf.log), 1)
conf.log[0] = 'foo'
self.assertTrue(conf.needs_save())
conf.log[0] = 'heavy'
conf.log[0] = 'round'
conf.save()
self.assertEqual(len(self.protocol.sets), 1)
self.assertEqual(self.protocol.sets[0], ('Log', 'round'))