forked from Silverfish/proton-bridge
GODT-2120: Encrypt gluon store with gzip
This commit is contained in:
@ -25,12 +25,14 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/Masterminds/semver/v3"
|
"github.com/Masterminds/semver/v3"
|
||||||
"github.com/ProtonMail/gluon"
|
"github.com/ProtonMail/gluon"
|
||||||
imapEvents "github.com/ProtonMail/gluon/events"
|
imapEvents "github.com/ProtonMail/gluon/events"
|
||||||
"github.com/ProtonMail/gluon/reporter"
|
"github.com/ProtonMail/gluon/reporter"
|
||||||
|
"github.com/ProtonMail/gluon/store"
|
||||||
"github.com/ProtonMail/proton-bridge/v2/internal/async"
|
"github.com/ProtonMail/proton-bridge/v2/internal/async"
|
||||||
"github.com/ProtonMail/proton-bridge/v2/internal/constants"
|
"github.com/ProtonMail/proton-bridge/v2/internal/constants"
|
||||||
"github.com/ProtonMail/proton-bridge/v2/internal/logging"
|
"github.com/ProtonMail/proton-bridge/v2/internal/logging"
|
||||||
@ -248,6 +250,7 @@ func newIMAPServer(
|
|||||||
imapServer, err := gluon.New(
|
imapServer, err := gluon.New(
|
||||||
gluon.WithTLS(tlsConfig),
|
gluon.WithTLS(tlsConfig),
|
||||||
gluon.WithDataDir(gluonDir),
|
gluon.WithDataDir(gluonDir),
|
||||||
|
gluon.WithStoreBuilder(new(storeBuilder)),
|
||||||
gluon.WithLogger(imapClientLog, imapServerLog),
|
gluon.WithLogger(imapClientLog, imapServerLog),
|
||||||
getGluonVersionInfo(version),
|
getGluonVersionInfo(version),
|
||||||
gluon.WithReporter(reporter),
|
gluon.WithReporter(reporter),
|
||||||
@ -298,3 +301,17 @@ func isEmpty(dir string) (bool, bool, error) {
|
|||||||
|
|
||||||
return len(entries) == 0, true, nil
|
return len(entries) == 0, true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type storeBuilder struct{}
|
||||||
|
|
||||||
|
func (*storeBuilder) New(path, userID string, passphrase []byte) (store.Store, error) {
|
||||||
|
return store.NewOnDiskStore(
|
||||||
|
filepath.Join(path, userID),
|
||||||
|
passphrase,
|
||||||
|
store.WithCompressor(new(store.GZipCompressor)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*storeBuilder) Delete(path, userID string) error {
|
||||||
|
return os.RemoveAll(filepath.Join(path, userID))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user