| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /* | 5 /* |
| 6 Serves a webpage for easy management of Skia bugs. | 6 Serves a webpage for easy management of Skia bugs. |
| 7 | 7 |
| 8 WARNING: This server is NOT secure and should not be made publicly | 8 WARNING: This server is NOT secure and should not be made publicly |
| 9 accessible. | 9 accessible. |
| 10 */ | 10 */ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 oauthConfigFile = "oauth_client_secret.json" | 37 oauthConfigFile = "oauth_client_secret.json" |
| 38 localHost = "127.0.0.1" | 38 localHost = "127.0.0.1" |
| 39 maxSessionLen = time.Duration(3600 * time.Second) | 39 maxSessionLen = time.Duration(3600 * time.Second) |
| 40 priorityPrefix = "Priority-" | 40 priorityPrefix = "Priority-" |
| 41 project = "skia" | 41 project = "skia" |
| 42 cookieName = "BugChomperCookie" | 42 cookieName = "BugChomperCookie" |
| 43 ) | 43 ) |
| 44 | 44 |
| 45 // Flags: | 45 // Flags: |
| 46 var ( | 46 var ( |
| 47 » port = flag.String("port", ":8000", "HTTP service address (e.g., ':8000'
)") | 47 » port = flag.String("port", ":8000", "HTTP service address (e.g., ':800
0')") |
| 48 » public = flag.Bool("public", false, "Make this server publicly accessibl
e.") |
| 48 ) | 49 ) |
| 49 | 50 |
| 50 var ( | 51 var ( |
| 51 scheme = "http" | 52 scheme = "http" |
| 52 | 53 |
| 53 curdir, _ = filepath.Abs(".") | 54 curdir, _ = filepath.Abs(".") |
| 54 templatePath, _ = filepath.Abs("templates") | 55 templatePath, _ = filepath.Abs("templates") |
| 55 templates = template.Must(template.ParseFiles( | 56 templates = template.Must(template.ParseFiles( |
| 56 path.Join(templatePath, "bug_chomper.html"), | 57 path.Join(templatePath, "bug_chomper.html"), |
| 57 path.Join(templatePath, "submitted.html"), | 58 path.Join(templatePath, "submitted.html"), |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 log.Println("Fetching " + r.URL.Path) | 352 log.Println("Fetching " + r.URL.Path) |
| 352 if r.URL.Path == "/" || r.URL.Path == "/index.html" { | 353 if r.URL.Path == "/" || r.URL.Path == "/index.html" { |
| 353 handleBugChomper(w, r) | 354 handleBugChomper(w, r) |
| 354 return | 355 return |
| 355 } | 356 } |
| 356 http.NotFound(w, r) | 357 http.NotFound(w, r) |
| 357 } | 358 } |
| 358 | 359 |
| 359 // Run the BugChomper server. | 360 // Run the BugChomper server. |
| 360 func main() { | 361 func main() { |
| 361 var public bool | |
| 362 flag.BoolVar( | |
| 363 &public, "public", false, "Make this server publicly accessible.
") | |
| 364 flag.Parse() | 362 flag.Parse() |
| 365 | 363 |
| 366 http.HandleFunc("/", handleRoot) | 364 http.HandleFunc("/", handleRoot) |
| 367 http.HandleFunc(oauthCallbackPath, handleOAuth2Callback) | 365 http.HandleFunc(oauthCallbackPath, handleOAuth2Callback) |
| 368 http.Handle("/res/", http.FileServer(http.Dir(curdir))) | 366 http.Handle("/res/", http.FileServer(http.Dir(curdir))) |
| 369 log.Println("Server is running at " + scheme + "://" + localHost + *port
) | 367 log.Println("Server is running at " + scheme + "://" + localHost + *port
) |
| 370 var err error | 368 var err error |
| 371 » if public { | 369 » if *public { |
| 372 log.Println("WARNING: This server is not secure and should not b
e made " + | 370 log.Println("WARNING: This server is not secure and should not b
e made " + |
| 373 "publicly accessible.") | 371 "publicly accessible.") |
| 374 scheme = "https" | 372 scheme = "https" |
| 375 err = http.ListenAndServeTLS(*port, certFile, keyFile, nil) | 373 err = http.ListenAndServeTLS(*port, certFile, keyFile, nil) |
| 376 } else { | 374 } else { |
| 377 scheme = "http" | 375 scheme = "http" |
| 378 err = http.ListenAndServe(localHost+*port, nil) | 376 err = http.ListenAndServe(localHost+*port, nil) |
| 379 } | 377 } |
| 380 if err != nil { | 378 if err != nil { |
| 381 log.Println(err.Error()) | 379 log.Println(err.Error()) |
| 382 } | 380 } |
| 383 } | 381 } |
| OLD | NEW |