added pop3 STARTTLS queryResponse (#84)

* added pop3 STARTTLS queryResponse

* implemented pop3 test, added pop3 starttls parameter to README

Co-authored-by: Timo Boldt <tb@teuto.net>
This commit is contained in:
teuto.net Netzdienste GmbH
2021-12-31 14:47:05 +01:00
committed by GitHub
parent 8e318931c5
commit 65249bc2e7
4 changed files with 78 additions and 1 deletions

View File

@@ -164,6 +164,33 @@ func (t *TCPServer) StartIMAP() {
}()
}
// StartPOP3 starts a listener that negotiates a TLS connection with an pop3
// client using STARTTLS
func (t *TCPServer) StartPOP3() {
go func() {
conn, err := t.Listener.Accept()
if err != nil {
panic(fmt.Sprintf("Error accepting on socket: %s", err))
}
defer conn.Close()
fmt.Fprintf(conn, "+OK XPOP3 ready.\n")
if _, e := fmt.Fscanf(conn, "STLS\n"); e != nil {
panic("Error in dialog. No STLS received.")
}
fmt.Fprintf(conn, "+OK Begin TLS negotiation now.\n")
// Upgrade to TLS.
tlsConn := tls.Server(conn, t.TLS)
if err := tlsConn.Handshake(); err != nil {
level.Error(t.logger).Log("msg", err)
}
defer tlsConn.Close()
t.stopCh <- struct{}{}
}()
}
// StartPostgreSQL starts a listener that negotiates a TLS connection with an postgresql
// client using STARTTLS
func (t *TCPServer) StartPostgreSQL() {