Browse Source

Make mapping of room name to room type configurable.

pull/284/head
Joachim Bauch 9 years ago
parent
commit
7fbc4449ca
  1. 2
      dependencies.tsv
  2. 2
      go/channelling/config.go
  3. 42
      go/channelling/server/config.go
  4. 14
      server.conf.in
  5. 5
      src/app/spreed-webrtc-server/main.go

2
dependencies.tsv

@ -8,5 +8,5 @@ github.com/nats-io/nats git 355b5b97e0842dc94f1106729aa88e33e06317ca 2015-12-09T
github.com/satori/go.uuid git afe1e2ddf0f05b7c29d388a3f8e76cb15c2231ca 2015-06-15T02:45:37Z github.com/satori/go.uuid git afe1e2ddf0f05b7c29d388a3f8e76cb15c2231ca 2015-06-15T02:45:37Z
github.com/strukturag/goacceptlanguageparser git 68066e68c2940059aadc6e19661610cf428b6647 2014-02-13T13:31:23Z github.com/strukturag/goacceptlanguageparser git 68066e68c2940059aadc6e19661610cf428b6647 2014-02-13T13:31:23Z
github.com/strukturag/httputils git afbf05c71ac03ee7989c96d033a9571ba4ded468 2014-07-02T01:35:33Z github.com/strukturag/httputils git afbf05c71ac03ee7989c96d033a9571ba4ded468 2014-07-02T01:35:33Z
github.com/strukturag/phoenix git c3429c4e93588d848606263a7f96f91c90e43178 2016-03-02T12:52:52Z github.com/strukturag/phoenix git 31b7f25f4815e6e0b8e7c4010f6e9a71c4165b19 2016-06-01T11:34:58Z
github.com/strukturag/sloth git 74a8bcf67368de59baafe5d3e17aee9875564cfc 2015-04-22T08:59:42Z github.com/strukturag/sloth git 74a8bcf67368de59baafe5d3e17aee9875564cfc 2015-04-22T08:59:42Z

1 github.com/dlintw/goconf git dcc070983490608a14480e3bf943bad464785df5 2012-02-28T08:26:10Z
8 github.com/satori/go.uuid git afe1e2ddf0f05b7c29d388a3f8e76cb15c2231ca 2015-06-15T02:45:37Z
9 github.com/strukturag/goacceptlanguageparser git 68066e68c2940059aadc6e19661610cf428b6647 2014-02-13T13:31:23Z
10 github.com/strukturag/httputils git afbf05c71ac03ee7989c96d033a9571ba4ded468 2014-07-02T01:35:33Z
11 github.com/strukturag/phoenix git c3429c4e93588d848606263a7f96f91c90e43178 31b7f25f4815e6e0b8e7c4010f6e9a71c4165b19 2016-03-02T12:52:52Z 2016-06-01T11:34:58Z
12 github.com/strukturag/sloth git 74a8bcf67368de59baafe5d3e17aee9875564cfc 2015-04-22T08:59:42Z

2
go/channelling/config.go

