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


Python endpoints.SSL4ServerEndpoint方法代码示例

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


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

示例1: createServerEndpoint

# 需要导入模块: from twisted.internet import endpoints [as 别名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 别名]
def createServerEndpoint(self, reactor, factory, **listenArgs):
        """
        Create an L{SSL4ServerEndpoint} and return the tools to verify its
        behaviour.

        @param factory: The thing that we expect to be passed to our
            L{IStreamServerEndpoint.listen} implementation.
        @param reactor: A fake L{IReactorSSL} that L{SSL4ServerEndpoint} can
            call L{IReactorSSL.listenSSL} on.
        @param listenArgs: Optional dictionary of arguments to
            L{IReactorSSL.listenSSL}.
        """
        address = IPv4Address("TCP", "0.0.0.0", 0)

        return (endpoints.SSL4ServerEndpoint(reactor,
                                             address.port,
                                             self.serverSSLContext,
                                             **listenArgs),
                (address.port, factory, self.serverSSLContext,
                 listenArgs.get('backlog', 50),
                 listenArgs.get('interface', '')),
                address) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:24,代码来源:test_endpoints.py

示例2: test_ssl

# 需要导入模块: from twisted.internet import endpoints [as 别名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 别名]
def test_ssl(self):
        """
        When passed an SSL strports description, L{endpoints.serverFromString}
        returns a L{SSL4ServerEndpoint} instance initialized with the values
        from the string.
        """
        reactor = object()
        server = endpoints.serverFromString(
            reactor,
            "ssl:1234:backlog=12:privateKey=%s:"
            "certKey=%s:sslmethod=TLSv1_METHOD:interface=10.0.0.1"
            % (escapedPEMPathName, escapedPEMPathName))
        self.assertIsInstance(server, endpoints.SSL4ServerEndpoint)
        self.assertIs(server._reactor, reactor)
        self.assertEqual(server._port, 1234)
        self.assertEqual(server._backlog, 12)
        self.assertEqual(server._interface, "10.0.0.1")
        self.assertEqual(server._sslContextFactory.method, TLSv1_METHOD)
        ctx = server._sslContextFactory.getContext()
        self.assertIsInstance(ctx, ContextType) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:22,代码来源:test_endpoints.py

示例3: test_sslWithDefaults

# 需要导入模块: from twisted.internet import endpoints [as 别名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 别名]
def test_sslWithDefaults(self):
        """
        An SSL string endpoint description with minimal arguments returns
        a properly initialized L{SSL4ServerEndpoint} instance.
        """
        reactor = object()
        server = endpoints.serverFromString(
            reactor, "ssl:4321:privateKey=%s" % (escapedPEMPathName,))
        self.assertIsInstance(server, endpoints.SSL4ServerEndpoint)
        self.assertIs(server._reactor, reactor)
        self.assertEqual(server._port, 4321)
        self.assertEqual(server._backlog, 50)
        self.assertEqual(server._interface, "")
        self.assertEqual(server._sslContextFactory.method, SSLv23_METHOD)
        self.assertTrue(
            server._sslContextFactory._options & OP_NO_SSLv3,
        )
        ctx = server._sslContextFactory.getContext()
        self.assertIsInstance(ctx, ContextType)


    # Use a class variable to ensure we use the exactly same endpoint string
    # except for the chain file itself. 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:25,代码来源:test_endpoints.py

示例4: test_sslNoTrailingNewlinePem

# 需要导入模块: from twisted.internet import endpoints [as 别名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 别名]
def test_sslNoTrailingNewlinePem(self):
        """
        Lack of a trailing newline in key and cert .pem files should not
        generate an exception.
        """
        reactor = object()
        server = endpoints.serverFromString(
            reactor,
            "ssl:1234:backlog=12:privateKey=%s:"
            "certKey=%s:sslmethod=TLSv1_METHOD:interface=10.0.0.1"
            % (
                escapedNoTrailingNewlineKeyPEMPathName,
                escapedNoTrailingNewlineCertPEMPathName,
            )
        )
        self.assertIsInstance(server, endpoints.SSL4ServerEndpoint)
        self.assertIs(server._reactor, reactor)
        self.assertEqual(server._port, 1234)
        self.assertEqual(server._backlog, 12)
        self.assertEqual(server._interface, "10.0.0.1")
        self.assertEqual(server._sslContextFactory.method, TLSv1_METHOD)
        ctx = server._sslContextFactory.getContext()
        self.assertIsInstance(ctx, ContextType) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:25,代码来源:test_endpoints.py

示例5: test_ssl

# 需要导入模块: from twisted.internet import endpoints [as 别名]
# 或者: from twisted.internet.endpoints import SSL4ServerEndpoint [as 别名]
def test_ssl(self):
        """
        When passed an SSL strports description, L{endpoints.serverFromString}
        returns a L{SSL4ServerEndpoint} instance initialized with the values
        from the string.
        """
        reactor = object()
        server = endpoints.serverFromString(
            reactor,
            "ssl:1234:backlog=12:privateKey=%s:"
            "certKey=%s:interface=10.0.0.1" % (escapedPEMPathName,
                                               escapedPEMPathName))
        self.assertIsInstance(server, endpoints.SSL4ServerEndpoint)
        self.assertIdentical(server._reactor, reactor)
        self.assertEquals(server._port, 1234)
        self.assertEquals(server._backlog, 12)
        self.assertEquals(server._interface, "10.0.0.1")
        ctx = server._sslContextFactory.getContext()
        self.assertIsInstance(ctx, ContextType) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:test_endpoints.py


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