verify 校验规则配置,并在需要时编译正则。
()
| 91 | ProtocolTCP: {}, |
| 92 | ProtocolSOCKS5: {}, |
| 93 | } |
| 94 | |
| 95 | // Config is the complete Moto configuration. |
| 96 | type Config struct { |
| 97 | Log LogConfig `json:"log"` |
| 98 | Metrics MetricsConfig `json:"metrics,omitempty"` |
| 99 | Rules []*Rule `json:"rules"` |
| 100 | } |
| 101 | |
| 102 | // MetricsConfig controls the optional local-only observability listener. |
| 103 | // Listen must remain on a numeric loopback address so metrics and health |
| 104 | // endpoints cannot be exposed accidentally. |
| 105 | type MetricsConfig struct { |
| 106 | Enabled bool `json:"enabled"` |
| 107 | Listen string `json:"listen"` |
| 108 | } |
| 109 | |
| 110 | // LogConfig controls the minimum log level and the optional rolling log file. |
| 111 | // Logs are always written to stdout; Path adds a second, rolling destination. |
| 112 | type LogConfig struct { |
| 113 | Level string `json:"level"` |
| 114 | Path string `json:"path"` |
| 115 | } |
| 116 | |
| 117 | // Target is one upstream endpoint. Regexp is used by regex-mode rules and Re |
| 118 | // holds its validated, compiled form. |
| 119 | type Target struct { |
| 120 | Regexp string `json:"regexp"` |
| 121 | Re *regexp.Regexp `json:"-"` |
| 122 | Address string `json:"address"` |
| 123 | ServerNames []string `json:"serverNames,omitempty"` |
| 124 | ALPN []string `json:"alpn,omitempty"` |