Support disabling the web UI with disableWebFeatures. Closes #32
This commit is contained in:
@@ -24,6 +24,7 @@ type config struct {
|
|||||||
S3 s3 `yaml:"s3"`
|
S3 s3 `yaml:"s3"`
|
||||||
InstanceDetails InstanceDetails `yaml:"instanceDetails"`
|
InstanceDetails InstanceDetails `yaml:"instanceDetails"`
|
||||||
VersionInfo string `yaml:"-"`
|
VersionInfo string `yaml:"-"`
|
||||||
|
DisableWebFeatures bool `yaml:"disableWebFeatures"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InstanceDetails defines the user-visible information about this particular instance.
|
// InstanceDetails defines the user-visible information about this particular instance.
|
||||||
|
|||||||
@@ -29,9 +29,18 @@ type MetadataPage struct {
|
|||||||
func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
middleware.EnableCors(&w)
|
middleware.EnableCors(&w)
|
||||||
|
|
||||||
|
isIndexRequest := r.URL.Path == "/" || r.URL.Path == "/index.html"
|
||||||
|
|
||||||
|
// Reject requests for the web UI if it's disabled.
|
||||||
|
if isIndexRequest && config.Config.DisableWebFeatures {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
w.Write([]byte("404 - y u ask 4 this? If this is an error let us know: https://github.com/gabek/owncast/issues"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ua := user_agent.New(r.UserAgent())
|
ua := user_agent.New(r.UserAgent())
|
||||||
|
|
||||||
if ua != nil && ua.Bot() && (r.URL.Path == "/" || r.URL.Path == "/index.html") {
|
if ua != nil && ua.Bot() && isIndexRequest {
|
||||||
handleScraperMetadataPage(w, r)
|
handleScraperMetadataPage(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ import (
|
|||||||
|
|
||||||
//Start starts the router for the http, ws, and rtmp
|
//Start starts the router for the http, ws, and rtmp
|
||||||
func Start() error {
|
func Start() error {
|
||||||
// websocket chat server
|
|
||||||
go chat.Start()
|
|
||||||
|
|
||||||
// start the rtmp server
|
// start the rtmp server
|
||||||
go rtmp.Start()
|
go rtmp.Start()
|
||||||
|
|
||||||
@@ -26,11 +23,16 @@ func Start() error {
|
|||||||
// status of the system
|
// status of the system
|
||||||
http.HandleFunc("/status", controllers.GetStatus)
|
http.HandleFunc("/status", controllers.GetStatus)
|
||||||
|
|
||||||
|
if !config.Config.DisableWebFeatures {
|
||||||
|
// websocket chat server
|
||||||
|
go chat.Start()
|
||||||
|
|
||||||
// chat rest api
|
// chat rest api
|
||||||
http.HandleFunc("/chat", controllers.GetChatMessages)
|
http.HandleFunc("/chat", controllers.GetChatMessages)
|
||||||
|
|
||||||
// web config api
|
// web config api
|
||||||
http.HandleFunc("/config", controllers.GetWebConfig)
|
http.HandleFunc("/config", controllers.GetWebConfig)
|
||||||
|
}
|
||||||
|
|
||||||
port := config.Config.WebServerPort
|
port := config.Config.WebServerPort
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user