-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.go
50 lines (42 loc) · 870 Bytes
/
options.go
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
41
42
43
44
45
46
47
48
49
50
package sshd
import (
"github.com/inoc603/go-sshd/auth"
"github.com/pkg/errors"
)
func WithAddress(addr string) Option {
return func(s *Server) error {
s.addr = addr
return nil
}
}
func WithAuth(a interface{}) Option {
return func(s *Server) error {
if pkAuth, ok := a.(auth.PublicKeyAuth); ok {
s.pkAuth = append(s.pkAuth, pkAuth)
return nil
}
if pwAuth, ok := a.(auth.PasswordAuth); ok {
s.pwAuth = append(s.pwAuth, pwAuth)
return nil
}
return errors.Errorf("invalid auth middleware")
}
}
func WithHostFile(f string) Option {
return func(s *Server) error {
s.hostkeyFile = f
return nil
}
}
func WithUserStore(us auth.UserStore) Option {
return func(s *Server) error {
s.userStore = us
return nil
}
}
func WithRecorder(r RecorderFactory) Option {
return func(s *Server) error {
s.getRecorder = r
return nil
}
}