|
@@ -1,337 +1,228 @@
|
|
|
|
|
|
[](https://travis-ci.org/flashmob/go-guerrilla)
|
|
|
|
|
|
-Go-Guerrilla SMTPd
|
|
|
+Go-Guerrilla SMTP Daemon
|
|
|
====================
|
|
|
|
|
|
-An minimalist SMTP server written in Go, made for receiving large volumes of mail.
|
|
|
+A lightweight SMTP server written in Go, made for receiving large volumes of mail.
|
|
|
+To be used as a package in your Go project, or as a stand-alone daemon by running the "guerrillad" binary.
|
|
|
+
|
|
|
+Supports MySQL and Redis out-of-the-box, with many other vendor provided _processors_,
|
|
|
+such as [MailDir](https://github.com/flashmob/maildir-processor) and even [FastCGI](https://github.com/flashmob/fastcgi-processor)!
|
|
|
+See below for a list of available processors.
|
|
|
|
|
|

|
|
|
|
|
|
-### What is Go Guerrilla SMTPd?
|
|
|
+### What is Go-Guerrilla?
|
|
|
|
|
|
-It's a small SMTP server written in Go, for the purpose of receiving large volume of email.
|
|
|
-Written for GuerrillaMail.com which processes hundreds of thousands of emails
|
|
|
-every hour.
|
|
|
+It's an SMTP server written in Go, for the purpose of receiving large volumes of email.
|
|
|
+It started as a project for GuerrillaMail.com which processes millions of emails every day,
|
|
|
+and needed a daemon with less bloat & written in a more memory-safe language that can
|
|
|
+take advantage of modern multi-core architectures.
|
|
|
|
|
|
The purpose of this daemon is to grab the email, save it,
|
|
|
and disconnect as quickly as possible, essentially performing the services of a
|
|
|
-Mail Transfer Agent (MTA).
|
|
|
-
|
|
|
-A typical user of this software would probably use it as a package in their own
|
|
|
-Go project in order to receive and deliver email.
|
|
|
+Mail Transfer Agent (MTA) without the sending functionality.
|
|
|
|
|
|
-Go-Guerrilla allows you to customize how the email is delivered.
|
|
|
+The software also includes a modular backend implementation, which can extend the email
|
|
|
+processing functionality to whatever needs you may require. We refer to these modules as
|
|
|
+"_Processors_". Processors can be chained via the config to perform different tasks on
|
|
|
+received email, or to validate recipients.
|
|
|
|
|
|
-Out of the box, Go-Guerrilla does not attempt to filter HTML, check for spam or do any
|
|
|
-sender verification. However, it comes with a modular middleware-like backend system which
|
|
|
-support a range of different features and ways of delivering email.
|
|
|
See the list of available _Processors_ below.
|
|
|
|
|
|
+For more details about the backend system, see the:
|
|
|
+[Backends, configuring and extending](https://github.com/flashmob/go-guerrilla/wiki/Backends,-configuring-and-extending) page.
|
|
|
+
|
|
|
+### License
|
|
|
+
|
|
|
The software is using MIT License (MIT) - contributors welcome.
|
|
|
|
|
|
### Features
|
|
|
|
|
|
-- Multi-server. The daemon can spawn multiple servers at once, all sharing the same backend
|
|
|
+#### Main Features
|
|
|
+
|
|
|
+- Multi-server. Can spawn multiple servers, all sharing the same backend
|
|
|
for saving email.
|
|
|
-- Config hot-reloading. Add/Remove/Enable/Disable servers without restarting. Reload TLS configuration, and most other settings on the fly.
|
|
|
+- Config hot-reloading. Add/Remove/Enable/Disable servers without restarting.
|
|
|
+Reload TLS configuration, change most other settings on the fly.
|
|
|
- Graceful shutdown: Minimise loss of email if you need to shutdown/restart.
|
|
|
-- Pooling: The daemon uses pooling where possible. It's friendly to the garbage collector.
|
|
|
-- Modular, component based, backend system for processing email that's easy to extend.
|
|
|
-- Backend system arranged in a producer/consumer type structure, making use of Go's channels.
|
|
|
-- Fuzz tested.
|
|
|
-- Can be used as a package in your Go project.
|
|
|
+- Be a gentleman to the garbage collector: resources are pooled & recycled where possible.
|
|
|
+- Modular [Backend system](https://github.com/flashmob/go-guerrilla/wiki/Backends,-configuring-and-extending)
|
|
|
+- Modern TLS support (STARTTLS or SMTPS).
|
|
|
+- Can be [used as a package](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package) in your Go project.
|
|
|
+Get started in just a few lines of code!
|
|
|
+- [Fuzz tested](https://github.com/flashmob/go-guerrilla/wiki/Fuzz-testing).
|
|
|
+[Auto-tested](https://travis-ci.org/flashmob/go-guerrilla). Battle Tested.
|
|
|
+
|
|
|
+#### Backend Features
|
|
|
+
|
|
|
+- Arranged as workers running in parallel, using a producer/consumer type structure,
|
|
|
+ taking advantage of Go's channels and go-routines.
|
|
|
+- Modular [backend system](https://github.com/flashmob/go-guerrilla/wiki/Backends,-configuring-and-extending)
|
|
|
+ structured using a [decorator-like pattern](https://en.wikipedia.org/wiki/Decorator_pattern) which allows the chaining of components (a.k.a. _Processors_) via the config.
|
|
|
+- Different ways for processing / delivering email: Supports MySQL and Redis out-of-the box, many other
|
|
|
+vendor provided processors available.
|
|
|
|
|
|
### Roadmap / Contributing & Bounties
|
|
|
|
|
|
+Pull requests / issue reporting & discussion / code reviews always
|
|
|
+welcome. To encourage more pull requests, we are now offering bounties.
|
|
|
|
|
|
-Pull requests / issue reporting & discussion / code reviews always
|
|
|
-welcome. To encourage more pull requests, we are now offering bounties
|
|
|
-funded from our bitcoin donation address:
|
|
|
-
|
|
|
-`1grr11aWtbsyMUeB4EGfHvTuu7eFzkJ4A`
|
|
|
-
|
|
|
-So far we have the following bounties are still open:
|
|
|
-(Updated 22 Dec 2016)
|
|
|
-
|
|
|
-- Let's encrypt TLS certificate support!
|
|
|
-Take a look at https://github.com/flashmob/go-guerrilla/issues/29
|
|
|
-(0.5 for a successful merge)
|
|
|
-
|
|
|
-- Analytics: A web based admin panel that displays live statistics,
|
|
|
-including the number of clients, memory usage, graph the number of
|
|
|
-connections/bytes/memory used for the last 24h.
|
|
|
-Show the top source clients by: IP, by domain & by HELO message.
|
|
|
-Using websocket via https & password protected.
|
|
|
-Update: Currently WIP, see branch https://github.com/flashmob/go-guerrilla/tree/dashboard.
|
|
|
-(1 BTC for a successful merge)
|
|
|
-
|
|
|
-- Fuzz Testing: Using https://github.com/dvyukov/go-fuzz
|
|
|
-Implement a fuzzing client that will send input to the
|
|
|
-server's connection.
|
|
|
-Maybe another area to fuzz would be the config file,
|
|
|
-fuzz the config file and then send a sighup to the server to see if it
|
|
|
-can crash? Please open an issue before to discuss scope
|
|
|
-(0.25 BTC for a successful merge / bugs found.)
|
|
|
+Take a look at our [Bounties and Roadmap](https://github.com/flashmob/go-guerrilla/wiki/Roadmap-and-Bounties) page!
|
|
|
|
|
|
-- Testing: Add some automated more tests to increase coverage.
|
|
|
-(0.1 BTC for a successful merge, judged to be a satisfactory increase
|
|
|
-in coverage. Please open an issue before to discuss scope)
|
|
|
|
|
|
-- Profiling: Simulate a configurable number of simultaneous clients
|
|
|
-(eg 5000) which send commands at random speeds with messages of various
|
|
|
-lengths. Some connections to use TLS. Some connections may produce
|
|
|
-errors, eg. disconnect randomly after a few commands, issue unexpected
|
|
|
-input or timeout. Provide a report of all the bottlenecks and setup so
|
|
|
-that the report can be run automatically run when code is pushed to
|
|
|
-github. (Flame graph maybe? https://github.com/uber/go-torch
|
|
|
-Please open an issue before to discuss scope)
|
|
|
-(0.25 BTC)
|
|
|
+Getting started
|
|
|
+===========================
|
|
|
|
|
|
-- Looking for someone to do a code review & possibly fix any tidbits,
|
|
|
-they find, or suggestions for doing things better.
|
|
|
-(Already one bounty of 0.25 paid, however, more is always welcome)
|
|
|
+(Assuming that you have GNU make and latest Go on your system)
|
|
|
|
|
|
-Ready to roll up your sleeves and have a go?
|
|
|
-Please open an issue for more clarification / details on Github.
|
|
|
-Also, welcome your suggestions for adding things to this Roadmap - please open an issue.
|
|
|
+#### Dependencies
|
|
|
|
|
|
-Another way to contribute is to donate to our bitcoin address to help
|
|
|
-us fund more bounties!
|
|
|
-`1grr11aWtbsyMUeB4EGfHvTuu7eFzkJ4A`
|
|
|
+Go-Guerrilla uses [Glide](https://github.com/Masterminds/glide) to manage
|
|
|
+dependencies. If you have glide installed, just run `glide install` as usual.
|
|
|
+
|
|
|
+You can also run `$ go get ./..` if you don't want to use glide, and then run `$ make test`
|
|
|
+to ensure all is good.
|
|
|
|
|
|
-### Brief History and purpose
|
|
|
+To build the binary run:
|
|
|
|
|
|
-Go-Guerrilla is used as the primary server for receiving email at
|
|
|
-Guerrilla Mail. As of 2016, it's handling all connections without any
|
|
|
-proxy (Nginx).
|
|
|
+```
|
|
|
+$ make guerrillad
|
|
|
+```
|
|
|
|
|
|
-Originally, Guerrilla Mail ran Exim which piped email to a php script (2009).
|
|
|
-As the site got popular and more email came through, this approach
|
|
|
-eventually swamped the server.
|
|
|
+This will create a executable file named `guerrillad` that's ready to run.
|
|
|
|
|
|
-The next solution was to decrease the heavy setup into something more
|
|
|
-lightweight. A small script was written to implement a basic SMTP server (2010).
|
|
|
-Eventually that script also got swamped, so it was re-written to use
|
|
|
-event driven I/O (2012). A year later, the latest script also became inadequate
|
|
|
- so it was ported to Go and has served us well since.
|
|
|
+Next, copy the `goguerrilla.conf.sample` file to `goguerrilla.conf.json`.
|
|
|
+You may need to customize the `pid_file` setting to somewhere local,
|
|
|
+and also set `tls_always_on` to false if you don't have a valid certificate setup yet.
|
|
|
|
|
|
+Next, run your server like this:
|
|
|
|
|
|
-Getting started
|
|
|
-===========================
|
|
|
+`$ ./guerrillad serve`
|
|
|
|
|
|
-(Assuming that you have GNU make and latest Go on your system)
|
|
|
+The configuration options are detailed on the [configuration page](https://github.com/flashmob/go-guerrilla/wiki/Configuration).
|
|
|
+The main takeaway here is:
|
|
|
|
|
|
-To build for the first time (installs dependencies and builds the web dashboard):
|
|
|
-```
|
|
|
-$ make dependencies
|
|
|
-$ make dashboard
|
|
|
-$ make guerrillad
|
|
|
-```
|
|
|
+The default configuration uses 3 _processors_, they are set using the `save_process`
|
|
|
+config option. Notice that it contains the following value:
|
|
|
+`"HeadersParser|Header|Debugger"` - this means, once an email is received, it will
|
|
|
+first go through the `HeadersParser` processor where headers will be parsed.
|
|
|
+Next, it will go through the `Header` processor, where delivery headers will be added.
|
|
|
+Finally, it will finish at the `Debugger` which will log some debug messages.
|
|
|
|
|
|
-To build afterward, just run
|
|
|
-```
|
|
|
-$ make guerrillad
|
|
|
-```
|
|
|
+Where to go next?
|
|
|
|
|
|
-Rename goguerrilla.conf.sample to goguerrilla.conf
|
|
|
-```
|
|
|
-$ cp goguerrilla.conf.sample goguerrilla.conf
|
|
|
-```
|
|
|
+- Try setting up an [example configuration](https://github.com/flashmob/go-guerrilla/wiki/Configuration-example:-save-to-Redis-&-MySQL)
|
|
|
+which saves email bodies to Redis and metadata to MySQL.
|
|
|
+- Try importing some of the 'vendored' processors into your project. See [MailDiranasaurus](https://github.com/flashmob/maildiranasaurus)
|
|
|
+as an example project which imports the [MailDir](https://github.com/flashmob/maildir-processor) and [FastCGI](https://github.com/flashmob/fastcgi-processor) processors.
|
|
|
+- Try hacking the source and [create your own processor](https://github.com/flashmob/go-guerrilla/wiki/Backends,-configuring-and-extending).
|
|
|
+- Once your daemon is running, you might want to stup [log rotation](https://github.com/flashmob/go-guerrilla/wiki/Automatic-log-file-management-with-logrotate).
|
|
|
|
|
|
-See `backends/guerrilla_db_redis.go` source to use an example for creating your own email saving backend,
|
|
|
-or the dummy one if you'd like to start from scratch.
|
|
|
-
|
|
|
-If you want to build on the sample `guerrilla-db-redis` module, setup the following table
|
|
|
-in MySQL:
|
|
|
-
|
|
|
- CREATE TABLE IF NOT EXISTS `new_mail` (
|
|
|
- `mail_id` BIGINT(20) unsigned NOT NULL AUTO_INCREMENT,
|
|
|
- `date` datetime NOT NULL,
|
|
|
- `from` varchar(128) character set latin1 NOT NULL,
|
|
|
- `to` varchar(128) character set latin1 NOT NULL,
|
|
|
- `subject` varchar(255) NOT NULL,
|
|
|
- `body` text NOT NULL,
|
|
|
- `charset` varchar(32) character set latin1 NOT NULL,
|
|
|
- `mail` longblob NOT NULL,
|
|
|
- `spam_score` float NOT NULL,
|
|
|
- `hash` char(32) character set latin1 NOT NULL,
|
|
|
- `content_type` varchar(64) character set latin1 NOT NULL,
|
|
|
- `recipient` varchar(128) character set latin1 NOT NULL,
|
|
|
- `has_attach` int(11) NOT NULL,
|
|
|
- `ip_addr` varchar(15) NOT NULL,
|
|
|
- `return_path` VARCHAR(255) NOT NULL,
|
|
|
- `is_tls` BIT(1) DEFAULT b'0' NOT NULL,
|
|
|
- PRIMARY KEY (`mail_id`),
|
|
|
- KEY `to` (`to`),
|
|
|
- KEY `hash` (`hash`),
|
|
|
- KEY `date` (`date`)
|
|
|
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
|
|
-
|
|
|
-The above table does not store the body of the email which makes it quick
|
|
|
-to query and join, while the body of the email is fetched from Redis
|
|
|
-for future processing. The `mail` field can contain data in case Redis is down.
|
|
|
-Otherwise, if data is in Redis, the `mail` will be blank, and
|
|
|
-the `body` field will contain the word 'redis'.
|
|
|
-
|
|
|
-You can implement your own saveMail function to use whatever storage /
|
|
|
-backend fits for you. Please share them ^_^, in particular, we would
|
|
|
-like to see other formats such as maildir and mbox.
|
|
|
|
|
|
|
|
|
Use as a package
|
|
|
============================
|
|
|
-Guerrilla SMTPd can also be imported and used as a package in your project.
|
|
|
+Go-Guerrilla can be imported and used as a package in your Go project.
|
|
|
+
|
|
|
+### Quickstart
|
|
|
+
|
|
|
|
|
|
-## Import Guerrilla.
|
|
|
+#### 1. Import the guerrilla package
|
|
|
```go
|
|
|
-import "github.com/flashmob/go-guerrilla"
|
|
|
+import (
|
|
|
+ "github.com/flashmob/go-guerrilla/guerrilla"
|
|
|
+)
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
-## Implement the `Backend` interface
|
|
|
-Or use one of the implementations in the `backends` sub-package). This is how
|
|
|
-your application processes emails received by the Guerrilla app.
|
|
|
-```go
|
|
|
-import "github.com/flashmob/go-guerrilla/mail"
|
|
|
-import "github.com/flashmob/go-guerrilla/backends"
|
|
|
+You may use ``$ go get ./...`` to get all dependencies, also Go-Guerrilla uses
|
|
|
+[glide](https://github.com/Masterminds/glide) for dependency management.
|
|
|
|
|
|
-type CustomBackend struct {...}
|
|
|
+#### 2. Start a server
|
|
|
|
|
|
-func (cb *CustomBackend) Process(e *mail.Envelope) backends.Result {
|
|
|
- err := saveSomewhere(e.NewReader())
|
|
|
- if err != nil {
|
|
|
- return guerrilla.NewResult(fmt.Sprintf("554 Error: %s", err.Error()))
|
|
|
- }
|
|
|
- return guerrilla.NewResult("250 OK")
|
|
|
-}
|
|
|
-```
|
|
|
+This will start a server with the default settings, listening on `127.0.0.1:2525`
|
|
|
|
|
|
-## Create a logger
|
|
|
|
|
|
```go
|
|
|
-import "github.com/flashmob/go-guerrilla/log"
|
|
|
|
|
|
-mainlog, err := log.GetLogger(log.OutputStderr.String());
|
|
|
-if err != nil {
|
|
|
- fmt.Println("Cannot open log:", err)
|
|
|
- os.Exit(1)
|
|
|
-}
|
|
|
-```
|
|
|
+d := guerrilla.Daemon{}
|
|
|
+err := d.Start()
|
|
|
|
|
|
-## Create an app instance.
|
|
|
-See Configuration section below for setting configuration options.
|
|
|
-```go
|
|
|
-config := &guerrilla.AppConfig{
|
|
|
- Servers: []guerrilla.ServerConfig{...},
|
|
|
- AllowedHosts: []string{...}
|
|
|
+if err == nil {
|
|
|
+ fmt.Println("Server Started!")
|
|
|
}
|
|
|
-backend := &CustomBackend{...}
|
|
|
-app, err := guerrilla.New(config, backend, mainlog)
|
|
|
```
|
|
|
|
|
|
-## Start the app.
|
|
|
-`Start` is non-blocking, so make sure the main goroutine is kept busy
|
|
|
-```go
|
|
|
-startErrors := app.Start()
|
|
|
-```
|
|
|
+`d.Start()` *does not block* after the server has been started, so make sure that you keep your program busy.
|
|
|
+
|
|
|
+The defaults are:
|
|
|
+* Server listening to 127.0.0.1:2525
|
|
|
+* use your hostname to determine your which hosts to accept email for
|
|
|
+* 100 maximum clients
|
|
|
+* 10MB max message size
|
|
|
+* log to Stderror,
|
|
|
+* log level set to "`debug`"
|
|
|
+* timeout to 30 sec
|
|
|
+* Backend configured with the following processors: `HeadersParser|Header|Debugger` where it will log the received emails.
|
|
|
+
|
|
|
+Next, you may want to [change the interface](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#starting-a-server---custom-listening-interface) (`127.0.0.1:2525`) to the one of your own choice.
|
|
|
+
|
|
|
+#### API Documentation topics
|
|
|
+
|
|
|
+Please continue to the [API documentation](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package) for the following topics:
|
|
|
+
|
|
|
+
|
|
|
+- [Suppressing log output](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#starting-a-server---suppressing-log-output)
|
|
|
+- [Custom listening interface](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#starting-a-server---custom-listening-interface)
|
|
|
+- [What else can be configured](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#what-else-can-be-configured)
|
|
|
+- [Backends](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#backends)
|
|
|
+ - [About the backend system](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#about-the-backend-system)
|
|
|
+ - [Backend Configuration](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#backend-configuration)
|
|
|
+ - [Registering a Processor](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#registering-a-processor)
|
|
|
+- [Loading config from JSON](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#loading-config-from-json)
|
|
|
+- [Config hot-reloading](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#config-hot-reloading)
|
|
|
+- [Logging](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#logging-stuff)
|
|
|
+- [Log re-opening](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#log-re-opening)
|
|
|
+- [Graceful shutdown](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#graceful-shutdown)
|
|
|
+- [Pub/Sub](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#pubsub)
|
|
|
+- [More Examples](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#more-examples)
|
|
|
+
|
|
|
+Use as a Daemon
|
|
|
+==========================================================
|
|
|
|
|
|
-## Shutting down.
|
|
|
-`Shutdown` will do a graceful shutdown, close all the connections, close
|
|
|
- the ports, and gracefully shutdown the backend. It will block until all
|
|
|
- operations are complete.
|
|
|
+### Manual for using from the command line
|
|
|
|
|
|
-```go
|
|
|
-app.Shutdown()
|
|
|
-```
|
|
|
+- [guerrillad command](https://github.com/flashmob/go-guerrilla/wiki/Running-from-command-line#guerrillad-command)
|
|
|
+ - [Starting](https://github.com/flashmob/go-guerrilla/wiki/Running-from-command-line#starting)
|
|
|
+ - [Re-loading configuration](https://github.com/flashmob/go-guerrilla/wiki/Running-from-command-line#re-loading-the-config)
|
|
|
+ - [Re-open logs](https://github.com/flashmob/go-guerrilla/wiki/Running-from-command-line#re-open-log-file)
|
|
|
+ - [Examples](https://github.com/flashmob/go-guerrilla/wiki/Running-from-command-line#examples)
|
|
|
+
|
|
|
+### Other topics
|
|
|
+
|
|
|
+- [Using Nginx as a proxy](https://github.com/flashmob/go-guerrilla/wiki/Using-Nginx-as-a-proxy)
|
|
|
+- [Testing STARTTLS](https://github.com/flashmob/go-guerrilla/wiki/Running-from-command-line#testing-starttls)
|
|
|
+- [Benchmarking](https://github.com/flashmob/go-guerrilla/wiki/Profiling#benchmarking)
|
|
|
|
|
|
-Configuration
|
|
|
-============================================
|
|
|
-The configuration is in strict JSON format. Here is an annotated configuration.
|
|
|
-Copy goguerrilla.conf.sample to goguerrilla.conf
|
|
|
-
|
|
|
-
|
|
|
- {
|
|
|
- "allowed_hosts": ["guerrillamail.com","guerrillamailblock.com","sharklasers.com","guerrillamail.net","guerrillamail.org"], // What hosts to accept
|
|
|
- "pid_file" : "/var/run/go-guerrilla.pid", // pid = process id, so that other programs can send signals to our server
|
|
|
- "log_file" : "stderr", // can be "off", "stderr", "stdout" or any path to a file
|
|
|
- "log_level" : "info", // can be "debug", "info", "error", "warn", "fatal", "panic"
|
|
|
- "backend_name": "guerrilla-db-redis", // what backend to use for saving email. See /backends dir
|
|
|
- "backend_config" :
|
|
|
- {
|
|
|
- "mysql_db":"gmail_mail",
|
|
|
- "mysql_host":"127.0.0.1:3306",
|
|
|
- "mysql_pass":"ok",
|
|
|
- "mysql_user":"root",
|
|
|
- "mail_table":"new_mail",
|
|
|
- "redis_interface" : "127.0.0.1:6379",
|
|
|
- "redis_expire_seconds" : 7200,
|
|
|
- "save_workers_size" : 3,
|
|
|
- "primary_mail_host":"sharklasers.com"
|
|
|
- },
|
|
|
- "dashboard": {
|
|
|
- "is_enable": true,
|
|
|
- "listen_interface": ":8080", // Where the dashboard will be accessible
|
|
|
- "tick_interval": "5s", // Interval at which data is measured, parseable by time.ParseDuration
|
|
|
- "max_window": "24h", // Maximum interval to keep data
|
|
|
- "ranking_aggregation_interval": "6h" // Aggregation granularity of rankings
|
|
|
- },
|
|
|
- "servers" : [ // the following is an array of objects, each object represents a new server that will be spawned
|
|
|
- {
|
|
|
- "is_enabled" : true, // boolean
|
|
|
- "host_name":"mail.test.com", // the hostname of the server as set by MX record
|
|
|
- "max_size": 1000000, // maximum size of an email in bytes
|
|
|
- "private_key_file":"/path/to/pem/file/test.com.key", // full path to pem file private key
|
|
|
- "public_key_file":"/path/to/pem/file/test.com.crt", // full path to pem file certificate
|
|
|
- "timeout":180, // timeout in number of seconds before an idle connection is closed
|
|
|
- "listen_interface":"127.0.0.1:25", // listen on ip and port
|
|
|
- "start_tls_on":true, // supports the STARTTLS command?
|
|
|
- "tls_always_on":false, // always connect using TLS? If true, start_tls_on will be false
|
|
|
- "max_clients": 1000, // max clients at one time
|
|
|
- "log_file":"/dev/stdout" // optional. Can be "off", "stderr", "stdout" or any path to a file. Will use global setting of empty.
|
|
|
- },
|
|
|
- // the following is a second server, but listening on port 465 and always using TLS
|
|
|
- {
|
|
|
- "is_enabled" : true,
|
|
|
- "host_name":"mail.test.com",
|
|
|
- "max_size":1000000,
|
|
|
- "private_key_file":"/path/to/pem/file/test.com.key",
|
|
|
- "public_key_file":"/path/to/pem/file/test.com.crt",
|
|
|
- "timeout":180,
|
|
|
- "listen_interface":"127.0.0.1:465",
|
|
|
- "start_tls_on":false,
|
|
|
- "tls_always_on":true,
|
|
|
- "max_clients":500
|
|
|
- }
|
|
|
- // repeat as many servers as you need
|
|
|
- ]
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-The Json parser is very strict on syntax. If there's a parse error and it
|
|
|
-doesn't give much clue, then test your syntax here:
|
|
|
-http://jsonlint.com/#
|
|
|
|
|
|
Email Processing Backend
|
|
|
=====================
|
|
|
|
|
|
-The main job of a go-guerrilla backend is to validate recipients and deliver emails. The term
|
|
|
+The main job of a Go-Guerrilla backend is to validate recipients and deliver emails. The term
|
|
|
"delivery" is often synonymous with saving email to secondary storage.
|
|
|
|
|
|
-The default backend implementation manages multiple workers. These workers are composed of
|
|
|
+The default backend implementation manages multiple workers. These workers are composed of
|
|
|
smaller components called "Processors" which are chained using the config to perform a series of steps.
|
|
|
Each processor specifies a distinct feature of behaviour. For example, a processor may save
|
|
|
-the emails to a particular storage system such as MySQL, or it may add additional headers before
|
|
|
+the emails to a particular storage system such as MySQL, or it may add additional headers before
|
|
|
passing the email to the next _processor_.
|
|
|
|
|
|
To extend or add a new feature, one would write a new Processor, then add it to the config.
|
|
|
There are a few default _processors_ to get you started.
|
|
|
|
|
|
-### Documentation
|
|
|
-
|
|
|
-See the full documentation here:
|
|
|
-[About Backends: introduction, configuration, extending](https://github.com/flashmob/go-guerrilla/wiki/About-Backends:-introduction,-configuring-and-extending)
|
|
|
|
|
|
### Included Processors
|
|
|
|
|
@@ -346,183 +237,56 @@ See the full documentation here:
|
|
|
|Redis|Saves the email data to Redis.|
|
|
|
|GuerrillaDbRedis|A 'monolithic' processor used at Guerrilla Mail; included for example
|
|
|
|
|
|
-### External Processors
|
|
|
+### Available Processors
|
|
|
+
|
|
|
+The following processors can be imported to your project, then use the
|
|
|
+[Daemon.AddProcessor](https://github.com/flashmob/go-guerrilla/wiki/Using-as-a-package#registering-a-processor) function to register, then add to your config.
|
|
|
|
|
|
| Processor | Description |
|
|
|
|-----------|-------------|
|
|
|
|[MailDir](https://github.com/flashmob/maildir-processor)|Save emails to a maildir. [MailDiranasaurus](https://github.com/flashmob/maildiranasaurus) is an example project|
|
|
|
-|[FastCgi](https://github.com/flashmob/fastcgi-processor)|Deliver email directly to PHP-FPM or a similar FastCGI backend.
|
|
|
+|[FastCGI](https://github.com/flashmob/fastcgi-processor)|Deliver email directly to PHP-FPM or a similar FastCGI backend.
|
|
|
|
|
|
Have a processor that you would like to share? Submit a PR to add it to the list!
|
|
|
|
|
|
-Web Dashboard
|
|
|
-=============
|
|
|
-
|
|
|
-An optional web-based dashboard is built into Go-Guerrilla. To use it, set the dashboard options in the config file, as shown in the Configuration section.
|
|
|
-
|
|
|
Releases
|
|
|
========
|
|
|
|
|
|
-(Master branch - Release Candidate 1 for v2.0)
|
|
|
-Large refactoring of the code.
|
|
|
-- Introduced "backends": modular architecture for saving email
|
|
|
-- Issue: Use as a package in your own projects! https://github.com/flashmob/go-guerrilla/issues/20
|
|
|
-- Issue: Do not include dot-suffix in emails https://github.com/flashmob/go-guerrilla/issues/24
|
|
|
-- Logging functionality: logrus is now used for logging. Currently output is going to stdout
|
|
|
-- Incompatible change: Config's allowed_hosts is now an array
|
|
|
-- Incompatible change: The server's command is now a command called `guerrillad`
|
|
|
-- Config re-loading via SIGHUP: reload TLS, add/remove/enable/disable servers, change allowed hosts, timeout.
|
|
|
-- Begin writing automated tests
|
|
|
-
|
|
|
-
|
|
|
-1.5.1 - 4nd Nov 2016 (Latest tagged release)
|
|
|
-- Small optimizations to the way email is saved
|
|
|
-
|
|
|
-1.5 - 2nd Nov 2016
|
|
|
-- Fixed a DoS vulnerability, stop reading after an input limit is reached
|
|
|
-- Fixed syntax error in Json goguerrilla.conf.sample
|
|
|
-- Do not load certificates if SSL is not enabled
|
|
|
-- check database back-end connections before starting
|
|
|
-
|
|
|
-1.4 - 25th Oct 2016
|
|
|
-- New Feature: multiple servers!
|
|
|
-- Changed the configuration file format to support multiple servers,
|
|
|
-this means that a new configuration file would need to be created form the
|
|
|
-sample (goguerrilla.conf.sample)
|
|
|
-- Organised code into separate files. Config is now strongly typed, etc
|
|
|
-- Deprecated nginx proxy support
|
|
|
-
|
|
|
-
|
|
|
-1.3 14th July 2016
|
|
|
-- Number of saveMail workers added to config (GM_SAVE_WORKERS)
|
|
|
-- convenience function for reading int values form config
|
|
|
-- advertise PIPELINING
|
|
|
-- added HELP command
|
|
|
-- rcpt to host validation: now case insensitive and done earlier (after DATA)
|
|
|
-- iconv switched to: go get gopkg.in/iconv.v1
|
|
|
-
|
|
|
-1.2 1st July 2016
|
|
|
-- Reload config on SIGHUP
|
|
|
-- Write current process id (pid) to a file, /var/run/go-guerrilla.pid by default
|
|
|
-
|
|
|
-
|
|
|
-Using Nginx as a proxy
|
|
|
-======================
|
|
|
-Note: This release temporarily does not have proxy support.
|
|
|
-An issue has been opened to put back in https://github.com/flashmob/go-guerrilla/issues/30
|
|
|
-Nginx can be used to proxy SMTP traffic for GoGuerrilla SMTPd
|
|
|
-
|
|
|
-Why proxy SMTP with Nginx?
|
|
|
-
|
|
|
- * Terminate TLS connections: (eg. Early Golang versions were not there yet when it came to TLS.)
|
|
|
- OpenSSL on the other hand, used in Nginx, has a complete implementation of TLS with familiar configuration.
|
|
|
- * Nginx could be used for load balancing and authentication
|
|
|
-
|
|
|
- 1. Compile nginx with --with-mail --with-mail_ssl_module (most current nginx packages have this compiled already)
|
|
|
-
|
|
|
- 2. Configuration:
|
|
|
-
|
|
|
-
|
|
|
- mail {
|
|
|
- server {
|
|
|
- listen 15.29.8.163:25;
|
|
|
- protocol smtp;
|
|
|
- server_name ak47.example.com;
|
|
|
- auth_http smtpauth.local:80/auth.txt;
|
|
|
- smtp_auth none;
|
|
|
- timeout 30000;
|
|
|
- smtp_capabilities "SIZE 15728640";
|
|
|
-
|
|
|
- # ssl default off. Leave off if starttls is on
|
|
|
- #ssl on;
|
|
|
- ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
|
|
|
- ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
|
|
|
- ssl_session_timeout 5m;
|
|
|
- # See https://mozilla.github.io/server-side-tls/ssl-config-generator/ Intermediate settings
|
|
|
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
|
|
- ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
|
|
|
- ssl_prefer_server_ciphers on;
|
|
|
- # TLS off unless client issues STARTTLS command
|
|
|
- starttls on;
|
|
|
- proxy on;
|
|
|
- }
|
|
|
- }
|
|
|
+Current release: 1.5.1 - 4th Nov 2016
|
|
|
|
|
|
- http {
|
|
|
+Next Planned release: 2.0.0 - TBA
|
|
|
|
|
|
- # Add somewhere inside your http block..
|
|
|
- # make sure that you have added smtpauth.local to /etc/hosts
|
|
|
- # What this block does is tell the above stmp server to connect
|
|
|
- # to our golang server configured to run on 127.0.0.1:2525
|
|
|
+See our [change log](https://github.com/flashmob/go-guerrilla/wiki/Change-Log) for change and release history
|
|
|
|
|
|
- server {
|
|
|
- listen 15.29.8.163:80;
|
|
|
- server_name 15.29.8.163 smtpauth.local;
|
|
|
- root /home/user/http/auth/;
|
|
|
- access_log off;
|
|
|
- location /auth.txt {
|
|
|
- add_header Auth-Status OK;
|
|
|
- # where to find your smtp server?
|
|
|
- add_header Auth-Server 127.0.0.1;
|
|
|
- add_header Auth-Port 2525;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-Starting / Command Line usage
|
|
|
-==========================================================
|
|
|
-
|
|
|
-All command line arguments are optional
|
|
|
-
|
|
|
- -config="goguerrilla.conf": Path to the configuration file
|
|
|
- -if="": Interface and port to listen on, eg. 127.0.0.1:2525
|
|
|
- -v="n": Verbose, [y | n]
|
|
|
-
|
|
|
-Starting from the command line (example)
|
|
|
-
|
|
|
- /usr/bin/nohup /home/mike/goguerrilla -config=/home/mike/goguerrilla.conf 2>&1 &
|
|
|
-
|
|
|
-This will place goguerrilla in the background and continue running
|
|
|
-
|
|
|
-You may also put another process to watch your goguerrilla process and re-start it
|
|
|
-if something goes wrong.
|
|
|
-
|
|
|
-Testing STARTTLS
|
|
|
-
|
|
|
-Use openssl:
|
|
|
-
|
|
|
- $ openssl s_client -starttls smtp -crlf -connect 127.0.0.1:2526
|
|
|
|
|
|
+Using Nginx as a proxy
|
|
|
+======================
|
|
|
|
|
|
-Benchmarking:
|
|
|
-==========================================================
|
|
|
+For such purposes as load balancing, terminating TLS early,
|
|
|
+ or supporting SSL versions not supported by Go (highly not recommenced if you
|
|
|
+ want to use older SSL versions),
|
|
|
+ it is possible to [use NGINX as a proxy](https://github.com/flashmob/go-guerrilla/wiki/Using-Nginx-as-a-proxy).
|
|
|
|
|
|
-https://web.archive.org/web/20110725141905/http://www.jrh.org/smtp/index.html
|
|
|
|
|
|
-Test 500 clients:
|
|
|
-$ time smtp-source -c -l 5000 -t [email protected] -s 500 -m 5000 5.9.7.183
|
|
|
|
|
|
-Authors
|
|
|
+Credits
|
|
|
=======
|
|
|
|
|
|
-Project Lead:
|
|
|
+Project Lead:
|
|
|
-------------
|
|
|
Flashmob, GuerrillaMail.com, Contact: [email protected]
|
|
|
|
|
|
-Major Contributors:
|
|
|
+Major Contributors:
|
|
|
-------------------
|
|
|
|
|
|
* Reza Mohammadi https://github.com/remohammadi
|
|
|
-* Jordan Schalm https://github.com/jordanschalm
|
|
|
+* Jordan Schalm https://github.com/jordanschalm
|
|
|
+* Philipp Resch https://github.com/dapaxx
|
|
|
|
|
|
Thanks to:
|
|
|
----------
|
|
|
* https://github.com/dvcrn
|
|
|
* https://github.com/athoune
|
|
|
+* https://github.com/Xeoncross
|
|
|
|
|
|
... and anyone else who opened an issue / sent a PR / gave suggestions!
|