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