Helper image for automated burgerdev/ocaml-addressmapper builds.
3.9K
Implementation of a postfix tcp lookup table that transforms the requested address according to a configurable set of mapping rules. A common use case is to transform an address to a canonical form.
Built-in mapping rules are accept, reject, match a regular expression
and replace a regular expression with a fixed string. Those can be combined
with all and first. Additionally, you can use the case transforming rules
lower and upper. The mapping rules are specified as S-expressions:
(
(matches "^.*@example.com$")
(replace "+[^@]*@" "@")
)
This accepts emails for domain example.com and removes a sub-address (the
plus part).
make fetch_deps # installs dependencies using opam
make all
There's a special docker image for building this project. Run the above
commands inside the container, or use the docker-build.sh script. The latter
builds the development image, compiles the OCaml sources, runs tests (triggered
by environment variable CI) and builds the production image.
export CI=true
bash docker-build.sh alpine
./main.native --help
Command line arguments:
-r <file>
path to the rules file on the container (default: /rules/rules.sexp)-b <address>
IP address to bind to (default: 127.0.0.1)-p <port>
listening port (default: 30303)-u
re-read the rules file for each request (default: false)Run the AddressMapper as a docker container in the background, forward the port
to localhost:30303 and use the rules file /tmp/rules.sexp below.
docker run -d -p 30303:30303 -v /tmp/rules.sexp:/rules.sexp:ro burgerdev/ocaml-addressmapper
(
(lower (replace "+[^@]*@" "@"))
(not (prefix_matches "sauron"))
(first
(
(
(matches "^[^@]+@business\.com$")
(first ((matches "^ceo@.*")
(matches "^pr@.*"))
)
)
(equals "[email protected]")
)
)
)
This file contains the following instructions (see configuration.md for an explanation of the addressmapper rules):
business.com, the CEO and the
Public Relations Department.Let's see some examples for how to use the container we spawned:
echo "get [email protected]" | nc localhost 30303
# we convert everything to lower case, so the result should be
# '200 [email protected]'.
echo "get [email protected]" | nc localhost 30303
echo "get [email protected]" | nc localhost 30303
# Both with and without a sub-address, this should result in
# '200 [email protected]'.
echo "get [email protected]" | nc localhost 30303
# Sauron is explicitly excluded, this should be '500 not-found'.
echo "put [email protected]" | nc localhost 30303
# This is not valid postfix mapper syntax, therefore '400 malformed request'.
Content type
Image
Digest
Size
472.6 MB
Last updated
over 8 years ago
docker pull burgerdev/ocaml-addressmapper-devel