Returns the mask string for a given connection.

@param \Phergie\Irc\ConnectionInterface $connection
@return string
17277
protected function getConnectionMask(ConnectionInterface $connection)
    {
        return strtolower(sprintf(
            '%s!%s@%s',
            $connection->getNickname(),
            $connection->getUsername(),
            $connection->getServerHostname()
        ));
    }
365536
protected function getRemote(ConnectionInterface $connection)
    {
        $hostname = $connection->getServerHostname();
        $port = $connection->getServerPort();

        $deferred = new Deferred();
        $this->resolveHostname($hostname)
            ->then(
                function($ip) use($deferred, $port) {
                    $deferred->resolve('tcp://' . $ip . ':' . $port);
                },
                function($error) use ($deferred) {
                    $deferred->reject($error);
                }
            );

        return $deferred->promise();
    }
827291
protected function getQueue($connection)
    {
        $connection = $connection ?: $this->laravel['config']['queue.default'];

        return $this->input->getOption('queue') ?: $this->laravel['config']->get(
            "queue.connections.{$connection}.queue", 'default'
        );
    }
1202098
public function getCount(ConnectionInterface $connection)
    {
        $obj = $this->deepClone();
        $obj->addAnnotation(['annotation' => count_('*'), 'alias' => '_count', 'isSummary' => true]);
        $alias = '_count';
        $result = $obj->getAggregation($connection, [$alias]);

        return ArrayHelper::getValue($result, $alias, 0);
    }
400924
public static function getInstance(LdapConnectionInterface $connection = null)
    {
        if ($connection && $connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD) {
            $filterBuilder = new ADFilterBuilder();
        } else {
            $filterBuilder = new self();
        }
        
        return $filterBuilder;
    }
1265610
public function getServersCredentials($connection = null)
    {
        $connection = $this->sanitizeConnection($connection);
        $available = $this->connections->getAvailableConnections();

        // Get and filter servers
        $servers = Arr::get($available, $connection->name.'.servers');
        if ($this->hasCommand() && $allowed = $this->command->option('server')) {
            $allowed = explode(',', $allowed);
            $servers = array_intersect_key((array) $servers, array_flip($allowed));
        }

        return $servers;
    }
925374
protected static function maskHasFlag($mask, $flag)
    {
        $flag   = (int)$flag;
        return ((int)$mask & $flag) === $flag;
    }
216398
public function connection(?string $connection = null)
	{
		$connection = $connection ?? $this->default;

		if(!isset($this->connections[$connection]))
		{
			$this->connections[$connection] = $this->connect($connection);
		}

		return $this->connections[$connection];
	}
1324900
public static function encode($buffer, ConnectionInterface $connection)
    {
        if (!is_scalar($buffer)) {
            throw new \Exception("You can't send(" . gettype($buffer) . ") to client, you need to convert it to a string. ");
        }
        $len = strlen($buffer);
        if (empty($connection->websocketType)) {
            $connection->websocketType = static::BINARY_TYPE_BLOB;
        }

        $first_byte = $connection->websocketType;

        if ($len <= 125) {
            $encode_buffer = $first_byte . chr($len) . $buffer;
        } else {
            if ($len <= 65535) {
                $encode_buffer = $first_byte . chr(126) . pack("n", $len) . $buffer;
            } else {
                $encode_buffer = $first_byte . chr(127) . pack("xxxxN", $len) . $buffer;
            }
        }

        // Handshake not completed so temporary buffer websocket data waiting for send.
        if (empty($connection->websocketHandshake)) {
            if (empty($connection->tmpWebsocketData)) {
                $connection->tmpWebsocketData = '';
            }
            // If buffer has already full then discard the current package.
            if (strlen($connection->tmpWebsocketData) > $connection->maxSendBufferSize) {
                if ($connection->onError) {
                    try {
                        call_user_func($connection->onError, $connection, WORKERMAN_SEND_FAIL, 'send buffer full and drop package');
                    } catch (\Exception $e) {
                        Worker::log($e);
                        exit(250);
                    } catch (\Error $e) {
                        Worker::log($e);
                        exit(250);
                    }
                }
                return '';
            }
            $connection->tmpWebsocketData .= $encode_buffer;
            // Check buffer is full.
            if ($connection->maxSendBufferSize <= strlen($connection->tmpWebsocketData)) {
                if ($connection->onBufferFull) {
                    try {
                        call_user_func($connection->onBufferFull, $connection);
                    } catch (\Exception $e) {
                        Worker::log($e);
                        exit(250);
                    } catch (\Error $e) {
                        Worker::log($e);
                        exit(250);
                    }
                }
            }

            // Return empty string.
            return '';
        }

        return $encode_buffer;
    }
