mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Disable serving a directory listing. Closes #530
This commit is contained in:
parent
46fa26bc3a
commit
8328d1cb11
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -43,6 +44,13 @@ func IndexHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this is a directory listing request then return a 404
|
||||||
|
info, err := os.Stat(path.Join(config.WebRoot, r.URL.Path))
|
||||||
|
if err != nil || (info.IsDir() && !isIndexRequest) {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if path.Ext(r.URL.Path) == ".m3u8" {
|
if path.Ext(r.URL.Path) == ".m3u8" {
|
||||||
middleware.DisableCache(w)
|
middleware.DisableCache(w)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user