|
|
@@ -16,7 +16,7 @@ type Config struct {
|
|
16
|
16
|
TCPBuffer TypeBytes `json:"tcp-buffer"`
|
|
17
|
17
|
PreferIP TypePreferIP `json:"prefer-ip"`
|
|
18
|
18
|
CloakPort TypePort `json:"cloak-port"`
|
|
19
|
|
- Probes struct {
|
|
|
19
|
+ Defense struct {
|
|
20
|
20
|
Time struct {
|
|
21
|
21
|
Enabled bool `json:"enabled"`
|
|
22
|
22
|
AllowSkewness TypeDuration `json:"allow-skewness"`
|
|
|
@@ -26,7 +26,7 @@ type Config struct {
|
|
26
|
26
|
MaxSize TypeBytes `json:"max-size"`
|
|
27
|
27
|
ErrorRate TypeErrorRate `json:"error-rate"`
|
|
28
|
28
|
} `json:"anti-replay"`
|
|
29
|
|
- } `json:"probes"`
|
|
|
29
|
+ } `json:"defense"`
|
|
30
|
30
|
Network struct {
|
|
31
|
31
|
PublicIP struct {
|
|
32
|
32
|
IPv4 TypeIP `json:"ipv4"`
|
|
|
@@ -58,6 +58,9 @@ func (c *Config) Validate() error {
|
|
58
|
58
|
if !c.Secret.Valid() {
|
|
59
|
59
|
return fmt.Errorf("invalid secret %s", c.Secret.String())
|
|
60
|
60
|
}
|
|
|
61
|
+ if len(c.BindTo.HostValue(nil)) == 0 || c.BindTo.PortValue(0) == 0 {
|
|
|
62
|
+ return fmt.Errorf("incorrect bind-to parameter %s", c.BindTo.String())
|
|
|
63
|
+ }
|
|
61
|
64
|
|
|
62
|
65
|
return nil
|
|
63
|
66
|
}
|
|
|
@@ -76,48 +79,48 @@ func (c *Config) String() string {
|
|
76
|
79
|
}
|
|
77
|
80
|
|
|
78
|
81
|
type configRaw struct {
|
|
79
|
|
- Debug bool `toml:"debug" json:"debug"`
|
|
|
82
|
+ Debug bool `toml:"debug" json:"debug,omitempty"`
|
|
80
|
83
|
Secret string `toml:"secret" json:"secret"`
|
|
81
|
84
|
BindTo string `toml:"bind-to" json:"bind-to"`
|
|
82
|
|
- TCPBuffer string `toml:"tcp-buffer" json:"tcp-buffer"`
|
|
83
|
|
- PreferIP string `toml:"prefer-ip" json:"prefer-ip"`
|
|
84
|
|
- CloakPort uint `toml:"cloak-port" json:"cloak-port"`
|
|
85
|
|
- Probes struct {
|
|
|
85
|
+ TCPBuffer string `toml:"tcp-buffer" json:"tcp-buffer,omitempty"`
|
|
|
86
|
+ PreferIP string `toml:"prefer-ip" json:"prefer-ip,omitempty"`
|
|
|
87
|
+ CloakPort uint `toml:"cloak-port" json:"cloak-port,omitempty"`
|
|
|
88
|
+ Defense struct {
|
|
86
|
89
|
Time struct {
|
|
87
|
|
- Enabled bool `toml:"enabled" json:"enabled"`
|
|
88
|
|
- AllowSkewness string `toml:"allow-skewness" json:"allow-skewness"`
|
|
89
|
|
- } `toml:"time" json:"time"`
|
|
|
90
|
+ Enabled bool `toml:"enabled" json:"enabled,omitempty"`
|
|
|
91
|
+ AllowSkewness string `toml:"allow-skewness" json:"allow-skewness,omitempty"`
|
|
|
92
|
+ } `toml:"time" json:"time,omitempty"`
|
|
90
|
93
|
AntiReplay struct {
|
|
91
|
|
- Enabled bool `toml:"enabled" json:"enabled"`
|
|
92
|
|
- MaxSize string `toml:"max-size" json:"max-size"`
|
|
93
|
|
- ErrorRate float64 `toml:"error-rate" json:"error-rate"`
|
|
94
|
|
- } `toml:"anti-replay" json:"anti-replay"`
|
|
95
|
|
- } `toml:"probes" json:"probes"`
|
|
|
94
|
+ Enabled bool `toml:"enabled" json:"enabled,omitempty"`
|
|
|
95
|
+ MaxSize string `toml:"max-size" json:"max-size,omitempty"`
|
|
|
96
|
+ ErrorRate float64 `toml:"error-rate" json:"error-rate,omitempty"`
|
|
|
97
|
+ } `toml:"anti-replay" json:"anti-replay,omitempty"`
|
|
|
98
|
+ } `toml:"defense" json:"defense,omitempty"`
|
|
96
|
99
|
Network struct {
|
|
97
|
100
|
PublicIP struct {
|
|
98
|
|
- IPv4 string `toml:"ipv4" json:"ipv4"`
|
|
99
|
|
- IPv6 string `toml:"ipv6" json:"ipv6"`
|
|
100
|
|
- } `toml:"public-ip" json:"public-ip"`
|
|
|
101
|
+ IPv4 string `toml:"ipv4" json:"ipv4,omitempty"`
|
|
|
102
|
+ IPv6 string `toml:"ipv6" json:"ipv6,omitempty"`
|
|
|
103
|
+ } `toml:"public-ip" json:"public-ip,omitempty"`
|
|
101
|
104
|
Timeout struct {
|
|
102
|
|
- TCP string `toml:"tcp" json:"tcp"`
|
|
103
|
|
- Idle string `toml:"idle" json:"idle"`
|
|
104
|
|
- } `toml:"timeout" json:"timeout"`
|
|
105
|
|
- DOHIP string `toml:"doh-ip" json:"doh-ip"`
|
|
106
|
|
- Proxies []string `toml:"proxies" json:"proxies"`
|
|
107
|
|
- } `toml:"network" json:"network"`
|
|
|
105
|
+ TCP string `toml:"tcp" json:"tcp,omitempty"`
|
|
|
106
|
+ Idle string `toml:"idle" json:"idle,omitempty"`
|
|
|
107
|
+ } `toml:"timeout" json:"timeout,omitempty"`
|
|
|
108
|
+ DOHIP string `toml:"doh-ip" json:"doh-ip,omitempty"`
|
|
|
109
|
+ Proxies []string `toml:"proxies" json:"proxies,omitempty"`
|
|
|
110
|
+ } `toml:"network" json:"network,omitempty"`
|
|
108
|
111
|
Stats struct {
|
|
109
|
112
|
StatsD struct {
|
|
110
|
|
- Enabled bool `toml:"enabled" json:"enabled"`
|
|
111
|
|
- Address string `toml:"address" json:"address"`
|
|
112
|
|
- MetricPrefix string `toml:"metric-prefix" json:"metric-prefix"`
|
|
113
|
|
- } `toml:"statsd" json:"statsd"`
|
|
|
113
|
+ Enabled bool `toml:"enabled" json:"enabled,omitempty"`
|
|
|
114
|
+ Address string `toml:"address" json:"address,omitempty"`
|
|
|
115
|
+ MetricPrefix string `toml:"metric-prefix" json:"metric-prefix,omitempty"`
|
|
|
116
|
+ } `toml:"statsd" json:"statsd,omitempty"`
|
|
114
|
117
|
Prometheus struct {
|
|
115
|
|
- Enabled bool `toml:"enabled" json:"enabled"`
|
|
116
|
|
- BindTo string `toml:"bind-to" json:"bind-to"`
|
|
117
|
|
- HTTPPath string `toml:"http-path" json:"http-path"`
|
|
118
|
|
- MetricPrefix string `toml:"metric-prefix" json:"metric-prefix"`
|
|
119
|
|
- } `toml:"prometheus" json:"prometheus"`
|
|
120
|
|
- } `toml:"stats" json:"stats"`
|
|
|
118
|
+ Enabled bool `toml:"enabled" json:"enabled,omitempty"`
|
|
|
119
|
+ BindTo string `toml:"bind-to" json:"bind-to,omitempty"`
|
|
|
120
|
+ HTTPPath string `toml:"http-path" json:"http-path,omitempty"`
|
|
|
121
|
+ MetricPrefix string `toml:"metric-prefix" json:"metric-prefix,omitempty"`
|
|
|
122
|
+ } `toml:"prometheus" json:"prometheus,omitempty"`
|
|
|
123
|
+ } `toml:"stats" json:"stats,omitempty"`
|
|
121
|
124
|
}
|
|
122
|
125
|
|
|
123
|
126
|
func Parse(rawData []byte) (*Config, error) {
|