Fix stream key loading
Somehow I broke this without noticing. Also, If a stream key is provided as a command line flag, load it but do not save it to settings.json.
This commit is contained in:
parent
2e17d92cae
commit
1a217775ff
13
main.go
13
main.go
|
@ -74,12 +74,7 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
streamKey := settings.StreamKey
|
if urlParts[1] != settings.GetStreamKey() {
|
||||||
if sKey != nil && len(*sKey) != 0 {
|
|
||||||
streamKey = *sKey
|
|
||||||
}
|
|
||||||
|
|
||||||
if urlParts[1] != streamKey {
|
|
||||||
fmt.Println("Due to key not match, denied stream")
|
fmt.Println("Due to key not match, denied stream")
|
||||||
return //If key not match, deny stream
|
return //If key not match, deny stream
|
||||||
}
|
}
|
||||||
|
@ -161,7 +156,11 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Stream key: ", streamKey)
|
if sKey != nil && len(*sKey) != 0 {
|
||||||
|
settings.SetTempKey(*sKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Stream key: ", settings.GetStreamKey())
|
||||||
fmt.Println("Admin password: ", settings.AdminPassword)
|
fmt.Println("Admin password: ", settings.AdminPassword)
|
||||||
|
|
||||||
go http.ListenAndServe(address, nil)
|
go http.ListenAndServe(address, nil)
|
||||||
|
|
18
settings.go
18
settings.go
|
@ -19,6 +19,7 @@ type Settings struct {
|
||||||
Bans []BanInfo
|
Bans []BanInfo
|
||||||
StreamKey string
|
StreamKey string
|
||||||
ListenAddress string
|
ListenAddress string
|
||||||
|
cmdLineKey string // stream key from the command line
|
||||||
}
|
}
|
||||||
|
|
||||||
type BanInfo struct {
|
type BanInfo struct {
|
||||||
|
@ -128,3 +129,20 @@ func (s *Settings) IsBanned(host string) (bool, []string) {
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Settings) SetTempKey(key string) {
|
||||||
|
defer settingsMtx.Unlock()
|
||||||
|
settingsMtx.Lock()
|
||||||
|
|
||||||
|
s.cmdLineKey = key
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Settings) GetStreamKey() string {
|
||||||
|
defer settingsMtx.Unlock()
|
||||||
|
settingsMtx.Lock()
|
||||||
|
|
||||||
|
if len(s.cmdLineKey) > 0 {
|
||||||
|
return s.cmdLineKey
|
||||||
|
}
|
||||||
|
return s.StreamKey
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue