Browse Source

Removed obsolete different TURN user formats.

pull/17/merge
Simon Eisenmann 11 years ago
parent
commit
919e758a31
  1. 1
      server.conf.in
  2. 12
      src/app/spreed-speakfreely-server/hub.go
  3. 7
      src/app/spreed-speakfreely-server/main.go

1
server.conf.in

@ -16,7 +16,6 @@ listen = 127.0.0.1:8080
#stunURIs = stun.l.google.com:19302 #stunURIs = stun.l.google.com:19302
#turnURIs = turn:turnserver:port?transport=udp turn:anotherturnserver:port?transport=tcp turns:turnserver:443?transport=tcp #turnURIs = turn:turnserver:port?transport=udp turn:anotherturnserver:port?transport=tcp turns:turnserver:443?transport=tcp
#turnSecret = the-default-turn-shared-secret-do-not-keep #turnSecret = the-default-turn-shared-secret-do-not-keep
#turnUsernameFormat = id:time # Set the format for turn username generator. Valid values are time:id, id:time (default).
sessionSecret = the-default-secret-do-not-keep sessionSecret = the-default-secret-do-not-keep
#tokenFile = tokens.txt # If set, everyone needs to give one of the tokens to launch the web client. One token per line in the file. #tokenFile = tokens.txt # If set, everyone needs to give one of the tokens to launch the web client. One token per line in the file.
#globalRoom = global # Enables a global room. Users in that room are in all rooms. #globalRoom = global # Enables a global room. Users in that room are in all rooms.

12
src/app/spreed-speakfreely-server/hub.go

@ -69,7 +69,6 @@ type Hub struct {
config *Config config *Config
sessionSecret []byte sessionSecret []byte
turnSecret []byte turnSecret []byte
turnUsernameFormat string
tickets *securecookie.SecureCookie tickets *securecookie.SecureCookie
count uint64 count uint64
mutex sync.RWMutex mutex sync.RWMutex
@ -78,7 +77,7 @@ type Hub struct {
unicastChatMessages uint64 unicastChatMessages uint64
} }
func NewHub(version string, config *Config, sessionSecret, turnSecret, turnUsernameFormat string) *Hub { func NewHub(version string, config *Config, sessionSecret, turnSecret string) *Hub {
h := &Hub{ h := &Hub{
connectionTable: make(map[string]*Connection), connectionTable: make(map[string]*Connection),
@ -88,7 +87,6 @@ func NewHub(version string, config *Config, sessionSecret, turnSecret, turnUsern
config: config, config: config,
sessionSecret: []byte(sessionSecret), sessionSecret: []byte(sessionSecret),
turnSecret: []byte(turnSecret), turnSecret: []byte(turnSecret),
turnUsernameFormat: turnUsernameFormat,
} }
h.tickets = securecookie.New(h.sessionSecret, nil) h.tickets = securecookie.New(h.sessionSecret, nil)
@ -141,18 +139,12 @@ func (h *Hub) CreateTurnData(id string) *DataTurn {
if len(h.turnSecret) == 0 { if len(h.turnSecret) == 0 {
return &DataTurn{} return &DataTurn{}
} }
var user string
bar := sha256.New() bar := sha256.New()
bar.Write([]byte(id)) bar.Write([]byte(id))
id = base64.StdEncoding.EncodeToString(bar.Sum(nil)) id = base64.StdEncoding.EncodeToString(bar.Sum(nil))
foo := hmac.New(sha1.New, h.turnSecret) foo := hmac.New(sha1.New, h.turnSecret)
expiration := int32(time.Now().Unix())+turnTTL expiration := int32(time.Now().Unix())+turnTTL
switch h.turnUsernameFormat { user := fmt.Sprintf("%d:%s", expiration, id)
case "time:id":
user = fmt.Sprintf("%d:%s", expiration, id)
default:
user = fmt.Sprintf("%s:%d", id, expiration)
}
foo.Write([]byte(user)) foo.Write([]byte(user))
password := base64.StdEncoding.EncodeToString(foo.Sum(nil)) password := base64.StdEncoding.EncodeToString(foo.Sum(nil))
return &DataTurn{user, password, turnTTL, h.config.TurnURIs} return &DataTurn{user, password, turnTTL, h.config.TurnURIs}

7
src/app/spreed-speakfreely-server/main.go

@ -211,11 +211,6 @@ func runner(runtime phoenix.Runtime) error {
turnSecret = "" turnSecret = ""
} }
turnUsernameFormat, err := runtime.GetString("app", "turnUsernameFormat")
if err != nil {
turnUsernameFormat = "id:time"
}
stunURIsString, err := runtime.GetString("app", "stunURIs") stunURIsString, err := runtime.GetString("app", "stunURIs")
if err != nil { if err != nil {
stunURIsString = "" stunURIsString = ""
@ -274,7 +269,7 @@ func runner(runtime phoenix.Runtime) error {
} }
// Create our hub instance. // Create our hub instance.
hub := NewHub(runtimeVersion, config, sessionSecret, turnSecret, turnUsernameFormat) hub := NewHub(runtimeVersion, config, sessionSecret, turnSecret)
// Set number of go routines if it is 1 // Set number of go routines if it is 1
if goruntime.GOMAXPROCS(0) == 1 { if goruntime.GOMAXPROCS(0) == 1 {

Loading…
Cancel
Save