From f61c95266503fb67e9d4a34747a31e2ea868bc77 Mon Sep 17 00:00:00 2001 From: Smile Rex Date: Wed, 4 Mar 2026 00:50:09 +0300 Subject: [PATCH] fix --- main.go | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index a455138..3b78b7d 100644 --- a/main.go +++ b/main.go @@ -112,19 +112,14 @@ func main() { log.Fatal(err) } - tlsConf.NextProtos = []string{"h3"} + tlsConf.NextProtos = []string{"h3", "http/1.1"} tlsConf.MinVersion = tls.VersionTLS13 server := NewServer() mux := http.NewServeMux() - wtServer := &webtransport.Server{ - H3: &http3.Server{ - Addr: ":443", - TLSConfig: tlsConf, - }, - } + wtServer := &webtransport.Server{} mux.HandleFunc("/room/", func(w http.ResponseWriter, r *http.Request) { roomName := strings.TrimPrefix(r.URL.Path, "/room/") @@ -138,9 +133,27 @@ func main() { 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.Fatal(wtServer.ListenAndServe()) + // Запускаем HTTP/3 + go func() { + log.Fatal(h3Server.ListenAndServe()) + }() + + // Запускаем HTTPS (TCP) + log.Fatal(httpServer.ListenAndServeTLS("", "")) }