Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Support setting admin password and temp stream key via cli flag

Gabe Kangas0f3d8038c5b1
diff --git a/config/config.go b/config/config.go
index 152c17a576..d4f590382a 100644
--- a/config/config.go
+++ b/config/config.go
@@ -40,6 +40,9 @@ var BuildPlatform = "dev"
// EnableAutoUpdate will explicitly enable in-place auto-updates via the admin.
var EnableAutoUpdate = false
+// A temporary stream key that can be set via the command line.
+var TemporaryStreamKey = ""
+
// GetCommit will return an identifier used for identifying the point in time this build took place.
func GetCommit() string {
if GitCommit == "" {
diff --git a/core/rtmp/rtmp.go b/core/rtmp/rtmp.go
index 01d0fa38c7..35214a400f 100644
--- a/core/rtmp/rtmp.go
+++ b/core/rtmp/rtmp.go
@@ -11,6 +11,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/nareix/joy5/format/rtmp"
+ "github.com/owncast/owncast/config"
"github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/models"
)
@@ -87,6 +88,11 @@ func HandleConn(c *rtmp.Conn, nc net.Conn) {
}
}
+ // Test against the temporary key if it was set at runtime.
+ if config.TemporaryStreamKey != "" && secretMatch(config.TemporaryStreamKey, c.URL.Path) {
+ accessGranted = true
+ }
+
if !accessGranted {
log.Errorln("invalid streaming key; rejecting incoming stream")
_ = nc.Close()
diff --git a/main.go b/main.go
index bf00ed8e0d..2e34f5dd85 100644
--- a/main.go
+++ b/main.go
@@ -23,7 +23,8 @@ var (
enableDebugOptions = flag.Bool("enableDebugFeatures", false, "Enable additional debugging options.")
enableVerboseLogging = flag.Bool("enableVerboseLogging", false, "Enable additional logging.")
restoreDatabaseFile = flag.String("restoreDatabase", "", "Restore an Owncast database backup")
- newStreamKey = flag.String("streamkey", "", "Set your stream key/admin password")
+ newAdminPassword = flag.String("adminpassword", "", "Set your admin password")
+ newStreamKey = flag.String("streamkey", "", "Set a temporary stream key for this session")
webServerPortOverride = flag.String("webserverport", "", "Force the web server to listen on a specific port")
webServerIPOverride = flag.String("webserverip", "", "Force web server to listen on this IP address")
rtmpPortOverride = flag.Int("rtmpport", 0, "Set listen port for the RTMP server")
@@ -101,15 +102,20 @@ func main() {
}
func handleCommandLineFlags() {
- if *newStreamKey != "" {
- if err := data.SetAdminPassword(*newStreamKey); err != nil {
- log.Errorln("Error setting your stream key.", err)
+ if *newAdminPassword != "" {
+ if err := data.SetAdminPassword(*newAdminPassword); err != nil {
+ log.Errorln("Error setting your admin password.", err)
log.Exit(1)
} else {
- log.Infoln("Stream key changed")
+ log.Infoln("Admin password changed")
}
}
+ if *newStreamKey != "" {
+ log.Println("Temporary stream key is set for this session.")
+ config.TemporaryStreamKey = *newStreamKey
+ }
+
// Set the web server port
if *webServerPortOverride != "" {
portNumber, err := strconv.Atoi(*webServerPortOverride)