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.

  • read is invoked when a packet is received on the local downstream port and is to be sent to an upstream endpoint.
  • write is 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_seconds The duration it took for a filter’s read implementation to execute.

    • Labels
      • filter The name of the filter being executed.
  • filter_write_duration_seconds The duration it took for a filter’s write implementation to execute.

    • Labels
      • filter The name of the filter being executed.

Provided methods

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.

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.

Implementors