fix proxy rules behavior and implemented a few more rules and commands, dependencies upgrade

This commit is contained in:
yusing
2025-01-11 12:22:42 +08:00
parent f2df756c17
commit 0ce7f29976
20 changed files with 991 additions and 443 deletions

View File

@@ -0,0 +1,27 @@
package rules
import "golang.org/x/crypto/bcrypt"
type (
HashedCrendentials struct {
Username string
CheckMatch func(inputPwd []byte) bool
}
Credentials struct {
Username string
Password []byte
}
)
func BCryptCrendentials(username string, hashedPassword []byte) *HashedCrendentials {
return &HashedCrendentials{username, func(inputPwd []byte) bool {
return bcrypt.CompareHashAndPassword(hashedPassword, inputPwd) == nil
}}
}
func (hc *HashedCrendentials) Match(cred *Credentials) bool {
if cred == nil {
return false
}
return hc.Username == cred.Username && hc.CheckMatch(cred.Password)
}