fix: use embed cert

This commit is contained in:
langhuihui
2023-06-11 13:25:09 +08:00
parent 4500cad948
commit 6b95b8c8b6

24
main.go
View File

@@ -20,17 +20,21 @@ 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
if c.CertFile != "" {
_, 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
if c.KeyFile != "" {
_, 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) {