# IPRestrictionRules

**Kind:** Interface

**Source:** [`src/middleware/ip-restriction/index.ts`](https://github.com/honojs/hono/blob/main/src/middleware/ip-restriction/index.ts#L172)

**Part of:** [Middleware](subsystem-src-middleware)

Rules for IP Restriction Middleware

`IPRestrictionRules` defines the allow and deny rule collections used by IP Restriction Middleware. The middleware reads `allowList` and `denyList` to determine whether an incoming IP address matches a restriction rule.

## Properties

| Property | Type |
|---|---|
| `denyList` | `IPRestrictionRule[]` |
| `allowList` | `IPRestrictionRule[]` |

## Diagram

```mermaid
graph LR
  Rules[IPRestrictionRules]
  Allow[allowList: IPRestrictionRule[]]
  Deny[denyList: IPRestrictionRule[]]
  Rule[IPRestrictionRule]

  Rules --> Allow
  Rules --> Deny
  Allow --> Rule
  Deny --> Rule
```

## Usage

```ts
import type { IPRestrictionRules } from "./middleware/ip-restriction";

const rules: IPRestrictionRules = {
  allowList: [],
  denyList: [],
};

// Pass `rules` to the IP Restriction Middleware configuration.
```

## AI Coding Instructions

- Keep both `allowList` and `denyList` present when creating an `IPRestrictionRules` object.
- Store only `IPRestrictionRule` entries in each list.
- Check middleware behavior when an IP matches entries in both lists.
- Keep rule construction consistent with the `IPRestrictionRule` type.
