Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Dec 1, 2023
1 parent 73813fa commit 136dec9
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 102 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ php artisan vendor:publish --tag="laravel-trusted-proxies-cloudflare-views"
## Usage

```php
$laravelTrustedProxiesCloudflare = new Vormkracht10\LaravelTrustedProxiesCloudflare();
echo $laravelTrustedProxiesCloudflare->echoPhrase('Hello, Vormkracht10!');
$TrustedProxiesCloudflare = new Vormkracht10\TrustedProxiesCloudflare();
echo $TrustedProxiesCloudflare->echoPhrase('Hello, Vormkracht10!');
```

## Testing
Expand All @@ -68,8 +68,8 @@ Please review [our security policy](../../security/policy) on how to report secu

## Credits

- [Mark van Eijk](https://github.com/markvaneijk)
- [All Contributors](../../contributors)
- [Mark van Eijk](https://github.com/markvaneijk)
- [All Contributors](../../contributors)

## License

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
},
"autoload": {
"psr-4": {
"Vormkracht10\\LaravelTrustedProxiesCloudflare\\": "src/",
"Vormkracht10\\LaravelTrustedProxiesCloudflare\\Database\\Factories\\": "database/factories/"
"Vormkracht10\\TrustedProxiesCloudflare\\": "src/",
"Vormkracht10\\TrustedProxiesCloudflare\\Database\\Factories\\": "database/factories/"
}
},
"autoload-dev": {
"psr-4": {
"Vormkracht10\\LaravelTrustedProxiesCloudflare\\Tests\\": "tests/"
"Vormkracht10\\TrustedProxiesCloudflare\\Tests\\": "tests/"
}
},
"scripts": {
Expand All @@ -60,13 +60,13 @@
"extra": {
"laravel": {
"providers": [
"Vormkracht10\\LaravelTrustedProxiesCloudflare\\LaravelTrustedProxiesCloudflareServiceProvider"
"Vormkracht10\\TrustedProxiesCloudflare\\TrustedProxiesCloudflareServiceProvider"
],
"aliases": {
"LaravelTrustedProxiesCloudflare": "Vormkracht10\\LaravelTrustedProxiesCloudflare\\Facades\\LaravelTrustedProxiesCloudflare"
"TrustedProxiesCloudflare": "Vormkracht10\\TrustedProxiesCloudflare\\Facades\\TrustedProxiesCloudflare"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
11 changes: 10 additions & 1 deletion config/trusted-proxies-cloudflare.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?php

// config for Vormkracht10/LaravelTrustedProxiesCloudflare
return [
'enabled' => (bool) env('TRUSTED_PROXIES_CLOUDFLARE_ENABLED', false),

'cache' => [
'key' => env('TRUSTED_PROXIES_CLOUDFLARE_CACHE_KEY', 'trusted-proxies-cloudflare'),
'store' => env('TRUSTED_PROXIES_CLOUDFLARE_CACHE_STORE', 'file'),
],

'api' => [
'ipv4' => 'https://www.cloudflare.com/ips-v4',
'ipv6' => 'https://www.cloudflare.com/ips-v6',
],
];
19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

This file was deleted.

Empty file removed resources/views/.gitkeep
Empty file.
14 changes: 14 additions & 0 deletions src/Actions/GetCloudflareIPs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Vormkracht10\TrustedProxiesCloudflare\Actions;

class GetCloudflareIPs
{
public function __invoke()
{
$ipv4 = explode(PHP_EOL, trim(file_get_contents(config('trusted-proxies-cloudflare.api.ipv4')));
$ipv6 = explode(PHP_EOL, trim(file_get_contents(config('trusted-proxies-cloudflare.api.ipv4')));

return $ipv4 + $ipv6;
}
}
24 changes: 24 additions & 0 deletions src/Commands/CacheCloudflareProxies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Vormkracht10\TrustedProxiesCloudflare\Commands;

use Illuminate\Console\Command;
use Vormkracht10\TrustedProxiesCloudflare\Actions\GetCloudflareIPs;

class CacheCloudflareProxies extends Command
{
public $signature = 'cloudflare:cache-trusted-proxies';

public $description = '';

public function handle(): int
{
$ips = (new GetCloudflareIPs)();

dd($ips);

$this->comment('All done');

return self::SUCCESS;
}
}
19 changes: 0 additions & 19 deletions src/Commands/LaravelTrustedProxiesCloudflareCommand.php

This file was deleted.

16 changes: 0 additions & 16 deletions src/Facades/LaravelTrustedProxiesCloudflare.php

This file was deleted.

16 changes: 16 additions & 0 deletions src/Facades/TrustedProxiesCloudflare.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Vormkracht10\TrustedProxiesCloudflare\Facades;

use Illuminate\Support\Facades\Facade;

/**
* @see \Vormkracht10\TrustedProxiesCloudflare\TrustedProxiesCloudflare
*/
class TrustedProxiesCloudflare extends Facade
{
protected static function getFacadeAccessor()
{
return \Vormkracht10\TrustedProxiesCloudflare\TrustedProxiesCloudflare::class;
}
}
7 changes: 0 additions & 7 deletions src/LaravelTrustedProxiesCloudflare.php

This file was deleted.

7 changes: 7 additions & 0 deletions src/TrustedProxiesCloudflare.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Vormkracht10\TrustedProxiesCloudflare;

class TrustedProxiesCloudflare
{
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace Vormkracht10\LaravelTrustedProxiesCloudflare;
namespace Vormkracht10\TrustedProxiesCloudflare;

use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Vormkracht10\LaravelTrustedProxiesCloudflare\Commands\LaravelTrustedProxiesCloudflareCommand;
use Vormkracht10\TrustedProxiesCloudflare\Commands\CacheCloudflareProxies;

class LaravelTrustedProxiesCloudflareServiceProvider extends PackageServiceProvider
class TrustedProxiesCloudflareServiceProvider extends PackageServiceProvider
{
public function configurePackage(Package $package): void
{
Expand All @@ -18,8 +18,6 @@ public function configurePackage(Package $package): void
$package
->name('laravel-trusted-proxies-cloudflare')
->hasConfigFile()
->hasViews()
->hasMigration('create_laravel-trusted-proxies-cloudflare_table')
->hasCommand(LaravelTrustedProxiesCloudflareCommand::class);
->hasCommand(CacheCloudflareProxies::class);
}
}
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

use Vormkracht10\LaravelTrustedProxiesCloudflare\Tests\TestCase;
use Vormkracht10\TrustedProxiesCloudflare\Tests\TestCase;

uses(TestCase::class)->in(__DIR__);
8 changes: 4 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Vormkracht10\LaravelTrustedProxiesCloudflare\Tests;
namespace Vormkracht10\TrustedProxiesCloudflare\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Vormkracht10\LaravelTrustedProxiesCloudflare\LaravelTrustedProxiesCloudflareServiceProvider;
use Vormkracht10\TrustedProxiesCloudflare\TrustedProxiesCloudflareServiceProvider;

class TestCase extends Orchestra
{
Expand All @@ -13,14 +13,14 @@ protected function setUp(): void
parent::setUp();

Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'Vormkracht10\\LaravelTrustedProxiesCloudflare\\Database\\Factories\\'.class_basename($modelName).'Factory'
fn (string $modelName) => 'Vormkracht10\\TrustedProxiesCloudflare\\Database\\Factories\\'.class_basename($modelName).'Factory'
);
}

protected function getPackageProviders($app)
{
return [
LaravelTrustedProxiesCloudflareServiceProvider::class,
TrustedProxiesCloudflareServiceProvider::class,
];
}

Expand Down

0 comments on commit 136dec9

Please sign in to comment.