From 52e5978b19dfff1959bde225395ba4d47581f7d4 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 7 Oct 2020 15:00:35 +0200 Subject: [PATCH] Handle old-style MCU configuration with type but no url. In the past this disabled the MCU but now was triggering an error due to an invalid (empty) URL. Keep old behaviour and disable MCU again. --- src/server/main.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/server/main.go b/src/server/main.go index 05c4e63..df7791c 100644 --- a/src/server/main.go +++ b/src/server/main.go @@ -159,12 +159,16 @@ func main() { if mcuType == "" && mcuUrl != "" { log.Printf("WARNING: Old-style MCU configuration detected with url but no type, defaulting to type %s", signaling.McuTypeJanus) mcuType = signaling.McuTypeJanus + } else if mcuType == signaling.McuTypeJanus && mcuUrl == "" { + log.Printf("WARNING: Old-style MCU configuration detected with type but no url, disabling") + mcuType = "" } if mcuType != "" { var mcu signaling.Mcu mcuRetry := initialMcuRetry mcuRetryTimer := time.NewTimer(mcuRetry) + mcuTypeLoop: for { switch mcuType { case signaling.McuTypeJanus: @@ -201,6 +205,10 @@ func main() { if mcuType == "" && mcuUrl != "" { log.Printf("WARNING: Old-style MCU configuration detected with url but no type, defaulting to type %s", signaling.McuTypeJanus) mcuType = signaling.McuTypeJanus + } else if mcuType == signaling.McuTypeJanus && mcuUrl == "" { + log.Printf("WARNING: Old-style MCU configuration detected with type but no url, disabling") + mcuType = "" + break mcuTypeLoop } } } @@ -212,10 +220,12 @@ func main() { } } } - defer mcu.Stop() + if mcu != nil { + defer mcu.Stop() - log.Printf("Using %s MCU", mcuType) - hub.SetMcu(mcu) + log.Printf("Using %s MCU", mcuType) + hub.SetMcu(mcu) + } } go hub.Run()