check turn domain and port range (#90)

* check negative turn port

* check turn domain

* domain check test code
This commit is contained in:
PJC
2021-08-23 10:49:16 -07:00
committed by GitHub
parent bcf6e15e07
commit 9016da1936
3 changed files with 28 additions and 2 deletions
+6 -2
View File
@@ -26,7 +26,7 @@ func NewTurnServer(conf *config.Config, roomStore RoomStore, node routing.LocalN
return nil, nil
}
if turnConf.TLSPort == 0 && turnConf.UDPPort == 0 {
if turnConf.TLSPort <= 0 && turnConf.UDPPort <= 0 {
return nil, errors.New("invalid TURN ports")
}
@@ -49,6 +49,10 @@ func NewTurnServer(conf *config.Config, roomStore RoomStore, node routing.LocalN
return nil, errors.New("TURN domain required")
}
if IsValidDomain(turnConf.Domain) == false {
return nil, errors.New("TURN domain is not correct")
}
cert, err := tls.LoadX509KeyPair(turnConf.CertFile, turnConf.KeyFile)
if err != nil {
return nil, errors.Wrap(err, "TURN tls cert required")
@@ -99,4 +103,4 @@ func newTurnAuthHandler(roomStore RoomStore) turn.AuthHandler {
return turn.GenerateAuthKey(username, livekitRealm, rm.TurnPassword), true
}
}
}