pps

package module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 10 Imported by: 0

README

postfix-policy-server

Go Reference Go Report Card Build Status pps docs buy ma a coffee

postfix-policy-server (or short: pps) provides a simple framework to create Postfix SMTP Access Policy Delegation Servers Servers in Go.

The pps documentation provides you with all you need, to quickly get started with your own Postifx policy service.

Alternatively check out the Go reference for further details or have a look at the example echo-server that is provided with this package.

Documentation

Index

Constants

View Source
const DefaultAddr = "0.0.0.0"

DefaultAddr is the default address the server is listening on

View Source
const DefaultPort = "10005"

DefaultPort is the default port the server is listening on

Variables

This section is empty.

Functions

This section is empty.

Types

type CtxKey

type CtxKey int

CtxKey represents the different key ids for values added to contexts

const (

	// CtxNoLog lets the user control wether the server should log to
	// STDERR or not
	CtxNoLog CtxKey
)

type Handler

type Handler interface {
	Handle(*PolicySet) PostfixResp
}

Handler interface for handling incoming policy requests and returning the corresponding action

type PolicySet

type PolicySet struct {
	// Postfix version 2.1 and later
	Request           string
	ProtocolState     string
	ProtocolName      string
	HELOName          string
	QueueId           string
	Sender            string
	Recipient         string
	RecipientCount    uint64
	ClientAddress     net.IP
	ClientName        string
	ReverseClientName string
	Instance          string

	// Postfix version 2.2 and later
	SASLMethod       string
	SASLUsername     string
	SASLSender       string
	Size             uint64
	CCertSubject     string
	CCertIssuer      string
	CCertFingerprint string

	// Postfix version 2.3 and later
	EncryptionProtocol string
	EncryptionCipher   string
	EncryptionKeysize  uint64
	ETRNDomain         string

	// Postfix version 2.5 and later
	Stress bool

	// Postfix version 2.9 and later
	CCertPubkeyFingerprint string

	// Postfix version 3.0 and later
	ClientPort uint64

	// Postfix version 3.1 and later
	PolicyContext string

	// Postfix version 3.2 and later
	ServerAddress net.IP
	ServerPort    uint64

	// postfix-policy-server specific values
	PPSConnId string
}

PolicySet is a set information provided by the postfix policyd request

type PostfixResp

type PostfixResp string

PostfixResp is a possible response value for the policy request

const (
	RespOk            PostfixResp = "OK"
	RespReject        PostfixResp = "REJECT"
	RespDefer         PostfixResp = "DEFER"
	RespDeferIfReject PostfixResp = "DEFER_IF_REJECT"
	RespDeferIfPermit PostfixResp = "DEFER_IF_PERMIT"
	RespDiscard       PostfixResp = "DISCARD"
	RespDunno         PostfixResp = "DUNNO"
	RespHold          PostfixResp = "HOLD"
	RespInfo          PostfixResp = "INFO"
	RespWarn          PostfixResp = "WARN"
)

Possible responses to the postfix server See: http://www.postfix.org/access.5.html

func TextResponseNonOpt added in v0.1.3

func TextResponseNonOpt(rt PostfixTextResp, t string) PostfixResp

TextResponseNonOpt allows you to use a PostfixTextResp with a non-optional text as response to the Postfix server

func TextResponseOpt added in v0.1.3

func TextResponseOpt(rt PostfixResp, t string) PostfixResp

TextResponseOpt allows you to use a PostfixResp with an optional text as response to the Postfix server

type PostfixTextResp added in v0.1.3

type PostfixTextResp string

PostfixTextResp is a possible response value that requires additional text

const (
	TextRespFilter   PostfixTextResp = "FILTER"
	TextRespPrepend  PostfixTextResp = "PREPEND"
	TextRespRedirect PostfixTextResp = "REDIRECT"
)

Possible non-optional text responses to the postfix server

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server defines a new policy server with corresponding settings

func New

func New(options ...ServerOpt) Server

New returns a new server object

func (*Server) Run

func (s *Server) Run(ctx context.Context, h Handler) error

Run starts a server based on the Server object

func (*Server) RunWithListener added in v0.1.2

func (s *Server) RunWithListener(ctx context.Context, h Handler, l net.Listener) error

RunWithListener starts a server based on the Server object with a given network listener

func (*Server) SetAddr added in v0.1.1

func (s *Server) SetAddr(a string)

SetAddr will override the listening address on an already existing policy server

func (*Server) SetPort added in v0.1.1

func (s *Server) SetPort(p string)

SetPort will override the listening port on an already existing policy server

type ServerOpt

type ServerOpt func(*Server)

ServerOpt is an override function for the New() method

func WithAddr

func WithAddr(a string) ServerOpt

WithAddr overrides the default listening address for the policy server

func WithPort

func WithPort(p string) ServerOpt

WithPort overrides the default listening port for the policy server

Directories

Path Synopsis
example-code
echo-server command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL