-
Notifications
You must be signed in to change notification settings - Fork 57
/
options.go
43 lines (35 loc) · 905 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
package proxy
import "time"
// Options defines per datasource options for creating the proxy dialer.
type Options struct {
Enabled bool
Auth *AuthOptions
Timeouts *TimeoutOptions
}
// AuthOptions socks5 username and password options.
// Every datasource can have separate credentials to the proxy.
type AuthOptions struct {
Username string
Password string
}
// TimeoutOptions timeout/connection options.
type TimeoutOptions struct {
Timeout time.Duration
KeepAlive time.Duration
}
// DefaultTimeoutOptions default timeout/connection options for the proxy.
var DefaultTimeoutOptions = TimeoutOptions{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}
func createOptions(providedOpts *Options) Options {
var opts Options
if providedOpts == nil {
return opts
}
opts = *providedOpts
if opts.Timeouts == nil {
opts.Timeouts = &DefaultTimeoutOptions
}
return opts
}