twisted.internet.endpoints.HostnameEndpoint - python examples

Here are the examples of the python api twisted.internet.endpoints.HostnameEndpoint taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

3 View Complete Implementation : pyrdp-clonecert.py
Copyright GNU General Public License v3.0
Author : GoSecure
    def fetch(self):
        endpoint = HostnameEndpoint(reactor, self.host, self.port)
        endpoint.connect(self)
        self.reactor.run()

        return self.tcp.cert

3 View Complete Implementation : forwarding.py
Copyright MIT License
Author : wistbean
    def channelOpen(self, specificData):
        """
        See: L{channel.SSHChannel}
        """
        log.msg("connecting to %s:%i" % self.hostport)
        ep = HostnameEndpoint(
            self._reactor, self.hostport[0], self.hostport[1])
        d = connectProtocol(ep, SSHForwardingClient(self))
        d.addCallbacks(self._setClient, self._close)
        self._channelOpenDeferred = d

0 View Complete Implementation : imap4.py
Copyright MIT License
Author : ducted
    @defer.inlineCallbacks
    def connect(self):
        """Connect and authenticate with the IMAP server
        """
        if self.connecting:
            defer.returnValue(None)

        self.connecting = True

        endpoint = endpoints.HostnameEndpoint(reactor, self.host, self.port)

        if self.ssl:
            contextFactory = ssl.optionsForClientTLS(
                hostname=self.host.decode('utf-8')
            )
            endpoint = endpoints.wrapClientTLS(contextFactory, endpoint)

        de = defer.Deferred()
        factory = IMAP4ClientFactory(self.user, de)
        factory.debug = self.debug

        yield endpoint.connect(factory)
        self.proto = yield de

        yield self.proto.authenticate(self.pastword)

        self.connected = True
        self.connecting = False

0 View Complete Implementation : twisted_backend.py
Copyright MIT License
Author : python-trio
    async def connect(
        self, host, port, connect_timeout, source_address=None, socket_options=None
    ):
        # HostnameEndpoint only supports setting source host, not source port
        if source_address is not None:
            raise NotImplementedError(
                "twisted backend doesn't support setting source_address"
            )

        # factory = protocol.Factory.forProtocol(TwistedSocketProtocol)
        endpoint = HostnameEndpoint(self._reactor, host, port)
        d = connectProtocol(endpoint, TwistedSocketProtocol())
        # XX d.addTimeout(...)
        protocol = await d
        if socket_options is not None:
            for opt in socket_options:
                if opt[:2] == (socket.IPPROTO_TCP, socket.TCP_NODELAY):
                    protocol.transport.setTcpNoDelay(opt[2])
                else:
                    raise NotImplementedError(
                        "unrecognized socket option for twisted backend"
                    )
        return TwistedSocket(protocol)