Other: Only listen on localhost and add send test

We should only listen on constants.Host when serving IMAP and SMTP.
This change fixes that. It also adds a test that we can send over SMTP
and receive over IMAP.
This commit is contained in:
James Houlahan
2022-10-28 13:38:16 +02:00
parent cb42358e2f
commit 93d9ae32fc
7 changed files with 124 additions and 11 deletions

View File

@ -487,7 +487,7 @@ func loadTLSConfig(vault *vault.Vault) (*tls.Config, error) {
func newListener(port int, useTLS bool, tlsConfig *tls.Config) (net.Listener, error) {
if useTLS {
tlsListener, err := tls.Listen("tcp", fmt.Sprintf(":%v", port), tlsConfig)
tlsListener, err := tls.Listen("tcp", fmt.Sprintf("%v:%v", constants.Host, port), tlsConfig)
if err != nil {
return nil, err
}
@ -495,7 +495,7 @@ func newListener(port int, useTLS bool, tlsConfig *tls.Config) (net.Listener, er
return tlsListener, nil
}
netListener, err := net.Listen("tcp", fmt.Sprintf(":%v", port))
netListener, err := net.Listen("tcp", fmt.Sprintf("%v:%v", constants.Host, port))
if err != nil {
return nil, err
}