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


Python portforward.ProxyFactory方法代码示例

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


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

示例1: vtproxy

# 需要导入模块: from twisted.protocols import portforward [as 别名]
# 或者: from twisted.protocols.portforward import ProxyFactory [as 别名]
def vtproxy():
	reactor.listenTCP(lport, portforward.ProxyFactory(dhost, dport))
	reactor.run() 
开发者ID:mertsarica,项目名称:hack4career,代码行数:5,代码来源:vtp.py

示例2: makeService

# 需要导入模块: from twisted.protocols import portforward [as 别名]
# 或者: from twisted.protocols.portforward import ProxyFactory [as 别名]
def makeService(config):
    f = portforward.ProxyFactory(config['host'], int(config['dest_port']))
    return strports.service(config['port'], f) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:5,代码来源:portforward.py

示例3: buildProtocol

# 需要导入模块: from twisted.protocols import portforward [as 别名]
# 或者: from twisted.protocols.portforward import ProxyFactory [as 别名]
def buildProtocol(self, addr):
        """
        Create the protocol instance, keeps track of it, and makes it use
        C{clientFactoryInstance} as client factory.
        """
        proto = portforward.ProxyFactory.buildProtocol(self, addr)
        self.clientFactoryInstance = TestableProxyClientFactory()
        # Force the use of this specific instance
        proto.clientProtocolFactory = lambda: self.clientFactoryInstance
        self.protoInstance = proto
        return proto 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:test_protocols.py

示例4: test_registerProducers

# 需要导入模块: from twisted.protocols import portforward [as 别名]
# 或者: from twisted.protocols.portforward import ProxyFactory [as 别名]
def test_registerProducers(self):
        """
        The proxy client registers itself as a producer of the proxy server and
        vice versa.
        """
        # create a ProxyServer instance
        addr = address.IPv4Address('TCP', '127.0.0.1', 0)
        server = portforward.ProxyFactory('127.0.0.1', 0).buildProtocol(addr)

        # set the reactor for this test
        reactor = proto_helpers.MemoryReactor()
        server.reactor = reactor

        # make the connection
        serverTransport = proto_helpers.StringTransport()
        server.makeConnection(serverTransport)

        # check that the ProxyClientFactory is connecting to the backend
        self.assertEqual(len(reactor.tcpClients), 1)
        # get the factory instance and check it's the one we expect
        host, port, clientFactory, timeout, _ = reactor.tcpClients[0]
        self.assertIsInstance(clientFactory, portforward.ProxyClientFactory)

        # Connect it
        client = clientFactory.buildProtocol(addr)
        clientTransport = proto_helpers.StringTransport()
        client.makeConnection(clientTransport)

        # check that the producers are registered
        self.assertIs(clientTransport.producer, serverTransport)
        self.assertIs(serverTransport.producer, clientTransport)
        # check the streaming attribute in both transports
        self.assertTrue(clientTransport.streaming)
        self.assertTrue(serverTransport.streaming) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:36,代码来源:test_protocols.py

示例5: starttcpproxy

# 需要导入模块: from twisted.protocols import portforward [as 别名]
# 或者: from twisted.protocols.portforward import ProxyFactory [as 别名]
def starttcpproxy():
	reactor.listenTCP(localport, portforward.ProxyFactory(desthost, destport))
	reactor.run() 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:5,代码来源:proxyfuzz.py

示例6: testPortforward

# 需要导入模块: from twisted.protocols import portforward [as 别名]
# 或者: from twisted.protocols.portforward import ProxyFactory [as 别名]
def testPortforward(self):
        serverProtocol = wire.Echo()
        realServerFactory = protocol.ServerFactory()
        realServerFactory.protocol = lambda: serverProtocol
        realServerPort = reactor.listenTCP(0, realServerFactory,
                                           interface='127.0.0.1')

        proxyServerFactory = portforward.ProxyFactory('127.0.0.1',
                                                      realServerPort.getHost().port)
        proxyServerPort = reactor.listenTCP(0, proxyServerFactory,
                                            interface='127.0.0.1')

        nBytes = 1000
        received = []
        clientProtocol = protocol.Protocol()
        clientProtocol.dataReceived = received.extend
        clientProtocol.connectionMade = lambda: clientProtocol.transport.write('x' * nBytes)
        clientFactory = protocol.ClientFactory()
        clientFactory.protocol = lambda: clientProtocol

        reactor.connectTCP('127.0.0.1', proxyServerPort.getHost().port,
                           clientFactory)

        c = 0
        while len(received) < nBytes and c < 100:
            reactor.iterate(0.01)
            c += 1

        self.assertEquals(''.join(received), 'x' * nBytes)
        
        clientProtocol.transport.loseConnection()
        serverProtocol.transport.loseConnection()
        return defer.gatherResults([
            defer.maybeDeferred(realServerPort.stopListening),
            defer.maybeDeferred(proxyServerPort.stopListening)]) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:37,代码来源:test_protocols.py


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