Documentation
¶
Overview ¶
Package socketmap implements Postfix' socketmap_table lookup protocol.
Background ¶
The Postfix mail server uses lookup tables in various places, when it needs to translate some value into another. The most common use case is alias expansion for mail addresses.
While most tasks can be achieved using Postfix' built-in tables and flat files, sometimes, a more dynamic approach is needed. Therefore, Postfix can query external services using the socketmap_table protocol.
Implementing a lookup server ¶
To implement a socketmap_table lookup server, only two things are needed:
- A lookup function with the signature of LookupFn which implements the lookup itself and returns a response
- A network net.Listener to listen for Postfix' connections on
The source code repository has examples.
A single server can handle many different named maps, by registering different lookup functions with the SocketMapServer.RegisterMap function.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LookupFn ¶
type LookupFn func(key string) (*SocketMapResult, error)
Lookup function called by the SocketMapServer for each request to the map it is registered for
type SocketMapRequest ¶
A request as received from Postfix
type SocketMapResult ¶
A result sent to Postfix
func (*SocketMapResult) Encode ¶
func (r *SocketMapResult) Encode() *netstring.Netstring
Encode the result into a netstring object for further serialization
type SocketMapServer ¶
type SocketMapServer struct {
// contains filtered or unexported fields
}
A server handling socketmap_table connections on one network listener
func NewSocketMapServer ¶
func NewSocketMapServer() *SocketMapServer
Create a new SocketMapServer with an empty mapping map
func (*SocketMapServer) RegisterMap ¶
func (s *SocketMapServer) RegisterMap(name string, fn LookupFn)
Register a lookup function as a named map The map name is sent by Postfix, according to its configuration.