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 @@ -16,7 +16,6 @@ listen = 127.0.0.1:8080
#stunURIs = stun.l.google.com:19302
#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
#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
#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.

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

@ -69,7 +69,6 @@ type Hub struct { @@ -69,7 +69,6 @@ type Hub struct {
config *Config
sessionSecret []byte
turnSecret []byte
turnUsernameFormat string
tickets *securecookie.SecureCookie
count uint64
mutex sync.RWMutex
@ -78,7 +77,7 @@ type Hub struct { @@ -78,7 +77,7 @@ type Hub struct {
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{
connectionTable: make(map[string]*Connection),
@ -88,7 +87,6 @@ func NewHub(version string, config *Config, sessionSecret, turnSecret, turnUsern @@ -88,7 +87,6 @@ func NewHub(version string, config *Config, sessionSecret, turnSecret, turnUsern
config: config,
sessionSecret: []byte(sessionSecret),
turnSecret: []byte(turnSecret),
turnUsernameFormat: turnUsernameFormat,
}
h.tickets = securecookie.New(h.sessionSecret, nil)
@ -141,18 +139,12 @@ func (h *Hub) CreateTurnData(id string) *DataTurn { @@ -141,18 +139,12 @@ func (h *Hub) CreateTurnData(id string) *DataTurn {
if len(h.turnSecret) == 0 {
return &DataTurn{}
}
var user string
bar := sha256.New()
bar.Write([]byte(id))
id = base64.StdEncoding.EncodeToString(bar.Sum(nil))
foo := hmac.New(sha1.New, h.turnSecret)
expiration := int32(time.Now().Unix())+turnTTL
switch h.turnUsernameFormat {
case "time:id":
user = fmt.Sprintf("%d:%s", expiration, id)
default:
user = fmt.Sprintf("%s:%d", id, expiration)
}
user := fmt.Sprintf("%d:%s", expiration, id)
foo.Write([]byte(user))
password := base64.StdEncoding.EncodeToString(foo.Sum(nil))
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 { @@ -211,11 +211,6 @@ func runner(runtime phoenix.Runtime) error {
turnSecret = ""
}
turnUsernameFormat, err := runtime.GetString("app", "turnUsernameFormat")
if err != nil {
turnUsernameFormat = "id:time"
}
stunURIsString, err := runtime.GetString("app", "stunURIs")
if err != nil {
stunURIsString = ""
@ -274,7 +269,7 @@ func runner(runtime phoenix.Runtime) error { @@ -274,7 +269,7 @@ func runner(runtime phoenix.Runtime) error {
}
// 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
if goruntime.GOMAXPROCS(0) == 1 {

Loading…
Cancel
Save