go-socks5/credentials.go
2020-04-22 10:32:03 +08:00

20 lines
544 B
Go

package socks5
// CredentialStore is used to support user/pass authentication optional network addr
// if you want to limit user network addr,you can refuse it.
type CredentialStore interface {
Valid(user, password, userAddr string) bool
}
// StaticCredentials enables using a map directly as a credential store
type StaticCredentials map[string]string
// Valid implement interface CredentialStore
func (s StaticCredentials) Valid(user, password, _ string) bool {
pass, ok := s[user]
if !ok {
return false
}
return password == pass
}