go-socks5/credentials.go

20 lines
549 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-21 14:28:34 +00:00
Valid(user, password, userIP 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-21 14:31:04 +00:00
func (s StaticCredentials) Valid(user, password, userAddr string) bool {
2014-01-23 19:10:54 +00:00
pass, ok := s[user]
if !ok {
return false
}
return password == pass
}