Don't add "irc" in ALPN list for WebSocket servers

This is incorrect because HTTP listeners don't handle plain IRC
connections. This also prevents net/http from setting up an HTTP/2
server.
This commit is contained in:
Simon Ser 2021-03-18 11:33:30 +01:00
parent e35a116188
commit 0c0397407c

View File

@ -55,10 +55,7 @@ func main() {
if err != nil {
log.Fatalf("failed to load TLS certificate and key: %v", err)
}
tlsCfg = &tls.Config{
NextProtos: []string{"irc"},
Certificates: []tls.Certificate{cert},
}
tlsCfg = &tls.Config{Certificates: []tls.Certificate{cert}}
}
srv := soju.NewServer(db)
@ -89,7 +86,9 @@ func main() {
if _, _, err := net.SplitHostPort(host); err != nil {
host = host + ":6697"
}
ln, err := tls.Listen("tcp", host, tlsCfg)
ircsTLSCfg := tlsCfg.Clone()
ircsTLSCfg.NextProtos = []string{"irc"}
ln, err := tls.Listen("tcp", host, ircsTLSCfg)
if err != nil {
log.Fatalf("failed to start TLS listener on %q: %v", listen, err)
}