mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
feat: move config into services
This commit is contained in:
parent
4856397acf
commit
77e2a44713
@ -9,8 +9,8 @@ import (
|
|||||||
"github.com/owncast/owncast/activitypub/crypto"
|
"github.com/owncast/owncast/activitypub/crypto"
|
||||||
"github.com/owncast/owncast/activitypub/persistence"
|
"github.com/owncast/owncast/activitypub/persistence"
|
||||||
"github.com/owncast/owncast/activitypub/requests"
|
"github.com/owncast/owncast/activitypub/requests"
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -95,6 +95,7 @@ func NodeInfoV2Controller(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
localPostCount, _ := persistence.GetLocalPostCount()
|
localPostCount, _ := persistence.GetLocalPostCount()
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
res := response{
|
res := response{
|
||||||
Version: "2.0",
|
Version: "2.0",
|
||||||
@ -104,7 +105,7 @@ func NodeInfoV2Controller(w http.ResponseWriter, r *http.Request) {
|
|||||||
},
|
},
|
||||||
Software: software{
|
Software: software{
|
||||||
Name: "owncast",
|
Name: "owncast",
|
||||||
Version: config.VersionNumber,
|
Version: c.VersionNumber,
|
||||||
},
|
},
|
||||||
Usage: usage{
|
Usage: usage{
|
||||||
Users: users{
|
Users: users{
|
||||||
@ -175,6 +176,7 @@ func XNodeInfo2Controller(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
localPostCount, _ := persistence.GetLocalPostCount()
|
localPostCount, _ := persistence.GetLocalPostCount()
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
res := &response{
|
res := &response{
|
||||||
Organization: Organization{
|
Organization: Organization{
|
||||||
@ -183,7 +185,7 @@ func XNodeInfo2Controller(w http.ResponseWriter, r *http.Request) {
|
|||||||
},
|
},
|
||||||
Server: Server{
|
Server: Server{
|
||||||
BaseURL: serverURL,
|
BaseURL: serverURL,
|
||||||
Version: config.VersionNumber,
|
Version: c.VersionNumber,
|
||||||
Name: "owncast",
|
Name: "owncast",
|
||||||
Software: "owncast",
|
Software: "owncast",
|
||||||
},
|
},
|
||||||
@ -192,7 +194,7 @@ func XNodeInfo2Controller(w http.ResponseWriter, r *http.Request) {
|
|||||||
Outbound: []string{"activitypub"},
|
Outbound: []string{"activitypub"},
|
||||||
},
|
},
|
||||||
Protocols: []string{"activitypub"},
|
Protocols: []string{"activitypub"},
|
||||||
Version: config.VersionNumber,
|
Version: c.VersionNumber,
|
||||||
Usage: Usage{
|
Usage: Usage{
|
||||||
Users: Users{
|
Users: Users{
|
||||||
ActiveWeek: 1,
|
ActiveWeek: 1,
|
||||||
@ -251,13 +253,14 @@ func InstanceV1Controller(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
thumbnail.Path = "/logo/external"
|
thumbnail.Path = "/logo/external"
|
||||||
localPostCount, _ := persistence.GetLocalPostCount()
|
localPostCount, _ := persistence.GetLocalPostCount()
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
res := response{
|
res := response{
|
||||||
URI: serverURL,
|
URI: serverURL,
|
||||||
Title: data.GetServerName(),
|
Title: data.GetServerName(),
|
||||||
ShortDescription: data.GetServerSummary(),
|
ShortDescription: data.GetServerSummary(),
|
||||||
Description: data.GetServerSummary(),
|
Description: data.GetServerSummary(),
|
||||||
Version: config.GetReleaseString(),
|
Version: c.GetReleaseString(),
|
||||||
Stats: Stats{
|
Stats: Stats{
|
||||||
UserCount: 1,
|
UserCount: 1,
|
||||||
StatusCount: int(localPostCount),
|
StatusCount: int(localPostCount),
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-fed/httpsig"
|
"github.com/go-fed/httpsig"
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -77,7 +77,9 @@ func CreateSignedRequest(payload []byte, url *url.URL, fromActorIRI *url.URL) (*
|
|||||||
|
|
||||||
req, _ := http.NewRequest("POST", url.String(), bytes.NewBuffer(payload))
|
req, _ := http.NewRequest("POST", url.String(), bytes.NewBuffer(payload))
|
||||||
|
|
||||||
ua := fmt.Sprintf("%s; https://owncast.online", config.GetReleaseString())
|
c := config.GetConfig()
|
||||||
|
ua := fmt.Sprintf("%s; https://owncast.online", c.GetReleaseString())
|
||||||
|
|
||||||
req.Header.Set("User-Agent", ua)
|
req.Header.Set("User-Agent", ua)
|
||||||
req.Header.Set("Content-Type", "application/activity+json")
|
req.Header.Set("Content-Type", "application/activity+json")
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,8 @@ import (
|
|||||||
"github.com/owncast/owncast/activitypub/workerpool"
|
"github.com/owncast/owncast/activitypub/workerpool"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/teris-io/shortid"
|
"github.com/teris-io/shortid"
|
||||||
@ -77,8 +77,9 @@ func SendLive() error {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
var imageToAttach string
|
var imageToAttach string
|
||||||
var mediaType string
|
var mediaType string
|
||||||
previewGif := filepath.Join(config.TempDir, "preview.gif")
|
c := config.GetConfig()
|
||||||
thumbnailJpg := filepath.Join(config.TempDir, "thumbnail.jpg")
|
previewGif := filepath.Join(c.TempDir, "preview.gif")
|
||||||
|
thumbnailJpg := filepath.Join(c.TempDir, "thumbnail.jpg")
|
||||||
uniquenessString := shortid.MustGenerate()
|
uniquenessString := shortid.MustGenerate()
|
||||||
if utils.DoesFileExists(previewGif) {
|
if utils.DoesFileExists(previewGif) {
|
||||||
imageToAttach = "preview.gif"
|
imageToAttach = "preview.gif"
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/go-fed/activity/streams"
|
"github.com/go-fed/activity/streams"
|
||||||
"github.com/go-fed/activity/streams/vocab"
|
"github.com/go-fed/activity/streams/vocab"
|
||||||
"github.com/owncast/owncast/activitypub/crypto"
|
"github.com/owncast/owncast/activitypub/crypto"
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -60,8 +60,8 @@ func CreateSignedRequest(payload []byte, url *url.URL, fromActorIRI *url.URL) (*
|
|||||||
log.Debugln("Sending", string(payload), "to", url)
|
log.Debugln("Sending", string(payload), "to", url)
|
||||||
|
|
||||||
req, _ := http.NewRequest(http.MethodPost, url.String(), bytes.NewBuffer(payload))
|
req, _ := http.NewRequest(http.MethodPost, url.String(), bytes.NewBuffer(payload))
|
||||||
|
c := config.GetConfig()
|
||||||
ua := fmt.Sprintf("%s; https://owncast.online", config.GetReleaseString())
|
ua := fmt.Sprintf("%s; https://owncast.online", c.GetReleaseString())
|
||||||
req.Header.Set("User-Agent", ua)
|
req.Header.Set("User-Agent", ua)
|
||||||
req.Header.Set("Content-Type", "application/activity+json")
|
req.Header.Set("Content-Type", "application/activity+json")
|
||||||
|
|
||||||
|
|||||||
@ -1,70 +0,0 @@
|
|||||||
package config
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// These are runtime-set values used for configuration.
|
|
||||||
|
|
||||||
// DatabaseFilePath is the path to the file ot be used as the global database for this run of the application.
|
|
||||||
var DatabaseFilePath = "data/owncast.db"
|
|
||||||
|
|
||||||
// LogDirectory is the path to various log files.
|
|
||||||
var LogDirectory = "./data/logs"
|
|
||||||
|
|
||||||
// TempDir is where we store temporary files.
|
|
||||||
var TempDir = "./data/tmp"
|
|
||||||
|
|
||||||
// EnableDebugFeatures will print additional data to help in debugging.
|
|
||||||
var EnableDebugFeatures = false
|
|
||||||
|
|
||||||
// VersionNumber is the current version string.
|
|
||||||
var VersionNumber = StaticVersionNumber
|
|
||||||
|
|
||||||
// WebServerPort is the port for Owncast's webserver that is used for this execution of the service.
|
|
||||||
var WebServerPort = 8080
|
|
||||||
|
|
||||||
// WebServerIP is the IP address to bind the web server to. All interfaces by default.
|
|
||||||
var WebServerIP = "0.0.0.0"
|
|
||||||
|
|
||||||
// InternalHLSListenerPort is the port for HLS writes that is used for this execution of the service.
|
|
||||||
var InternalHLSListenerPort = "8927"
|
|
||||||
|
|
||||||
// GitCommit is an optional commit this build was made from.
|
|
||||||
var GitCommit = ""
|
|
||||||
|
|
||||||
// BuildPlatform is the optional platform this release was built for.
|
|
||||||
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 == "" {
|
|
||||||
GitCommit = time.Now().Format("20060102")
|
|
||||||
}
|
|
||||||
|
|
||||||
return GitCommit
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultForbiddenUsernames are a list of usernames forbidden from being used in chat.
|
|
||||||
var DefaultForbiddenUsernames = []string{
|
|
||||||
"owncast", "operator", "admin", "system",
|
|
||||||
}
|
|
||||||
|
|
||||||
// MaxSocketPayloadSize is the maximum payload we will allow to to be received via the chat socket.
|
|
||||||
const MaxSocketPayloadSize = 2048
|
|
||||||
|
|
||||||
// GetReleaseString gets the version string.
|
|
||||||
func GetReleaseString() string {
|
|
||||||
versionNumber := VersionNumber
|
|
||||||
buildPlatform := BuildPlatform
|
|
||||||
gitCommit := GetCommit()
|
|
||||||
|
|
||||||
return fmt.Sprintf("Owncast v%s-%s (%s)", versionNumber, buildPlatform, gitCommit)
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
package config
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
//go:build enable_updates
|
|
||||||
// +build enable_updates
|
|
||||||
|
|
||||||
package config
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
EnableAutoUpdate = true
|
|
||||||
}
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
package config
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"golang.org/x/mod/semver"
|
|
||||||
)
|
|
||||||
|
|
||||||
// VerifyFFMpegPath verifies that the path exists, is a file, and is executable.
|
|
||||||
func VerifyFFMpegPath(path string) error {
|
|
||||||
stat, err := os.Stat(path)
|
|
||||||
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
return errors.New("ffmpeg path does not exist")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error while verifying the ffmpeg path: %s", err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
if stat.IsDir() {
|
|
||||||
return errors.New("ffmpeg path can not be a folder")
|
|
||||||
}
|
|
||||||
|
|
||||||
mode := stat.Mode()
|
|
||||||
// source: https://stackoverflow.com/a/60128480
|
|
||||||
if mode&0o111 == 0 {
|
|
||||||
return errors.New("ffmpeg path is not executable")
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command(path)
|
|
||||||
out, _ := cmd.CombinedOutput()
|
|
||||||
|
|
||||||
response := string(out)
|
|
||||||
if response == "" {
|
|
||||||
return fmt.Errorf("unable to determine the version of your ffmpeg installation at %s you may experience issues with video", path)
|
|
||||||
}
|
|
||||||
|
|
||||||
responseComponents := strings.Split(response, " ")
|
|
||||||
if len(responseComponents) < 3 {
|
|
||||||
log.Debugf("unable to determine the version of your ffmpeg installation at %s you may experience issues with video", path)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
fullVersionString := responseComponents[2]
|
|
||||||
|
|
||||||
versionString := "v" + strings.Split(fullVersionString, "-")[0]
|
|
||||||
|
|
||||||
// Some builds of ffmpeg have weird build numbers that we can't parse
|
|
||||||
if !semver.IsValid(versionString) {
|
|
||||||
log.Debugf("unable to determine if ffmpeg version %s is recent enough. if you experience issues with video you may want to look into updating", fullVersionString)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if semver.Compare(versionString, FfmpegSuggestedVersion) == -1 {
|
|
||||||
return fmt.Errorf("your %s version of ffmpeg at %s may be older than the suggested version of %s you may experience issues with video", versionString, path, FfmpegSuggestedVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@ -5,10 +5,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/chat/events"
|
"github.com/owncast/owncast/core/chat/events"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -29,12 +29,13 @@ func Start(getStatusFunc func() models.Status) error {
|
|||||||
go _server.Run()
|
go _server.Run()
|
||||||
|
|
||||||
log.Traceln("Chat server started with max connection count of", _server.maxSocketConnectionLimit)
|
log.Traceln("Chat server started with max connection count of", _server.maxSocketConnectionLimit)
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
chatMessagesSentCounter = promauto.NewGauge(prometheus.GaugeOpts{
|
chatMessagesSentCounter = promauto.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "total_chat_message_count",
|
Name: "total_chat_message_count",
|
||||||
Help: "The number of chat messages incremented over time.",
|
Help: "The number of chat messages incremented over time.",
|
||||||
ConstLabels: map[string]string{
|
ConstLabels: map[string]string{
|
||||||
"version": config.VersionNumber,
|
"version": c.VersionNumber,
|
||||||
"host": data.GetServerURL(),
|
"host": data.GetServerURL(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -11,9 +11,9 @@ import (
|
|||||||
"golang.org/x/time/rate"
|
"golang.org/x/time/rate"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/chat/events"
|
"github.com/owncast/owncast/core/chat/events"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/services/geoip"
|
"github.com/owncast/owncast/services/geoip"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -6,9 +6,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/chat/events"
|
"github.com/owncast/owncast/core/chat/events"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/services/webhooks"
|
"github.com/owncast/owncast/services/webhooks"
|
||||||
"github.com/owncast/owncast/storage"
|
"github.com/owncast/owncast/storage"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
|
|||||||
@ -11,10 +11,10 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/chat/events"
|
"github.com/owncast/owncast/core/chat/events"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/services/geoip"
|
"github.com/owncast/owncast/services/geoip"
|
||||||
"github.com/owncast/owncast/services/webhooks"
|
"github.com/owncast/owncast/services/webhooks"
|
||||||
"github.com/owncast/owncast/storage"
|
"github.com/owncast/owncast/storage"
|
||||||
|
|||||||
@ -7,11 +7,11 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/chat"
|
"github.com/owncast/owncast/core/chat"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
"github.com/owncast/owncast/services/auth"
|
"github.com/owncast/owncast/services/auth"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/services/notifications"
|
"github.com/owncast/owncast/services/notifications"
|
||||||
"github.com/owncast/owncast/services/webhooks"
|
"github.com/owncast/owncast/services/webhooks"
|
||||||
"github.com/owncast/owncast/services/yp"
|
"github.com/owncast/owncast/services/yp"
|
||||||
@ -113,7 +113,8 @@ func transitionToOfflineVideoStreamContent() {
|
|||||||
|
|
||||||
// Copy the logo to be the thumbnail
|
// Copy the logo to be the thumbnail
|
||||||
logo := data.GetLogoPath()
|
logo := data.GetLogoPath()
|
||||||
dst := filepath.Join(config.TempDir, "thumbnail.jpg")
|
c := config.GetConfig()
|
||||||
|
dst := filepath.Join(c.TempDir, "thumbnail.jpg")
|
||||||
if err = utils.Copy(filepath.Join("data", logo), dst); err != nil {
|
if err = utils.Copy(filepath.Join("data", logo), dst); err != nil {
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
}
|
}
|
||||||
@ -126,7 +127,8 @@ func resetDirectories() {
|
|||||||
log.Trace("Resetting file directories to a clean slate.")
|
log.Trace("Resetting file directories to a clean slate.")
|
||||||
|
|
||||||
// Wipe hls data directory
|
// Wipe hls data directory
|
||||||
utils.CleanupDirectory(config.HLSStoragePath)
|
c := config.GetConfig()
|
||||||
|
utils.CleanupDirectory(c.HLSStoragePath)
|
||||||
|
|
||||||
// Remove the previous thumbnail
|
// Remove the previous thumbnail
|
||||||
logo := data.GetLogoPath()
|
logo := data.GetLogoPath()
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/static"
|
"github.com/owncast/owncast/static"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -596,7 +596,8 @@ func GetVideoCodec() string {
|
|||||||
|
|
||||||
// VerifySettings will perform a sanity check for specific settings values.
|
// VerifySettings will perform a sanity check for specific settings values.
|
||||||
func VerifySettings() error {
|
func VerifySettings() error {
|
||||||
if len(GetStreamKeys()) == 0 && config.TemporaryStreamKey == "" {
|
c := config.GetConfig()
|
||||||
|
if len(GetStreamKeys()) == 0 && c.TemporaryStreamKey == "" {
|
||||||
log.Errorln("No stream key set. Streaming is disabled. Please set one via the admin or command line arguments")
|
log.Errorln("No stream key set. Streaming is disabled. Please set one via the admin or command line arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -118,7 +118,8 @@ func SetupPersistence(file string) error {
|
|||||||
|
|
||||||
dbBackupTicker := time.NewTicker(1 * time.Hour)
|
dbBackupTicker := time.NewTicker(1 * time.Hour)
|
||||||
go func() {
|
go func() {
|
||||||
backupFile := filepath.Join(config.BackupDirectory, "owncastdb.bak")
|
c := config.GetConfig()
|
||||||
|
backupFile := filepath.Join(c.BackupDirectory, "owncastdb.bak")
|
||||||
for range dbBackupTicker.C {
|
for range dbBackupTicker.C {
|
||||||
utils.Backup(_db, backupFile)
|
utils.Backup(_db, backupFile)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package data
|
package data
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HasPopulatedDefaults will determine if the defaults have been inserted into the database.
|
// HasPopulatedDefaults will determine if the defaults have been inserted into the database.
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/static"
|
"github.com/owncast/owncast/static"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -102,11 +102,13 @@ func SetupEmojiDirectory() (err error) {
|
|||||||
isDir bool
|
isDir bool
|
||||||
}
|
}
|
||||||
|
|
||||||
if utils.DoesFileExists(config.CustomEmojiPath) {
|
c := config.GetConfig()
|
||||||
|
|
||||||
|
if utils.DoesFileExists(c.CustomEmojiPath) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = os.MkdirAll(config.CustomEmojiPath, 0o750); err != nil {
|
if err = os.MkdirAll(c.CustomEmojiPath, 0o750); err != nil {
|
||||||
return fmt.Errorf("unable to create custom emoji directory: %w", err)
|
return fmt.Errorf("unable to create custom emoji directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +139,7 @@ func SetupEmojiDirectory() (err error) {
|
|||||||
|
|
||||||
// Now copy all built-in emojis to the custom emoji directory
|
// Now copy all built-in emojis to the custom emoji directory
|
||||||
for _, path := range files {
|
for _, path := range files {
|
||||||
emojiPath := filepath.Join(config.CustomEmojiPath, path.path)
|
emojiPath := filepath.Join(c.CustomEmojiPath, path.path)
|
||||||
|
|
||||||
if path.isDir {
|
if path.isDir {
|
||||||
if err := os.Mkdir(emojiPath, 0o700); err != nil {
|
if err := os.Mkdir(emojiPath, 0o700); err != nil {
|
||||||
|
|||||||
@ -6,15 +6,17 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/teris-io/shortid"
|
"github.com/teris-io/shortid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func migrateDatabaseSchema(db *sql.DB, from, to int) error {
|
func migrateDatabaseSchema(db *sql.DB, from, to int) error {
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
log.Printf("Migrating database from version %d to %d", from, to)
|
log.Printf("Migrating database from version %d to %d", from, to)
|
||||||
dbBackupFile := filepath.Join(config.BackupDirectory, fmt.Sprintf("owncast-v%d.bak", from))
|
dbBackupFile := filepath.Join(c.BackupDirectory, fmt.Sprintf("owncast-v%d.bak", from))
|
||||||
utils.Backup(db, dbBackupFile)
|
utils.Backup(db, dbBackupFile)
|
||||||
for v := from; v < to; v++ {
|
for v := from; v < to; v++ {
|
||||||
log.Tracef("Migration step from %d to %d\n", v, v+1)
|
log.Tracef("Migration step from %d to %d\n", v, v+1)
|
||||||
|
|||||||
@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
// sqlite requires a blank import.
|
// sqlite requires a blank import.
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/db"
|
"github.com/owncast/owncast/db"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/grafov/m3u8"
|
"github.com/grafov/m3u8"
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/static"
|
"github.com/owncast/owncast/static"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -19,8 +19,9 @@ func appendOfflineToVariantPlaylist(index int, playlistFilePath string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
tmpFileName := fmt.Sprintf("tmp-stream-%d.m3u8", index)
|
tmpFileName := fmt.Sprintf("tmp-stream-%d.m3u8", index)
|
||||||
atomicWriteTmpPlaylistFile, err := os.CreateTemp(config.TempDir, tmpFileName)
|
atomicWriteTmpPlaylistFile, err := os.CreateTemp(c.TempDir, tmpFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("error creating tmp playlist file to write to", playlistFilePath, err)
|
log.Errorln("error creating tmp playlist file to write to", playlistFilePath, err)
|
||||||
return
|
return
|
||||||
@ -49,8 +50,9 @@ func appendOfflineToVariantPlaylist(index int, playlistFilePath string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeVariantIndexOffline(index int, offlineFilePath string, offlineFilename string) {
|
func makeVariantIndexOffline(index int, offlineFilePath string, offlineFilename string) {
|
||||||
playlistFilePath := fmt.Sprintf(filepath.Join(config.HLSStoragePath, "%d/stream.m3u8"), index)
|
c := config.GetConfig()
|
||||||
segmentFilePath := fmt.Sprintf(filepath.Join(config.HLSStoragePath, "%d/%s"), index, offlineFilename)
|
playlistFilePath := fmt.Sprintf(filepath.Join(c.HLSStoragePath, "%d/stream.m3u8"), index)
|
||||||
|
segmentFilePath := fmt.Sprintf(filepath.Join(c.HLSStoragePath, "%d/%s"), index, offlineFilename)
|
||||||
|
|
||||||
if err := utils.Copy(offlineFilePath, segmentFilePath); err != nil {
|
if err := utils.Copy(offlineFilePath, segmentFilePath); err != nil {
|
||||||
log.Warnln(err)
|
log.Warnln(err)
|
||||||
@ -94,7 +96,8 @@ func createEmptyOfflinePlaylist(playlistFilePath string, offlineFilename string)
|
|||||||
|
|
||||||
func saveOfflineClipToDisk(offlineFilename string) (string, error) {
|
func saveOfflineClipToDisk(offlineFilename string) (string, error) {
|
||||||
offlineFileData := static.GetOfflineSegment()
|
offlineFileData := static.GetOfflineSegment()
|
||||||
offlineTmpFile, err := os.CreateTemp(config.TempDir, offlineFilename)
|
c := config.GetConfig()
|
||||||
|
offlineTmpFile, err := os.CreateTemp(c.TempDir, offlineFilename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("unable to create temp file for offline video segment", err)
|
log.Errorln("unable to create temp file for offline video segment", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetStatus gets the status of the system.
|
// GetStatus gets the status of the system.
|
||||||
@ -17,6 +17,8 @@ func GetStatus() models.Status {
|
|||||||
viewerCount = len(_stats.Viewers)
|
viewerCount = len(_stats.Viewers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
return models.Status{
|
return models.Status{
|
||||||
Online: IsStreamConnected(),
|
Online: IsStreamConnected(),
|
||||||
ViewerCount: viewerCount,
|
ViewerCount: viewerCount,
|
||||||
@ -24,7 +26,7 @@ func GetStatus() models.Status {
|
|||||||
SessionMaxViewerCount: _stats.SessionMaxViewerCount,
|
SessionMaxViewerCount: _stats.SessionMaxViewerCount,
|
||||||
LastDisconnectTime: _stats.LastDisconnectTime,
|
LastDisconnectTime: _stats.LastDisconnectTime,
|
||||||
LastConnectTime: _stats.LastConnectTime,
|
LastConnectTime: _stats.LastConnectTime,
|
||||||
VersionNumber: config.VersionNumber,
|
VersionNumber: c.VersionNumber,
|
||||||
StreamTitle: data.GetStreamTitle(),
|
StreamTitle: data.GetStreamTitle(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,10 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/owncast/owncast/activitypub"
|
"github.com/owncast/owncast/activitypub"
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/chat"
|
"github.com/owncast/owncast/core/chat"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/services/notifications"
|
"github.com/owncast/owncast/services/notifications"
|
||||||
"github.com/owncast/owncast/services/webhooks"
|
"github.com/owncast/owncast/services/webhooks"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
@ -51,7 +51,8 @@ func setStreamAsConnected(rtmpOut *io.PipeReader) {
|
|||||||
go _yp.Start()
|
go _yp.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
segmentPath := config.HLSStoragePath
|
c := config.GetConfig()
|
||||||
|
segmentPath := c.HLSStoragePath
|
||||||
|
|
||||||
if err := setupStorage(); err != nil {
|
if err := setupStorage(); err != nil {
|
||||||
log.Fatalln("failed to setup the storage", err)
|
log.Fatalln("failed to setup the storage", err)
|
||||||
|
|||||||
@ -3,14 +3,16 @@ package logging
|
|||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetTranscoderLogFilePath returns the logging path for the transcoder log output.
|
// GetTranscoderLogFilePath returns the logging path for the transcoder log output.
|
||||||
func GetTranscoderLogFilePath() string {
|
func GetTranscoderLogFilePath() string {
|
||||||
return filepath.Join(config.LogDirectory, "transcoder.log")
|
c := config.GetConfig()
|
||||||
|
return filepath.Join(c.LogDirectory, "transcoder.log")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLogFilePath() string {
|
func getLogFilePath() string {
|
||||||
return filepath.Join(config.LogDirectory, "owncast.log")
|
c := config.GetConfig()
|
||||||
|
return filepath.Join(c.LogDirectory, "owncast.log")
|
||||||
}
|
}
|
||||||
|
|||||||
6
main.go
6
main.go
@ -9,10 +9,11 @@ import (
|
|||||||
"github.com/owncast/owncast/webserver"
|
"github.com/owncast/owncast/webserver"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core"
|
"github.com/owncast/owncast/core"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
|
configservice "github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/services/metrics"
|
"github.com/owncast/owncast/services/metrics"
|
||||||
|
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,12 +29,15 @@ var (
|
|||||||
webServerPortOverride = flag.String("webserverport", "", "Force the web server to listen on a specific port")
|
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")
|
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")
|
rtmpPortOverride = flag.Int("rtmpport", 0, "Set listen port for the RTMP server")
|
||||||
|
config *configservice.Config
|
||||||
)
|
)
|
||||||
|
|
||||||
// nolint:cyclop
|
// nolint:cyclop
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
config = configservice.NewConfig()
|
||||||
|
|
||||||
if *logDirectory != "" {
|
if *logDirectory != "" {
|
||||||
config.LogDirectory = *logDirectory
|
config.LogDirectory = *logDirectory
|
||||||
}
|
}
|
||||||
|
|||||||
106
services/config/config.go
Normal file
106
services/config/config.go
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// These are runtime-set values used for configuration.
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
// DatabaseFilePath is the path to the file ot be used as the global database for this run of the application.
|
||||||
|
DatabaseFilePath string
|
||||||
|
// LogDirectory is the path to various log files.
|
||||||
|
LogDirectory string
|
||||||
|
// TempDir is where we store temporary files.
|
||||||
|
TempDir string
|
||||||
|
// EnableDebugFeatures will print additional data to help in debugging.
|
||||||
|
EnableDebugFeatures bool
|
||||||
|
// VersionNumber is the current version string.
|
||||||
|
VersionNumber string
|
||||||
|
// WebServerPort is the port for Owncast's webserver that is used for this execution of the service.
|
||||||
|
WebServerPort int
|
||||||
|
// WebServerIP is the IP address to bind the web server to. All interfaces by default.
|
||||||
|
WebServerIP string
|
||||||
|
// InternalHLSListenerPort is the port for HLS writes that is used for this execution of the service.
|
||||||
|
InternalHLSListenerPort string
|
||||||
|
// GitCommit is an optional commit this build was made from.
|
||||||
|
GitCommit string
|
||||||
|
// BuildPlatform is the optional platform this release was built for.
|
||||||
|
BuildPlatform string
|
||||||
|
// EnableAutoUpdate will explicitly enable in-place auto-updates via the admin.
|
||||||
|
EnableAutoUpdate bool
|
||||||
|
// A temporary stream key that can be set via the command line.
|
||||||
|
TemporaryStreamKey string
|
||||||
|
// BackupDirectory is the directory we write backup files to.
|
||||||
|
BackupDirectory string
|
||||||
|
// HLSStoragePath is the directory HLS video is written to.
|
||||||
|
HLSStoragePath string
|
||||||
|
// CustomEmojiPath is the emoji directory.
|
||||||
|
CustomEmojiPath string
|
||||||
|
// PublicFilesPath is the optional directory for hosting public files.
|
||||||
|
PublicFilesPath string
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFediAuth creates a new FediAuth instance.
|
||||||
|
func NewConfig() *Config {
|
||||||
|
// Default config values.
|
||||||
|
c := &Config{
|
||||||
|
DatabaseFilePath: "data/owncast.db",
|
||||||
|
LogDirectory: "./data/logs",
|
||||||
|
TempDir: "./data/tmp",
|
||||||
|
EnableDebugFeatures: false,
|
||||||
|
VersionNumber: StaticVersionNumber,
|
||||||
|
WebServerPort: 8080,
|
||||||
|
WebServerIP: "0.0.0.0",
|
||||||
|
InternalHLSListenerPort: "8927",
|
||||||
|
GitCommit: "",
|
||||||
|
BuildPlatform: "dev",
|
||||||
|
EnableAutoUpdate: false,
|
||||||
|
TemporaryStreamKey: "",
|
||||||
|
BackupDirectory: filepath.Join(DataDirectory, "backup"),
|
||||||
|
HLSStoragePath: filepath.Join(DataDirectory, "hls"),
|
||||||
|
CustomEmojiPath: filepath.Join(DataDirectory, "emoji"),
|
||||||
|
PublicFilesPath: filepath.Join(DataDirectory, "public"),
|
||||||
|
}
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
var temporaryGlobalInstance *Config
|
||||||
|
|
||||||
|
// GetConfig returns the temporary global instance.
|
||||||
|
// Remove this after dependency injection is implemented.
|
||||||
|
func GetConfig() *Config {
|
||||||
|
if temporaryGlobalInstance == nil {
|
||||||
|
temporaryGlobalInstance = NewConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
return temporaryGlobalInstance
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCommit will return an identifier used for identifying the point in time this build took place.
|
||||||
|
func (c *Config) GetCommit() string {
|
||||||
|
if c.GitCommit == "" {
|
||||||
|
c.GitCommit = time.Now().Format("20060102")
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.GitCommit
|
||||||
|
}
|
||||||
|
|
||||||
|
// DefaultForbiddenUsernames are a list of usernames forbidden from being used in chat.
|
||||||
|
var DefaultForbiddenUsernames = []string{
|
||||||
|
"owncast", "operator", "admin", "system",
|
||||||
|
}
|
||||||
|
|
||||||
|
// MaxSocketPayloadSize is the maximum payload we will allow to to be received via the chat socket.
|
||||||
|
const MaxSocketPayloadSize = 2048
|
||||||
|
|
||||||
|
// GetReleaseString gets the version string.
|
||||||
|
func (c *Config) GetReleaseString() string {
|
||||||
|
versionNumber := c.VersionNumber
|
||||||
|
buildPlatform := c.BuildPlatform
|
||||||
|
gitCommit := c.GetCommit()
|
||||||
|
|
||||||
|
return fmt.Sprintf("Owncast v%s-%s (%s)", versionNumber, buildPlatform, gitCommit)
|
||||||
|
}
|
||||||
@ -1,7 +1,5 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import "path/filepath"
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// StaticVersionNumber is the version of Owncast that is used when it's not overwritten via build-time settings.
|
// StaticVersionNumber is the version of Owncast that is used when it's not overwritten via build-time settings.
|
||||||
StaticVersionNumber = "0.1.3" // Shown when you build from develop
|
StaticVersionNumber = "0.1.3" // Shown when you build from develop
|
||||||
@ -17,17 +15,3 @@ const (
|
|||||||
// MaxChatDisplayNameLength is the maximum length of a chat display name.
|
// MaxChatDisplayNameLength is the maximum length of a chat display name.
|
||||||
MaxChatDisplayNameLength = 30
|
MaxChatDisplayNameLength = 30
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// BackupDirectory is the directory we write backup files to.
|
|
||||||
BackupDirectory = filepath.Join(DataDirectory, "backup")
|
|
||||||
|
|
||||||
// HLSStoragePath is the directory HLS video is written to.
|
|
||||||
HLSStoragePath = filepath.Join(DataDirectory, "hls")
|
|
||||||
|
|
||||||
// CustomEmojiPath is the emoji directory.
|
|
||||||
CustomEmojiPath = filepath.Join(DataDirectory, "emoji")
|
|
||||||
|
|
||||||
// PublicFilesPath is the optional directory for hosting public files.
|
|
||||||
PublicFilesPath = filepath.Join(DataDirectory, "public")
|
|
||||||
)
|
|
||||||
@ -4,9 +4,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// How often we poll for updates.
|
// How often we poll for updates.
|
||||||
@ -61,8 +61,11 @@ func Start(getStatus func() models.Status) {
|
|||||||
if host == "" {
|
if host == "" {
|
||||||
host = "unknown"
|
host = "unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
labels = map[string]string{
|
labels = map[string]string{
|
||||||
"version": config.VersionNumber,
|
"version": c.VersionNumber,
|
||||||
"host": host,
|
"host": host,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package notifications
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/services/notifications/browser"
|
"github.com/owncast/owncast/services/notifications/browser"
|
||||||
"github.com/owncast/owncast/services/notifications/discord"
|
"github.com/owncast/owncast/services/notifications/discord"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|||||||
@ -8,9 +8,9 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -8,10 +8,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/db"
|
"github.com/owncast/owncast/db"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/teris-io/shortid"
|
"github.com/teris-io/shortid"
|
||||||
|
|||||||
@ -11,9 +11,9 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/nareix/joy5/format/rtmp"
|
"github.com/nareix/joy5/format/rtmp"
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _hasInboundRTMPConnection = false
|
var _hasInboundRTMPConnection = false
|
||||||
@ -81,9 +81,11 @@ func HandleConn(c *rtmp.Conn, nc net.Conn) {
|
|||||||
accessGranted := false
|
accessGranted := false
|
||||||
validStreamingKeys := data.GetStreamKeys()
|
validStreamingKeys := data.GetStreamKeys()
|
||||||
|
|
||||||
|
configservice := config.GetConfig()
|
||||||
|
|
||||||
// If a stream key override was specified then use that instead.
|
// If a stream key override was specified then use that instead.
|
||||||
if config.TemporaryStreamKey != "" {
|
if configservice.TemporaryStreamKey != "" {
|
||||||
validStreamingKeys = []models.StreamKey{{Key: config.TemporaryStreamKey}}
|
validStreamingKeys = []models.StreamKey{{Key: configservice.TemporaryStreamKey}}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, key := range validStreamingKeys {
|
for _, key := range validStreamingKeys {
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LocalStorage represents an instance of the local storage provider for HLS video.
|
// LocalStorage represents an instance of the local storage provider for HLS video.
|
||||||
@ -66,7 +66,8 @@ func (s *LocalStorage) Cleanup() error {
|
|||||||
// Determine how many files we should keep on disk
|
// Determine how many files we should keep on disk
|
||||||
maxNumber := data.GetStreamLatencyLevel().SegmentCount
|
maxNumber := data.GetStreamLatencyLevel().SegmentCount
|
||||||
buffer := 10
|
buffer := 10
|
||||||
baseDirectory := config.HLSStoragePath
|
c := config.GetConfig()
|
||||||
|
baseDirectory := c.HLSStoragePath
|
||||||
|
|
||||||
files, err := getAllFilesRecursive(baseDirectory)
|
files, err := getAllFilesRecursive(baseDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/grafov/m3u8"
|
"github.com/grafov/m3u8"
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
playlist "github.com/owncast/owncast/video/playlists"
|
playlist "github.com/owncast/owncast/video/playlists"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -34,8 +34,8 @@ func rewritePlaylistLocations(localFilePath, remoteServingEndpoint, pathPrefix s
|
|||||||
}
|
}
|
||||||
item.URI = remoteServingEndpoint + filepath.Join(finalPath, item.URI)
|
item.URI = remoteServingEndpoint + filepath.Join(finalPath, item.URI)
|
||||||
}
|
}
|
||||||
|
c := config.GetConfig()
|
||||||
publicPath := filepath.Join(config.HLSStoragePath, filepath.Base(localFilePath))
|
publicPath := filepath.Join(c.HLSStoragePath, filepath.Base(localFilePath))
|
||||||
|
|
||||||
newPlaylist := p.String()
|
newPlaylist := p.String()
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import (
|
|||||||
"github.com/aws/aws-sdk-go/service/s3"
|
"github.com/aws/aws-sdk-go/service/s3"
|
||||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// S3Storage is the s3 implementation of a storage provider.
|
// S3Storage is the s3 implementation of a storage provider.
|
||||||
@ -158,8 +158,10 @@ func (s *S3Storage) Save(filePath string, retryCount int) (string, error) {
|
|||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
// Convert the local path to the variant/file path by stripping the local storage location.
|
// Convert the local path to the variant/file path by stripping the local storage location.
|
||||||
normalizedPath := strings.TrimPrefix(filePath, config.HLSStoragePath)
|
normalizedPath := strings.TrimPrefix(filePath, c.HLSStoragePath)
|
||||||
// Build the remote path by adding the "hls" path prefix.
|
// Build the remote path by adding the "hls" path prefix.
|
||||||
remotePath := strings.Join([]string{"hls", normalizedPath}, "")
|
remotePath := strings.Join([]string{"hls", normalizedPath}, "")
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -42,8 +42,9 @@ func (s *FileWriterReceiverService) SetupFileWriterReceiverService(callbacks Fil
|
|||||||
log.Fatalln("Unable to start internal video writing service", err)
|
log.Fatalln("Unable to start internal video writing service", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
listenerPort := strings.Split(listener.Addr().String(), ":")[1]
|
listenerPort := strings.Split(listener.Addr().String(), ":")[1]
|
||||||
config.InternalHLSListenerPort = listenerPort
|
c.InternalHLSListenerPort = listenerPort
|
||||||
log.Traceln("Transcoder response service listening on: " + listenerPort)
|
log.Traceln("Transcoder response service listening on: " + listenerPort)
|
||||||
go func() {
|
go func() {
|
||||||
//nolint: gosec
|
//nolint: gosec
|
||||||
@ -59,8 +60,9 @@ func (s *FileWriterReceiverService) uploadHandler(w http.ResponseWriter, r *http
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
path := r.URL.Path
|
path := r.URL.Path
|
||||||
writePath := filepath.Join(config.HLSStoragePath, path)
|
writePath := filepath.Join(c.HLSStoragePath, path)
|
||||||
f, err := os.Create(writePath) //nolint: gosec
|
f, err := os.Create(writePath) //nolint: gosec
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnError(err, w)
|
returnError(err, w)
|
||||||
|
|||||||
@ -10,8 +10,8 @@ import (
|
|||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -52,9 +52,11 @@ func StartThumbnailGenerator(chunkPath string, variantIndex int, isVideoPassthro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
|
func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
// JPG takes less time to encode than PNG
|
// JPG takes less time to encode than PNG
|
||||||
outputFile := path.Join(config.TempDir, "thumbnail.jpg")
|
outputFile := path.Join(c.TempDir, "thumbnail.jpg")
|
||||||
previewGifFile := path.Join(config.TempDir, "preview.gif")
|
previewGifFile := path.Join(c.TempDir, "preview.gif")
|
||||||
|
|
||||||
framePath := path.Join(segmentPath, strconv.Itoa(variantIndex))
|
framePath := path.Join(segmentPath, strconv.Itoa(variantIndex))
|
||||||
files, err := os.ReadDir(framePath)
|
files, err := os.ReadDir(framePath)
|
||||||
@ -91,7 +93,7 @@ func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
|
|||||||
|
|
||||||
mostRecentFile := path.Join(framePath, names[0])
|
mostRecentFile := path.Join(framePath, names[0])
|
||||||
ffmpegPath := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
ffmpegPath := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
||||||
outputFileTemp := path.Join(config.TempDir, "tempthumbnail.jpg")
|
outputFileTemp := path.Join(c.TempDir, "tempthumbnail.jpg")
|
||||||
|
|
||||||
thumbnailCmdFlags := []string{
|
thumbnailCmdFlags := []string{
|
||||||
ffmpegPath,
|
ffmpegPath,
|
||||||
@ -120,8 +122,9 @@ func fireThumbnailGenerator(segmentPath string, variantIndex int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeAnimatedGifPreview(sourceFile string, outputFile string) {
|
func makeAnimatedGifPreview(sourceFile string, outputFile string) {
|
||||||
|
c := config.GetConfig()
|
||||||
ffmpegPath := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
ffmpegPath := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
||||||
outputFileTemp := path.Join(config.TempDir, "temppreview.gif")
|
outputFileTemp := path.Join(c.TempDir, "temppreview.gif")
|
||||||
|
|
||||||
// Filter is pulled from https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
|
// Filter is pulled from https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
|
||||||
animatedGifFlags := []string{
|
animatedGifFlags := []string{
|
||||||
|
|||||||
@ -11,10 +11,10 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/teris-io/shortid"
|
"github.com/teris-io/shortid"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/logging"
|
"github.com/owncast/owncast/logging"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -120,7 +120,9 @@ func (t *Transcoder) Start(shouldLog bool) {
|
|||||||
}
|
}
|
||||||
createVariantDirectories()
|
createVariantDirectories()
|
||||||
|
|
||||||
if config.EnableDebugFeatures {
|
c := config.GetConfig()
|
||||||
|
|
||||||
|
if c.EnableDebugFeatures {
|
||||||
log.Println(command)
|
log.Println(command)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,16 +276,17 @@ func getVariantFromConfigQuality(quality models.StreamOutputVariant, index int)
|
|||||||
// NewTranscoder will return a new Transcoder, populated by the config.
|
// NewTranscoder will return a new Transcoder, populated by the config.
|
||||||
func NewTranscoder() *Transcoder {
|
func NewTranscoder() *Transcoder {
|
||||||
ffmpegPath := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
ffmpegPath := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
transcoder := new(Transcoder)
|
transcoder := new(Transcoder)
|
||||||
transcoder.ffmpegPath = ffmpegPath
|
transcoder.ffmpegPath = ffmpegPath
|
||||||
transcoder.internalListenerPort = config.InternalHLSListenerPort
|
transcoder.internalListenerPort = c.InternalHLSListenerPort
|
||||||
|
|
||||||
transcoder.currentStreamOutputSettings = data.GetStreamOutputVariants()
|
transcoder.currentStreamOutputSettings = data.GetStreamOutputVariants()
|
||||||
transcoder.currentLatencyLevel = data.GetStreamLatencyLevel()
|
transcoder.currentLatencyLevel = data.GetStreamLatencyLevel()
|
||||||
transcoder.codec = getCodec(data.GetVideoCodec())
|
transcoder.codec = getCodec(data.GetVideoCodec())
|
||||||
transcoder.segmentOutputPath = config.HLSStoragePath
|
transcoder.segmentOutputPath = c.HLSStoragePath
|
||||||
transcoder.playlistOutputPath = config.HLSStoragePath
|
transcoder.playlistOutputPath = c.HLSStoragePath
|
||||||
|
|
||||||
transcoder.input = "pipe:0" // stdin
|
transcoder.input = "pipe:0" // stdin
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -97,17 +97,19 @@ func handleTranscoderMessage(message string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createVariantDirectories() {
|
func createVariantDirectories() {
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
// Create private hls data dirs
|
// Create private hls data dirs
|
||||||
utils.CleanupDirectory(config.HLSStoragePath)
|
utils.CleanupDirectory(c.HLSStoragePath)
|
||||||
|
|
||||||
if len(data.GetStreamOutputVariants()) != 0 {
|
if len(data.GetStreamOutputVariants()) != 0 {
|
||||||
for index := range data.GetStreamOutputVariants() {
|
for index := range data.GetStreamOutputVariants() {
|
||||||
if err := os.MkdirAll(path.Join(config.HLSStoragePath, strconv.Itoa(index)), 0o750); err != nil {
|
if err := os.MkdirAll(path.Join(c.HLSStoragePath, strconv.Itoa(index)), 0o750); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dir := path.Join(config.HLSStoragePath, strconv.Itoa(0))
|
dir := path.Join(c.HLSStoragePath, strconv.Itoa(0))
|
||||||
log.Traceln("Creating", dir)
|
log.Traceln("Creating", dir)
|
||||||
if err := os.MkdirAll(dir, 0o750); err != nil {
|
if err := os.MkdirAll(dir, 0o750); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/owncast/owncast/webserver/requests"
|
"github.com/owncast/owncast/webserver/requests"
|
||||||
"github.com/owncast/owncast/webserver/responses"
|
"github.com/owncast/owncast/webserver/responses"
|
||||||
@ -38,10 +38,11 @@ func (h *Handlers) UploadCustomEmoji(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prevent path traversal attacks
|
// Prevent path traversal attacks
|
||||||
|
c := config.GetConfig()
|
||||||
emojiFileName := filepath.Base(emoji.Name)
|
emojiFileName := filepath.Base(emoji.Name)
|
||||||
targetPath := filepath.Join(config.CustomEmojiPath, emojiFileName)
|
targetPath := filepath.Join(c.CustomEmojiPath, emojiFileName)
|
||||||
|
|
||||||
err = os.MkdirAll(config.CustomEmojiPath, 0o700)
|
err = os.MkdirAll(c.CustomEmojiPath, 0o700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responses.WriteSimpleResponse(w, false, err.Error())
|
responses.WriteSimpleResponse(w, false, err.Error())
|
||||||
return
|
return
|
||||||
@ -77,8 +78,8 @@ func (h *Handlers) DeleteCustomEmoji(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// var emojiFileName = filepath.Base(emoji.Name)
|
c := config.GetConfig()
|
||||||
targetPath := filepath.Join(config.CustomEmojiPath, emoji.Name)
|
targetPath := filepath.Join(c.CustomEmojiPath, emoji.Name)
|
||||||
|
|
||||||
if err := os.Remove(targetPath); err != nil {
|
if err := os.Remove(targetPath); err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
|||||||
@ -6,8 +6,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/models"
|
||||||
"github.com/owncast/owncast/core/user"
|
"github.com/owncast/owncast/services/config"
|
||||||
|
"github.com/owncast/owncast/storage"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/owncast/owncast/webserver/responses"
|
"github.com/owncast/owncast/webserver/responses"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -4,9 +4,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/owncast/owncast/video/transcoder"
|
"github.com/owncast/owncast/video/transcoder"
|
||||||
"github.com/owncast/owncast/webserver/middleware"
|
"github.com/owncast/owncast/webserver/middleware"
|
||||||
@ -18,6 +18,7 @@ func (h *Handlers) GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
ffmpeg := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
ffmpeg := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
||||||
usernameBlocklist := data.GetForbiddenUsernameList()
|
usernameBlocklist := data.GetForbiddenUsernameList()
|
||||||
usernameSuggestions := data.GetSuggestedUsernamesList()
|
usernameSuggestions := data.GetSuggestedUsernamesList()
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
videoQualityVariants := make([]models.StreamOutputVariant, 0)
|
videoQualityVariants := make([]models.StreamOutputVariant, 0)
|
||||||
for _, variant := range data.GetStreamOutputVariants() {
|
for _, variant := range data.GetStreamOutputVariants() {
|
||||||
@ -52,9 +53,9 @@ func (h *Handlers) GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
FFmpegPath: ffmpeg,
|
FFmpegPath: ffmpeg,
|
||||||
AdminPassword: data.GetAdminPassword(),
|
AdminPassword: data.GetAdminPassword(),
|
||||||
StreamKeys: data.GetStreamKeys(),
|
StreamKeys: data.GetStreamKeys(),
|
||||||
StreamKeyOverridden: config.TemporaryStreamKey != "",
|
StreamKeyOverridden: c.TemporaryStreamKey != "",
|
||||||
WebServerPort: config.WebServerPort,
|
WebServerPort: c.WebServerPort,
|
||||||
WebServerIP: config.WebServerIP,
|
WebServerIP: c.WebServerIP,
|
||||||
RTMPServerPort: data.GetRTMPPortNumber(),
|
RTMPServerPort: data.GetRTMPPortNumber(),
|
||||||
ChatDisabled: data.GetChatDisabled(),
|
ChatDisabled: data.GetChatDisabled(),
|
||||||
ChatJoinMessagesEnabled: data.GetChatJoinPartMessagesEnabled(),
|
ChatJoinMessagesEnabled: data.GetChatJoinPartMessagesEnabled(),
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/webserver/responses"
|
"github.com/owncast/owncast/webserver/responses"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -44,9 +44,11 @@ func (h *Handlers) AutoUpdateOptions(w http.ResponseWriter, r *http.Request) {
|
|||||||
CanRestart: false,
|
CanRestart: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
// Nothing is supported when running under "dev" or the feature is
|
// Nothing is supported when running under "dev" or the feature is
|
||||||
// explicitly disabled.
|
// explicitly disabled.
|
||||||
if config.BuildPlatform == "dev" || !config.EnableAutoUpdate {
|
if c.BuildPlatform == "dev" || !c.EnableAutoUpdate {
|
||||||
responses.WriteResponse(w, updateOptions)
|
responses.WriteResponse(w, updateOptions)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,9 +5,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/chat"
|
"github.com/owncast/owncast/core/chat"
|
||||||
"github.com/owncast/owncast/core/user"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
|
"github.com/owncast/owncast/storage"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/owncast/owncast/webserver/middleware"
|
"github.com/owncast/owncast/webserver/middleware"
|
||||||
"github.com/owncast/owncast/webserver/responses"
|
"github.com/owncast/owncast/webserver/responses"
|
||||||
|
|||||||
@ -7,9 +7,9 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/owncast/owncast/activitypub"
|
"github.com/owncast/owncast/activitypub"
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/owncast/owncast/webserver/middleware"
|
"github.com/owncast/owncast/webserver/middleware"
|
||||||
"github.com/owncast/owncast/webserver/responses"
|
"github.com/owncast/owncast/webserver/responses"
|
||||||
@ -118,13 +118,15 @@ func getConfigResponse() webConfigResponse {
|
|||||||
IndieAuthEnabled: data.GetServerURL() != "",
|
IndieAuthEnabled: data.GetServerURL() != "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
return webConfigResponse{
|
return webConfigResponse{
|
||||||
Name: data.GetServerName(),
|
Name: data.GetServerName(),
|
||||||
Summary: serverSummary,
|
Summary: serverSummary,
|
||||||
OfflineMessage: offlineMessage,
|
OfflineMessage: offlineMessage,
|
||||||
Logo: "/logo",
|
Logo: "/logo",
|
||||||
Tags: data.GetServerMetadataTags(),
|
Tags: data.GetServerMetadataTags(),
|
||||||
Version: config.GetReleaseString(),
|
Version: c.GetReleaseString(),
|
||||||
NSFW: data.GetNSFW(),
|
NSFW: data.GetNSFW(),
|
||||||
SocketHostOverride: data.GetWebsocketOverrideHost(),
|
SocketHostOverride: data.GetWebsocketOverrideHost(),
|
||||||
ExtraPageContent: pageContent,
|
ExtraPageContent: pageContent,
|
||||||
|
|||||||
@ -6,9 +6,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/router/middleware"
|
"github.com/owncast/owncast/router/middleware"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/webserver/responses"
|
"github.com/owncast/owncast/webserver/responses"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,7 +27,9 @@ func (h *Handlers) GetCustomEmojiImage(w http.ResponseWriter, r *http.Request) {
|
|||||||
path := strings.TrimPrefix(r.URL.Path, "/img/emoji/")
|
path := strings.TrimPrefix(r.URL.Path, "/img/emoji/")
|
||||||
r.URL.Path = path
|
r.URL.Path = path
|
||||||
|
|
||||||
emojiFS := os.DirFS(config.CustomEmojiPath)
|
c := config.GetConfig()
|
||||||
|
emojiFS := os.DirFS(c.CustomEmojiPath)
|
||||||
middleware.SetCachingHeaders(w, r)
|
middleware.SetCachingHeaders(w, r)
|
||||||
|
|
||||||
http.FileServer(http.FS(emojiFS)).ServeHTTP(w, r)
|
http.FileServer(http.FS(emojiFS)).ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,10 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core"
|
"github.com/owncast/owncast/core"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/owncast/owncast/webserver/middleware"
|
"github.com/owncast/owncast/webserver/middleware"
|
||||||
)
|
)
|
||||||
@ -23,9 +23,11 @@ func (h *Handlers) HandleHLSRequest(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
requestedPath := r.URL.Path
|
requestedPath := r.URL.Path
|
||||||
relativePath := strings.Replace(requestedPath, "/hls/", "", 1)
|
relativePath := strings.Replace(requestedPath, "/hls/", "", 1)
|
||||||
fullPath := filepath.Join(config.HLSStoragePath, relativePath)
|
fullPath := filepath.Join(c.HLSStoragePath, relativePath)
|
||||||
|
|
||||||
// If using external storage then only allow requests for the
|
// If using external storage then only allow requests for the
|
||||||
// master playlist at stream.m3u8, no variants or segments.
|
// master playlist at stream.m3u8, no variants or segments.
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/owncast/owncast/webserver/responses"
|
"github.com/owncast/owncast/webserver/responses"
|
||||||
)
|
)
|
||||||
@ -16,8 +16,9 @@ const (
|
|||||||
|
|
||||||
// GetThumbnail will return the thumbnail image as a response.
|
// GetThumbnail will return the thumbnail image as a response.
|
||||||
func (h *Handlers) GetThumbnail(w http.ResponseWriter, r *http.Request) {
|
func (h *Handlers) GetThumbnail(w http.ResponseWriter, r *http.Request) {
|
||||||
|
c := config.GetConfig()
|
||||||
imageFilename := "thumbnail.jpg"
|
imageFilename := "thumbnail.jpg"
|
||||||
imagePath := filepath.Join(config.TempDir, imageFilename)
|
imagePath := filepath.Join(c.TempDir, imageFilename)
|
||||||
|
|
||||||
var imageBytes []byte
|
var imageBytes []byte
|
||||||
var err error
|
var err error
|
||||||
@ -40,8 +41,9 @@ func (h *Handlers) GetThumbnail(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// GetPreview will return the preview gif as a response.
|
// GetPreview will return the preview gif as a response.
|
||||||
func (h *Handlers) GetPreview(w http.ResponseWriter, r *http.Request) {
|
func (h *Handlers) GetPreview(w http.ResponseWriter, r *http.Request) {
|
||||||
|
c := config.GetConfig()
|
||||||
imageFilename := "preview.gif"
|
imageFilename := "preview.gif"
|
||||||
imagePath := filepath.Join(config.TempDir, imageFilename)
|
imagePath := filepath.Join(c.TempDir, imageFilename)
|
||||||
|
|
||||||
var imageBytes []byte
|
var imageBytes []byte
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@ -5,8 +5,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
|
"github.com/owncast/owncast/services/config"
|
||||||
"github.com/owncast/owncast/static"
|
"github.com/owncast/owncast/static"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
"github.com/owncast/owncast/webserver/responses"
|
"github.com/owncast/owncast/webserver/responses"
|
||||||
|
|||||||
@ -4,10 +4,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/owncast/owncast/activitypub"
|
"github.com/owncast/owncast/activitypub"
|
||||||
"github.com/owncast/owncast/config"
|
|
||||||
"github.com/owncast/owncast/core/chat"
|
"github.com/owncast/owncast/core/chat"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/core/user"
|
"github.com/owncast/owncast/services/config"
|
||||||
|
"github.com/owncast/owncast/storage"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
fediverseauth "github.com/owncast/owncast/webserver/handlers/auth/fediverse"
|
fediverseauth "github.com/owncast/owncast/webserver/handlers/auth/fediverse"
|
||||||
"github.com/owncast/owncast/webserver/handlers/auth/indieauth"
|
"github.com/owncast/owncast/webserver/handlers/auth/indieauth"
|
||||||
@ -49,6 +49,8 @@ func (s *webServer) setupRoutes() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *webServer) setupWebAssetRoutes() {
|
func (s *webServer) setupWebAssetRoutes() {
|
||||||
|
c := config.GetConfig()
|
||||||
|
|
||||||
// The admin web app.
|
// The admin web app.
|
||||||
s.router.HandleFunc("/admin/", middleware.RequireAdminAuth(s.handlers.IndexHandler))
|
s.router.HandleFunc("/admin/", middleware.RequireAdminAuth(s.handlers.IndexHandler))
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ func (s *webServer) setupWebAssetRoutes() {
|
|||||||
s.router.HandleFunc("/robots.txt", s.handlers.GetRobotsDotTxt)
|
s.router.HandleFunc("/robots.txt", s.handlers.GetRobotsDotTxt)
|
||||||
|
|
||||||
// Optional public static files
|
// Optional public static files
|
||||||
s.router.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir(config.PublicFilesPath))))
|
s.router.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.Dir(c.PublicFilesPath))))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *webServer) setupInternalAPIRoutes() {
|
func (s *webServer) setupInternalAPIRoutes() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user