-
Notifications
You must be signed in to change notification settings - Fork 6
/
config.go
48 lines (44 loc) · 1.5 KB
/
config.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
package ncp
import "github.com/jinzhu/copier"
type Config struct {
NonStream bool
SessionWindowSize int32 // in bytes
MTU int32 // in bytes
MinConnectionWindowSize int32 // in packets
MaxAckSeqListSize int32
FlushInterval int32 // in millisecond
Linger int32 // in millisecond
InitialRetransmissionTimeout int32 // in millisecond
MaxRetransmissionTimeout int32 // in millisecond
SendAckInterval int32 // in millisecond
CheckTimeoutInterval int32 // in millisecond
CheckBytesReadInterval int32 // in millisecond
SendBytesReadThreshold int32 // in millisecond
Verbose bool
}
var DefaultConfig = Config{
NonStream: false,
SessionWindowSize: 4 << 20,
MTU: 1024,
MinConnectionWindowSize: 1,
MaxAckSeqListSize: 32,
FlushInterval: 10,
Linger: 1000,
InitialRetransmissionTimeout: 5000,
MaxRetransmissionTimeout: 10000,
SendAckInterval: 50,
CheckTimeoutInterval: 50,
CheckBytesReadInterval: 100,
SendBytesReadThreshold: 200,
Verbose: false,
}
func MergeConfig(conf *Config) (*Config, error) {
merged := DefaultConfig
if conf != nil {
err := copier.CopyWithOption(&merged, conf, copier.Option{IgnoreEmpty: true})
if err != nil {
return nil, err
}
}
return &merged, nil
}