go-socks5/credentials.go

17 lines
522 B
Go
Raw Normal View History

2014-01-23 19:10:54 +00:00
package socks5
2020-04-21 14:31:04 +00:00
// CredentialStore is used to support user/pass authentication optional network addr
// if you want to limit user network addr,you can refuse it.
2014-01-23 19:10:54 +00:00
type CredentialStore interface {
2020-04-22 02:32:03 +00:00
Valid(user, password, userAddr string) bool
2014-01-23 19:10:54 +00:00
}
// StaticCredentials enables using a map directly as a credential store
type StaticCredentials map[string]string
2020-04-22 02:15:40 +00:00
// Valid implement interface CredentialStore
2020-04-22 02:32:03 +00:00
func (s StaticCredentials) Valid(user, password, _ string) bool {
2014-01-23 19:10:54 +00:00
pass, ok := s[user]
2020-08-05 06:40:07 +00:00
return ok && password == pass
2014-01-23 19:10:54 +00:00
}