Skip to content

Commit

Permalink
added extra IP validation to get telegram requests via proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirmuxsin committed Dec 21, 2023
1 parent 98824f8 commit 84e78a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Types/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ public static function get(): array
* @return array
* @throws Exception
*/
private static function filterUpdate (Request $update) {
private static function filterUpdate (Request $update)
{

if (IpUtils::checkIp($update->ip(), config('laragram.trusted_ips'))) {
return $update->all();
}

if (App::environment('local') && IpUtils::checkIp($update->ip(), self::$localIpNets)) {
return $update->all();
Expand Down
9 changes: 7 additions & 2 deletions src/config/laragram.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@

return [
'token' => env('TELEGRAM_BOT_TOKEN'),
'url' => '/api/bot'
];
'url' => '/api/bot',

// Trusted Telegram IP addresses or proxies
'trusted_ips' => [
// '127.0.0.1/32'
],
];

0 comments on commit 84e78a6

Please sign in to comment.