Trait quilkin::filters::Filter [−][src]
pub trait Filter: Send + Sync {
fn read(&self, ctx: ReadContext) -> Option<ReadResponse> { ... }
fn write(&self, ctx: WriteContext<'_>) -> Option<WriteResponse> { ... }
}Expand description
Trait for routing and manipulating packets.
An implementation of Filter provides a read and a write method. Both
methods are invoked by the proxy when it consults the filter chain - their
arguments contain information about the packet being processed.
readis invoked when a packet is received on the local downstream port and is to be sent to an upstream endpoint.writeis invoked in the opposite direction when a packet is received from an upstream endpoint and is to be sent to a downstream client.
Metrics
-
filter_read_duration_secondsThe duration it took for afilter’sreadimplementation to execute.- Labels
filterThe name of the filter being executed.
- Labels
-
filter_write_duration_secondsThe duration it took for afilter’swriteimplementation to execute.- Labels
filterThe name of the filter being executed.
- Labels
Provided methods
fn read(&self, ctx: ReadContext) -> Option<ReadResponse>
fn read(&self, ctx: ReadContext) -> Option<ReadResponse>
Filter::read is invoked when the proxy receives data from a
downstream connection on the listening port.
This function should return a ReadResponse containing the array of
endpoints that the packet should be sent to and the packet that should
be sent (which may be manipulated) as well. If the packet should be
rejected, return None. By default, the context passes
through unchanged.
fn write(&self, ctx: WriteContext<'_>) -> Option<WriteResponse>
fn write(&self, ctx: WriteContext<'_>) -> Option<WriteResponse>
Filter::write is invoked when the proxy is about to send data to a
downstream connection via the listening port after receiving it via one
of the upstream Endpoints.
This function should return an WriteResponse containing the packet to
be sent (which may be manipulated). If the packet should be rejected,
return None. By default, the context passes through unchanged.
