Records a discovered gateway, for connecting to later.
500476
def _on_gateway(self, header, payload, rest, addr):
        
        if payload.get('service') == SERVICE_UDP:
            self.gateway = Gateway(addr[0], payload['port'], header.gateway)
            self.gateway_found_event.set()
84301
def connection_made(self, transport):
        '''
        
        '''

        self.transport = transport
        self.remote_ip, self.port = transport.get_extra_info('peername')[:2]

        logging.debug(
            'Connection made (address: {} port: {})'
            .format(self.remote_ip, self.port))

        self.future = self.send_package(
                protomap.CPROTO_REQ_INFO,
                data=None,
                timeout=10)
388554
async def random_connection(self):
        
        addr = choice(list(self._connections.keys()))
        return await self.env.connect(addr)
416792
def connectionMade(self):
        
        self._buffer = b''
        self._queue = {}
        self._stopped = None
        self._tag = 0
622830
def _connect_to_gateway(self):
        
        for key in self.ssh_pkeys:
            self.logger.debug('Trying to log in with key: {0}'
                              .format(hexlify(key.get_fingerprint())))
            try:
                self._transport = self._get_transport()
                self._transport.connect(hostkey=self.ssh_host_key,
                                        username=self.ssh_username,
                                        pkey=key)
                if self._transport.is_alive:
                    return
            except paramiko.AuthenticationException:
                self.logger.debug('Authentication error')
                self._stop_transport()

        if self.ssh_password:  # avoid conflict using both pass and pkey
            self.logger.debug('Trying to log in with password: {0}'
                              .format('*' * len(self.ssh_password)))
            try:
                self._transport = self._get_transport()
                self._transport.connect(hostkey=self.ssh_host_key,
                                        username=self.ssh_username,
                                        password=self.ssh_password)
                if self._transport.is_alive:
                    return
            except paramiko.AuthenticationException:
                self.logger.debug('Authentication error')
                self._stop_transport()

        self.logger.error('Could not open connection to gateway')
815671
def connect(self, addr):
        """"""
        if _debug: RouterToRouterService._debug("connect %r", addr)

        # make a connection
        conn = ConnectionState(addr)
        self.multiplexer.connections[addr] = conn

        # associate with this service, but it is not connected until the ack comes back
        conn.service = self

        # keep a list of pending NPDU objects until the ack comes back
        conn.pendingNPDU = []

        # build a service request
        request = ServiceRequest(ROUTER_TO_ROUTER_SERVICE_ID)
        request.pduDestination = addr

        # send it
        self.service_request(request)

        # return the connection object
        return conn
153241
def _connectionEstablished(self, transport):
        ''''''
        self.transport = transport
        self.transport.writeOpen()
        self.heartbeater.schedule()
925023
async def async_discovery(session):
    """"""
    bridges = []
    response = await async_request(session.get, URL_DISCOVER)

    if not response:
        _LOGGER.info("No discoverable bridges available.")
        return bridges

    for bridge in response:
        bridges.append({'bridgeid': bridge['id'],
                        'host': bridge['internalipaddress'],
                        'port': bridge['internalport']})

    _LOGGER.info("Discovered the following bridges: %s.", bridges)

    return bridges
1044751
def _propagated_record(self, rdtype, name, content, nameservers=None):
        
        latency = self._get_provider_option('latency')
        propagated = self._get_provider_option('propagated')
        if propagated == 'yes':
            retry, max_retry = 0, 20
            while retry < max_retry:
                for rdata in Provider._dns_lookup(name, rdtype, nameservers):
                    if content == rdata.to_text():
                        LOGGER.info('Hetzner => Record %s has %s %s', name, rdtype, content)
                        return True
                retry += 1
                retry_log = (', retry ({}/{}) in {}s...'.format((retry + 1), max_retry, latency)
                             if retry < max_retry else '')
                LOGGER.info('Hetzner => Record is not propagated%s', retry_log)
                time.sleep(latency)
        return False
