User agent detected by fake IMAP extension instead of AUTH callback
This commit is contained in:
@ -28,6 +28,7 @@ import (
|
||||
imapid "github.com/ProtonMail/go-imap-id"
|
||||
"github.com/ProtonMail/proton-bridge/internal/bridge"
|
||||
"github.com/ProtonMail/proton-bridge/internal/events"
|
||||
"github.com/ProtonMail/proton-bridge/internal/imap/currentclient"
|
||||
"github.com/ProtonMail/proton-bridge/internal/imap/uidplus"
|
||||
"github.com/ProtonMail/proton-bridge/pkg/listener"
|
||||
"github.com/emersion/go-imap"
|
||||
@ -66,28 +67,6 @@ func NewIMAPServer(debugClient, debugServer bool, port int, tls *tls.Config, ima
|
||||
}
|
||||
|
||||
s.EnableAuth(sasl.Login, func(conn imapserver.Conn) sasl.Server {
|
||||
conn.Server().ForEachConn(func(candidate imapserver.Conn) {
|
||||
if id, ok := candidate.(imapid.Conn); ok {
|
||||
if conn.Context() == candidate.Context() {
|
||||
// ID is not available right at the beginning of the connection.
|
||||
// Clients send ID quickly after AUTH. We need to wait for it.
|
||||
go func() {
|
||||
start := time.Now()
|
||||
for {
|
||||
if id.ID() != nil {
|
||||
imapBackend.setLastMailClient(id.ID())
|
||||
break
|
||||
}
|
||||
if time.Since(start) > 10*time.Second {
|
||||
break
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return sasl.NewLoginServer(func(address, password string) error {
|
||||
user, err := conn.Server().Backend.Login(nil, address, password)
|
||||
if err != nil {
|
||||
@ -109,6 +88,7 @@ func NewIMAPServer(debugClient, debugServer bool, port int, tls *tls.Config, ima
|
||||
imapquota.NewExtension(),
|
||||
imapappendlimit.NewExtension(),
|
||||
imapunselect.NewExtension(),
|
||||
currentclient.NewExtension(imapBackend.bridge),
|
||||
uidplus.NewExtension(),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user