MCPcopy Create free account
hub / github.com/ContentSquare/chproxy / startTLS

Function startTLS

main_test.go:1038–1063  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1036}}
1037
1038func startTLS() (*http.Server, chan struct{}) {
1039 cfg, err := loadConfig()
1040 if err != nil {
1041 panic(fmt.Sprintf("error while loading config: %s", err))
1042 }
1043 if err = applyConfig(cfg); err != nil {
1044 panic(fmt.Sprintf("error while applying config: %s", err))
1045 }
1046 done := make(chan struct{})
1047 ln, err := net.Listen("tcp4", cfg.Server.HTTPS.ListenAddr)
1048 if err != nil {
1049 panic(fmt.Sprintf("cannot listen for %q: %s", cfg.Server.HTTPS.ListenAddr, err))
1050 }
1051 tlsCfg, err := cfg.Server.HTTPS.TLS.BuildTLSConfig(autocertManager)
1052 if err != nil {
1053 panic(fmt.Sprintf("cannot build TLS config: %s", err))
1054 }
1055 tln := tls.NewListener(ln, tlsCfg)
1056 h := http.HandlerFunc(serveHTTP)
1057 s := newServer(tln, h, config.TimeoutCfg{})
1058 go func() {
1059 s.Serve(tln)
1060 close(done)
1061 }()
1062 return s, done
1063}
1064
1065func startHTTP() (*http.Server, chan struct{}) {
1066 cfg, err := loadConfig()

Callers

nothing calls this directly

Calls 4

loadConfigFunction · 0.85
applyConfigFunction · 0.85
newServerFunction · 0.85
BuildTLSConfigMethod · 0.80

Tested by

no test coverage detected