461803
public function toString(ResponseInterface $response)
    {
        $string = sprintf(
            "HTTP/%s %s %s\n",
            $response->getProtocolVersion(),
            $response->getStatusCode(),
            $response->getReasonPhrase()
        );

        $string .= $this->headersAndBody($response);

        return $string;
    }
639742
protected function isConnectionActive(ConnectionInterface $connection)
    {
        $connectionKey = $connection->getConnectionKey();
        $defaults = $this->getDefaultConnectionsHandles();

        return
            in_array($connectionKey->toHandle(), $defaults, true) ||
            in_array($connectionKey->name, $defaults, true) ||
            $connection->isActive();
    }
233964
public function getMask(): IP
    {
        if ($this->mask === null) {
            if ($this->prefix == 0) {
                $this->mask = new static::$ip_class(0);
            } else {
                $max_int = gmp_init(static::$ip_class::MAX_INT);
                $mask = gmp_shiftl($max_int, static::$ip_class::NB_BITS - $this->prefix);
                $mask = gmp_and($mask, $max_int); // truncate to 128 bits only
                $this->mask = new static::$ip_class($mask);
            }
        }

        return $this->mask;
    }
639478
protected function getToken(ConnectionInterface $connection)
    {
        $token = null;

        if (isset($connection->Session) && $connection->Session) {
            foreach ($this->firewalls as $firewall) {
                if (false !== $serializedToken = $connection->Session->get('_security_'.$firewall, false)) {
                    /** @var TokenInterface $token */
                    $token = unserialize($serializedToken);

                    break;
                }
            }
        }

        if (null === $token) {
            $token = new AnonymousToken($this->firewalls[0], 'anon-'.$connection->WAMP->sessionId);
        }

        return $token;
    }
579710
public function userHasMode(ConnectionInterface $connection, $channel, $nick, $mode)
    {
        $connectionMask = $this->getConnectionMask($connection);
        return isset($this->modes[$connectionMask][$channel][$nick][$mode]);
    }
669308
public static function getQueryBuilder(Connection $connection)
    {
        switch ($connection->getDriver()->getName()) {
            case 'pdo_mysql':
                $adapter = new Database\Mysql\Adapter($connection);
                break;

            case 'pdo_sqlite':
                $adapter = new Database\Sqlite\Adapter($connection);
                break;

            case 'pdo_pgsql':
                $adapter = new Database\Pgsql\Adapter($connection);
                break;

            default:
                throw new NotSupportedException('Unknown driver');
        }

        $lookupBuilder = new LookupBuilder();
        $lookupBuilder->addLookupCollection($adapter->getLookupCollection());

        return new QueryBuilder($connection, $adapter, $lookupBuilder);
    }
194360
function mask($pattern,$url=NULL) {
		if (!$url)
			$url=$this->rel($this->hive['URI']);
		$case=$this->hive['CASELESS']?'i':'';
		preg_match('/^'.
			preg_replace('/@(\w+\b)/','(?P<\1>[^\/\?]+)',
			str_replace('\*','([^\?]+)',preg_quote($pattern,'/'))).
				'\/?(?:\?.*)?$/'.$case.'um',$url,$args);
		return $args;
	}
812674
protected function applyIpMask(string $ip, int $maskLength): string
    {
        if (empty($ip) || $maskLength === 0) {
            return $ip;
        }

        // IPv4 or mapped IPv4 in IPv6
        if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
            return $this->applyIpV4Mask($ip, $maskLength);
        }

        return $this->applyIpV6Mask($ip, $maskLength);
    }