mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-26 04:22:30 -07:00
Do not share Server instance with multiple listeners
to avoid mixing TLS and non TLS configurations in the same server.
This commit is contained in:
14
main.go
14
main.go
@@ -41,18 +41,17 @@ func main() {
|
|||||||
|
|
||||||
iniflags.Parse()
|
iniflags.Parse()
|
||||||
|
|
||||||
server := &smtpd.Server{
|
|
||||||
Hostname: *hostName,
|
|
||||||
WelcomeMessage: *welcomeMsg,
|
|
||||||
Handler: handler,
|
|
||||||
ForceTLS: *localForceTLS,
|
|
||||||
}
|
|
||||||
|
|
||||||
listeners := strings.Split(*listen, " ")
|
listeners := strings.Split(*listen, " ")
|
||||||
|
|
||||||
for i := range(listeners) {
|
for i := range(listeners) {
|
||||||
listener := listeners[i]
|
listener := listeners[i]
|
||||||
|
|
||||||
|
server := &smtpd.Server{
|
||||||
|
Hostname: *hostName,
|
||||||
|
WelcomeMessage: *welcomeMsg,
|
||||||
|
Handler: handler,
|
||||||
|
}
|
||||||
|
|
||||||
if strings.Index(listeners[i], "://") == -1 {
|
if strings.Index(listeners[i], "://") == -1 {
|
||||||
;
|
;
|
||||||
} else if strings.HasPrefix(listeners[i], "tls://") || strings.HasPrefix(listeners[i], "starttls://") {
|
} else if strings.HasPrefix(listeners[i], "tls://") || strings.HasPrefix(listeners[i], "starttls://") {
|
||||||
@@ -69,6 +68,7 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server.ForceTLS = *localForceTLS
|
||||||
server.TLSConfig = &tls.Config {
|
server.TLSConfig = &tls.Config {
|
||||||
Certificates: [] tls.Certificate{cert},
|
Certificates: [] tls.Certificate{cert},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
;local_key = smtpd.key
|
;local_key = smtpd.key
|
||||||
|
|
||||||
; Enforce encrypted connection on STARTTLS ports before
|
; Enforce encrypted connection on STARTTLS ports before
|
||||||
; accepting mails from client. Cannot be used with plain
|
; accepting mails from client.
|
||||||
; non encrypted listeners.
|
|
||||||
;local_forcetls = false
|
;local_forcetls = false
|
||||||
|
|
||||||
; Relay all mails to this SMTP server
|
; Relay all mails to this SMTP server
|
||||||
|
|||||||
Reference in New Issue
Block a user