h2demo.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package main
  5. import (
  6. "bytes"
  7. "context"
  8. "crypto/tls"
  9. "flag"
  10. "fmt"
  11. "hash/crc32"
  12. "image"
  13. "image/jpeg"
  14. "io"
  15. "io/ioutil"
  16. "log"
  17. "net"
  18. "net/http"
  19. "path"
  20. "regexp"
  21. "runtime"
  22. "strconv"
  23. "strings"
  24. "sync"
  25. "time"
  26. "cloud.google.com/go/storage"
  27. "go4.org/syncutil/singleflight"
  28. "golang.org/x/build/autocertcache"
  29. "golang.org/x/crypto/acme/autocert"
  30. "golang.org/x/net/http2"
  31. )
  32. var (
  33. prod = flag.Bool("prod", false, "Whether to configure itself to be the production http2.golang.org server.")
  34. httpsAddr = flag.String("https_addr", "localhost:4430", "TLS address to listen on ('host:port' or ':port'). Required.")
  35. httpAddr = flag.String("http_addr", "", "Plain HTTP address to listen on ('host:port', or ':port'). Empty means no HTTP.")
  36. hostHTTP = flag.String("http_host", "", "Optional host or host:port to use for http:// links to this service. By default, this is implied from -http_addr.")
  37. hostHTTPS = flag.String("https_host", "", "Optional host or host:port to use for http:// links to this service. By default, this is implied from -https_addr.")
  38. )
  39. func homeOldHTTP(w http.ResponseWriter, r *http.Request) {
  40. if r.Host == "http1.golang.org" {
  41. http.Redirect(w, r, "https://http2.golang.org/", http.StatusFound)
  42. return
  43. }
  44. io.WriteString(w, `<html>
  45. <body>
  46. <h1>Go + HTTP/2</h1>
  47. <p>Welcome to <a href="https://golang.org/">the Go language</a>'s <a href="https://http2.github.io/">HTTP/2</a> demo & interop server.</p>
  48. <p>Unfortunately, you're <b>not</b> using HTTP/2 right now. To do so:</p>
  49. <ul>
  50. <li>Use Firefox Nightly or go to <b>about:config</b> and enable "network.http.spdy.enabled.http2draft"</li>
  51. <li>Use Google Chrome Canary and/or go to <b>chrome://flags/#enable-spdy4</b> to <i>Enable SPDY/4</i> (Chrome's name for HTTP/2)</li>
  52. </ul>
  53. <p>See code & instructions for connecting at <a href="https://github.com/golang/net/tree/master/http2">https://github.com/golang/net/tree/master/http2</a>.</p>
  54. </body></html>`)
  55. }
  56. func home(w http.ResponseWriter, r *http.Request) {
  57. if r.URL.Path != "/" {
  58. http.NotFound(w, r)
  59. return
  60. }
  61. io.WriteString(w, `<html>
  62. <body>
  63. <h1>Go + HTTP/2</h1>
  64. <p>Welcome to <a href="https://golang.org/">the Go language</a>'s <a
  65. href="https://http2.github.io/">HTTP/2</a> demo & interop server.</p>
  66. <p>Congratulations, <b>you're using HTTP/2 right now</b>.</p>
  67. <p>This server exists for others in the HTTP/2 community to test their HTTP/2 client implementations and point out flaws in our server.</p>
  68. <p>
  69. The code is at <a href="https://golang.org/x/net/http2">golang.org/x/net/http2</a> and
  70. is used transparently by the Go standard library from Go 1.6 and later.
  71. </p>
  72. <p>Contact info: <i>bradfitz@golang.org</i>, or <a
  73. href="https://golang.org/s/http2bug">file a bug</a>.</p>
  74. <h2>Handlers for testing</h2>
  75. <ul>
  76. <li>GET <a href="/reqinfo">/reqinfo</a> to dump the request + headers received</li>
  77. <li>GET <a href="/clockstream">/clockstream</a> streams the current time every second</li>
  78. <li>GET <a href="/gophertiles">/gophertiles</a> to see a page with a bunch of images</li>
  79. <li>GET <a href="/serverpush">/serverpush</a> to see a page with server push</li>
  80. <li>GET <a href="/file/gopher.png">/file/gopher.png</a> for a small file (does If-Modified-Since, Content-Range, etc)</li>
  81. <li>GET <a href="/file/go.src.tar.gz">/file/go.src.tar.gz</a> for a larger file (~10 MB)</li>
  82. <li>GET <a href="/redirect">/redirect</a> to redirect back to / (this page)</li>
  83. <li>GET <a href="/goroutines">/goroutines</a> to see all active goroutines in this server</li>
  84. <li>PUT something to <a href="/crc32">/crc32</a> to get a count of number of bytes and its CRC-32</li>
  85. <li>PUT something to <a href="/ECHO">/ECHO</a> and it will be streamed back to you capitalized</li>
  86. </ul>
  87. </body></html>`)
  88. }
  89. func reqInfoHandler(w http.ResponseWriter, r *http.Request) {
  90. w.Header().Set("Content-Type", "text/plain")
  91. fmt.Fprintf(w, "Method: %s\n", r.Method)
  92. fmt.Fprintf(w, "Protocol: %s\n", r.Proto)
  93. fmt.Fprintf(w, "Host: %s\n", r.Host)
  94. fmt.Fprintf(w, "RemoteAddr: %s\n", r.RemoteAddr)
  95. fmt.Fprintf(w, "RequestURI: %q\n", r.RequestURI)
  96. fmt.Fprintf(w, "URL: %#v\n", r.URL)
  97. fmt.Fprintf(w, "Body.ContentLength: %d (-1 means unknown)\n", r.ContentLength)
  98. fmt.Fprintf(w, "Close: %v (relevant for HTTP/1 only)\n", r.Close)
  99. fmt.Fprintf(w, "TLS: %#v\n", r.TLS)
  100. fmt.Fprintf(w, "\nHeaders:\n")
  101. r.Header.Write(w)
  102. }
  103. func crcHandler(w http.ResponseWriter, r *http.Request) {
  104. if r.Method != "PUT" {
  105. http.Error(w, "PUT required.", 400)
  106. return
  107. }
  108. crc := crc32.NewIEEE()
  109. n, err := io.Copy(crc, r.Body)
  110. if err == nil {
  111. w.Header().Set("Content-Type", "text/plain")
  112. fmt.Fprintf(w, "bytes=%d, CRC32=%x", n, crc.Sum(nil))
  113. }
  114. }
  115. type capitalizeReader struct {
  116. r io.Reader
  117. }
  118. func (cr capitalizeReader) Read(p []byte) (n int, err error) {
  119. n, err = cr.r.Read(p)
  120. for i, b := range p[:n] {
  121. if b >= 'a' && b <= 'z' {
  122. p[i] = b - ('a' - 'A')
  123. }
  124. }
  125. return
  126. }
  127. type flushWriter struct {
  128. w io.Writer
  129. }
  130. func (fw flushWriter) Write(p []byte) (n int, err error) {
  131. n, err = fw.w.Write(p)
  132. if f, ok := fw.w.(http.Flusher); ok {
  133. f.Flush()
  134. }
  135. return
  136. }
  137. func echoCapitalHandler(w http.ResponseWriter, r *http.Request) {
  138. if r.Method != "PUT" {
  139. http.Error(w, "PUT required.", 400)
  140. return
  141. }
  142. if f, ok := w.(http.Flusher); ok {
  143. f.Flush()
  144. }
  145. io.Copy(flushWriter{w}, capitalizeReader{r.Body})
  146. }
  147. var (
  148. fsGrp singleflight.Group
  149. fsMu sync.Mutex // guards fsCache
  150. fsCache = map[string]http.Handler{}
  151. )
  152. // fileServer returns a file-serving handler that proxies URL.
  153. // It lazily fetches URL on the first access and caches its contents forever.
  154. func fileServer(url string, latency time.Duration) http.Handler {
  155. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  156. if latency > 0 {
  157. time.Sleep(latency)
  158. }
  159. hi, err := fsGrp.Do(url, func() (interface{}, error) {
  160. fsMu.Lock()
  161. if h, ok := fsCache[url]; ok {
  162. fsMu.Unlock()
  163. return h, nil
  164. }
  165. fsMu.Unlock()
  166. res, err := http.Get(url)
  167. if err != nil {
  168. return nil, err
  169. }
  170. defer res.Body.Close()
  171. slurp, err := ioutil.ReadAll(res.Body)
  172. if err != nil {
  173. return nil, err
  174. }
  175. modTime := time.Now()
  176. var h http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  177. http.ServeContent(w, r, path.Base(url), modTime, bytes.NewReader(slurp))
  178. })
  179. fsMu.Lock()
  180. fsCache[url] = h
  181. fsMu.Unlock()
  182. return h, nil
  183. })
  184. if err != nil {
  185. http.Error(w, err.Error(), 500)
  186. return
  187. }
  188. hi.(http.Handler).ServeHTTP(w, r)
  189. })
  190. }
  191. func clockStreamHandler(w http.ResponseWriter, r *http.Request) {
  192. clientGone := w.(http.CloseNotifier).CloseNotify()
  193. w.Header().Set("Content-Type", "text/plain")
  194. ticker := time.NewTicker(1 * time.Second)
  195. defer ticker.Stop()
  196. fmt.Fprintf(w, "# ~1KB of junk to force browsers to start rendering immediately: \n")
  197. io.WriteString(w, strings.Repeat("# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n", 13))
  198. for {
  199. fmt.Fprintf(w, "%v\n", time.Now())
  200. w.(http.Flusher).Flush()
  201. select {
  202. case <-ticker.C:
  203. case <-clientGone:
  204. log.Printf("Client %v disconnected from the clock", r.RemoteAddr)
  205. return
  206. }
  207. }
  208. }
  209. func registerHandlers() {
  210. tiles := newGopherTilesHandler()
  211. push := newPushHandler()
  212. mux2 := http.NewServeMux()
  213. http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  214. switch {
  215. case r.URL.Path == "/gophertiles":
  216. tiles.ServeHTTP(w, r) // allow HTTP/2 + HTTP/1.x
  217. return
  218. case strings.HasPrefix(r.URL.Path, "/serverpush"):
  219. push.ServeHTTP(w, r) // allow HTTP/2 + HTTP/1.x
  220. return
  221. case r.TLS == nil: // do not allow HTTP/1.x for anything else
  222. http.Redirect(w, r, "https://"+httpsHost()+"/", http.StatusFound)
  223. return
  224. }
  225. if r.ProtoMajor == 1 {
  226. if r.URL.Path == "/reqinfo" {
  227. reqInfoHandler(w, r)
  228. return
  229. }
  230. homeOldHTTP(w, r)
  231. return
  232. }
  233. mux2.ServeHTTP(w, r)
  234. })
  235. mux2.HandleFunc("/", home)
  236. mux2.Handle("/file/gopher.png", fileServer("https://golang.org/doc/gopher/frontpage.png", 0))
  237. mux2.Handle("/file/go.src.tar.gz", fileServer("https://storage.googleapis.com/golang/go1.4.1.src.tar.gz", 0))
  238. mux2.HandleFunc("/reqinfo", reqInfoHandler)
  239. mux2.HandleFunc("/crc32", crcHandler)
  240. mux2.HandleFunc("/ECHO", echoCapitalHandler)
  241. mux2.HandleFunc("/clockstream", clockStreamHandler)
  242. mux2.Handle("/gophertiles", tiles)
  243. mux2.HandleFunc("/redirect", func(w http.ResponseWriter, r *http.Request) {
  244. http.Redirect(w, r, "/", http.StatusFound)
  245. })
  246. stripHomedir := regexp.MustCompile(`/(Users|home)/\w+`)
  247. mux2.HandleFunc("/goroutines", func(w http.ResponseWriter, r *http.Request) {
  248. w.Header().Set("Content-Type", "text/plain; charset=utf-8")
  249. buf := make([]byte, 2<<20)
  250. w.Write(stripHomedir.ReplaceAll(buf[:runtime.Stack(buf, true)], nil))
  251. })
  252. }
  253. var pushResources = map[string]http.Handler{
  254. "/serverpush/static/jquery.min.js": fileServer("https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js", 100*time.Millisecond),
  255. "/serverpush/static/godocs.js": fileServer("https://golang.org/lib/godoc/godocs.js", 100*time.Millisecond),
  256. "/serverpush/static/playground.js": fileServer("https://golang.org/lib/godoc/playground.js", 100*time.Millisecond),
  257. "/serverpush/static/style.css": fileServer("https://golang.org/lib/godoc/style.css", 100*time.Millisecond),
  258. }
  259. func newPushHandler() http.Handler {
  260. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  261. for path, handler := range pushResources {
  262. if r.URL.Path == path {
  263. handler.ServeHTTP(w, r)
  264. return
  265. }
  266. }
  267. cacheBust := time.Now().UnixNano()
  268. if pusher, ok := w.(http.Pusher); ok {
  269. for path := range pushResources {
  270. url := fmt.Sprintf("%s?%d", path, cacheBust)
  271. if err := pusher.Push(url, nil); err != nil {
  272. log.Printf("Failed to push %v: %v", path, err)
  273. }
  274. }
  275. }
  276. time.Sleep(100 * time.Millisecond) // fake network latency + parsing time
  277. if err := pushTmpl.Execute(w, struct {
  278. CacheBust int64
  279. HTTPSHost string
  280. HTTP1Prefix string
  281. }{
  282. CacheBust: cacheBust,
  283. HTTPSHost: httpsHost(),
  284. HTTP1Prefix: http1Prefix(),
  285. }); err != nil {
  286. log.Printf("Executing server push template: %v", err)
  287. }
  288. })
  289. }
  290. func newGopherTilesHandler() http.Handler {
  291. const gopherURL = "https://blog.golang.org/2years/2years-gophers.jpg"
  292. res, err := http.Get(gopherURL)
  293. if err != nil {
  294. log.Fatal(err)
  295. }
  296. if res.StatusCode != 200 {
  297. log.Fatalf("Error fetching %s: %v", gopherURL, res.Status)
  298. }
  299. slurp, err := ioutil.ReadAll(res.Body)
  300. res.Body.Close()
  301. if err != nil {
  302. log.Fatal(err)
  303. }
  304. im, err := jpeg.Decode(bytes.NewReader(slurp))
  305. if err != nil {
  306. if len(slurp) > 1024 {
  307. slurp = slurp[:1024]
  308. }
  309. log.Fatalf("Failed to decode gopher image: %v (got %q)", err, slurp)
  310. }
  311. type subImager interface {
  312. SubImage(image.Rectangle) image.Image
  313. }
  314. const tileSize = 32
  315. xt := im.Bounds().Max.X / tileSize
  316. yt := im.Bounds().Max.Y / tileSize
  317. var tile [][][]byte // y -> x -> jpeg bytes
  318. for yi := 0; yi < yt; yi++ {
  319. var row [][]byte
  320. for xi := 0; xi < xt; xi++ {
  321. si := im.(subImager).SubImage(image.Rectangle{
  322. Min: image.Point{xi * tileSize, yi * tileSize},
  323. Max: image.Point{(xi + 1) * tileSize, (yi + 1) * tileSize},
  324. })
  325. buf := new(bytes.Buffer)
  326. if err := jpeg.Encode(buf, si, &jpeg.Options{Quality: 90}); err != nil {
  327. log.Fatal(err)
  328. }
  329. row = append(row, buf.Bytes())
  330. }
  331. tile = append(tile, row)
  332. }
  333. return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  334. ms, _ := strconv.Atoi(r.FormValue("latency"))
  335. const nanosPerMilli = 1e6
  336. if r.FormValue("x") != "" {
  337. x, _ := strconv.Atoi(r.FormValue("x"))
  338. y, _ := strconv.Atoi(r.FormValue("y"))
  339. if ms <= 1000 {
  340. time.Sleep(time.Duration(ms) * nanosPerMilli)
  341. }
  342. if x >= 0 && x < xt && y >= 0 && y < yt {
  343. http.ServeContent(w, r, "", time.Time{}, bytes.NewReader(tile[y][x]))
  344. return
  345. }
  346. }
  347. io.WriteString(w, "<html><body onload='showtimes()'>")
  348. fmt.Fprintf(w, "A grid of %d tiled images is below. Compare:<p>", xt*yt)
  349. for _, ms := range []int{0, 30, 200, 1000} {
  350. d := time.Duration(ms) * nanosPerMilli
  351. fmt.Fprintf(w, "[<a href='https://%s/gophertiles?latency=%d'>HTTP/2, %v latency</a>] [<a href='%s/gophertiles?latency=%d'>HTTP/1, %v latency</a>]<br>\n",
  352. httpsHost(), ms, d,
  353. http1Prefix(), ms, d,
  354. )
  355. }
  356. io.WriteString(w, "<p>\n")
  357. cacheBust := time.Now().UnixNano()
  358. for y := 0; y < yt; y++ {
  359. for x := 0; x < xt; x++ {
  360. fmt.Fprintf(w, "<img width=%d height=%d src='/gophertiles?x=%d&y=%d&cachebust=%d&latency=%d'>",
  361. tileSize, tileSize, x, y, cacheBust, ms)
  362. }
  363. io.WriteString(w, "<br/>\n")
  364. }
  365. io.WriteString(w, `<p><div id='loadtimes'></div></p>
  366. <script>
  367. function showtimes() {
  368. var times = 'Times from connection start:<br>'
  369. times += 'DOM loaded: ' + (window.performance.timing.domContentLoadedEventEnd - window.performance.timing.connectStart) + 'ms<br>'
  370. times += 'DOM complete (images loaded): ' + (window.performance.timing.domComplete - window.performance.timing.connectStart) + 'ms<br>'
  371. document.getElementById('loadtimes').innerHTML = times
  372. }
  373. </script>
  374. <hr><a href='/'>&lt;&lt Back to Go HTTP/2 demo server</a></body></html>`)
  375. })
  376. }
  377. func httpsHost() string {
  378. if *hostHTTPS != "" {
  379. return *hostHTTPS
  380. }
  381. if v := *httpsAddr; strings.HasPrefix(v, ":") {
  382. return "localhost" + v
  383. } else {
  384. return v
  385. }
  386. }
  387. func http1Prefix() string {
  388. if *prod {
  389. return "https://http1.golang.org"
  390. }
  391. return "http://" + httpHost()
  392. }
  393. func httpHost() string {
  394. if *hostHTTP != "" {
  395. return *hostHTTP
  396. }
  397. if v := *httpAddr; strings.HasPrefix(v, ":") {
  398. return "localhost" + v
  399. } else {
  400. return v
  401. }
  402. }
  403. func serveProdTLS(autocertManager *autocert.Manager) error {
  404. srv := &http.Server{
  405. TLSConfig: &tls.Config{
  406. GetCertificate: autocertManager.GetCertificate,
  407. GetConfigForClient: func(hello *tls.ClientHelloInfo) (*tls.Config, error) {
  408. if hello.ServerName == "http1.golang.org" {
  409. return &tls.Config{
  410. GetCertificate: autocertManager.GetCertificate,
  411. }, nil
  412. }
  413. return nil, nil // fallback to other methods
  414. },
  415. },
  416. }
  417. http2.ConfigureServer(srv, &http2.Server{
  418. NewWriteScheduler: func() http2.WriteScheduler {
  419. return http2.NewPriorityWriteScheduler(nil)
  420. },
  421. })
  422. ln, err := net.Listen("tcp", ":443")
  423. if err != nil {
  424. return err
  425. }
  426. return srv.Serve(tls.NewListener(tcpKeepAliveListener{ln.(*net.TCPListener)}, srv.TLSConfig))
  427. }
  428. type tcpKeepAliveListener struct {
  429. *net.TCPListener
  430. }
  431. func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) {
  432. tc, err := ln.AcceptTCP()
  433. if err != nil {
  434. return
  435. }
  436. tc.SetKeepAlive(true)
  437. tc.SetKeepAlivePeriod(3 * time.Minute)
  438. return tc, nil
  439. }
  440. func serveProd() error {
  441. log.Printf("running in production mode.")
  442. storageClient, err := storage.NewClient(context.Background())
  443. if err != nil {
  444. log.Fatalf("storage.NewClient: %v", err)
  445. }
  446. autocertManager := &autocert.Manager{
  447. Prompt: autocert.AcceptTOS,
  448. HostPolicy: autocert.HostWhitelist("http1.golang.org", "http2.golang.org"),
  449. Cache: autocertcache.NewGoogleCloudStorageCache(storageClient, "golang-h2demo-autocert"),
  450. }
  451. errc := make(chan error, 2)
  452. go func() { errc <- http.ListenAndServe(":80", autocertManager.HTTPHandler(http.DefaultServeMux)) }()
  453. go func() { errc <- serveProdTLS(autocertManager) }()
  454. return <-errc
  455. }
  456. const idleTimeout = 5 * time.Minute
  457. const activeTimeout = 10 * time.Minute
  458. // TODO: put this into the standard library and actually send
  459. // PING frames and GOAWAY, etc: golang.org/issue/14204
  460. func idleTimeoutHook() func(net.Conn, http.ConnState) {
  461. var mu sync.Mutex
  462. m := map[net.Conn]*time.Timer{}
  463. return func(c net.Conn, cs http.ConnState) {
  464. mu.Lock()
  465. defer mu.Unlock()
  466. if t, ok := m[c]; ok {
  467. delete(m, c)
  468. t.Stop()
  469. }
  470. var d time.Duration
  471. switch cs {
  472. case http.StateNew, http.StateIdle:
  473. d = idleTimeout
  474. case http.StateActive:
  475. d = activeTimeout
  476. default:
  477. return
  478. }
  479. m[c] = time.AfterFunc(d, func() {
  480. log.Printf("closing idle conn %v after %v", c.RemoteAddr(), d)
  481. go c.Close()
  482. })
  483. }
  484. }
  485. func main() {
  486. var srv http.Server
  487. flag.BoolVar(&http2.VerboseLogs, "verbose", false, "Verbose HTTP/2 debugging.")
  488. flag.Parse()
  489. srv.Addr = *httpsAddr
  490. srv.ConnState = idleTimeoutHook()
  491. registerHandlers()
  492. if *prod {
  493. *hostHTTP = "http2.golang.org"
  494. *hostHTTPS = "http2.golang.org"
  495. log.Fatal(serveProd())
  496. }
  497. url := "https://" + httpsHost() + "/"
  498. log.Printf("Listening on " + url)
  499. http2.ConfigureServer(&srv, &http2.Server{})
  500. if *httpAddr != "" {
  501. go func() {
  502. log.Printf("Listening on http://" + httpHost() + "/ (for unencrypted HTTP/1)")
  503. log.Fatal(http.ListenAndServe(*httpAddr, nil))
  504. }()
  505. }
  506. go func() {
  507. log.Fatal(srv.ListenAndServeTLS("server.crt", "server.key"))
  508. }()
  509. select {}
  510. }