# IpAllowlist

> Matches a requesting IP against the debugger's allowed IP filters and host allowlist.

[API reference](/docs/api/index.md) › [Debug](/docs/extensions/debug/reference/index.md) › IpAllowlist

| final readonly class | `yii\debug\IpAllowlist` |
| --- | --- |
| Source | [`src/IpAllowlist.php`](https://github.com/yii2-extensions/debug/blob/main/src/IpAllowlist.php#L17) |

Matches a requesting IP against the debugger's allowed IP filters and host allowlist.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Retains the IP filters and hostnames used when checking access. | `IpAllowlist` |
| [`matches()`](#method-matches) | Returns whether the IP matches any allowed IP filter or resolves from any allowed host. | `IpAllowlist` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(list<string> $allowedIPs, list<string> $allowedHosts)
```

Retains the IP filters and hostnames used when checking access.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$allowedIPs` | `list<string>` | Exact, wildcard, or CIDR IP filters. |
| `$allowedHosts` | `list<string>` | Hostnames resolved to IPs at check time. |

### matches() <span id="method-matches"></span>

```php
public function matches(string $ip): bool
```

Returns whether the IP matches any allowed IP filter or resolves from any allowed host.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$ip` | `string` | Requesting IP address. |

**Returns**

`bool`: `true` when the IP is allowed.