# distinctRemoteAddr

**Kind:** Function

**Source:** [`src/utils/ipaddr.ts`](https://github.com/honojs/hono/blob/main/src/utils/ipaddr.ts#L59)

**Part of:** [Utils](subsystem-src-utils)

Distinct Remote Addr

`distinctRemoteAddr` derives a distinct remote-address value from the address data passed to it. It belongs to the IP-address utility layer and centralizes remote-address handling for callers that need a consistent value.

## Signature

```ts
function distinctRemoteAddr(remoteAddr: string): AddressType
```

## Parameters

| Name | Type |
|---|---|
| `remoteAddr` | `string` |

**Returns:** `AddressType`

## Diagram

```mermaid
graph LR
  Input[Remote address data] --> Function[distinctRemoteAddr]
  Function --> Output[Distinct remote address]
```

## Usage

```ts
import { distinctRemoteAddr } from "./utils/ipaddr";

const remoteAddress = request.socket.remoteAddress;
const address = distinctRemoteAddr(remoteAddress);

if (address) {
  auditLog({ remoteAddress: address });
}
```

## AI Coding Instructions

- Keep remote-address parsing and normalization inside `src/utils/ipaddr.ts`.
- Pass the address value in the format expected by `distinctRemoteAddr`.
- Check the returned value before using it in logs, access checks, or storage.
- Do not duplicate remote-address handling logic at call sites.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (1)

- `IPRestrictionRule` — `src/middleware/ip-restriction/index.ts`:38
