2020-10-02 09:06:14 +02:00
|
|
|
package admin
|
2020-10-02 09:02:42 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
|
2020-10-05 19:07:09 +02:00
|
|
|
"github.com/owncast/owncast/config"
|
2021-02-19 08:05:52 +01:00
|
|
|
"github.com/owncast/owncast/core/data"
|
2021-04-15 22:55:51 +02:00
|
|
|
"github.com/owncast/owncast/core/transcoder"
|
2021-02-19 08:05:52 +01:00
|
|
|
"github.com/owncast/owncast/models"
|
2021-11-17 05:58:03 +01:00
|
|
|
"github.com/owncast/owncast/router/middleware"
|
2021-02-19 08:05:52 +01:00
|
|
|
"github.com/owncast/owncast/utils"
|
2020-11-15 03:39:53 +01:00
|
|
|
log "github.com/sirupsen/logrus"
|
2020-10-02 09:02:42 +02:00
|
|
|
)
|
|
|
|
|
2020-11-13 00:14:59 +01:00
|
|
|
// GetServerConfig gets the config details of the server.
|
2020-10-02 09:02:42 +02:00
|
|
|
func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
2021-04-15 22:55:51 +02:00
|
|
|
ffmpeg := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
2021-07-20 04:22:29 +02:00
|
|
|
usernameBlocklist := data.GetForbiddenUsernameList()
|
2022-01-12 19:18:08 +01:00
|
|
|
usernameSuggestions := data.GetSuggestedUsernamesList()
|
2021-04-15 22:55:51 +02:00
|
|
|
|
2021-11-17 05:58:03 +01:00
|
|
|
videoQualityVariants := make([]models.StreamOutputVariant, 0)
|
2021-02-19 08:05:52 +01:00
|
|
|
for _, variant := range data.GetStreamOutputVariants() {
|
|
|
|
videoQualityVariants = append(videoQualityVariants, models.StreamOutputVariant{
|
2021-03-11 21:51:43 +01:00
|
|
|
Name: variant.GetName(),
|
2020-11-20 07:07:28 +01:00
|
|
|
IsAudioPassthrough: variant.GetIsAudioPassthrough(),
|
2020-10-26 17:14:05 +01:00
|
|
|
IsVideoPassthrough: variant.IsVideoPassthrough,
|
|
|
|
Framerate: variant.GetFramerate(),
|
|
|
|
VideoBitrate: variant.VideoBitrate,
|
|
|
|
AudioBitrate: variant.AudioBitrate,
|
2021-04-15 22:55:51 +02:00
|
|
|
CPUUsageLevel: variant.CPUUsageLevel,
|
2021-02-26 20:01:53 +01:00
|
|
|
ScaledWidth: variant.ScaledWidth,
|
|
|
|
ScaledHeight: variant.ScaledHeight,
|
2020-10-26 17:14:05 +01:00
|
|
|
})
|
|
|
|
}
|
2020-10-02 09:02:42 +02:00
|
|
|
response := serverConfigAdminResponse{
|
2021-02-19 08:05:52 +01:00
|
|
|
InstanceDetails: webConfigResponse{
|
|
|
|
Name: data.GetServerName(),
|
|
|
|
Summary: data.GetServerSummary(),
|
|
|
|
Tags: data.GetServerMetadataTags(),
|
|
|
|
ExtraPageContent: data.GetExtraPageBodyContent(),
|
|
|
|
StreamTitle: data.GetStreamTitle(),
|
2021-03-21 22:10:56 +01:00
|
|
|
WelcomeMessage: data.GetServerWelcomeMessage(),
|
2021-02-19 08:05:52 +01:00
|
|
|
Logo: data.GetLogoPath(),
|
|
|
|
SocialHandles: data.GetSocialHandles(),
|
|
|
|
NSFW: data.GetNSFW(),
|
2021-04-12 02:40:22 +02:00
|
|
|
CustomStyles: data.GetCustomStyles(),
|
2021-02-19 08:05:52 +01:00
|
|
|
},
|
2022-03-06 07:34:06 +01:00
|
|
|
FFmpegPath: ffmpeg,
|
|
|
|
StreamKey: data.GetStreamKey(),
|
|
|
|
WebServerPort: config.WebServerPort,
|
|
|
|
WebServerIP: config.WebServerIP,
|
|
|
|
RTMPServerPort: data.GetRTMPPortNumber(),
|
|
|
|
ChatDisabled: data.GetChatDisabled(),
|
|
|
|
ChatJoinMessagesEnabled: data.GetChatJoinMessagesEnabled(),
|
2022-03-07 02:11:51 +01:00
|
|
|
SocketHostOverride: data.GetWebsocketOverrideHost(),
|
2022-03-07 08:26:24 +01:00
|
|
|
ChatEstablishedUserMode: data.GetChatEstbalishedUsersOnlyMode(),
|
2022-06-26 09:46:55 +02:00
|
|
|
HideViewerCount: data.GetHideViewerCount(),
|
2020-10-02 09:02:42 +02:00
|
|
|
VideoSettings: videoSettings{
|
2021-02-19 08:05:52 +01:00
|
|
|
VideoQualityVariants: videoQualityVariants,
|
|
|
|
LatencyLevel: data.GetStreamLatencyLevel().Level,
|
|
|
|
},
|
|
|
|
YP: yp{
|
|
|
|
Enabled: data.GetDirectoryEnabled(),
|
|
|
|
InstanceURL: data.GetServerURL(),
|
2020-10-02 09:02:42 +02:00
|
|
|
},
|
2021-07-20 04:22:29 +02:00
|
|
|
S3: data.GetS3Config(),
|
|
|
|
ExternalActions: data.GetExternalActions(),
|
|
|
|
SupportedCodecs: transcoder.GetCodecs(ffmpeg),
|
|
|
|
VideoCodec: data.GetVideoCodec(),
|
|
|
|
ForbiddenUsernames: usernameBlocklist,
|
2022-01-12 19:18:08 +01:00
|
|
|
SuggestedUsernames: usernameSuggestions,
|
2022-01-12 22:53:10 +01:00
|
|
|
Federation: federationConfigResponse{
|
|
|
|
Enabled: data.GetFederationEnabled(),
|
|
|
|
IsPrivate: data.GetFederationIsPrivate(),
|
|
|
|
Username: data.GetFederationUsername(),
|
|
|
|
GoLiveMessage: data.GetFederationGoLiveMessage(),
|
|
|
|
ShowEngagement: data.GetFederationShowEngagement(),
|
|
|
|
BlockedDomains: data.GetBlockedFederatedDomains(),
|
|
|
|
},
|
2022-03-18 21:33:23 +01:00
|
|
|
Notifications: notificationsConfigResponse{
|
|
|
|
Discord: data.GetDiscordConfig(),
|
|
|
|
Browser: data.GetBrowserPushConfig(),
|
|
|
|
Twitter: data.GetTwitterConfiguration(),
|
|
|
|
},
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
2021-11-17 05:58:03 +01:00
|
|
|
middleware.DisableCache(w)
|
|
|
|
|
2021-07-09 20:16:44 +02:00
|
|
|
if err := json.NewEncoder(w).Encode(response); err != nil {
|
2020-11-15 03:39:53 +01:00
|
|
|
log.Errorln(err)
|
|
|
|
}
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type serverConfigAdminResponse struct {
|
2022-03-18 21:33:23 +01:00
|
|
|
InstanceDetails webConfigResponse `json:"instanceDetails"`
|
|
|
|
FFmpegPath string `json:"ffmpegPath"`
|
|
|
|
StreamKey string `json:"streamKey"`
|
|
|
|
WebServerPort int `json:"webServerPort"`
|
|
|
|
WebServerIP string `json:"webServerIP"`
|
|
|
|
RTMPServerPort int `json:"rtmpServerPort"`
|
|
|
|
S3 models.S3 `json:"s3"`
|
|
|
|
VideoSettings videoSettings `json:"videoSettings"`
|
|
|
|
YP yp `json:"yp"`
|
|
|
|
ChatDisabled bool `json:"chatDisabled"`
|
|
|
|
ChatJoinMessagesEnabled bool `json:"chatJoinMessagesEnabled"`
|
|
|
|
ChatEstablishedUserMode bool `json:"chatEstablishedUserMode"`
|
|
|
|
ExternalActions []models.ExternalAction `json:"externalActions"`
|
|
|
|
SupportedCodecs []string `json:"supportedCodecs"`
|
|
|
|
VideoCodec string `json:"videoCodec"`
|
|
|
|
ForbiddenUsernames []string `json:"forbiddenUsernames"`
|
|
|
|
Federation federationConfigResponse `json:"federation"`
|
|
|
|
SuggestedUsernames []string `json:"suggestedUsernames"`
|
|
|
|
SocketHostOverride string `json:"socketHostOverride,omitempty"`
|
|
|
|
Notifications notificationsConfigResponse `json:"notifications"`
|
2022-06-26 09:46:55 +02:00
|
|
|
HideViewerCount bool `json:"hideViewerCount"`
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type videoSettings struct {
|
2021-02-19 08:05:52 +01:00
|
|
|
VideoQualityVariants []models.StreamOutputVariant `json:"videoQualityVariants"`
|
|
|
|
LatencyLevel int `json:"latencyLevel"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type webConfigResponse struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Summary string `json:"summary"`
|
2021-03-21 22:10:56 +01:00
|
|
|
WelcomeMessage string `json:"welcomeMessage"`
|
2021-02-19 08:05:52 +01:00
|
|
|
Logo string `json:"logo"`
|
|
|
|
Tags []string `json:"tags"`
|
|
|
|
Version string `json:"version"`
|
|
|
|
NSFW bool `json:"nsfw"`
|
|
|
|
ExtraPageContent string `json:"extraPageContent"`
|
|
|
|
StreamTitle string `json:"streamTitle"` // What's going on with the current stream
|
|
|
|
SocialHandles []models.SocialHandle `json:"socialHandles"`
|
2021-04-12 02:40:22 +02:00
|
|
|
CustomStyles string `json:"customStyles"`
|
2021-02-19 08:05:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type yp struct {
|
|
|
|
Enabled bool `json:"enabled"`
|
|
|
|
InstanceURL string `json:"instanceUrl"` // The public URL the directory should link to
|
|
|
|
YPServiceURL string `json:"-"` // The base URL to the YP API to register with (optional)
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|
2022-01-12 22:53:10 +01:00
|
|
|
|
|
|
|
type federationConfigResponse struct {
|
|
|
|
Enabled bool `json:"enabled"`
|
|
|
|
IsPrivate bool `json:"isPrivate"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
GoLiveMessage string `json:"goLiveMessage"`
|
|
|
|
ShowEngagement bool `json:"showEngagement"`
|
|
|
|
BlockedDomains []string `json:"blockedDomains"`
|
|
|
|
}
|
2022-03-18 21:33:23 +01:00
|
|
|
|
|
|
|
type notificationsConfigResponse struct {
|
|
|
|
Browser models.BrowserNotificationConfiguration `json:"browser"`
|
|
|
|
Discord models.DiscordConfiguration `json:"discord"`
|
|
|
|
Twitter models.TwitterConfiguration `json:"twitter"`
|
|
|
|
}
|