2023-06-10 03:29:02 +03:00
|
|
|
package handlers
|
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"
|
|
|
|
"github.com/owncast/owncast/models"
|
|
|
|
"github.com/owncast/owncast/utils"
|
2023-06-15 03:36:55 +03:00
|
|
|
"github.com/owncast/owncast/video/transcoder"
|
2023-06-09 23:25:04 +03:00
|
|
|
"github.com/owncast/owncast/webserver/middleware"
|
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.
|
2023-06-10 03:29:02 +03:00
|
|
|
func (h *Handlers) 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{
|
2023-06-10 03:29:02 +03:00
|
|
|
InstanceDetails: adminWebConfigResponse{
|
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(),
|
2023-09-10 20:58:11 +03:00
|
|
|
ChatJoinMessagesEnabled: data.GetChatJoinPartMessagesEnabled(),
|
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,
|
2023-06-10 03:29:02 +03:00
|
|
|
Federation: adminFederationConfigResponse{
|
2022-01-13 00:53:10 +03:00
|
|
|
Enabled: data.GetFederationEnabled(),
|
|
|
|
IsPrivate: data.GetFederationIsPrivate(),
|
|
|
|
Username: data.GetFederationUsername(),
|
|
|
|
GoLiveMessage: data.GetFederationGoLiveMessage(),
|
|
|
|
ShowEngagement: data.GetFederationShowEngagement(),
|
|
|
|
BlockedDomains: data.GetBlockedFederatedDomains(),
|
|
|
|
},
|
2023-06-10 03:29:02 +03:00
|
|
|
Notifications: adminNotificationsConfigResponse{
|
2022-03-18 23:33:23 +03:00
|
|
|
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 {
|
2023-06-10 03:29:02 +03:00
|
|
|
InstanceDetails adminWebConfigResponse `json:"instanceDetails"`
|
|
|
|
Notifications adminNotificationsConfigResponse `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 adminFederationConfigResponse `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"`
|
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
2023-06-10 03:29:02 +03:00
|
|
|
type adminWebConfigResponse 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
|
|
|
|
2023-06-10 03:29:02 +03:00
|
|
|
type adminFederationConfigResponse struct {
|
2022-01-13 00:53:10 +03:00
|
|
|
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
|
|
|
|
2023-06-10 03:29:02 +03:00
|
|
|
type adminNotificationsConfigResponse struct {
|
2022-03-18 23:33:23 +03:00
|
|
|
Browser models.BrowserNotificationConfiguration `json:"browser"`
|
|
|
|
Discord models.DiscordConfiguration `json:"discord"`
|
|
|
|
}
|