(c *cli.Command)
| 193 | } |
| 194 | |
| 195 | func getConfig(c *cli.Command) (*config.Config, error) { |
| 196 | confString, err := getConfigString(c.String("config"), c.String("config-body")) |
| 197 | if err != nil { |
| 198 | return nil, err |
| 199 | } |
| 200 | |
| 201 | strictMode := !c.Bool("disable-strict-config") |
| 202 | |
| 203 | conf, err := config.NewConfig(confString, strictMode, c, baseFlags) |
| 204 | if err != nil { |
| 205 | return nil, err |
| 206 | } |
| 207 | config.InitLoggerFromConfig(&conf.Logging) |
| 208 | |
| 209 | if conf.Development { |
| 210 | logger.Infow("starting in development mode") |
| 211 | |
| 212 | if len(conf.Keys) == 0 { |
| 213 | logger.Infow("no keys provided, using placeholder keys", |
| 214 | "API Key", "devkey", |
| 215 | "API Secret", "secret", |
| 216 | ) |
| 217 | conf.Keys = map[string]string{ |
| 218 | "devkey": "secret", |
| 219 | } |
| 220 | shouldMatchRTCIP := false |
| 221 | // when dev mode and using shared keys, we'll bind to localhost by default |
| 222 | if conf.BindAddresses == nil { |
| 223 | conf.BindAddresses = []string{ |
| 224 | "127.0.0.1", |
| 225 | "::1", |
| 226 | } |
| 227 | } else { |
| 228 | // if non-loopback addresses are provided, then we'll match RTC IP to bind address |
| 229 | // our IP discovery ignores loopback addresses |
| 230 | for _, addr := range conf.BindAddresses { |
| 231 | ip := net.ParseIP(addr) |
| 232 | if ip != nil && !ip.IsLoopback() && !ip.IsUnspecified() { |
| 233 | shouldMatchRTCIP = true |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | if shouldMatchRTCIP { |
| 238 | for _, bindAddr := range conf.BindAddresses { |
| 239 | conf.RTC.IPs.Includes = append(conf.RTC.IPs.Includes, bindAddr+"/24") |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | return conf, nil |
| 245 | } |
| 246 | |
| 247 | func startServer(ctx context.Context, c *cli.Command) error { |
| 248 | conf, err := getConfig(c) |
no test coverage detected