Pick the identity bound to the configured server whose host is the longest dot-boundary suffix of `remote_host`. When several profiles' hosts match with the same length (e.g. the legacy `[server]` block and a named profile pointing at the same server), the **active** profile wins — the one `default_server` selects, else the legacy block. Longest-suffix still wins over active: a more specific serv
(remote_host: &str, servers: &[ServerBinding])
| 196 | /// for hosts under both — e.g. `x.staging.atomic.storage` resolves to the |
| 197 | /// staging identity, not prod. |
| 198 | fn match_server_identity(remote_host: &str, servers: &[ServerBinding]) -> Option<String> { |
| 199 | servers |
| 200 | .iter() |
| 201 | .filter(|b| host_is_under(remote_host, &b.host)) |
| 202 | .max_by_key(|b| (b.host.len(), b.active)) |
| 203 | // An agent bound to this profile is the one that should be signing |
| 204 | // repository traffic: that is the whole reason it was created. The |
| 205 | // human binding remains the fallback, so a profile with no agent |
| 206 | // behaves exactly as before. |
| 207 | .map(|b| { |
| 208 | b.agent_identity |
| 209 | .clone() |
| 210 | .unwrap_or_else(|| b.identity.clone()) |
| 211 | }) |
| 212 | } |
| 213 | |
| 214 | /// Whether `remote_host` is the server host itself or a subdomain of it, |
| 215 | /// matching only on dot boundaries (so `notatomic.storage` does NOT match |
no test coverage detected