Commit 87a2533
authored
Add support for filter chains (#6820)
Motivation:
Listener `filter_chains` and `default_filter_chain` were not resolved
into the snapshot tree, so consumers could not access per-filter-chain
transport socket or route configurations. The server-side
`DownstreamTlsContext` was also not supported, meaning downstream TLS
certificates could not be resolved. Additionally, internal extension
factories were loaded via SPI and could be overridden by user code.
Modifications:
**Filter chain resolution**
- Added `FilterChainSnapshot` to hold the resolved match criteria,
transport socket, and route snapshot for each filter chain, including
`toDebugString()`.
- Added `ListenerFilterChainFactory` to resolve each `FilterChain` into
a `FilterChainSnapshot` by extracting HCM and resolving routes and
transport sockets.
- Extended `ListenerSnapshot` with `filterChains()`,
`defaultFilterChain()`, and updated `routeSnapshot()` to fall back
through api_listener → filter chains → default filter chain. Updated
`toDebugString()` to delegate to `FilterChainSnapshot.toDebugString()`.
**Downstream TLS support**
- Added `DownstreamTlsTransportSocketFactory` to support server-side
`DownstreamTlsContext` with multiple TLS certificates.
- Extracted `resolveValidationContext()` and `resolveTlsCertificates()`
from `UpstreamTlsTransportSocketFactory` into `TransportSocketFactory`
as shared static methods. `resolveTlsCertificates()` now resolves all
certificates (not just the first), returning
`SnapshotStream<List<TlsCertificateSnapshot>>`.
- Updated `TransportSocketSnapshot` to hold
`List<TlsCertificateSnapshot>` instead of
`Optional<TlsCertificateSnapshot>`.
- Added fail-fast validation in `UpstreamTlsTransportSocketFactory` to
reject more than one TLS certificate before creating any streams.
**Server-side HTTP filters**
- Added `XdsHttpFilter.serviceDecorator()` returning `@Nullable
DecoratingHttpServiceFunction` for server-side filter support.
- Added `buildDownstreamServerFilter()` in `FilterUtil` to compose
server-side filter chains using `DelegatingHttpService` as the terminal
service.
- Added `RouteEntry.httpService()` to expose the composed server-side
`HttpService`.
- Added `CachingStream` to deduplicate filter instantiation across
routes sharing the same merged filter config.
**Extension registry**
- Moved internal extension factories (`RouterFilterFactory`,
`CredentialInjectorFilterFactory`, `StaticClusterTypeFactory`,
`StrictDnsClusterTypeFactory`) from SPI to explicit built-in
registration in `XdsExtensionRegistry` with `buildKeepingLast()`
precedence (builtin > builder > SPI). Deleted the now-empty SPI service
files.
- Added `XdsBootstrapBuilder.extensionFactories()` varargs and
`Iterable` overloads for registering custom extension factories.
Result:
- `ListenerSnapshot` now fully resolves `filter_chains` and
`default_filter_chain`, enabling filter-chain-level TLS and routing.
- Downstream (server-side) TLS supports multiple certificates; upstream
enforces at most one.
- Internal extension factories can no longer be overridden via SPI.
- Server-side HTTP filter chains are resolved and accessible via
`RouteEntry.httpService()`.1 parent c152e49 commit 87a2533
43 files changed
Lines changed: 2000 additions & 380 deletions
File tree
- it/xds-client/src/test/java/com/linecorp/armeria/xds/it
- xds-api/src/main/proto/envoy
- config/listener/v3
- extensions
- filters/http/router/v3
- transport_sockets/tls/v3
- xds/src
- main
- java/com/linecorp/armeria/xds
- client/endpoint
- filter
- stream
- resources/META-INF/services
- test/java/com/linecorp/armeria/xds
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
| 495 | + | |
499 | 496 | | |
500 | 497 | | |
501 | 498 | | |
| |||
Lines changed: 4 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
| 347 | + | |
351 | 348 | | |
352 | 349 | | |
353 | 350 | | |
| |||
357 | 354 | | |
358 | 355 | | |
359 | 356 | | |
360 | | - | |
| 357 | + | |
361 | 358 | | |
362 | 359 | | |
363 | 360 | | |
| |||
377 | 374 | | |
378 | 375 | | |
379 | 376 | | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
| 377 | + | |
384 | 378 | | |
385 | 379 | | |
386 | 380 | | |
| |||
525 | 519 | | |
526 | 520 | | |
527 | 521 | | |
528 | | - | |
| 522 | + | |
529 | 523 | | |
530 | 524 | | |
531 | 525 | | |
| |||
Lines changed: 149 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
0 commit comments