protected function isAllowedIp($whitelist)
    {
        $server = $this->pool->getServer();

        if (empty($server[static::REMOTE_ADDRESS]) === true) {
            $remote = '';
        } else {
            $remote = $server[static::REMOTE_ADDRESS];
        }

        $whitelist = explode(',', $whitelist);
        if (php_sapi_name() === 'cli' || in_array($remote, $whitelist) === true) {
            // Either the IP is matched, or we are in CLI
            return true;
        }

        // Check the wildcards.
        foreach ($whitelist as $ip) {
            $ip = trim($ip);
            $wildcardPos = strpos($ip, '*');
            // Check if the ip has a wildcard.
            if ($wildcardPos !== false && substr($remote, 0, $wildcardPos) . '*' === $ip) {
                return true;
            }
        }

        return false;
    }