| 261 | } |
| 262 | |
| 263 | func (c Bootstrap) checkHTTP(ctx context.Context, cfg *cli.Config, drv *ui.Driver, srv *api.Service, diagPort string, requestc <-chan string) (bool, error) { |
| 264 | domain := srv.Slug + ".lcl.host" // TODO: look this up properly |
| 265 | |
| 266 | httpURL, err := url.Parse("http://" + domain + ":" + diagPort) |
| 267 | if err != nil { |
| 268 | return false, err |
| 269 | } |
| 270 | httpConfirmCh := make(chan struct{}) |
| 271 | |
| 272 | drv.Activate(ctx, &models.Bootstrap{ |
| 273 | ConfirmCh: httpConfirmCh, |
| 274 | |
| 275 | Domain: domain, |
| 276 | Port: diagPort, |
| 277 | Scheme: "http", |
| 278 | ShowHeader: true, |
| 279 | }) |
| 280 | |
| 281 | drv.Send(models.OpenURLMsg(httpURL.String())) |
| 282 | |
| 283 | select { |
| 284 | case <-httpConfirmCh: |
| 285 | case <-ctx.Done(): |
| 286 | return false, ctx.Err() |
| 287 | } |
| 288 | |
| 289 | var browserless bool |
| 290 | if !cfg.Trust.MockMode { |
| 291 | if err := browser.OpenURL(httpURL.String()); err != nil { |
| 292 | browserless = true |
| 293 | drv.Activate(ctx, models.Browserless) |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | var requestedScheme string |
| 298 | if !browserless { |
| 299 | select { |
| 300 | case requestedScheme = <-requestc: |
| 301 | case <-ctx.Done(): |
| 302 | return false, ctx.Err() |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | if requestedScheme == "https" { |
| 307 | drv.Activate(ctx, new(models.BootstrapSuccess)) |
| 308 | return true, nil |
| 309 | } |
| 310 | |
| 311 | return false, nil |
| 312 | } |
| 313 | |
| 314 | func (c Bootstrap) checkHTTPS(ctx context.Context, cfg *cli.Config, drv *ui.Driver, srv *api.Service, diagPort string, requestc <-chan string) error { |
| 315 | domain := srv.Slug + ".lcl.host" // TODO: look this up properly |