Documentation ¶
Index ¶
Constants ¶
const ( // DNSBLTimeout is the timeout for DNSBL requests DNSBLTimeout = 5 * time.Second // DNSBLDefaultSignal is the default signal for DNSBLs DNSBLDefaultSignal = "127.0.0.2" )
const ( // NoUserCode SMTP code NoUserCode = 550 // BannedCode SMTP code BannedCode = 554 // GreylistCode SMTP code GreylistCode = 451 // RBLCode SMTP code RBLCode = 450 )
const ( // Incoming is the direction of the email Incoming = "incoming" // Outgoing is the direction of the email Outoing = "outgoing" )
Variables ¶
var ( // NoUserEnhancedCode enhanced SMTP code NoUserEnhancedCode = smtp.EnhancedCode{5, 5, 0} // BannedEnhancedCode enhanced SMTP code BannedEnhancedCode = smtp.EnhancedCode{5, 5, 4} // GreylistEnhancedCode is GraylistCode in enhanced code notation GreylistEnhancedCode = smtp.EnhancedCode{4, 5, 1} // RBLEnhancedCode is RBLCode in enhanced code notation RBLEnhancedCode = smtp.EnhancedCode{4, 5, 0} // ErrBanned returned to banned hosts ErrBanned = &smtp.SMTPError{ Code: BannedCode, EnhancedCode: BannedEnhancedCode, Message: "please, don't bother me anymore, kupo.", } // ErrNoUser returned when no such mailbox found ErrNoUser = &smtp.SMTPError{ Code: NoUserCode, EnhancedCode: NoUserEnhancedCode, Message: "no such user here, kupo.", } // ErrGreylisted returned when the host is graylisted ErrGreylisted = &smtp.SMTPError{ Code: GreylistCode, EnhancedCode: GreylistEnhancedCode, Message: "You have been greylisted, try again a bit later.", } // ErrRBL returned when the host is blacklisted ErrRBL = &smtp.SMTPError{ Code: RBLCode, EnhancedCode: RBLEnhancedCode, Message: "You are blacklisted, kupo.", } // ErrInvalidEmail for invalid emails :) ErrInvalidEmail = errors.New("please, provide valid email address") )
var DNSBLs = map[string][]string{ "b.barracudacentral.org": {DNSBLDefaultSignal}, "bl.spamcop.net": {DNSBLDefaultSignal, "127.0.0.3"}, "ix.dnsbl.manitu.net": {DNSBLDefaultSignal}, "psbl.surriel.com": {DNSBLDefaultSignal}, "rbl.interserver.net": {DNSBLDefaultSignal}, "spam.dnsbl.anonmails.de": {DNSBLDefaultSignal}, "zen.spamhaus.org": {DNSBLDefaultSignal, "127.0.0.3", "127.0.0.4", "127.0.0.5", "127.0.0.6", "127.0.0.7", "127.0.0.9"}, "rbl.your-server.de": {DNSBLDefaultSignal}, }
DNSBLs is a list of Domain Name System Blacklists with list of signals they use
Functions ¶
Types ¶
type DNSBLRequest ¶
type DNSBLRequest struct {
// contains filtered or unexported fields
}
DNSBLRequest is a request to check if an IP address is listed in any of the DNSBLs
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener that rejects connections from banned hosts
func NewListener ¶
func (*Listener) Close ¶
Close closes the listener. Any blocked Accept operations will be unblocked and return errors.
func (*Listener) SetTLSConfig ¶
type MailSender ¶
type PlainAuthServer ¶
type PlainAuthServer struct {
// contains filtered or unexported fields
}
PlainAuthServer is a server implementation of the PLAIN authentication mechanism. It's a modified version of the original plainServer from https://github.com/emersion/go-sasl package (MIT License) ref: https://github.com/emersion/go-sasl/blob/e73c9f7bad438a9bf3f5b28e661b74d752ecafdd/plain.go The reason for modification is to extend automatic banning mechanism of Postmoogle, as the original implementation doesn't provide a way to return an error to the caller before the actual authentication process.
func NewPlainAuthServer ¶
func NewPlainAuthServer(ctx context.Context, bot matrixbot, conn *smtp.Conn, auth sasl.PlainAuthenticator) *PlainAuthServer
NewPlainAuthServer creates a new PLAIN authentication server.