2020-06-22 20:11:56 -05:00
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
|
2022-03-06 17:26:52 -08:00
|
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
2020-06-22 20:11:56 -05:00
|
|
|
log "github.com/sirupsen/logrus"
|
2022-04-07 11:43:26 -07:00
|
|
|
"golang.org/x/net/http2"
|
|
|
|
"golang.org/x/net/http2/h2c"
|
2020-06-22 20:11:56 -05:00
|
|
|
|
2022-01-12 13:53:10 -08:00
|
|
|
"github.com/owncast/owncast/activitypub"
|
2020-10-06 01:07:09 +08:00
|
|
|
"github.com/owncast/owncast/config"
|
|
|
|
"github.com/owncast/owncast/controllers"
|
|
|
|
"github.com/owncast/owncast/controllers/admin"
|
|
|
|
"github.com/owncast/owncast/core/chat"
|
2022-01-12 13:53:10 -08:00
|
|
|
"github.com/owncast/owncast/core/data"
|
2021-07-19 19:22:29 -07:00
|
|
|
"github.com/owncast/owncast/core/user"
|
2020-10-06 01:07:09 +08:00
|
|
|
"github.com/owncast/owncast/router/middleware"
|
2021-09-13 10:26:28 +02:00
|
|
|
"github.com/owncast/owncast/utils"
|
2020-10-06 01:07:09 +08:00
|
|
|
"github.com/owncast/owncast/yp"
|
2020-06-22 20:11:56 -05:00
|
|
|
)
|
|
|
|
|
2020-11-13 00:14:59 +01:00
|
|
|
// Start starts the router for the http, ws, and rtmp.
|
2020-06-22 20:11:56 -05:00
|
|
|
func Start() error {
|
|
|
|
// static files
|
|
|
|
http.HandleFunc("/", controllers.IndexHandler)
|
2022-01-12 13:53:10 -08:00
|
|
|
http.HandleFunc("/recordings", controllers.IndexHandler)
|
|
|
|
http.HandleFunc("/schedule", controllers.IndexHandler)
|
2020-06-22 20:11:56 -05:00
|
|
|
|
2020-11-06 15:12:35 -08:00
|
|
|
// admin static files
|
|
|
|
http.HandleFunc("/admin/", middleware.RequireAdminAuth(admin.ServeAdmin))
|
|
|
|
|
2020-06-22 20:11:56 -05:00
|
|
|
// status of the system
|
2020-09-14 16:15:53 -07:00
|
|
|
http.HandleFunc("/api/status", controllers.GetStatus)
|
2020-06-22 20:11:56 -05:00
|
|
|
|
2020-08-12 21:56:41 -07:00
|
|
|
// custom emoji supported in the chat
|
2020-09-14 16:15:53 -07:00
|
|
|
http.HandleFunc("/api/emoji", controllers.GetCustomEmoji)
|
2020-08-12 21:56:41 -07:00
|
|
|
|
2020-10-03 14:35:03 -07:00
|
|
|
// chat rest api
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/chat", middleware.RequireUserAccessToken(controllers.GetChatMessages))
|
2020-06-23 15:11:01 -05:00
|
|
|
|
2020-10-03 14:35:03 -07:00
|
|
|
// web config api
|
|
|
|
http.HandleFunc("/api/config", controllers.GetWebConfig)
|
2020-08-30 16:32:09 -07:00
|
|
|
|
2021-08-01 01:21:30 +02:00
|
|
|
// pre v0.0.8 chat embed
|
|
|
|
http.HandleFunc("/embed/chat", controllers.GetChatEmbedreadonly)
|
|
|
|
|
|
|
|
// readonly chat embed
|
|
|
|
http.HandleFunc("/embed/chat/readonly", controllers.GetChatEmbedreadonly)
|
|
|
|
|
|
|
|
// readwrite chat embed
|
|
|
|
http.HandleFunc("/embed/chat/readwrite", controllers.GetChatEmbedreadwrite)
|
2020-08-30 16:32:09 -07:00
|
|
|
|
2020-10-03 14:35:03 -07:00
|
|
|
// video embed
|
|
|
|
http.HandleFunc("/embed/video", controllers.GetVideoEmbed)
|
2020-10-01 23:55:38 -07:00
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// return the YP protocol data
|
2020-10-03 14:35:03 -07:00
|
|
|
http.HandleFunc("/api/yp", yp.GetYPResponse)
|
2020-06-28 15:10:00 -07:00
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// list of all social platforms
|
|
|
|
http.HandleFunc("/api/socialplatforms", controllers.GetAllSocialPlatforms)
|
|
|
|
|
|
|
|
// return the logo
|
|
|
|
http.HandleFunc("/logo", controllers.GetLogo)
|
|
|
|
|
2021-08-27 16:20:16 -07:00
|
|
|
// return a logo that's compatible with external social networks
|
|
|
|
http.HandleFunc("/logo/external", controllers.GetCompatibleLogo)
|
|
|
|
|
2021-03-11 12:51:43 -08:00
|
|
|
// return the list of video variants available
|
|
|
|
http.HandleFunc("/api/video/variants", controllers.GetVideoStreamOutputVariants)
|
|
|
|
|
2021-06-20 17:26:35 -07:00
|
|
|
// tell the backend you're an active viewer
|
|
|
|
http.HandleFunc("/api/ping", controllers.Ping)
|
|
|
|
|
2021-07-19 19:22:29 -07:00
|
|
|
// register a new chat user
|
|
|
|
http.HandleFunc("/api/chat/register", controllers.RegisterAnonymousChatUser)
|
|
|
|
|
2022-01-12 13:53:10 -08:00
|
|
|
// return remote follow details
|
|
|
|
http.HandleFunc("/api/remotefollow", controllers.RemoteFollow)
|
|
|
|
|
|
|
|
// return followers
|
2022-03-06 17:18:51 -08:00
|
|
|
http.HandleFunc("/api/followers", middleware.HandlePagination(controllers.GetFollowers))
|
2022-01-12 13:53:10 -08:00
|
|
|
|
2022-03-16 17:34:44 -07:00
|
|
|
// save client video playback metrics
|
|
|
|
http.HandleFunc("/api/metrics/playback", controllers.ReportPlaybackMetrics)
|
|
|
|
|
2022-03-18 13:33:23 -07:00
|
|
|
// Register for notifications
|
|
|
|
http.HandleFunc("/api/notifications/register", middleware.RequireUserAccessToken(controllers.RegisterForLiveNotifications))
|
|
|
|
|
2020-10-01 18:16:58 -07:00
|
|
|
// Authenticated admin requests
|
|
|
|
|
2020-10-02 00:12:47 -07:00
|
|
|
// Current inbound broadcaster
|
2020-11-05 18:29:16 -08:00
|
|
|
http.HandleFunc("/api/admin/status", middleware.RequireAdminAuth(admin.Status))
|
2020-10-02 00:12:47 -07:00
|
|
|
|
2021-09-12 11:32:42 -07:00
|
|
|
// Return HLS video
|
|
|
|
http.HandleFunc("/hls/", controllers.HandleHLSRequest)
|
|
|
|
|
2020-10-01 18:16:58 -07:00
|
|
|
// Disconnect inbound stream
|
2020-10-01 23:17:27 -07:00
|
|
|
http.HandleFunc("/api/admin/disconnect", middleware.RequireAdminAuth(admin.DisconnectInboundConnection))
|
|
|
|
|
2020-10-02 00:02:42 -07:00
|
|
|
// Server config
|
2020-10-02 00:06:14 -07:00
|
|
|
http.HandleFunc("/api/admin/serverconfig", middleware.RequireAdminAuth(admin.GetServerConfig))
|
|
|
|
|
|
|
|
// Get viewer count over time
|
|
|
|
http.HandleFunc("/api/admin/viewersOverTime", middleware.RequireAdminAuth(admin.GetViewersOverTime))
|
2020-10-02 00:02:42 -07:00
|
|
|
|
2022-03-06 17:31:47 -08:00
|
|
|
// Get active viewers
|
|
|
|
http.HandleFunc("/api/admin/viewers", middleware.RequireAdminAuth(admin.GetActiveViewers))
|
|
|
|
|
2020-10-02 12:18:08 -07:00
|
|
|
// Get hardware stats
|
|
|
|
http.HandleFunc("/api/admin/hardwarestats", middleware.RequireAdminAuth(admin.GetHardwareStats))
|
|
|
|
|
2021-07-21 17:19:15 -07:00
|
|
|
// Get a a detailed list of currently connected chat clients
|
|
|
|
http.HandleFunc("/api/admin/chat/clients", middleware.RequireAdminAuth(admin.GetConnectedChatClients))
|
2020-10-06 23:14:33 -07:00
|
|
|
|
2020-10-29 18:17:04 -07:00
|
|
|
// Get all logs
|
|
|
|
http.HandleFunc("/api/admin/logs", middleware.RequireAdminAuth(admin.GetLogs))
|
|
|
|
|
|
|
|
// Get warning/error logs
|
|
|
|
http.HandleFunc("/api/admin/logs/warnings", middleware.RequireAdminAuth(admin.GetWarnings))
|
|
|
|
|
2020-12-29 13:35:33 -08:00
|
|
|
// Get all chat messages for the admin, unfiltered.
|
|
|
|
http.HandleFunc("/api/admin/chat/messages", middleware.RequireAdminAuth(admin.GetChatMessages))
|
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// Update chat message visibility
|
2020-12-29 13:35:33 -08:00
|
|
|
http.HandleFunc("/api/admin/chat/updatemessagevisibility", middleware.RequireAdminAuth(admin.UpdateMessageVisibility))
|
2021-07-19 19:22:29 -07:00
|
|
|
|
|
|
|
// Enable/disable a user
|
|
|
|
http.HandleFunc("/api/admin/chat/users/setenabled", middleware.RequireAdminAuth(admin.UpdateUserEnabled))
|
|
|
|
|
2022-03-06 20:34:49 -08:00
|
|
|
// Ban/unban an IP address
|
|
|
|
http.HandleFunc("/api/admin/chat/users/ipbans/create", middleware.RequireAdminAuth(admin.BanIPAddress))
|
|
|
|
|
|
|
|
// Remove an IP address ban
|
|
|
|
http.HandleFunc("/api/admin/chat/users/ipbans/remove", middleware.RequireAdminAuth(admin.UnBanIPAddress))
|
|
|
|
|
|
|
|
// Return all the banned IP addresses
|
|
|
|
http.HandleFunc("/api/admin/chat/users/ipbans", middleware.RequireAdminAuth(admin.GetIPAddressBans))
|
|
|
|
|
2021-07-19 19:22:29 -07:00
|
|
|
// Get a list of disabled users
|
|
|
|
http.HandleFunc("/api/admin/chat/users/disabled", middleware.RequireAdminAuth(admin.GetDisabledUsers))
|
|
|
|
|
2021-11-02 19:27:41 -07:00
|
|
|
// Set moderator status for a user
|
|
|
|
http.HandleFunc("/api/admin/chat/users/setmoderator", middleware.RequireAdminAuth(admin.UpdateUserModerator))
|
|
|
|
|
|
|
|
// Get a list of moderator users
|
|
|
|
http.HandleFunc("/api/admin/chat/users/moderators", middleware.RequireAdminAuth(admin.GetModerators))
|
|
|
|
|
2022-01-12 13:53:10 -08:00
|
|
|
// return followers
|
2022-03-06 17:18:51 -08:00
|
|
|
http.HandleFunc("/api/admin/followers", middleware.RequireAdminAuth(middleware.HandlePagination(controllers.GetFollowers)))
|
2022-01-12 13:53:10 -08:00
|
|
|
|
|
|
|
// Get a list of pending follow requests
|
|
|
|
http.HandleFunc("/api/admin/followers/pending", middleware.RequireAdminAuth(admin.GetPendingFollowRequests))
|
|
|
|
|
|
|
|
// Get a list of rejected or blocked follows
|
|
|
|
http.HandleFunc("/api/admin/followers/blocked", middleware.RequireAdminAuth(admin.GetBlockedAndRejectedFollowers))
|
|
|
|
|
|
|
|
// Set the following state of a follower or follow request.
|
|
|
|
http.HandleFunc("/api/admin/followers/approve", middleware.RequireAdminAuth(admin.ApproveFollower))
|
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// Update config values
|
|
|
|
|
|
|
|
// Change the current streaming key in memory
|
|
|
|
http.HandleFunc("/api/admin/config/key", middleware.RequireAdminAuth(admin.SetStreamKey))
|
|
|
|
|
|
|
|
// Change the extra page content in memory
|
|
|
|
http.HandleFunc("/api/admin/config/pagecontent", middleware.RequireAdminAuth(admin.SetExtraPageContent))
|
|
|
|
|
|
|
|
// Stream title
|
|
|
|
http.HandleFunc("/api/admin/config/streamtitle", middleware.RequireAdminAuth(admin.SetStreamTitle))
|
|
|
|
|
|
|
|
// Server name
|
|
|
|
http.HandleFunc("/api/admin/config/name", middleware.RequireAdminAuth(admin.SetServerName))
|
|
|
|
|
|
|
|
// Server summary
|
|
|
|
http.HandleFunc("/api/admin/config/serversummary", middleware.RequireAdminAuth(admin.SetServerSummary))
|
|
|
|
|
2021-03-21 17:10:56 -04:00
|
|
|
// Server welcome message
|
|
|
|
http.HandleFunc("/api/admin/config/welcomemessage", middleware.RequireAdminAuth(admin.SetServerWelcomeMessage))
|
|
|
|
|
2021-03-14 11:46:27 -07:00
|
|
|
// Disable chat
|
|
|
|
http.HandleFunc("/api/admin/config/chat/disable", middleware.RequireAdminAuth(admin.SetChatDisabled))
|
|
|
|
|
2022-03-05 22:34:06 -08:00
|
|
|
// Disable chat user join messages
|
|
|
|
http.HandleFunc("/api/admin/config/chat/joinmessagesenabled", middleware.RequireAdminAuth(admin.SetChatJoinMessagesEnabled))
|
|
|
|
|
2022-03-06 23:26:24 -08:00
|
|
|
// Enable/disable chat established user mode
|
|
|
|
http.HandleFunc("/api/admin/config/chat/establishedusermode", middleware.RequireAdminAuth(admin.SetEnableEstablishedChatUserMode))
|
|
|
|
|
2021-06-21 20:16:21 -07:00
|
|
|
// Set chat usernames that are not allowed
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/admin/config/chat/forbiddenusernames", middleware.RequireAdminAuth(admin.SetForbiddenUsernameList))
|
2021-06-21 20:16:21 -07:00
|
|
|
|
2022-01-12 19:18:08 +01:00
|
|
|
// Set the suggested chat usernames that will be assigned automatically
|
|
|
|
http.HandleFunc("/api/admin/config/chat/suggestedusernames", middleware.RequireAdminAuth(admin.SetSuggestedUsernameList))
|
|
|
|
|
2021-04-15 13:55:51 -07:00
|
|
|
// Set video codec
|
|
|
|
http.HandleFunc("/api/admin/config/video/codec", middleware.RequireAdminAuth(admin.SetVideoCodec))
|
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// Return all webhooks
|
|
|
|
http.HandleFunc("/api/admin/webhooks", middleware.RequireAdminAuth(admin.GetWebhooks))
|
|
|
|
|
|
|
|
// Delete a single webhook
|
|
|
|
http.HandleFunc("/api/admin/webhooks/delete", middleware.RequireAdminAuth(admin.DeleteWebhook))
|
|
|
|
|
|
|
|
// Create a single webhook
|
|
|
|
http.HandleFunc("/api/admin/webhooks/create", middleware.RequireAdminAuth(admin.CreateWebhook))
|
|
|
|
|
|
|
|
// Get all access tokens
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/admin/accesstokens", middleware.RequireAdminAuth(admin.GetExternalAPIUsers))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
|
|
|
// Delete a single access token
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/admin/accesstokens/delete", middleware.RequireAdminAuth(admin.DeleteExternalAPIUser))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
|
|
|
// Create a single access token
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/admin/accesstokens/create", middleware.RequireAdminAuth(admin.CreateExternalAPIUser))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
2021-11-30 13:15:18 -08:00
|
|
|
// Return the auto-update features that are supported for this instance.
|
|
|
|
http.HandleFunc("/api/admin/update/options", middleware.RequireAdminAuth(admin.AutoUpdateOptions))
|
|
|
|
|
|
|
|
// Begin the auto update
|
|
|
|
http.HandleFunc("/api/admin/update/start", middleware.RequireAdminAuth(admin.AutoUpdateStart))
|
|
|
|
|
|
|
|
// Force quit the service to restart it
|
|
|
|
http.HandleFunc("/api/admin/update/forcequit", middleware.RequireAdminAuth(admin.AutoUpdateForceQuit))
|
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// Send a system message to chat
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/integrations/chat/system", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendSystemMessage))
|
|
|
|
|
2021-09-13 10:26:28 +02:00
|
|
|
// Send a system message to a single client
|
|
|
|
http.HandleFunc(utils.RestEndpoint("/api/integrations/chat/system/client/{clientId}", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendSystemMessageToConnectedClient)))
|
|
|
|
|
2021-07-19 19:22:29 -07:00
|
|
|
// Send a user message to chat *NO LONGER SUPPORTED
|
|
|
|
http.HandleFunc("/api/integrations/chat/user", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendChatMessages, admin.SendUserMessage))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
2021-07-19 19:22:29 -07:00
|
|
|
// Send a message to chat as a specific 3rd party bot/integration based on its access token
|
|
|
|
http.HandleFunc("/api/integrations/chat/send", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendChatMessages, admin.SendIntegrationChatMessage))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
|
|
|
// Send a user action to chat
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/integrations/chat/action", middleware.RequireExternalAPIAccessToken(user.ScopeCanSendSystemMessages, admin.SendChatAction))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
|
|
|
// Hide chat message
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/integrations/chat/messagevisibility", middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalUpdateMessageVisibility))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
|
|
|
// Stream title
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/integrations/streamtitle", middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalSetStreamTitle))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
|
|
|
// Get chat history
|
2021-07-19 19:22:29 -07:00
|
|
|
http.HandleFunc("/api/integrations/chat", middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, controllers.ExternalGetChatMessages))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
|
|
|
// Connected clients
|
2021-07-21 17:19:15 -07:00
|
|
|
http.HandleFunc("/api/integrations/clients", middleware.RequireExternalAPIAccessToken(user.ScopeHasAdminAccess, admin.ExternalGetConnectedChatClients))
|
2021-03-15 15:32:52 -07:00
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// Logo path
|
2021-03-21 19:07:10 -04:00
|
|
|
http.HandleFunc("/api/admin/config/logo", middleware.RequireAdminAuth(admin.SetLogo))
|
2021-02-18 23:05:52 -08:00
|
|
|
|
|
|
|
// Server tags
|
|
|
|
http.HandleFunc("/api/admin/config/tags", middleware.RequireAdminAuth(admin.SetTags))
|
|
|
|
|
|
|
|
// ffmpeg
|
|
|
|
http.HandleFunc("/api/admin/config/ffmpegpath", middleware.RequireAdminAuth(admin.SetFfmpegPath))
|
|
|
|
|
|
|
|
// Server http port
|
|
|
|
http.HandleFunc("/api/admin/config/webserverport", middleware.RequireAdminAuth(admin.SetWebServerPort))
|
|
|
|
|
2021-05-25 01:13:49 +02:00
|
|
|
// Server http listen address
|
|
|
|
http.HandleFunc("/api/admin/config/webserverip", middleware.RequireAdminAuth(admin.SetWebServerIP))
|
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// Server rtmp port
|
|
|
|
http.HandleFunc("/api/admin/config/rtmpserverport", middleware.RequireAdminAuth(admin.SetRTMPServerPort))
|
|
|
|
|
2022-03-06 17:11:51 -08:00
|
|
|
// Websocket host override
|
|
|
|
http.HandleFunc("/api/admin/config/sockethostoverride", middleware.RequireAdminAuth(admin.SetSocketHostOverride))
|
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
// Is server marked as NSFW
|
|
|
|
http.HandleFunc("/api/admin/config/nsfw", middleware.RequireAdminAuth(admin.SetNSFW))
|
|
|
|
|
|
|
|
// directory enabled
|
|
|
|
http.HandleFunc("/api/admin/config/directoryenabled", middleware.RequireAdminAuth(admin.SetDirectoryEnabled))
|
|
|
|
|
|
|
|
// social handles
|
|
|
|
http.HandleFunc("/api/admin/config/socialhandles", middleware.RequireAdminAuth(admin.SetSocialHandles))
|
|
|
|
|
|
|
|
// set the number of video segments and duration per segment in a playlist
|
|
|
|
http.HandleFunc("/api/admin/config/video/streamlatencylevel", middleware.RequireAdminAuth(admin.SetStreamLatencyLevel))
|
|
|
|
|
|
|
|
// set an array of video output configurations
|
|
|
|
http.HandleFunc("/api/admin/config/video/streamoutputvariants", middleware.RequireAdminAuth(admin.SetStreamOutputVariants))
|
|
|
|
|
|
|
|
// set s3 configuration
|
|
|
|
http.HandleFunc("/api/admin/config/s3", middleware.RequireAdminAuth(admin.SetS3Configuration))
|
|
|
|
|
|
|
|
// set server url
|
|
|
|
http.HandleFunc("/api/admin/config/serverurl", middleware.RequireAdminAuth(admin.SetServerURL))
|
|
|
|
|
|
|
|
// reset the YP registration
|
|
|
|
http.HandleFunc("/api/admin/yp/reset", middleware.RequireAdminAuth(admin.ResetYPRegistration))
|
2020-12-29 13:35:33 -08:00
|
|
|
|
2021-03-15 15:32:52 -07:00
|
|
|
// set external action links
|
|
|
|
http.HandleFunc("/api/admin/config/externalactions", middleware.RequireAdminAuth(admin.SetExternalActions))
|
|
|
|
|
2021-04-11 17:40:22 -07:00
|
|
|
// set custom style css
|
2021-04-11 17:51:00 -07:00
|
|
|
http.HandleFunc("/api/admin/config/customstyles", middleware.RequireAdminAuth(admin.SetCustomStyles))
|
2021-04-11 17:40:22 -07:00
|
|
|
|
2022-03-16 17:34:44 -07:00
|
|
|
// Video playback metrics
|
|
|
|
http.HandleFunc("/api/admin/metrics/video", middleware.RequireAdminAuth(admin.GetVideoPlaybackMetrics))
|
|
|
|
|
2021-11-02 19:27:41 -07:00
|
|
|
// Inline chat moderation actions
|
|
|
|
|
|
|
|
// Update chat message visibility
|
|
|
|
http.HandleFunc("/api/chat/updatemessagevisibility", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateMessageVisibility))
|
|
|
|
|
|
|
|
// Enable/disable a user
|
|
|
|
http.HandleFunc("/api/chat/users/setenabled", middleware.RequireUserModerationScopeAccesstoken(admin.UpdateUserEnabled))
|
2022-01-18 15:38:23 -08:00
|
|
|
|
2022-01-12 13:53:10 -08:00
|
|
|
// Configure Federation features
|
|
|
|
|
|
|
|
// enable/disable federation features
|
|
|
|
http.HandleFunc("/api/admin/config/federation/enable", middleware.RequireAdminAuth(admin.SetFederationEnabled))
|
|
|
|
|
|
|
|
// set if federation activities are private
|
|
|
|
http.HandleFunc("/api/admin/config/federation/private", middleware.RequireAdminAuth(admin.SetFederationActivityPrivate))
|
|
|
|
|
|
|
|
// set if fediverse engagement appears in chat
|
|
|
|
http.HandleFunc("/api/admin/config/federation/showengagement", middleware.RequireAdminAuth(admin.SetFederationShowEngagement))
|
|
|
|
|
|
|
|
// set local federated username
|
|
|
|
http.HandleFunc("/api/admin/config/federation/username", middleware.RequireAdminAuth(admin.SetFederationUsername))
|
|
|
|
|
|
|
|
// set federated go live message
|
|
|
|
http.HandleFunc("/api/admin/config/federation/livemessage", middleware.RequireAdminAuth(admin.SetFederationGoLiveMessage))
|
|
|
|
|
|
|
|
// Federation blocked domains
|
|
|
|
http.HandleFunc("/api/admin/config/federation/blockdomains", middleware.RequireAdminAuth(admin.SetFederationBlockDomains))
|
|
|
|
|
|
|
|
// send a public message to the Fediverse from the server's user
|
|
|
|
http.HandleFunc("/api/admin/federation/send", middleware.RequireAdminAuth(admin.SendFederatedMessage))
|
|
|
|
|
|
|
|
// Return federated activities
|
2022-03-06 17:18:51 -08:00
|
|
|
http.HandleFunc("/api/admin/federation/actions", middleware.RequireAdminAuth(middleware.HandlePagination(admin.GetFederatedActions)))
|
2022-01-12 13:53:10 -08:00
|
|
|
|
2022-03-06 17:26:52 -08:00
|
|
|
// Prometheus metrics
|
|
|
|
http.Handle("/api/admin/prometheus", middleware.RequireAdminAuth(func(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
promhttp.Handler().ServeHTTP(rw, r)
|
|
|
|
}))
|
|
|
|
|
2022-03-18 13:33:23 -07:00
|
|
|
// Configure outbound notification channels.
|
|
|
|
http.HandleFunc("/api/admin/config/notifications/discord", middleware.RequireAdminAuth(admin.SetDiscordNotificationConfiguration))
|
|
|
|
http.HandleFunc("/api/admin/config/notifications/browser", middleware.RequireAdminAuth(admin.SetBrowserNotificationConfiguration))
|
|
|
|
http.HandleFunc("/api/admin/config/notifications/twitter", middleware.RequireAdminAuth(admin.SetTwitterConfiguration))
|
|
|
|
|
2022-01-12 13:53:10 -08:00
|
|
|
// ActivityPub has its own router
|
|
|
|
activitypub.Start(data.GetDatastore())
|
2021-11-02 19:27:41 -07:00
|
|
|
|
2021-07-19 19:22:29 -07:00
|
|
|
// websocket
|
|
|
|
http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
chat.HandleClientConnection(w, r)
|
|
|
|
})
|
|
|
|
|
2021-02-18 23:05:52 -08:00
|
|
|
port := config.WebServerPort
|
2021-05-25 01:13:49 +02:00
|
|
|
ip := config.WebServerIP
|
2020-06-22 20:11:56 -05:00
|
|
|
|
2022-04-07 11:43:26 -07:00
|
|
|
h2s := &http2.Server{}
|
|
|
|
server := &http.Server{
|
|
|
|
Addr: fmt.Sprintf("%s:%d", ip, port),
|
|
|
|
Handler: h2c.NewHandler(http.DefaultServeMux, h2s),
|
|
|
|
}
|
|
|
|
|
2021-10-09 13:23:48 -07:00
|
|
|
log.Infof("Web server is listening on IP %s port %d.", ip, port)
|
2021-02-26 13:23:15 -06:00
|
|
|
log.Infoln("The web admin interface is available at /admin.")
|
2020-06-22 20:11:56 -05:00
|
|
|
|
2022-04-07 11:43:26 -07:00
|
|
|
return server.ListenAndServe()
|
2020-06-22 20:11:56 -05:00
|
|
|
}
|