flashmob / go-guerrilla

Mini SMTP server written in golang
MIT License
2.79k stars 366 forks source link

Put proxy support back in #30

Closed flashmob closed 7 years ago

flashmob commented 7 years ago

Even though proxying via Nginx is not necessary these days, proxy support may still be useful for load balancing purposes.

The proxy server uses the XCLIENT command to tell the server behind the proxy what the source IP address is.

Requirements:

Support the XCLIENT command (with an option to enable it in config).

case strings.Index(cmd, "XCLIENT") == 0:
                // Nginx sends this
                // XCLIENT ADDR=212.96.64.216 NAME=[UNAVAILABLE]
                client.Address = input[13:]
                client.Address = client.Address[0:strings.Index(client.Address, " ")]
                fmt.Println("client address:[" + client.Address + "]")
                responseAdd(client, "250 OK")