turbo124/bot-licker
Composer 安装命令:
composer require turbo124/bot-licker
包简介
Package for Laravel to block IPs at the network edge
关键字:
README 文档
README
BotLicker
Ban / Challenge IPs/Countries at the network edge.
The Problem: After researching some laravel packages that provide firewall functionality, a common theme was that they all block at the application level.
This may work for sites with low levels of traffic, but when dealing with a large number of requests it becomes ineffective. It also continues to use resources unnecessarily.
Enter BotLicker where you can send your WAF rules direct to Cloudflare for instant implementation.
Installation
composer require turbo124/bot-licker
Configuration
In your .env file, enter in the following environment variables:
CLOUDFLARE_API_KEY="your_cloudflare_API_KEY_that_has_permission to read/write/edit WAF rules"
CLOUDFLARE_EMAIL="your_cloudflare_email_address"
CLOUDFLARE_ZONE_ID="your_zone_id"
CLOUDFLARE_ACCOUNT_ID="your_account_id"
Usage
To permanently ban an IP address from reaching your server.
Firewall::ban('101.1.1.254');
To ban an IP address for a certain period of time, simply pass a Carbon instance as the second argument
Firewall::ban('10.1.1.1', Carbon::now()->addYear();
To unban and IP address
Firewall::unban('101.1.1.254');
If you would prefer to issue a challenge to an IP address
Firewall::challenge('101.1.1.254', Carbon::now()->addYear());
To then disable
Firewall::unchallenge('101.1.1.254');
If you would prefer to ban an entire country simply pass in the iso_3166_2 country code
Firewall::banCountry('DE');
To then disable
Firewall::unbanCountry('DE');
Protected IPs and Countries
If you need rules to whitelist IP address range or Countries simply...
These can be added to the configuration file bot-licker.php
Automated rules
Are you tired of seeing bots trying to hit .env or phpinfo.php in your logs? You can build a custom ruleset which matches a string in the request URI. And then perform an action on the user arriving from this IP (or Country).
Rule::matches('phpinfo.php', now()->addYear())->ban();
This will match any incoming request URIs with phpinfo.php in the URL ie https://domain.com/phpinfo.php and then ban the IP address for a year.
Extending BotLicker with new providers
Currently only Cloudflare is supported, however you can easily implement the ProviderContract and generate the corresponding methods for other WAFs. Once you have created your provider, simply inject it into the setProvider() or replace the default provider in the configuration file.
Firewall::setProvider(OtherWAF::class)->ban('101.1.1.254', now()->addMinutes(5));
Console commands
If you prefer to ban from the console you can use these commands:
- Firewall rules:
php artisan firewall:rule
- Delete rule from WAF
php artisan firewall:waf --delete=
- Ban from the command line:
firewall:cf-rules {--ban} {--challenge} {--unban} {--unchallenge}
php artisan cf-rules --ban=10.1.1.1
- Show bans
php artisan firewall:show
TODO:
Currently the package perform simply bans/unbans etc. In the next iteration, ban duration will be also be added in order for some rules to be removed after X timeperiod. ie
License
The MIT License (MIT)
turbo124/bot-licker 适用场景与选型建议
turbo124/bot-licker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16 次下载、GitHub Stars 达 25, 最近一次更新时间为 2023 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「firewall」 「cloudflare」 「bots」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 turbo124/bot-licker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 turbo124/bot-licker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 turbo124/bot-licker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A handler for Monolog that sends messages to Telegram Channels. Laravel
PHP Basic Firewall
Craft plugin for detecting bots/crawlers/spiders
Symfony bundle for Cloudflare integration: trusted proxies, real client IP detection, forwarded headers.
Contao helper class to detect search engines, bots, spiders, crawlers ...
Cloudflare Middleware For Guzzle
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 25
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-05-08
