Capture
The Capture filter’s job is to find a series of bytes within a packet, and capture it into
Filter Dynamic Metadata, so that it can be utilised by filters further
down the chain.
This is often used as a way of retrieving authentication tokens from a packet, and used in combination with Concatenate and TokenRouter filter to provide common packet routing utilities.
Capture strategies
There are multiple strategies for capturing bytes from the packet.
Suffix
Captures bytes from the end of the packet.
Prefix
Captures bytes from the start of the packet.
Regex
Captures bytes using a regular expression. Unlike other capture strategies, the regular expression can return one or many values if there are multiple matches.
Filter name
quilkin.filters.capture.v1alpha1.Capture
Configuration Examples
#![allow(unused)]
fn main() {
let yaml = "
version: v1alpha1
filters:
- name: quilkin.filters.capture.v1alpha1.Capture
config:
metadataKey: myapp.com/myownkey
prefix:
size: 3
remove: false
clusters:
- endpoints:
- address: 127.0.0.1:7001
";
let config = quilkin::config::Config::from_reader(yaml.as_bytes()).unwrap();
assert_eq!(config.filters.load().len(), 1);
}
Configuration Options (Rust Doc)
$schema: https://json-schema.org/draft/2020-12/schema
title: Config
type: object
properties:
metadata_key:
description: |-
The key to use when storing the captured value in the filter context.
If a match was found it is available
under `{{metadata_key}}/is_present`.
$ref: '#/$defs/Key'
strategy:
description: The capture strategy.
$ref: '#/$defs/Strategy'
required:
- metadata_key
- strategy
$defs:
Key:
description: A key in the metadata table.
type: string
Prefix:
description: Capture from the start of the packet.
type: object
properties:
remove:
description: Whether captured bytes are removed from the original packet.
type: boolean
default: false
size:
description: The number of bytes to capture.
type: integer
format: uint32
minimum: 0
required:
- size
Regex:
description: Capture from the start of the packet.
type: object
properties:
pattern:
description: The regular expression to use for capture.
type: string
required:
- pattern
Strategy:
description: Strategy to apply for acquiring a set of bytes in the UDP packet
oneOf:
- description: Looks for the set of bytes at the beginning of the packet
type: object
properties:
kind:
type: string
const: PREFIX
$ref: '#/$defs/Prefix'
required:
- kind
- description: Look for the set of bytes at the end of the packet
type: object
properties:
kind:
type: string
const: SUFFIX
$ref: '#/$defs/Suffix'
required:
- kind
- description: Look for the set of bytes at the end of the packet
type: object
properties:
kind:
type: string
const: REGEX
$ref: '#/$defs/Regex'
required:
- kind
Suffix:
description: Capture from the end of the packet.
type: object
properties:
remove:
description: The number of bytes to capture.
type: boolean
default: false
size:
description: Whether captured bytes are removed from the original packet.
type: integer
format: uint32
minimum: 0
required:
- size