fix: check cert files exist

This commit is contained in:
langhuihui
2023-05-16 23:08:40 +08:00
parent 89cfd967e4
commit 3dd0dd76df

14
main.go
View File

@@ -2,9 +2,11 @@ package webtransport
import (
"net/http"
"os"
"strconv"
"github.com/quic-go/quic-go"
"go.uber.org/zap"
. "m7s.live/engine/v4"
)
@@ -17,6 +19,18 @@ type WebTransportConfig struct {
func (c *WebTransportConfig) OnEvent(event any) {
switch event.(type) {
case FirstConfig:
_, err := os.Stat(c.CertFile)
if err != nil {
plugin.Error("need certfile", zap.Error(err))
plugin.Disabled = true
return
}
_, err = os.Stat(c.KeyFile)
if err != nil {
plugin.Error("need keyfile", zap.Error(err))
plugin.Disabled = true
return
}
mux := http.NewServeMux()
mux.HandleFunc("/play/", func(w http.ResponseWriter, r *http.Request) {
streamPath := r.URL.Path[len("/play/"):]