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

@ -87,28 +87,20 @@ func parseLine(line string) *Entry {
}
}
func isWild(s string) bool {
if s == "" || s == "*" {
func superCMP(fileitem, filteritem string) bool {
if filteritem == "*" {
return true
}
return false
}
func superCMP(s1, s2 string) bool {
if isWild(s1) || isWild(s2) {
return true
}
//fmt.Printf("sCMP: '%s' '%s'\n", s1, s2)
return s1 == s2
return fileitem == filteritem
}
// FindPassword finds the password for the provided synapsehost, localpart, and domain. An empty
// string will be returned if no match is found.
func (pf *Passfile) FindPassword(matrixhost, localpart, domain string) string {
for _, e := range pf.Entries {
if (e.Matrixhost == "*" || e.Matrixhost == matrixhost) &&
(e.Localpart == "*" || e.Localpart == localpart) &&
(e.Domain == "*" || e.Domain == domain) {
if superCMP(e.Matrixhost, matrixhost) &&
superCMP(e.Localpart, localpart) &&
superCMP(e.Domain, domain) {
return e.Token
}
}