Include available features in header of backend requests to Nextcloud.

The header "X-Spreed-Signaling-Features" will contain a comma-separated list
of feature flags.
This commit is contained in:
Joachim Bauch 2021-10-28 09:25:08 +02:00
parent 2f8e7f9f66
commit a05acc9cb4
No known key found for this signature in database
GPG Key ID: 77C1D22D53E15F02
2 changed files with 5 additions and 0 deletions

View File

@ -56,6 +56,7 @@ const (
)
type BackendClient struct {
hub *Hub
transport *http.Transport
version string
backends *BackendConfiguration
@ -342,6 +343,9 @@ func (b *BackendClient) PerformJSONRequest(ctx context.Context, u *url.URL, requ
req.Header.Set("Accept", "application/json")
req.Header.Set("OCS-APIRequest", "true")
req.Header.Set("User-Agent", "nextcloud-spreed-signaling/"+b.version)
if b.hub != nil {
req.Header.Set("X-Spreed-Signaling-Features", strings.Join(b.hub.info.Features, ", "))
}
// Add checksum so the backend can validate the request.
AddBackendChecksum(req, data, secret)

1
hub.go
View File

@ -333,6 +333,7 @@ func NewHub(config *goconf.ConfigFile, nats NatsClient, r *mux.Router, version s
geoip: geoip,
geoipOverrides: geoipOverrides,
}
backend.hub = hub
hub.upgrader.CheckOrigin = hub.checkOrigin
r.HandleFunc("/spreed", func(w http.ResponseWriter, r *http.Request) {
hub.serveWs(w, r)