Пример #1
0
    def _connect(self, connection, reactor):
        assert (reactor is not None)
        url = self.address.next()
        reactor.set_connection_host(connection, url.host, str(url.port))
        # if virtual-host not set, use host from address as default
        if self.virtual_host is None:
            connection.hostname = url.host
        log.debug("connecting to %s..." % url)

        transport = Transport()
        if self.sasl_enabled:
            sasl = transport.sasl()
            sasl.allow_insecure_mechs = self.allow_insecure_mechs
            if url.username:
                connection.user = url.username
            elif self.user:
                connection.user = self.user
            if url.password:
                connection.password = url.password
            elif self.password:
                connection.password = self.password
            if self.allowed_mechs:
                sasl.allowed_mechs(self.allowed_mechs)
        transport.bind(connection)
        if self.heartbeat:
            transport.idle_timeout = self.heartbeat
        if url.scheme == 'amqps':
            if not self.ssl_domain:
                raise SSLUnavailable("amqps: SSL libraries not found")
            self.ssl = SSL(transport, self.ssl_domain)
            self.ssl.peer_hostname = self.ssl_sni or self.virtual_host or url.host
        if self.max_frame_size:
            transport.max_frame_size = self.max_frame_size
Пример #2
0
    def _connect(self, connection):
        url = self.address.next()
        # IoHandler uses the hostname to determine where to try to connect to
        connection.hostname = "%s:%s" % (url.host, url.port)
        logging.info("connecting to %s..." % connection.hostname)

        transport = Transport()
        if self.sasl_enabled:
            sasl = transport.sasl()
            sasl.allow_insecure_mechs = self.allow_insecure_mechs
            if url.username:
                connection.user = url.username
            elif self.user:
                connection.user = self.user
            if url.password:
                connection.password = url.password
            elif self.password:
                connection.password = self.password
            if self.allowed_mechs:
                sasl.allowed_mechs(self.allowed_mechs)
        transport.bind(connection)
        if self.heartbeat:
            transport.idle_timeout = self.heartbeat
        if url.scheme == 'amqps' and self.ssl_domain:
            self.ssl = SSL(transport, self.ssl_domain)
            self.ssl.peer_hostname = url.host
Пример #3
0
 def accept(self, force_sasl=True, ssl_domain=None):
     if ssl_domain:
         self.ssl = SSL(self.transport, ssl_domain)
     if force_sasl:
         sasl = self.transport.sasl()
         sasl.mechanisms("ANONYMOUS")
         sasl.server()
         sasl.done(SASL.OK)
     #TODO: use SASL anyway if requested by peer
     return self
Пример #4
0
    def _connect(self, connection):
        url = self.address.next()
        # IoHandler uses the hostname to determine where to try to connect to
        connection.hostname = "%s:%i" % (url.host, url.port)
        logging.info("connecting to %s..." % connection.hostname)

        if url.username:
            connection.user = url.username
        if url.password:
            connection.password = url.password
        transport = Transport()
        transport.bind(connection)
        if self.heartbeat:
            transport.idle_timeout = self.heartbeat
        if url.scheme == 'amqps' and self.ssl_domain:
            self.ssl = SSL(transport, self.ssl_domain)
            self.ssl.peer_hostname = url.host
Пример #5
0
    def _connect(self, connection):
        url = self.address.next()
        # IoHandler uses the hostname to determine where to try to connect to
        connection.hostname = "%s:%i" % (url.host, url.port)
        logging.info("connecting to %s..." % connection.hostname)

        transport = Transport()
        transport.bind(connection)
        if self.heartbeat:
            transport.idle_timeout = self.heartbeat
        if url.scheme == 'amqps' and self.ssl_domain:
            self.ssl = SSL(transport, self.ssl_domain)
            self.ssl.peer_hostname = url.host
        if url.username:
            sasl = transport.sasl()
            if url.username == 'anonymous':
                sasl.mechanisms('ANONYMOUS')
            else:
                sasl.plain(url.username, url.password)
Пример #6
0
 def connect(self,
             host,
             port=None,
             username=None,
             password=None,
             force_sasl=True,
             ssl_domain=None):
     if ssl_domain:
         self.ssl = SSL(self.transport, ssl_domain)
         self.ssl.peer_hostname = host
     if username and password:
         sasl = self.transport.sasl()
         sasl.plain(username, password)
     elif force_sasl:
         sasl = self.transport.sasl()
         sasl.mechanisms('ANONYMOUS')
         sasl.client()
     try:
         self.socket.connect_ex((host, port or 5672))
     except socket.gaierror, e:
         raise ConnectionException("Cannot resolve '%s': %s" % (host, e))
Пример #7
0
def isSSLPresent():
    return SSL.present()
Пример #8
0
def isSSLPresent():
    return SSL.present()