|
|
@@ -2,20 +2,89 @@ package mtglib
|
|
2
|
2
|
|
|
3
|
3
|
import "time"
|
|
4
|
4
|
|
|
|
5
|
+// ProxyOpts is a structure with settings to mtg proxy.
|
|
|
6
|
+//
|
|
|
7
|
+// This is not required per se, but this is to shorten function
|
|
|
8
|
+// signature and give an ability to conveniently provide default values.
|
|
5
|
9
|
type ProxyOpts struct {
|
|
6
|
|
- Secret Secret
|
|
7
|
|
- Network Network
|
|
8
|
|
- AntiReplayCache AntiReplayCache
|
|
|
10
|
+ // Secret defines a secret which should be used by a proxy.
|
|
|
11
|
+ //
|
|
|
12
|
+ // This is a mandatory setting.
|
|
|
13
|
+ Secret Secret
|
|
|
14
|
+
|
|
|
15
|
+ // Network defines a network instance which should be used for all
|
|
|
16
|
+ // network communications made by proxies.
|
|
|
17
|
+ //
|
|
|
18
|
+ // This is a mandatory setting.
|
|
|
19
|
+ Network Network
|
|
|
20
|
+
|
|
|
21
|
+ // AntiReplayCache defines an instance of antireplay cache.
|
|
|
22
|
+ //
|
|
|
23
|
+ // This is a mandatory setting.
|
|
|
24
|
+ AntiReplayCache AntiReplayCache
|
|
|
25
|
+
|
|
|
26
|
+ // TimeAttackDetector defines an instance of timeattack detector.
|
|
|
27
|
+ //
|
|
|
28
|
+ // This is a mandatory setting.
|
|
9
|
29
|
TimeAttackDetector TimeAttackDetector
|
|
10
|
|
- IPBlocklist IPBlocklist
|
|
11
|
|
- EventStream EventStream
|
|
12
|
|
- Logger Logger
|
|
13
|
30
|
|
|
14
|
|
- BufferSize uint
|
|
15
|
|
- Concurrency uint
|
|
|
31
|
+ // IPBlocklist defines an instance of IP blocklist.
|
|
|
32
|
+ //
|
|
|
33
|
+ // This is a mandatory setting.
|
|
|
34
|
+ IPBlocklist IPBlocklist
|
|
|
35
|
+
|
|
|
36
|
+ // EventStream defines an instance of event stream.
|
|
|
37
|
+ //
|
|
|
38
|
+ // This ia a mandatory setting.
|
|
|
39
|
+ EventStream EventStream
|
|
|
40
|
+
|
|
|
41
|
+ // Logger defines an instance of the logger.
|
|
|
42
|
+ //
|
|
|
43
|
+ // This is a mandatory setting.
|
|
|
44
|
+ Logger Logger
|
|
|
45
|
+
|
|
|
46
|
+ // BufferSize is a size of the copy buffer in bytes.
|
|
|
47
|
+ //
|
|
|
48
|
+ // Please remember that we multiply this number in 2, because when
|
|
|
49
|
+ // we relay between proxies, we have to create 2 intermediate
|
|
|
50
|
+ // buffers: to and from.
|
|
|
51
|
+ //
|
|
|
52
|
+ // This is an optional setting.
|
|
|
53
|
+ BufferSize uint
|
|
|
54
|
+
|
|
|
55
|
+ // Concurrency is a size of the worker pool for connection management.
|
|
|
56
|
+ //
|
|
|
57
|
+ // If we have more connections than this number, they are going to be
|
|
|
58
|
+ // rejected.
|
|
|
59
|
+ //
|
|
|
60
|
+ // This is an optional setting.
|
|
|
61
|
+ Concurrency uint
|
|
|
62
|
+
|
|
|
63
|
+ // DomainFrontingPort is a port we use to connect to a fronting
|
|
|
64
|
+ // domain.
|
|
|
65
|
+ //
|
|
|
66
|
+ // This is required because secret does not specify a port. It
|
|
|
67
|
+ // specifies a hostname only.
|
|
|
68
|
+ //
|
|
|
69
|
+ // This is an optional setting.
|
|
16
|
70
|
DomainFrontingPort uint
|
|
17
|
|
- IdleTimeout time.Duration
|
|
18
|
|
- PreferIP string
|
|
|
71
|
+
|
|
|
72
|
+ // IdleTimeout is a timeout for relay when we have to break a
|
|
|
73
|
+ // stream.
|
|
|
74
|
+ //
|
|
|
75
|
+ // This is a timeout for any activity. So, if we have any message
|
|
|
76
|
+ // which will pass to either direction, a timer is reset. If we have
|
|
|
77
|
+ // no any reads or writes for this timeout, a connection will be
|
|
|
78
|
+ // aborted.
|
|
|
79
|
+ //
|
|
|
80
|
+ // This is an optional setting.
|
|
|
81
|
+ IdleTimeout time.Duration
|
|
|
82
|
+
|
|
|
83
|
+ // PreferIP defines an IP connectivity preference. Valid values are:
|
|
|
84
|
+ // 'prefer-ipv4', 'prefer-ipv6', 'only-ipv4', 'only-ipv6'.
|
|
|
85
|
+ //
|
|
|
86
|
+ // This is an optional setting.
|
|
|
87
|
+ PreferIP string
|
|
19
|
88
|
}
|
|
20
|
89
|
|
|
21
|
90
|
func (p ProxyOpts) valid() error {
|