Main password encrypted in memory
This commit is contained in:
@@ -288,19 +288,27 @@ func (p *Peer) SetDbPassword(password string) {
|
||||
p.dbPassword = password
|
||||
}
|
||||
|
||||
func (p *Peer) GetDbPassword() string {
|
||||
func (p *Peer) GetDbPassword() (string, error) {
|
||||
if p.dbPassword == "" {
|
||||
return GetConfig().memoryPassword
|
||||
return GetConfig().GetMemPass()
|
||||
}
|
||||
return p.dbPassword
|
||||
return p.dbPassword, nil
|
||||
}
|
||||
|
||||
func (p *Peer) StoreMessage(msg *meowlib.UserMessage, filenames []string) error {
|
||||
return StoreMessage(p, msg, filenames, p.GetDbPassword())
|
||||
password, err := p.GetDbPassword()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return StoreMessage(p, msg, filenames, password)
|
||||
}
|
||||
|
||||
func (p *Peer) GetFilePreview(filename string) ([]byte, error) {
|
||||
return FilePreview(filename, p.GetDbPassword())
|
||||
password, err := p.GetDbPassword()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return FilePreview(filename, password)
|
||||
}
|
||||
|
||||
func (p *Peer) UpdateMessage(msg InternalUserMessage) error {
|
||||
@@ -308,12 +316,20 @@ func (p *Peer) UpdateMessage(msg InternalUserMessage) error {
|
||||
}
|
||||
|
||||
func (p *Peer) LoadMessagesHistory(alreadyLoadedCount int, oldestMessageId int, qty int) ([]InternalUserMessage, error) {
|
||||
return GetMessagesHistory(p, alreadyLoadedCount, oldestMessageId, qty, p.GetDbPassword())
|
||||
password, err := p.GetDbPassword()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return GetMessagesHistory(p, alreadyLoadedCount, oldestMessageId, qty, password)
|
||||
|
||||
}
|
||||
|
||||
func (p *Peer) LoadNewMessages(lastMessageId int) ([]*InternalUserMessage, error) {
|
||||
return GetNewMessages(p, lastMessageId, p.GetDbPassword())
|
||||
password, err := p.GetDbPassword()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return GetNewMessages(p, lastMessageId, password)
|
||||
}
|
||||
|
||||
func (p *Peer) LoadMessage(uid string) (*InternalUserMessage, error) {
|
||||
|
||||
Reference in New Issue
Block a user