feat: persistent cookies

This commit is contained in:
James Houlahan
2020-08-12 10:37:10 +02:00
parent ce4a75caf5
commit e333ccd29e
9 changed files with 260 additions and 7 deletions

View File

@ -56,6 +56,7 @@ import (
"github.com/ProtonMail/proton-bridge/pkg/args"
"github.com/ProtonMail/proton-bridge/pkg/config"
"github.com/ProtonMail/proton-bridge/pkg/constants"
"github.com/ProtonMail/proton-bridge/pkg/cookies"
"github.com/ProtonMail/proton-bridge/pkg/listener"
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
"github.com/ProtonMail/proton-bridge/pkg/updates"
@ -273,6 +274,13 @@ func run(context *cli.Context) (contextError error) { // nolint[funlen]
// implementation depending on whether build flag pmapi_prod is used or not.
cm.SetRoundTripper(cfg.GetRoundTripper(cm, eventListener))
// Cookies must be persisted across restarts.
jar, err := cookies.New(cookies.NewPersister(pref))
if err != nil {
logrus.WithError(err).Fatal("Could not create cookie jar")
}
cm.SetCookieJar(jar)
bridgeInstance := bridge.New(cfg, pref, panicHandler, eventListener, cm, credentialsStore)
imapBackend := imap.NewIMAPBackend(panicHandler, eventListener, cfg, bridgeInstance)
smtpBackend := smtp.NewSMTPBackend(panicHandler, eventListener, pref, bridgeInstance)