From 5cdb5282ef7039ab363c494604f152b9269a70c6 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Sun, 4 Oct 2020 11:45:16 +0200 Subject: [PATCH] Display SRT url on web page --- main.go | 9 +++++++++ web/template/index.html | 6 +++--- web/template/viewer.html | 6 +++--- web/web.go | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 8eb2ab3..163154a 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ package main import ( "log" + "net" "strings" "github.com/spf13/viper" @@ -66,6 +67,14 @@ func loadConfiguration() { // Copy STUN configuration to clients viper.Set("Web.STUNServers", viper.Get("WebRTC.STUNServers")) + + // Copy SRT server port to display it on web page + hostport := viper.GetString("Srt.ListenAddress") + _, srtPort, err := net.SplitHostPort(hostport) + if err != nil { + log.Fatalf("Failed to split host and port from %s", hostport) + } + viper.Set("Web.SRTServerPort", srtPort) } func main() { diff --git a/web/template/index.html b/web/template/index.html index dc0b306..60eb3f7 100644 --- a/web/template/index.html +++ b/web/template/index.html @@ -21,11 +21,11 @@