wildcard_processor

package module
v0.0.0-...-532ab32 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2017 License: MIT Imports: 5 Imported by: 0

README

wildcard-processor

Build Status Coverage Status Go Report Card

Wildcard-processor adds wildcard support for recipient hosts validation for go-guerilla package

About

This package is a Processor for the Go-Guerrilla SMTP server. By default it is possible to match hosts using exact names or "." character. Wildcard-processor adds another configuration option, where it is possible to define recipient hosts using wildcard, e.g. "*.com", so it offers much greater flexibility.

Configuration

Set wildcard as validate_process in your backend config file and define hosts with wildcards under wildcard_hosts configuration field. Use commas for multiple values.

"backend_config":
{
    "validate_process": "wildcard",
    "wildcard_hosts": "*.com,*.org",
    "log_received_mails": false,
},

Then import github.com/DevelHell/wildcard-processor and add wildcard as a processor

app.AddProcessor("wildcard", wildcard_processor.WildcardProcessor)

And you're ready to go. For more information see go-guerilla documentation

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WildcardProcessor = func() backends.Decorator {
	var w *wildcard
	initializer := backends.InitializeWith(func(backendConfig backends.BackendConfig) error {
		configType := backends.BaseConfig(&WildcardConfig{})
		bcfg, err := backends.Svc.ExtractConfig(backendConfig, configType)
		if err != nil {
			return err
		}

		w = newWildcard(bcfg.(*WildcardConfig))

		return nil
	})

	backends.Svc.AddInitializer(initializer)

	return func(p backends.Processor) backends.Processor {
		return backends.ProcessWith(func(e *mail.Envelope, task backends.SelectTask) (backends.Result, error) {
			if task == backends.TaskValidateRcpt {

				for _, rcpt := range e.RcptTo {
					if !w.allowsRcpt(rcpt.Host) {
						backends.Log().Debugf("Recipients host %s did not pass", rcpt.Host)

						return backends.NewResult(response.Canned.FailNoSenderDataCmd), backends.NoSuchUser
					}
				}
			}

			return p.Process(e, task)
		})
	}
}

Functions

This section is empty.

Types

type WildcardConfig

type WildcardConfig struct {
	WildcardHosts string `json:"wildcard_hosts"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