# Listener keys

| Key | Type | Default | Takes effect |
|---|---|---|---|
| [`id`](#id) | id | generated | — |
| [`name`](#name) | string | empty | live |
| [`enabled`](#enabled) | bool | `true` | rebind |
| [`color`](#color) | int | empty | live |
| [`bind_ip`](#bind_ip) | ip | `0.0.0.0` | rebind |
| [`bind_port`](#bind_port) | portspec | **required** | rebind |
| [`mode`](#mode) | enum | `tcp` | live |
| [`tls_keystore`](#tls_keystore) | path | empty | live |
| [`tls_keystore_password`](#tls_keystore_password) | secret | empty | live |
| [`tls_protocols`](#tls_protocols) | csv | `TLSv1.3,TLSv1.2` | live |
| [`proxy_protocol_in`](#proxy_protocol_in) | bool | `false` | live |
| [`trusted_proxies`](#trusted_proxies) | addrlist | empty | live |
| [`idle_timeout`](#idle_timeout) | int | `3600` | live |
| [`max_connections`](#max_connections) | int | `0` | live |
| [`max_connections_per_client`](#max_connections_per_client) | int | `0` | live |
| [`algorithm`](#algorithm) | enum | `least_conn` | live |
| [`metric`](#metric) | enum | `server_cpu` | live |
| [`sticky`](#sticky) | enum | `ip` | live |
| [`sticky_cookies`](#sticky_cookies) | csv | `CrushAuth` | live |
| [`sticky_ttl`](#sticky_ttl) | int | `1800` | live |
| [`ip_rules`](#ip_rules) | list | empty list | live |
| [`endpoints`](#endpoints) | list | empty list | live |

### `id`

Stable identity.

- **Where:** `prefs/listeners/listeners_subitem/id`, in each listener
- **Type:** `id`
- **Default:** generated when missing
- **Applies:** always
- **Takes effect:** — (not a setting that changes)
- **Flags:** generated when missing
- **UI:** Header › Id: Stable identity of the listener, generated when missing.

### `name`

Display name and map legend.

- **Where:** `prefs/listeners/listeners_subitem/name`, in each listener
- **Type:** `string`, at most 64 characters
- **Default:** empty (shown as `bind_ip:bind_port`)
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** General › Name: Display name and map legend. Empty shows the bind IP and port.

### `enabled`

Listener on or off. The UI's Start and Stop buttons persist it.

- **Where:** `prefs/listeners/listeners_subitem/enabled`, in each listener
- **Type:** `bool`
- **Default:** `true`
- **Applies:** always
- **Takes effect:** the listener socket is closed and bound again; open sessions continue (no restart)
- **Flags:** none
- **UI:** Header › Enabled: Whether the listener accepts connections. Start and Stop set it.

### `color`

Index into the UI's 10-colour palette, used for the map and charts. The UI writes an explicit value for new listeners.

- **Where:** `prefs/listeners/listeners_subitem/color`, in each listener
- **Type:** `int`, 1–10
- **Default:** empty = the smallest index no earlier listener (in list order) uses; when all ten are used, the least-used index, ties to the smallest
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** General › Colour: Colour of the listener on the map and in charts, from a palette of 10. Empty picks the first colour no earlier listener uses.

### `bind_ip`

Local address. `0.0.0.0` and `::` accept both IPv4 and IPv6.

- **Where:** `prefs/listeners/listeners_subitem/bind_ip`, in each listener
- **Type:** `ip`
- **Default:** `0.0.0.0`
- **Applies:** always
- **Takes effect:** the listener socket is closed and bound again; open sessions continue (no restart)
- **Flags:** none
- **UI:** General › Bind IP: Local address to listen on. 0.0.0.0 and :: accept IPv4 and IPv6.

### `bind_port`

Port or port range. See "Range listeners" below this table.

- **Where:** `prefs/listeners/listeners_subitem/bind_port`, in each listener
- **Type:** `portspec`
- **Default:** none: the key is required
- **Applies:** always
- **Takes effect:** the listener socket is closed and bound again; open sessions continue (no restart)
- **Flags:** required: a missing value is ERROR REQUIRED on its object
- **UI:** General › Port: Port or port range (A-B) to listen on. On a range, each port relays to the same offset from the endpoint port.

### `mode`

`tcp`: byte relay. `tls`: terminate TLS and relay plaintext. `http`: HTTP/1.1 parsing (cookie stickiness, X-Forwarded-*). `https`: `tls` plus `http`. In `tls`, `http` and `https` mode, the back leg to an endpoint with `backend_tls=true` uses TLS.

- **Where:** `prefs/listeners/listeners_subitem/mode`, in each listener
- **Type:** `enum`: `tcp`, `tls`, `http` or `https`
- **Default:** `tcp`
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** General › Mode: tcp relays bytes, tls terminates TLS, http understands HTTP/1.1, and https is tls plus http.

### `tls_keystore`

Server certificate(s) for `tls` and `https`. The JDK picks among several entries by SNI. The file is re-checked every 60 s and reloaded when it changes. Unusable: listener ERROR KEYSTORE_UNUSABLE (on reload, the previous certificate stays); a listener not started because its keystore was unusable starts at the next apply (save, hand edit or restart), not from the 60 s check.

- **Where:** `prefs/listeners/listeners_subitem/tls_keystore`, in each listener
- **Type:** `path`
- **Default:** empty = per-install generated `listener-selfsigned.p12`
- **Applies:** when `mode` is `tls` or `https`
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** TLS › Keystore: Keystore (JKS, PKCS12 or JCEKS) with the server certificates for tls and https. Empty uses a generated certificate, which browsers warn about.

### `tls_keystore_password`

Keystore password, also used for the private key.

- **Where:** `prefs/listeners/listeners_subitem/tls_keystore_password`, in each listener
- **Type:** `secret`
- **Default:** empty
- **Applies:** when `mode` is `tls` or `https`
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** secret: stored encrypted (`enc:`), never returned by the admin API
- **UI:** TLS › Keystore password: Password of the keystore, also used for its private keys. Stored encrypted.

### `tls_protocols`

Client-side TLS versions. On a `tls` or `https` listener, an unknown or unsupported name gives WARN CSV_ITEM_DROPPED and is dropped (on a `tcp` or `http` listener the key is not parsed). If none remain: listener ERROR TLS_NO_PROTOCOL. `TLSv1` or `TLSv1.1` gives WARN TLS_OLD_PROTOCOL.

- **Where:** `prefs/listeners/listeners_subitem/tls_protocols`, in each listener
- **Type:** `csv` of `TLSv1.3`, `TLSv1.2`, `TLSv1.1` or `TLSv1`
- **Default:** `TLSv1.3,TLSv1.2`
- **Applies:** when `mode` is `tls` or `https`
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** TLS › TLS versions: TLS versions offered to clients. TLSv1 and TLSv1.1 are outdated and give a warning.

### `proxy_protocol_in`

`true`: every connection must start with a PROXY header, v1 or v2 (detected). Only sources in `trusted_proxies` may connect; others are reset. The client address from the header is used for rules, stickiness, caps, logs and outbound PROXY.

- **Where:** `prefs/listeners/listeners_subitem/proxy_protocol_in`, in each listener
- **Type:** `bool`
- **Default:** `false`
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** Limits › Inbound PROXY: Every connection must start with a PROXY header (v1 or v2) from a trusted proxy. The client address in the header is used for rules, stickiness, caps and logs.

### `trusted_proxies`

Upstream proxies in front of this listener. With `proxy_protocol_in=true` they are the only allowed sources, and the list is required (ERROR PROXY_IN_NO_TRUST when empty). With `proxy_protocol_in=false` in `http` or `https` mode, these are the peers whose `X-Forwarded-For` is extended and whose other forwarding headers (`X-Forwarded-Proto`/`-Host`/`-Port`, `X-Real-IP`, `Forwarded`) are kept; everyone else's are stripped. With `proxy_protocol_in=true` all forwarding headers from the stream are stripped.

- **Where:** `prefs/listeners/listeners_subitem/trusted_proxies`, in each listener
- **Type:** `addrlist`
- **Default:** empty
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** Limits › Trusted proxies: IP addresses and CIDR blocks of the proxies in front of this listener. With inbound PROXY they are the only allowed sources and the list is required; without it, in http and https mode, their forwarding headers are kept.

### `idle_timeout`

Closes a session after this long with no bytes in either direction. 0 = never. In `http` and `https` mode it also limits the wait for a response.

- **Where:** `prefs/listeners/listeners_subitem/idle_timeout`, in each listener
- **Type:** `int`, in seconds, 0 (never) or 10–604,800
- **Default:** `3600`
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** Limits › Idle timeout: Closes a session after this many seconds with no data in either direction; 0 = never.

### `max_connections`

Concurrent sessions on this listener. At the cap the listener pauses accepting.

- **Where:** `prefs/listeners/listeners_subitem/max_connections`, in each listener
- **Type:** `int`, 0–10,000,000 (0 = auto)
- **Default:** `0` = auto (80 % of the global cap)
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** Limits › Max connections: Concurrent sessions on this listener; 0 = auto, 80 % of the global cap. At the cap the listener pauses accepting.

### `max_connections_per_client`

Concurrent sessions per client (IPv4 address or IPv6 /64) on this listener; extra connections are reset. Ignored on range listeners (WARN CLIENT_CAP_ON_RANGE).

- **Where:** `prefs/listeners/listeners_subitem/max_connections_per_client`, in each listener
- **Type:** `int`, 0–1,000,000 (0 = off)
- **Default:** `0` = off
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** Limits › Max connections per client: Concurrent sessions per client (IPv4 address or IPv6 /64); 0 = off. Ignored on port ranges.

### `algorithm`

`least_conn`: fewest open connections per unit of weight. `round_robin`: smooth weighted round-robin. `metric`: `least_conn` among the endpoints whose CrushMFT `metric` is within a fixed band of the lowest. `metric` needs `probe=crushftp` endpoints; without them, WARN METRIC_NO_SOURCE and it behaves as `least_conn`.

- **Where:** `prefs/listeners/listeners_subitem/algorithm`, in each listener
- **Type:** `enum`: `least_conn`, `round_robin` or `metric`
- **Default:** `least_conn`
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** General › Algorithm: least_conn picks the fewest open connections per unit of weight, round_robin rotates by weight, and metric prefers the endpoints with the lowest CrushMFT metric.

### `metric`

The CrushMFT metric that `algorithm=metric` minimises. The names are exactly what CrushMFT's `command=prometheusMetrics&type=crushbalance` returns.

- **Where:** `prefs/listeners/listeners_subitem/metric`, in each listener
- **Type:** `enum`: `server_cpu`, `os_cpu`, `ram_used_percent`, `thread_pool_busy` or `server_total_throughput`
- **Default:** `server_cpu`
- **Applies:** when `algorithm` is `metric`
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** General › Metric: The CrushMFT metric that the metric algorithm keeps lowest. It needs endpoints with the crushftp probe.

### `sticky`

`ip`: a client keeps its backend host. `cookie` (`http` and `https` only): requests carrying a cookie named in `sticky_cookies` go to the backend that set it, with IP pins as the fallback. `cookie` on `tcp` or `tls` gives WARN COOKIE_NEEDS_HTTP and behaves as `ip`. Pins are keyed by backend **host** and shared by listeners whose endpoints have the same host set, so FTP control and passive listeners agree.

- **Where:** `prefs/listeners/listeners_subitem/sticky`, in each listener
- **Type:** `enum`: `none`, `ip` or `cookie`
- **Default:** `ip`
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** General › Stickiness: ip keeps a client on the same backend host. cookie (http and https only) follows a backend cookie, with the client IP as the fallback.

### `sticky_cookies`

Cookies learned from backend `Set-Cookie` when `sticky=cookie`.

- **Where:** `prefs/listeners/listeners_subitem/sticky_cookies`, in each listener
- **Type:** `csv` of 1–8 cookie names (RFC 6265 tokens, at most 64 characters each)
- **Default:** `CrushAuth`
- **Applies:** when `sticky` is `cookie`
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** General › Sticky cookies: Names of the backend cookies that keep a client on its backend when stickiness is cookie, comma-separated.

### `sticky_ttl`

Idle lifetime of the pins this listener creates or refreshes. Pins used by open sessions never expire. Pins survive restarts as hashed keys (`sticky-pins.dat`); downtime counts toward the idle lifetime.

- **Where:** `prefs/listeners/listeners_subitem/sticky_ttl`, in each listener
- **Type:** `int`, in seconds, 60–86,400
- **Default:** `1800`
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** General › Sticky TTL: Seconds an unused pin is kept. Pins of open sessions never expire.

### `ip_rules`

Listener rules, checked after the global rules.

- **Where:** `prefs/listeners/listeners_subitem/ip_rules`, in each listener
- **Type:** `list` of at most 10,000 [IP rule](Keys-IP-Rules.md) maps
- **Default:** empty list = allow all
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** Security › Listener IP rules: Rules checked after the global rules for every new client connection. An empty list allows everyone.

### `endpoints`

The backends.

- **Where:** `prefs/listeners/listeners_subitem/endpoints`, in each listener
- **Type:** `list` of at most 256 [endpoint](Keys-Endpoint.md) maps
- **Default:** empty list: the listener is not started (WARN NO_ENDPOINTS)
- **Applies:** always
- **Takes effect:** live, when saved or loaded (no restart)
- **Flags:** none
- **UI:** Endpoints › Endpoints: The backends of this listener. A listener without endpoints is not started.

### Notes on the listener keys

**Range listeners** (`bind_port` is `A-B`):
- The backend port is `endpoint port + (local port − A)`.
- `mode` must be `tcp` (ERROR RANGE_MODE).
- There is one connect attempt, with no failover.
- `max_connections_per_client` is ignored (WARN CLIENT_CAP_ON_RANGE).
- Endpoint `probe` must be `none` or `crushftp`, because a probe would take a passive slot. The same rule covers a `crushftp` `probe_url` whose host is the endpoint host and whose port lies in the endpoint's backend range. Otherwise: ERROR RANGE_PROBE on save; on load, WARN and treated as `none`.
- A range listener with more than one endpoint gives WARN SHARED_PASSIVE_RANGE. The recommended layout is one passive range per backend.
