From 99dd8cee1fe238f149146b328b29d4c2974f184e Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 23 Jan 2014 11:10:54 -0800 Subject: [PATCH] Adding simple credentials interface --- credentials.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 credentials.go diff --git a/credentials.go b/credentials.go new file mode 100644 index 0000000..9666427 --- /dev/null +++ b/credentials.go @@ -0,0 +1,17 @@ +package socks5 + +// CredentialStore is used to support user/pass authentication +type CredentialStore interface { + Valid(user, password string) bool +} + +// StaticCredentials enables using a map directly as a credential store +type StaticCredentials map[string]string + +func (s StaticCredentials) Valid(user, password string) bool { + pass, ok := s[user] + if !ok { + return false + } + return password == pass +}