fix
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 1m52s

This commit is contained in:
Smile Rex
2026-03-04 00:50:09 +03:00
parent 49086f7322
commit f61c952665

31
main.go
View File

@@ -112,19 +112,14 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
tlsConf.NextProtos = []string{"h3"} tlsConf.NextProtos = []string{"h3", "http/1.1"}
tlsConf.MinVersion = tls.VersionTLS13 tlsConf.MinVersion = tls.VersionTLS13
server := NewServer() server := NewServer()
mux := http.NewServeMux() mux := http.NewServeMux()
wtServer := &webtransport.Server{ wtServer := &webtransport.Server{}
H3: &http3.Server{
Addr: ":443",
TLSConfig: tlsConf,
},
}
mux.HandleFunc("/room/", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("/room/", func(w http.ResponseWriter, r *http.Request) {
roomName := strings.TrimPrefix(r.URL.Path, "/room/") roomName := strings.TrimPrefix(r.URL.Path, "/room/")
@@ -138,9 +133,27 @@ func main() {
go server.handleSession(roomName, sess) go server.handleSession(roomName, sess)
}) })
wtServer.H3.Handler = mux // HTTP/1.1 server (TCP 443)
httpServer := &http.Server{
Addr: ":443",
TLSConfig: tlsConf,
Handler: mux,
}
// HTTP/3 server (UDP 443)
h3Server := &http3.Server{
Addr: ":443",
TLSConfig: tlsConf,
Handler: mux,
}
log.Println("Relay running on https://" + domain + "/room/{room}") log.Println("Relay running on https://" + domain + "/room/{room}")
log.Fatal(wtServer.ListenAndServe()) // Запускаем HTTP/3
go func() {
log.Fatal(h3Server.ListenAndServe())
}()
// Запускаем HTTPS (TCP)
log.Fatal(httpServer.ListenAndServeTLS("", ""))
} }