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


Python router.Router类代码示例

本文整理汇总了Python中txtorcon.router.Router的典型用法代码示例。如果您正苦于以下问题:Python Router类的具体用法?Python Router怎么用?Python Router使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_policy_not_set_error

 def test_policy_not_set_error(self):
     router = Router(object())
     try:
         router.accepts_port(123)
         self.fail()
     except Exception, e:
         self.assertTrue("policy" in str(e))
开发者ID:arlolra,项目名称:txtorcon,代码行数:7,代码来源:test_router.py

示例2: test_policy_error

 def test_policy_error(self):
     router = Router(object())
     try:
         router.policy = 'foo 123'
         self.fail()
     except Exception, e:
         self.assertTrue("Don't understand" in str(e))
开发者ID:arlolra,项目名称:txtorcon,代码行数:7,代码来源:test_router.py

示例3: test_countrycode

 def test_countrycode(self):
     controller = FakeController()
     router = Router(controller)
     router.update("foo",
                   "AHhuQ8zFQJdT8l42Axxc6m6kNwI",
                   "MAANkj30tnFvmoh7FsjVFr+cmcs",
                   "2011-12-16 15:11:34",
                   "127.0.0.1",
                   "24051", "24052")
开发者ID:gsathya,项目名称:txtorcon,代码行数:9,代码来源:test_router.py

示例4: test_repr

 def test_repr(self):
     router = Router(FakeController())
     router.update("foo",
                   "AHhuQ8zFQJdT8l42Axxc6m6kNwI",
                   "MAANkj30tnFvmoh7FsjVFr+cmcs",
                   "2011-12-16 15:11:34",
                   "1.2.3.4",
                   "24051", "24052")
     router.flags = ['Named']
     repr(router)
开发者ID:arlolra,项目名称:txtorcon,代码行数:10,代码来源:test_router.py

示例5: test_ctor

 def test_ctor(self):
     controller = object()
     router = Router(controller)
     router.update("foo",
                   "AHhuQ8zFQJdT8l42Axxc6m6kNwI",
                   "MAANkj30tnFvmoh7FsjVFr+cmcs",
                   "2011-12-16 15:11:34",
                   "77.183.225.114",
                   "24051", "24052")
     self.assertEqual(router.id_hex, "$00786E43CCC5409753F25E36031C5CEA6EA43702")
     self.assertEqual(router.policy, '')
开发者ID:arlolra,项目名称:txtorcon,代码行数:11,代码来源:test_router.py

示例6: test_flags_from_string

 def test_flags_from_string(self):
     controller = object()
     router = Router(controller)
     router.update("foo",
                   "AHhuQ8zFQJdT8l42Axxc6m6kNwI",
                   "MAANkj30tnFvmoh7FsjVFr+cmcs",
                   "2011-12-16 15:11:34",
                   "77.183.225.114",
                   "24051", "24052")
     router.flags = "Exit Fast Named Running V2Dir Valid"
     self.assertEqual(router.name_is_unique, True)
开发者ID:arlolra,项目名称:txtorcon,代码行数:11,代码来源:test_router.py

示例7: test_get_location_unknown

    def test_get_location_unknown(self):

        class CountryCodeController(object):
            def get_info_raw(self, i):
                raise RuntimeError("shouldn't happen")
        controller = CountryCodeController()

        r = Router(controller)
        loc = yield r.get_location()

        self.assertEqual(loc.countrycode, None)
开发者ID:meejah,项目名称:txtorcon,代码行数:11,代码来源:test_router.py

示例8: test_unique_name

 def test_unique_name(self):
     controller = object()
     router = Router(controller)
     router.update("foo",
                   "AHhuQ8zFQJdT8l42Axxc6m6kNwI",
                   "MAANkj30tnFvmoh7FsjVFr+cmcs",
                   "2011-12-16 15:11:34",
                   "77.183.225.114",
                   "24051", "24052")
     self.assertTrue(router.id_hex == "$00786E43CCC5409753F25E36031C5CEA6EA43702")
     self.assertTrue(router.unique_name == "$00786E43CCC5409753F25E36031C5CEA6EA43702")
     router.flags = ['Named']
     self.assertTrue(router.unique_name == "foo")
开发者ID:gsathya,项目名称:txtorcon,代码行数:13,代码来源:test_router.py

示例9: test_get_location_something

    def test_get_location_something(self):

        class CountryCodeController(object):
            def get_info_raw(self, i):
                return defer.succeed(
                    '250-ip-to-country/8.8.8.8=US\r\n250 OK'
                )
        controller = CountryCodeController()
        r = Router(controller)
        r.update('routername', 'deadbeef', 'orhash', 'modified', '8.8.8.8', '', '')
        loc = yield r.get_location()

        self.assertNotEqual(loc.countrycode, None)
