Skip to content

Custom Providers ​

Register your own proxy IP sources when you use a private CDN, regional edge, or a narrower subset of a cloud provider's ranges.

Register a provider ​

Declaratively in config:

php
'custom_providers' => [
    'my-proxy' => \App\EdgeTrust\MyCustomProxyProvider::class,
],

Then enable it (alongside built-ins) via .env:

ini
EDGE_TRUST_PROVIDERS=cloudflare,my-proxy

Or at boot:

php
use Hosni\EdgeTrust\Facades\EdgeTrust;

public function boot(): void
{
    EdgeTrust::registerProvider('my-proxy', MyCustomProxyProvider::class);
}

Implement the provider ​

Prefer extending AbstractProvider so HTTP download, validation, and parsing stay consistent:

php
<?php

namespace App\EdgeTrust;

use Hosni\EdgeTrust\Providers\AbstractProvider;

class MyCustomProxyProvider extends AbstractProvider
{
    public function name(): string
    {
        return 'my-proxy';
    }

    public function displayName(): string
    {
        return 'My Proxy';
    }

    public function sourceUrls(): array
    {
        return [
            'https://example.com/proxy-ips.txt',
        ];
    }

    protected function parse(array $bodies): array
    {
        $lines = preg_split('/\R/', $bodies[$this->sourceUrls()[0]] ?? '') ?: [];
        $cidrs = [];

        foreach ($lines as $line) {
            $line = trim($line);
            if ($line !== '' && ! str_starts_with($line, '#')) {
                $cidrs[] = $line;
            }
        }

        return array_merge($this->splitByFamily($cidrs), [
            'metadata' => ['format' => 'plain-cidr-lines'],
        ]);
    }
}

You may also implement Hosni\EdgeTrust\Contracts\ProxyProvider directly if you need full control of fetch().

Optional static ranges ​

If a “provider” is just a fixed list, you can skip a class and use custom IP ranges or custom_provider_ranges instead.

Validate and sync ​

bash
php artisan edge-trust:providers
php artisan edge-trust:validate --provider=my-proxy
php artisan edge-trust:sync --provider=my-proxy
php artisan edge-trust:list --provider=my-proxy

Released under the MIT License.