| | |
| | | Password string `mapstructure:"password"` |
| | | } |
| | | |
| | | type client struct { |
| | | DeviceID string `mapstructure:"device-id"` |
| | | Username string `mapstructure:"username"` |
| | | Password string `mapstructure:"password"` |
| | | ServerAddr string `mapstructure:"server-addr"` |
| | | ServerPort string `mapstructure:"server-port"` |
| | | Proto string `mapstructure:"proto" ` // http, https |
| | | UploadType string `mapstructure:"upload-type"` // binary, url |
| | | ChannelNo string `mapstructure:"channel-number"` // 通道号, 同id |
| | | HeartbeatInterval int `mapstructure:"heartbeat-interval"` // 心跳周期 |
| | | HeartbeatCount int `mapstructure:"heartbeat-count"` // 心跳超时次数 |
| | | Enable bool `mapstructure:"enable"` |
| | | } |
| | | |
| | | type logConfig struct { |
| | | LogWay string `mapstructure:"log-way"` // 日志输出 |
| | | Path string `mapstructure:"path"` // 日志存储路径 |
| | |
| | | ReportInterval int `mapstructure:"report-interval"` |
| | | RetryInterval int `mapstructure:"retry-interval"` |
| | | CutFaceImage bool `mapstructure:"cut-face-image"` |
| | | Enable bool `mapstructure:"enable"` |
| | | } |
| | | |
| | | type rateLimitConfig struct { |
| | |
| | | var LogConf = &logConfig{} |
| | | var ForwardConf = &forward{} |
| | | var RateLimitConf = &rateLimitConfig{} |
| | | var ClientConf = &client{} |
| | | |
| | | // Init is an exported method that takes the environment starts the viper |
| | | // (external lib) and returns the configuration struct. |
| | |
| | | v.UnmarshalKey("log", LogConf) |
| | | v.UnmarshalKey("forward", ForwardConf) |
| | | v.UnmarshalKey("rate-limit", RateLimitConf) |
| | | v.UnmarshalKey("client", ClientConf) |
| | | |
| | | if LogConf.Level == "" { |
| | | LogConf.Level = "info" |