@ -2,6 +2,7 @@ package channelling
import ( import (
"net/http" "net/http"
"regexp"
) )
type Config struct { type Config struct {
@ -28,6 +29,7 @@ type Config struct {
ContentSecurityPolicy string `json:"-"` // HTML content security policy ContentSecurityPolicy string `json:"-"` // HTML content security policy
ContentSecurityPolicyReportOnly string `json:"-"` // HTML content security policy in report only mode ContentSecurityPolicyReportOnly string `json:"-"` // HTML content security policy in report only mode
RoomTypeDefault string `json:"-"` // New rooms default to this type RoomTypeDefault string `json:"-"` // New rooms default to this type
RoomTypes map[*regexp.Regexp]string `json:"-"` // Map of regular expression -> room type
} }
func (config *Config) WithModule(m string) bool { func (config *Config) WithModule(m string) bool {

42
go/channelling/server/config.go

@ -24,6 +24,7 @@ package server
import ( import (
"fmt" "fmt"
"log" "log"
"regexp"
"strings" "strings"
"time" "time"
@ -32,7 +33,17 @@ import (
"github.com/strukturag/phoenix" "github.com/strukturag/phoenix"
) )
func NewConfig(container phoenix.Container, tokens bool) *channelling.Config { const (
defaultRoomType = "Room"
)
var (
knownRoomTypes = map[string]bool{
"Conference": true,
}
)
func NewConfig(container phoenix.Container, tokens bool) (*channelling.Config, error) {
ver := container.GetStringDefault("app", "ver", "") ver := container.GetStringDefault("app", "ver", "")
version := container.Version() version := container.Version()
@ -83,6 +94,30 @@ func NewConfig(container phoenix.Container, tokens bool) *channelling.Config {
} }
log.Println("Enabled modules:", modules) log.Println("Enabled modules:", modules)
roomTypes := make(map[*regexp.Regexp]string)
if options, _ := container.GetOptions("roomtypes"); len(options) > 0 {
for _, option := range options {
rt := container.GetStringDefault("roomtypes", option, "")
if len(rt) == 0 {
continue
}
if rt != defaultRoomType {
if !knownRoomTypes[rt] {
return nil, fmt.Errorf("Unsupported room type '%s' with expression %s", rt, option)
}
re, err := regexp.Compile(option)
if err != nil {
return nil, fmt.Errorf("Invalid regular expression '%s' for type %s: %s", option, rt, err)
}
roomTypes[re] = rt
}
log.Printf("Using room type %s for %s\n", rt, option)
}
}
return &channelling.Config{ return &channelling.Config{
Title: container.GetStringDefault("app", "title", "Spreed WebRTC"), Title: container.GetStringDefault("app", "title", "Spreed WebRTC"),
Ver: ver, Ver: ver,
@ -106,8 +141,9 @@ func NewConfig(container phoenix.Container, tokens bool) *channelling.Config {
GlobalRoomID: container.GetStringDefault("app", "globalRoom", ""), GlobalRoomID: container.GetStringDefault("app", "globalRoom", ""),
ContentSecurityPolicy: container.GetStringDefault("app", "contentSecurityPolicy", ""), ContentSecurityPolicy: container.GetStringDefault("app", "contentSecurityPolicy", ""),
ContentSecurityPolicyReportOnly: container.GetStringDefault("app", "contentSecurityPolicyReportOnly", ""), ContentSecurityPolicyReportOnly: container.GetStringDefault("app", "contentSecurityPolicyReportOnly", ""),
RoomTypeDefault: "Room", RoomTypeDefault: defaultRoomType,
} RoomTypes: roomTypes,
}, nil
} }
// Helper function to clean up string arrays. // Helper function to clean up string arrays.

14
server.conf.in

@ -208,3 +208,17 @@ enabled = false
; Use client_id to distinguish between multipe servers. The value is sent ; Use client_id to distinguish between multipe servers. The value is sent
; together with every NATS request. Defaults to empty. ; together with every NATS request. Defaults to empty.
;client_id = ;client_id =
[roomtypes]
; You can define room types that should be used for given room names instead of
; the default type "Room". Use format "RegularExpression = RoomType" and make
; sure the regular expression doesn't contain any "=" or ":".
;
; Available room types:
; "Conference"
; All participants joining the room automatically call each other and are in
; a conference.
;
; Example (all rooms below "/conference/" are conference rooms):
;^/conference/.+ = Conference
;

5
src/app/spreed-webrtc-server/main.go

@ -170,7 +170,10 @@ func runner(runtime phoenix.Runtime) error {
natsClientId, _ := runtime.GetString("nats", "client_id") natsClientId, _ := runtime.GetString("nats", "client_id")
// Load remaining configuration items. // Load remaining configuration items.
config = server.NewConfig(runtime, tokenProvider != nil) config, err = server.NewConfig(runtime, tokenProvider != nil)
if err != nil {
return err
}
// Load templates. // Load templates.
templates = template.New("") templates = template.New("")

Loading…
Cancel
Save