Skip to content

Commit ce75c5f

Browse files
author
Bruno Cabral
committed
First readme
1 parent 86810a3 commit ce75c5f

File tree

4 files changed

+62
-67
lines changed

4 files changed

+62
-67
lines changed

README.md

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,91 @@
1-
# Project Title
1+
# Laravel Block Bots
22

3-
One Paragraph of project description goes here
43

5-
## Getting Started
4+
[![Latest Version on Packagist][ico-version]][link-packagist]
5+
[![Software License][ico-license]](LICENSE.md)
6+
[![Total Downloads][ico-downloads]][link-downloads]
67

7-
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
88

9-
### Prerequisites
9+
## Introduction
10+
Laravel Block bots is a pacakge that block bad crawlers, people trying to scrape your website or high-usage users, but lets good and important crawlers such as GoogleBot and Bing pass-thu.
1011

11-
What things you need to install the software and how to install them
1212

13-
```
14-
Give examples
15-
```
13+
## Features
14+
- ULTRA fast, less than 1ms increase in each request.
15+
- Verify Crawlers using reverse DNS
16+
- Highly configurable
17+
- Redirect users to a page when they got blocked
18+
- Allow Logged users to always bypass blocks
1619

17-
### Installing
1820

19-
A step by step series of examples that tell you how to get a development env running
2021

21-
Say what the step will be
22+
## Install
2223

24+
Via Composer
25+
``` bash
26+
composer require potelo/laravel-block-bots
2327
```
24-
Give the example
25-
```
28+
#### Requirement
29+
- This package rely on heavly on Redis. To use it, make sure that Redis is configured and ready. (see [Laravel Redis Configuration](https://laravel.com/docs/5.6/redis#configuration))
30+
2631

27-
And repeat
32+
#### Before Laravel 5.5
33+
In Laravel 5.4. you'll manually need to register the `\Potelo\LaravelBlockBots\BlockBots::class` service provider in `config/app.php`.
2834

35+
#### Config
36+
To adjust the library, you can publish the config file to your project using:
2937
```
30-
until finished
38+
php artisan vendor:publish --provider="\Potelo\LaravelBlockBots\BlockBotsServiceProvider"
3139
```
3240

33-
End with an example of getting some data out of the system or using it for a little demo
34-
35-
## Running the tests
36-
37-
Explain how to run the automated tests for this system
38-
39-
### Break down into end to end tests
40-
41-
Explain what these tests test and why
41+
## Usage
4242

43+
It's simple. Go to `Kernel.php` and add to the `$routeMiddleware` block as :
4344
```
44-
Give an example
45+
protected $routeMiddleware = [
46+
...
47+
'block' => \Potelo\LaravelBlockBots\BlockBots::class,
48+
];
4549
```
4650

47-
### And coding style tests
51+
Than you can put in the desired groups. For exemple, lets set to the Wrb group:
4852

49-
Explain what these tests test and why
50-
51-
```
52-
Give an example
5353
```
5454
55-
## Deployment
55+
protected $middlewareGroups = [
56+
'web' => [
57+
...
58+
\App\Http\Middleware\VerifyCsrfToken::class,
59+
'block:100,/limit'
60+
],
61+
```
5662

57-
Add additional notes about how to deploy this on a live system
63+
Where:
64+
- **100**: is the number of pages an IP can access every day
65+
- **/limit**: Is the route we going to redirect the IP after the limit
5866

59-
## Built With
6067

61-
* [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used
62-
* [Maven](https://maven.apache.org/) - Dependency Management
63-
* [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds
68+
## Change log
6469

65-
## Contributing
70+
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
6671

67-
Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.
6872

69-
## Versioning
70-
71-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
73+
## Contributing
7274

73-
## Authors
75+
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.
7476

75-
* **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth)
77+
## Credits
7678

77-
See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
79+
- [Potelo][link-author]
7880

7981
## License
8082

81-
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
82-
83-
## Acknowledgments
83+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
8484

85-
* Hat tip to anyone whose code was used
86-
* Inspiration
87-
* etc
85+
[ico-version]: https://img.shields.io/packagist/v/potelo/laravel-block-bots.svg?style=flat-square
86+
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
87+
[ico-downloads]: https://img.shields.io/packagist/dt/potelo/laravel-block-bots.svg?style=flat-square
8888

89+
[link-packagist]: https://packagist.org/packages/potelo/laravel-block-bots
90+
[link-downloads]: https://packagist.org/packages/potelo/laravel-block-bots
91+
[link-author]: https://github.com/potelo

src/Middleware/BlockBots.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Carbon\Carbon;
1212
use Potelo\LaravelBlockBots\CheckIfBotIsReal;
1313

14-
class BlockBots extends Middleware
14+
class BlockBots
1515
{
1616
protected $config;
1717

@@ -20,6 +20,11 @@ public function __construct()
2020
$this->config = config('block');
2121
}
2222

23+
private function enabled()
24+
{
25+
return $this->config['enabled'];
26+
}
27+
2328
/**
2429
* Register all visits in Redis
2530
*
@@ -154,7 +159,7 @@ public function isWhitelisted($ip, $user_agent)
154159
return true;
155160

156161
// If we got here, it is an unverified bot. Lets create a job to test it
157-
\Potelo\LaravelBlockBots\Jobs\CheckIfBotIsReal::dispatchNow($ip, $user_agent);
162+
\Potelo\LaravelBlockBots\Jobs\CheckIfBotIsReal::dispatch($ip, $user_agent);
158163

159164
}
160165

src/Middleware/Middleware.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/config/config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
'enabled' => env('BLOCK_BOTS_ENABLED', true),
11-
1211
/*
1312
* Whitelisted IP addresses
1413
* '127.0.0.1',
@@ -20,7 +19,7 @@
2019
],
2120

2221
'allow_logged_user' => env('BLOCK_BOTS_ALLOW_LOGGED_USER', true),
23-
'fake_mode' => env('BLOCK_BOTS_FAKE_MODE', true), // minutes - disabled by default
22+
'fake_mode' => env('BLOCK_BOTS_FAKE_MODE', true), //
2423

2524
/*
2625
* Send suspicious events to log?

0 commit comments

Comments
 (0)