check turn domain and port range (#90)
* check negative turn port * check turn domain * domain check test code
This commit is contained in:
+6
-2
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user