-
Notifications
You must be signed in to change notification settings - Fork 3
/
option.go
41 lines (34 loc) · 923 Bytes
/
option.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
package telnet
import "time"
// Settings contains option to Conn.
type Settings struct {
dialTimeout time.Duration
exitCommand string
clearResponse bool
}
// DefaultSettings provides default deadline settings to Conn.
var DefaultSettings = Settings{
dialTimeout: DefaultDialTimeout,
exitCommand: DefaultExitCommand,
clearResponse: false,
}
// Option allows to inject settings to Settings.
type Option func(s *Settings)
// SetDialTimeout injects dial Timeout to Settings.
func SetDialTimeout(timeout time.Duration) Option {
return func(s *Settings) {
s.dialTimeout = timeout
}
}
// SetExitCommand injects telnet exit command.
func SetExitCommand(command string) Option {
return func(s *Settings) {
s.exitCommand = command
}
}
// SetClearResponse injects clearResponse option to telnet client.
func SetClearResponse(clear bool) Option {
return func(s *Settings) {
s.clearResponse = clear
}
}