912850
def connect(self, successor):
        """"""
        if isinstance(self, ConnectToExitNode) and not isinstance(successor, EntryOrExitNode):
            return

        self.outgoing.append(successor)
        successor.ingoing.append(self)
540672
def connection_made(self, transport):
        
        _LOGGER.info('Connection established to Hub')
        _LOGGER.debug('Transport: %s', transport)
        self.transport = transport

        self._restart_writer = True
        self.restart_writing()

        if self._aldb.status != ALDBStatus.LOADED:
            asyncio.ensure_future(self._setup_devices(), loop=self._loop)
321167
def establish_connection(self):
        """"""
        conninfo = self.connection
        if not conninfo.hostname:
            raise KeyError("Missing hostname for AMQP connection.")
        if conninfo.userid is None:
            raise KeyError("Missing user id for AMQP connection.")
        if conninfo.password is None:
            raise KeyError("Missing password for AMQP connection.")
        if not conninfo.port:
            conninfo.port = self.default_port
        conn = amqp.Connection(host=conninfo.hostname,
                               port=conninfo.port,
                               userid=conninfo.userid,
                               password=conninfo.password,
                               virtual_host=conninfo.virtual_host)
        return conn
1004131
def _maybe_connect(self, node_id):
        """"""
        with self._lock:
            conn = self._conns.get(node_id)

            if conn is None:
                broker = self.cluster.broker_metadata(node_id)
                assert broker, 'Broker id %s not in current metadata' % (node_id,)

                log.debug("Initiating connection to node %s at %s:%s",
                          node_id, broker.host, broker.port)
                host, port, afi = get_ip_port_afi(broker.host)
                cb = WeakMethod(self._conn_state_change)
                conn = BrokerConnection(host, broker.port, afi,
                                        state_change_callback=cb,
                                        node_id=node_id,
                                        **self.config)
                self._conns[node_id] = conn

            # Check if existing connection should be recreated because host/port changed
            elif self._should_recycle_connection(conn):
                self._conns.pop(node_id)
                return False

            elif conn.connected():
                return True

            conn.connect()
            return conn.connected()
1235845
def new_conn(self):
        
        """
        :return:
        """
        logger.debug("Opening new connection to rethinkdb with args=%s" % self._conn_args)
        return ConnectionWrapper(self._pool, **self._conn_args)
846638
def _start_connection_setup(self):
        """"""
        logger.info('We are connected[%s], request connection setup',
                    self.link_uri)
        self.platform.fetch_platform_informations(self._platform_info_fetched)
843707
private IGatewayLink createGatewayLink(String gatewayId) throws PublishingException {
        try {
            GatewayBean gateway = storage.getGateway(gatewayId);
            if (gateway == null) {
                throw new GatewayNotFoundException();
            }
            IGatewayLink link = gatewayLinkFactory.create(gateway);
            return link;
        } catch (GatewayNotFoundException e) {
            throw e;
        } catch (Exception e) {
            throw new PublishingException(e.getMessage(), e);
        }
    }
1315601
function mainEntry(event, context, callback) {
    if ('httpMethod' in event) {
        // http.dispath
        try {
            var gatewayName = event.stageVariables ?
                event.stageVariables.gatewayName :
                http.Gateway.default();
            if (gatewayName === undefined)
                throw new Error("Undefined gateway");
            var gateway = http.allGateways[gatewayName];
            if (gateway === undefined)
                throw new Error("Undefined gateway '" + gatewayName + "'");
            /*
                        gateway.dispatch(event, (response: http.ResponseData) =>
                            done(null, response)
                        );
            */
            gateway.dispatch(event)
                .then(function (v) { return callback(null, v); })
                .catch(function (e) { return callback(null, {
                statusCode: 500,
                headers: {},
                body: "CRITICAL ERROR (level 2)\n\t" + e + "\n" + e.stack
            }); });
        }
        catch (e) {
            callback(null, {
                statusCode: 500,
                headers: {},
                body: "CRITICAL ERROR (level 1)\n\t" + e + "\n" + e.stack
            });
        }
    }
    else
        callback(new Error('unknow event source'), null);
}