add api and tool for query mxpassfiles, fixes

This commit is contained in:
saces 2026-03-13 13:02:30 +01:00
parent 41fa795971
commit 8df08611a9
7 changed files with 95 additions and 20 deletions

View file

@ -0,0 +1,20 @@
// Copyright (C) 2026 saces@c-base.org
// SPDX-License-Identifier: AGPL-3.0-only
package mxutils
import (
"errors"
"mxclientlib/determinant/mxpassfile"
)
func GetMXPassItem(mxpassfile_path string, url string, localpart string, domain string) (*mxpassfile.Entry, error) {
pf, err := mxpassfile.ReadPassfile(mxpassfile_path)
if err != nil {
return nil, err
}
e := pf.FindPasswordFill(url, localpart, domain)
if e == nil {
return nil, errors.New("no item found.")
}
return e, nil
}