14 releases

0.3.3 Jan 22, 2024
0.3.2 Jan 22, 2024
0.2.0 Jan 21, 2024
0.1.8 Nov 23, 2023
0.1.3 Jan 28, 2023

#641 in Database interfaces

22 downloads per month

Apache-2.0

51KB
1.5K SLoC

Prew

Prew is a reverse rewrite proxy for PostgreSQL (other protocol support pending). It generalizes rewrite rules into:

  • A parser
  • A filter
  • A transformer
  • An encoder
  • A reporter

A sample binary is included but it is primarily intended to be pulled in as a library and provided custom components for the rewrite rules.

Packets returned from the service being proxied are currently not subject to any rules and are always passed back to the client unmodified.

Proxy Components

Parser

The parser is responsible for parsing a packet into a standard struct, that will be used for the following rules.

Filter

The filter can selectively filter out packets. No response is sent for filtered packets.

Transformer

The transformer can optionally modify packet content (i.e., the rewrite step).

Encoder

The encoder encodes the transformed packet back into its raw format (skipped if no transformation was made).

Reporter

The reporter runs concurrently to provide logging or additional side-functionality based on the content of the packet.

Attributions

Prew is based in large part upon sql-proxy-rs by Raymond Cheng.

Dependencies

~30–45MB
~800K SLoC