mirror of
https://github.com/Monibuca/plugin-webtransport.git
synced 2025-12-24 11:51:00 +08:00
fix: check cert files exist
This commit is contained in:
14
main.go
14
main.go
@@ -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/"):]
|
||||
|
||||
Reference in New Issue
Block a user