-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathauth.go
More file actions
40 lines (35 loc) · 676 Bytes
/
Copy pathauth.go
File metadata and controls
40 lines (35 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package socks5
type Socks5Auth interface {
Authenticate(...interface{}) bool
}
type defAuth struct {
userInfo map[string]string
}
func (s *defAuth) Authenticate(b ...interface{}) bool {
if s.userInfo == nil {
return true
}
if len(b) != 2 {
return false
}
user, ok := b[0].(string)
if !ok {
return false
}
pwd, ok := b[1].(string)
if !ok {
return false
}
if s.userInfo[user] == pwd {
return true
}
return false
}
func (s *defAuth) LoadUserInfo(fn func() map[string]string) {
s.userInfo = fn()
}
type VerifyUser func(username, passwd string) bool
//DEFAULT method 2
func (s *VerifyUser) Authenticate(username, passwd string) bool {
return true
}