pub trait Filter: Send + Sync {
    fn read(&self, _: &mut ReadContext) -> Option<()> { ... }
    fn write(&self, _: &mut WriteContext) -> Option<()> { ... }
}
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 an Some if the packet processing should proceed. If the packet should be rejected, it will return None instead. 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 Some if the packet processing should proceed. If the packet should be rejected, it will return None

Implementors