src/BotManager.php
public function isValidRequest(): bool
    {
        // If we're running from CLI, requests are always valid, unless we're running the tests.
        if ((!self::inTest() && 'cli' === PHP_SAPI) || false === $this->params->getBotParam('validate_request')) {
            return true;
        }

        $ip = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
        foreach (['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR'] as $key) {
            if (filter_var($_SERVER[$key] ?? null, FILTER_VALIDATE_IP)) {
                $ip = $_SERVER[$key];
                break;
            }
        }

        return Ip::match($ip, array_merge(
            [self::TELEGRAM_IP_RANGE],
            (array) $this->params->getBotParam('valid_ips', [])
        ));
    }
public function isValidRequest(): bool
    {
        // If we're running from CLI, requests are always valid, unless we're running the tests.
        if ((!self::inTest() && 'cli' === PHP_SAPI) || false === $this->params->getBotParam('validate_request')) {
            return true;
        }

        $ip = $_SERVER['REMOTE_ADDR'] ?? '0.0.0.0';
        foreach (['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR'] as $key) {
            if (filter_var($_SERVER[$key] ?? null, FILTER_VALIDATE_IP)) {
                $ip = $_SERVER[$key];
                break;
            }
        }

        return Ip::match($ip, array_merge(
            [self::TELEGRAM_IP_RANGE],
            (array) $this->params->getBotParam('valid_ips', [])
        ));
    }
public function isValidRequest ( ) : bool { // If we're running from CLI, requests are always valid, unless we're running the tests. if ( ( ! self :: inTest ( ) && 'cli' === PHP_SAPI ) || false === $ this -> params -> getBotParam ( 'validate_request' ) ) { return true ; } $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ?? '0.0.0.0' ; foreach ( [ 'HTTP_CLIENT_IP' , 'HTTP_X_FORWARDED_FOR' ] as $ key ) { if ( filter_var ( $ _SERVER [ $ key ] ?? null , FILTER_VALIDATE_IP ) ) { $ ip = $ _SERVER [ $ key ] ; break ; } } return Ip :: match ( $ ip , array_merge ( [ self :: TELEGRAM_IP_RANGE ] , ( array ) $ this -> params -> getBotParam ( 'valid_ips' , [ ] ) ) ) ; }
Check if this is a valid request coming from a Telegram API IP address.

@link https://core.telegram.org/bots/webhooks#the-short-version

@return bool
Check if this is a valid request coming from a Telegram API IP address .