开发者ID:meejah,项目名称:txtorcon,代码行数:13,代码来源:test_router.py

示例10: test_countrycode

    def test_countrycode(self):
        class CountryCodeController(object):
            def get_info_raw(self, i):
                return defer.succeed('250-ip-to-country/127.1.2.3=ZZ\r\n250 OK')
        controller = CountryCodeController()
        router = Router(controller)
        router.update("foo",
                      "AHhuQ8zFQJdT8l42Axxc6m6kNwI",
                      "MAANkj30tnFvmoh7FsjVFr+cmcs",
                      "2011-12-16 15:11:34",
                      "127.1.2.3",
                      "24051", "24052")

        self.assertEqual(router.location.countrycode, 'ZZ')
开发者ID:arlolra,项目名称:txtorcon,代码行数:14,代码来源:test_router.py

示例11: test_get_location_private

    def test_get_location_private(self):

        class CountryCodeController(object):
            def get_info_raw(self, i):
                return defer.succeed(
                    '250-ip-to-country/192.168.0.1=ZZ\r\n250 OK'
                )
        controller = CountryCodeController()
        r = Router(controller)
        r.update('routername', 'deadbeef', 'orhash', 'modified', '192.168.0.1', '', '')
        loc0 = yield r.get_location()
        loc1 = yield r.get_location()

        self.assertEqual(loc0.countrycode, 'ZZ')
        self.assertEqual(loc1.countrycode, 'ZZ')
开发者ID:meejah,项目名称:txtorcon,代码行数:15,代码来源:test_router.py

示例12: _router_begin

    def _router_begin(self, data):
        args = data.split()
        self._router = Router(self.protocol)
        self._router.from_consensus = True
        self._router.update(args[1],         # nickname
                            args[2],         # idhash
                            args[3],         # orhash
                            datetime.datetime.strptime(args[4] + args[5], '%Y-%m-%f%H:%M:%S'),
                            args[6],         # ip address
                            args[7],         # ORPort
                            args[8])         # DirPort

        if self._router.id_hex in self.routers:
            ## FIXME should I do an update() on this one??
            self._router = self.routers[self._router.id_hex]
            return

        if self._router.name in self.routers_by_name:
            self.routers_by_name[self._router.name].append(self._router)

        else:
            self.routers_by_name[self._router.name] = [self._router]

        if self._router.name in self.routers:
            self.routers[self._router.name] = None

        else:
            self.routers[self._router.name] = self._router
        self.routers[self._router.id_hex] = self._router
开发者ID:enriquefynn,项目名称:txtorcon,代码行数:29,代码来源:torstate.py

示例13: test_ctor

    def test_ctor(self):
        controller = object()
        router = Router(controller)
        router.update("foo",
                      "AHhuQ8zFQJdT8l42Axxc6m6kNwI",
                      "MAANkj30tnFvmoh7FsjVFr+cmcs",
                      "2011-12-16 15:11:34",
                      "77.183.225.114",
                      "24051", "24052")
        self.assertEqual(
            router.id_hex,
            "$00786E43CCC5409753F25E36031C5CEA6EA43702"
        )

        # we assert this twice to cover the cached + uncached cases
        self.assertTrue(isinstance(router.modified, datetime))
        self.assertTrue(isinstance(router.modified, datetime))
        self.assertEqual(router.policy, '')
开发者ID:felipedau,项目名称:txtorcon,代码行数:18,代码来源:test_router.py

示例14: setUp

 def setUp(self):
     self.router = Router(FakeController())
     self.router.update(
         "foo",
         "AHhuQ8zFQJdT8l42Axxc6m6kNwI",
         "MAANkj30tnFvmoh7FsjVFr+cmcs",
         "2011-12-16 15:11:34",
         "1.2.3.4",
         "24051", "24052"
     )
开发者ID:felipedau,项目名称:txtorcon,代码行数:10,代码来源:test_router.py

示例15: router_from_id

    def router_from_id(self, routerid):
        """IRouterContainer API"""

        try:
            return self.routers[routerid]

        except KeyError:
            router = Router(self.protocol)
            if routerid[0] != '$':
                raise                   # just re-raise the KeyError

            idhash = routerid[1:41]
            nick = ''
            is_named = False
            if len(routerid) > 41:
                nick = routerid[42:]
                is_named = routerid[42] is '='
            router.update(nick, hashFromHexId(idhash), '0'*27, 'unknown', 'unknown', '0', '0')
            return router
开发者ID:narastabbocchi,项目名称:txtorcon,代码行数:19,代码来源:torstate.py


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