Support environment variables in URL / listener configuration.

This commit is contained in:
Joachim Bauch 2024-04-30 11:42:40 +02:00
parent 1d4667aa28
commit 3169554179
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
4 changed files with 10 additions and 8 deletions

View file

@ -36,6 +36,8 @@ import (
"github.com/dlintw/goconf"
"github.com/gorilla/mux"
signaling "github.com/strukturag/nextcloud-spreed-signaling"
)
var (
@ -90,7 +92,7 @@ func main() {
}
defer proxy.Stop()
if addr, _ := config.GetString("http", "listen"); addr != "" {
if addr, _ := signaling.GetStringOptionWithEnv(config, "http", "listen"); addr != "" {
readTimeout, _ := config.GetInt("http", "readtimeout")
if readTimeout <= 0 {
readTimeout = defaultReadTimeout

View file

@ -223,7 +223,7 @@ func (s *ProxyServer) checkOrigin(r *http.Request) bool {
}
func (s *ProxyServer) Start(config *goconf.ConfigFile) error {
s.url, _ = config.GetString("mcu", "url")
s.url, _ = signaling.GetStringOptionWithEnv(config, "mcu", "url")
if s.url == "" {
return fmt.Errorf("No MCU server url configured")
}

View file

@ -86,7 +86,7 @@ func (p *proxyConfigStatic) configure(config *goconf.ConfigFile, fromReload bool
remove[u] = ips
}
mcuUrl, _ := config.GetString("mcu", "url")
mcuUrl, _ := GetStringOptionWithEnv(config, "mcu", "url")
for _, u := range strings.Split(mcuUrl, " ") {
u = strings.TrimSpace(u)
if u == "" {

View file

@ -171,7 +171,7 @@ func main() {
signaling.RegisterStats()
natsUrl, _ := config.GetString("nats", "url")
natsUrl, _ := signaling.GetStringOptionWithEnv(config, "nats", "url")
if natsUrl == "" {
natsUrl = nats.DefaultURL
}
@ -224,7 +224,7 @@ func main() {
log.Fatal("Could not create hub: ", err)
}
mcuUrl, _ := config.GetString("mcu", "url")
mcuUrl, _ := signaling.GetStringOptionWithEnv(config, "mcu", "url")
mcuType, _ := config.GetString("mcu", "type")
if mcuType == "" && mcuUrl != "" {
log.Printf("WARNING: Old-style MCU configuration detected with url but no type, defaulting to type %s", signaling.McuTypeJanus)
@ -274,7 +274,7 @@ func main() {
if config, err = goconf.ReadConfigFile(*configFlag); err != nil {
log.Printf("Could not read configuration from %s: %s", *configFlag, err)
} else {
mcuUrl, _ = config.GetString("mcu", "url")
mcuUrl, _ = signaling.GetStringOptionWithEnv(config, "mcu", "url")
mcuType, _ = config.GetString("mcu", "type")
if mcuType == "" && mcuUrl != "" {
log.Printf("WARNING: Old-style MCU configuration detected with url but no type, defaulting to type %s", signaling.McuTypeJanus)
@ -328,7 +328,7 @@ func main() {
var listeners Listeners
if saddr, _ := config.GetString("https", "listen"); saddr != "" {
if saddr, _ := signaling.GetStringOptionWithEnv(config, "https", "listen"); saddr != "" {
cert, _ := config.GetString("https", "certificate")
key, _ := config.GetString("https", "key")
if cert == "" || key == "" {
@ -366,7 +366,7 @@ func main() {
}
}
if addr, _ := config.GetString("http", "listen"); addr != "" {
if addr, _ := signaling.GetStringOptionWithEnv(config, "http", "listen"); addr != "" {
readTimeout, _ := config.GetInt("http", "readtimeout")
if readTimeout <= 0 {
readTimeout = defaultReadTimeout