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
|
|
|
},
|
2024-04-10 08:25:41 +03:00
|
|
|
FFmpegPath: ffmpeg,
|
|
|
|
AdminPassword: data.GetAdminPassword(),
|
|
|
|
StreamKeys: data.GetStreamKeys(),
|
|
|
|
StreamKeyOverridden: config.TemporaryStreamKey != "",
|
|
|
|
WebServerPort: config.WebServerPort,
|
|
|
|
WebServerIP: config.WebServerIP,
|
|
|
|
RTMPServerPort: data.GetRTMPPortNumber(),
|
|
|
|
ChatDisabled: data.GetChatDisabled(),
|
|
|
|
ChatJoinMessagesEnabled: data.GetChatJoinPartMessagesEnabled(),
|
|
|
|
SocketHostOverride: data.GetWebsocketOverrideHost(),
|
|
|
|
VideoServingEndpoint: data.GetVideoServingEndpoint(),
|
|
|
|
ChatEstablishedUserMode: data.GetChatEstbalishedUsersOnlyMode(),
|
|
|
|
ChatSpamProtectionEnabled: data.GetChatSpamProtectionEnabled(),
|
|
|
|
ChatSlurFilterEnabled: data.GetChatSlurFilterEnabled(),
|
|
|
|
HideViewerCount: data.GetHideViewerCount(),
|
|
|
|
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 {
|
2024-04-10 08:25:41 +03:00
|
|
|
InstanceDetails webConfigResponse `json:"instanceDetails"`
|
|
|
|
Notifications notificationsConfigResponse `json:"notifications"`
|
|
|
|
YP yp `json:"yp"`
|
|
|
|
FFmpegPath string `json:"ffmpegPath"`
|
|
|
|
AdminPassword string `json:"adminPassword"`
|
|
|
|
SocketHostOverride string `json:"socketHostOverride,omitempty"`
|
|
|
|
WebServerIP string `json:"webServerIP"`
|
|
|
|
VideoCodec string `json:"videoCodec"`
|
|
|
|
VideoServingEndpoint string `json:"videoServingEndpoint"`
|
|
|
|
S3 models.S3 `json:"s3"`
|
|
|
|
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"`
|
|
|
|
VideoSettings videoSettings `json:"videoSettings"`
|
|
|
|
RTMPServerPort int `json:"rtmpServerPort"`
|
|
|
|
WebServerPort int `json:"webServerPort"`
|
|
|
|
ChatDisabled bool `json:"chatDisabled"`
|
|
|
|
ChatJoinMessagesEnabled bool `json:"chatJoinMessagesEnabled"`
|
|
|
|
ChatEstablishedUserMode bool `json:"chatEstablishedUserMode"`
|
|
|
|
ChatSpamProtectionEnabled bool `json:"chatSpamProtectionEnabled"`
|
|
|
|
ChatSlurFilterEnabled bool `json:"chatSlurFilterEnabled"`
|
|
|
|
DisableSearchIndexing bool `json:"disableSearchIndexing"`
|
|
|
|
StreamKeyOverridden bool `json:"streamKeyOverridden"`
|
|
|
|
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"`
|
|
|
|
}
|