diff --git a/dependencies.tsv b/dependencies.tsv index f886fd27..69616194 100644 --- a/dependencies.tsv +++ b/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/strukturag/goacceptlanguageparser git 68066e68c2940059aadc6e19661610cf428b6647 2014-02-13T13:31:23Z 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 diff --git a/go/channelling/config.go b/go/channelling/config.go index c35b0b92..162398de 100644 --- a/go/channelling/config.go +++ b/go/channelling/config.go @@ -2,32 +2,34 @@ package channelling import ( "net/http" + "regexp" ) type Config struct { - Title string // Title - Ver string `json:"-"` // Version (not exported to Javascript) - S string // Static URL prefix with version - B string // Base URL - Token string // Server token - Renegotiation bool // Renegotiation flag - StunURIs []string // STUN server URIs - TurnURIs []string // TURN server URIs - Tokens bool // True when we got a tokens file - Version string // Server version number - UsersEnabled bool // Flag if users are enabled - UsersAllowRegistration bool // Flag if users can register - UsersMode string // Users mode string - DefaultRoomEnabled bool // Flag if default room ("") is enabled - Plugin string // Plugin to load - AuthorizeRoomCreation bool // Whether a user account is required to create rooms - AuthorizeRoomJoin bool // Whether a user account is required to join rooms - Modules []string // List of enabled modules - ModulesTable map[string]bool `json:"-"` // Map of enabled modules - GlobalRoomID string `json:"-"` // Id of the global room (not exported to Javascript) - ContentSecurityPolicy string `json:"-"` // HTML content security policy - ContentSecurityPolicyReportOnly string `json:"-"` // HTML content security policy in report only mode - RoomTypeDefault string `json:"-"` // New rooms default to this type + Title string // Title + Ver string `json:"-"` // Version (not exported to Javascript) + S string // Static URL prefix with version + B string // Base URL + Token string // Server token + Renegotiation bool // Renegotiation flag + StunURIs []string // STUN server URIs + TurnURIs []string // TURN server URIs + Tokens bool // True when we got a tokens file + Version string // Server version number + UsersEnabled bool // Flag if users are enabled + UsersAllowRegistration bool // Flag if users can register + UsersMode string // Users mode string + DefaultRoomEnabled bool // Flag if default room ("") is enabled + Plugin string // Plugin to load + AuthorizeRoomCreation bool // Whether a user account is required to create rooms + AuthorizeRoomJoin bool // Whether a user account is required to join rooms + Modules []string // List of enabled modules + ModulesTable map[string]bool `json:"-"` // Map of enabled modules + GlobalRoomID string `json:"-"` // Id of the global room (not exported to Javascript) + ContentSecurityPolicy string `json:"-"` // HTML content security policy + ContentSecurityPolicyReportOnly string `json:"-"` // HTML content security policy in report only mode + 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 { diff --git a/go/channelling/server/config.go b/go/channelling/server/config.go index e35f0305..1f202ac6 100644 --- a/go/channelling/server/config.go +++ b/go/channelling/server/config.go @@ -24,6 +24,7 @@ package server import ( "fmt" "log" + "regexp" "strings" "time" @@ -32,7 +33,17 @@ import ( "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", "") version := container.Version() @@ -83,6 +94,30 @@ func NewConfig(container phoenix.Container, tokens bool) *channelling.Config { } 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{ Title: container.GetStringDefault("app", "title", "Spreed WebRTC"), Ver: ver, @@ -106,8 +141,9 @@ func NewConfig(container phoenix.Container, tokens bool) *channelling.Config { GlobalRoomID: container.GetStringDefault("app", "globalRoom", ""), ContentSecurityPolicy: container.GetStringDefault("app", "contentSecurityPolicy", ""), ContentSecurityPolicyReportOnly: container.GetStringDefault("app", "contentSecurityPolicyReportOnly", ""), - RoomTypeDefault: "Room", - } + RoomTypeDefault: defaultRoomType, + RoomTypes: roomTypes, + }, nil } // Helper function to clean up string arrays. diff --git a/server.conf.in b/server.conf.in index 715fb055..4a1b7cc5 100644 --- a/server.conf.in +++ b/server.conf.in @@ -208,3 +208,17 @@ enabled = false ; Use client_id to distinguish between multipe servers. The value is sent ; together with every NATS request. Defaults to empty. ;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 +; diff --git a/src/app/spreed-webrtc-server/main.go b/src/app/spreed-webrtc-server/main.go index 65a4d53c..07286e9f 100644 --- a/src/app/spreed-webrtc-server/main.go +++ b/src/app/spreed-webrtc-server/main.go @@ -170,7 +170,10 @@ func runner(runtime phoenix.Runtime) error { natsClientId, _ := runtime.GetString("nats", "client_id") // Load remaining configuration items. - config = server.NewConfig(runtime, tokenProvider != nil) + config, err = server.NewConfig(runtime, tokenProvider != nil) + if err != nil { + return err + } // Load templates. templates = template.New("")