# Key reference

Every `prefs.XML` key of CrushBalance 27, with where it lives, its type and allowed values, its default, when it applies, when a change takes effect, and where the admin UI shows it. The pages are generated from the code.

| Page | Keys |
|---|---|
| [Global keys](Keys-Global.md) | the admin server, logging, limits, GeoIP, the metrics token, the registration, the global IP rules |
| [Listener keys](Keys-Listener.md) | one listener: address, port, mode, TLS, inbound PROXY, limits, balancing, stickiness |
| [Endpoint keys](Keys-Endpoint.md) | one endpoint: host, port, weight, state, PROXY version, backend TLS, health probe |
| [IP rule keys](Keys-IP-Rules.md) | one IP rule, plus how rule lists and address lists are read |

## How to read the key pages

- **Type:** the value grammar with the key's own range, vocabulary or length. Every duration is in whole seconds; the only size key, `log_max_size_mb`, is in MiB. A list key gives the most items it may hold; the limits of the whole file are under [Limits](#limits), below.
- **Default:** the value used when the key is absent or empty, with its explanation. Absent, empty and the default mean the same.
- **Applies:** "always", or the settings of the key's own object (or of its listener) under which the key is read. A key that does not apply in its object's current mode is kept in the file but not read: it gets only INFO KEY_NOT_APPLICABLE, and switching the mode back restores it.
- **Takes effect:** live, rebind or after a restart. Only a restart key needs CrushBalance to be restarted.
- **Flags:** required (a missing value is ERROR REQUIRED on its object), generated when missing (the ids), secret (stored as an `enc:` value, AES-256-GCM with the key in `crushbalance.key`, never returned by the admin API), verifier (a one-way value written only by the server) and server-owned (ignored by whole-configuration writes, changed only by its own action or a hand edit).
- **UI:** the section and field of the admin UI that edit the key, and the UI's help text.

### Value types

| Type | Grammar and parse rule |
|---|---|
| `string` | XML text. Not trimmed. On save, these are rejected: characters illegal in XML 1.0, unpaired surrogates, and (for names, notes and ids) control characters. Each row gives a maximum length. |
| `bool` | Written as `true` or `false`. Read after trimming, case-insensitively. Anything else is ERROR BAD_VALUE on that key: on a disk load the lenient rule applies (a top-level key takes its default at startup and keeps its previous value on reload; a listener, endpoint or rule key disables its object or list scope: at startup not used, on reload the previous definition is kept); on a save the write is rejected with 422 `validation_failed`. |
| `int a–b` | ASCII decimal, trimmed, with no sign and no separators. Out of range is ERROR BAD_VALUE on that key: on a disk load the lenient rule applies (a top-level key takes its default at startup and keeps its previous value on reload; a listener, endpoint or rule key disables its object or list scope: at startup not used, on reload the previous definition is kept); on a save the write is rejected with 422 `validation_failed`. |
| `enum` | One of the listed lower-case words, read case-insensitively and written in lower case. TLS protocol names keep their JSSE spelling. |
| `csv` | Comma-separated items. Each item is trimmed; empty items are ignored. |
| `ip` | IPv4 or IPv6 literal, no zone id, never resolved (`IpAddr.parseLiteral`). |
| `host` | `ip`, or a DNS name ≤ 253 characters. |
| `addrlist` | `csv` of IPv4 or IPv6 literals and CIDR blocks. |
| `ipmatch` | One IP-rule match expression. |
| `portspec` | `N` or `A-B`, with 1 ≤ A < B ≤ 65535 and at most 10,000 ports. |
| `path` | File path. A relative path resolves against the **working directory**. That is the install directory under both the init script and the Windows service. |
| `url` | Absolute `http://` or `https://` URL, at most 2048 characters, with no userinfo. |
| `latlon` | `lat,lon` in decimal degrees, with `.` as the decimal point. Latitude −90..90, longitude −180..180. Example: `50.11,8.68`. |
| `id` | `[a-z0-9][a-z0-9_-]{0,31}`. |
| `secret` | `enc:` value, or plaintext entered by hand, which is adopted. |
| `verifier` | A one-way value written by the server. |

### Absent, empty and default

- **Absent, `""` and the default value mean the same thing.**
- **No inheritance.** No key inherits from another level or another key. Each value is either set or its default.
- **What the writer omits.** It omits keys whose value equals the default, so that a better default in a later CrushBalance 27 release takes effect. It always writes:
  - `prefs_version` and `listeners`;
  - every object's `id`;
  - the required keys `bind_port`, `host`, `port`, `action` and `match`.
- **Resetting a field to its default removes the key.**
- **Required key missing:** ERROR REQUIRED on that object.
- **Keys that do not apply to an object's current mode are kept verbatim and not parsed.** Examples: `tls_*` on a `tcp` listener, `backend_tls` on an endpoint of a `tcp` listener (range listeners included), `backend_tls_pin` while `backend_tls=false`, or `probe_user` with `probe=tcp`. Switching the mode back restores them.
  - Such a key gets only INFO KEY_NOT_APPLICABLE. It is not parsed, so no other diagnostic is raised for it. For example, a `probe_url` while `probe=tcp` gets no PROBE_URL_USERINFO, and `tls_protocols` on a `tcp` listener gets no CSV_ITEM_DROPPED.
  - So a `backend_tls_pin` that does not apply is never BAD_VALUE. Its grammar (ERROR BAD_VALUE) is checked only when `backend_tls=true` applies.
  - The one exception is a secret key. It is still encrypted on save, and a plaintext value is still reported as WARN SECRET_PLAINTEXT, so passwords never stay in plain text on disk.
  - The mapped values are the effective ones. `EndpointConfig.backendTls()` is false on an endpoint of a `tcp` listener (range listeners included). `EndpointConfig.backendTlsPin()` is `""` unless `backendTls()` is true; then it is the normalised form (upper-case byte pairs separated by `:`), or `""` for the JDK trust store.

### When a change takes effect

| Value | Meaning |
|---|---|
| `live` | Takes effect when it is saved or loaded, with no interruption. New connections, requests, probes and log lines use it. **Open proxied sessions keep the listener runtime they started with;** in `http`/`https` mode each new exchange is routed with the current routing snapshot. Admin settings apply to existing admin sessions from their next request. |
| `rebind` | The listener socket is closed and re-bound. Open sessions continue. |
| `restart` | Needs a process restart. The UI says so. |

No configuration change ever closes an established session. A deleted or disabled listener stops accepting, and its sessions run until they end.

### Limits

| Item | Limit |
|---|---|
| Listeners | 1,000 |
| Endpoints per listener | 256 |
| Rules per list | 10,000 |
| Ports per range | 10,000 |
| prefs.XML | 64 MiB |
| One value | 1 MiB |
| Nesting depth | 32 |
| Elements | 1,000,000 |
