// DialAndServeTLS dials a TLS connection, then serves incoming HTTP // requests. If h is nil, it uses http.DefaultHandler. // If config.NextProtos is nil, it uses "rspdy/3". func DialAndServeTLS(network, addr string, config *tls.Config, h http.Handler) error { var srv spdy.Server srv.Handler = h config1 := new(tls.Config) if config != nil { *config1 = *config } if config1.NextProtos == nil { config1.NextProtos = []string{"rspdy/3"} } // TODO(kr): cert stuff conn, err := tls.Dial(network, addr, config1) if err != nil { return err } return srv.ServeConn(conn) }
func listenBackends(dir *Directory) { var srv spdy.Server srv.Addr = os.Getenv("BKDADDR") if srv.Addr == "" { srv.Addr = defBackendAddr } log.Println("listen backends", srv.Addr) mux := http.NewServeMux() mux.HandleFunc("api.webx.io/mon/", dir.Monitor) srv.Handler = mux srv.TLSConfig = &tls.Config{ NextProtos: []string{"spdy/3", "rspdy/3", "http/1.1"}, } srv.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){ "rspdy/3": dir.ServeRSPDY, } err := srv.ListenAndServeTLS(innerCertFile, innerKeyFile) if err != nil { log.Fatal(err) } }